1 27 28 package org.nightlabs.editor2d.model; 29 30 import java.util.List ; 31 32 import org.eclipse.ui.views.properties.PropertyDescriptor; 33 import org.nightlabs.base.property.IntPropertyDescriptor; 34 import org.nightlabs.editor2d.DrawComponent; 35 import org.nightlabs.editor2d.EditorPlugin; 36 import org.nightlabs.editor2d.ImageDrawComponent; 37 import org.nightlabs.editor2d.properties.RotationPropertyDescriptor; 38 39 public class ImagePropertySource 40 extends DrawComponentPropertySource 41 { 42 public ImagePropertySource(ImageDrawComponent element) { 43 super(element); 44 } 45 46 protected List createPropertyDescriptors() 47 { 48 List descriptors = getDescriptors(); 49 50 57 PropertyDescriptor desc = new IntPropertyDescriptor(DrawComponent.PROP_X, 59 EditorPlugin.getResourceString("property.x.label")); 60 desc.setCategory(CATEGORY_GEOM); 61 descriptors.add(desc); 62 63 desc = new IntPropertyDescriptor(DrawComponent.PROP_Y, 65 EditorPlugin.getResourceString("property.y.label")); 66 desc.setCategory(CATEGORY_GEOM); 67 descriptors.add(desc); 68 69 desc = new IntPropertyDescriptor(DrawComponent.PROP_WIDTH, 71 EditorPlugin.getResourceString("property.width.label")); 72 desc.setCategory(CATEGORY_GEOM); 73 descriptors.add(desc); 74 75 desc = new IntPropertyDescriptor(DrawComponent.PROP_HEIGHT, 77 EditorPlugin.getResourceString("property.height.label")); 78 desc.setCategory(CATEGORY_GEOM); 79 descriptors.add(desc); 80 81 desc = new RotationPropertyDescriptor(DrawComponent.PROP_ROTATION, 83 EditorPlugin.getResourceString("property.rotation.label")); 84 desc.setCategory(CATEGORY_ROTATION); 85 descriptors.add(desc); 86 87 desc = new IntPropertyDescriptor(DrawComponent.PROP_ROTATION_X, 89 EditorPlugin.getResourceString("property.rotationx.label")); 90 desc.setCategory(CATEGORY_ROTATION); 91 descriptors.add(desc); 92 93 desc = new IntPropertyDescriptor(DrawComponent.PROP_ROTATION_Y, 95 EditorPlugin.getResourceString("property.rotationy.label")); 96 desc.setCategory(CATEGORY_ROTATION); 97 descriptors.add(desc); 98 99 return descriptors; 100 } 101 102 public Object getPropertyValue(Object id) 103 { 104 if (id.equals(DrawComponent.PROP_X)) { 105 return new Integer (drawComponent.getX()); 106 } 107 else if (id.equals(DrawComponent.PROP_Y)) { 108 return new Integer (drawComponent.getY()); 109 } 110 else if (id.equals(DrawComponent.PROP_WIDTH)) { 111 return new Integer (drawComponent.getWidth()); 112 } 113 else if (id.equals(DrawComponent.PROP_HEIGHT)) { 114 return new Integer (drawComponent.getHeight()); 115 } 116 else if (id.equals(DrawComponent.PROP_ROTATION)) { 117 return new Double (drawComponent.getRotation()); 118 } 119 else if (id.equals(DrawComponent.PROP_ROTATION_X)) { 120 return new Integer (drawComponent.getRotationX()); 121 } 122 else if (id.equals(DrawComponent.PROP_ROTATION_Y)) { 123 return new Integer (drawComponent.getRotationY()); 124 } 125 129 return null; 130 } 131 132 public void setPropertyValue(Object id, Object value) 133 { 134 if (id.equals(DrawComponent.PROP_X)) { 135 drawComponent.setX(((Integer )value).intValue()); 136 } 137 else if (id.equals(DrawComponent.PROP_Y)) { 138 drawComponent.setY(((Integer )value).intValue()); 139 } 140 else if (id.equals(DrawComponent.PROP_WIDTH)) { 141 drawComponent.setWidth(((Integer )value).intValue()); 142 } 143 else if (id.equals(DrawComponent.PROP_HEIGHT)) { 144 drawComponent.setHeight(((Integer )value).intValue()); 145 } 146 else if (id.equals(DrawComponent.PROP_ROTATION)) { 147 drawComponent.setRotation(((Double )value).doubleValue()); 148 } 149 else if (id.equals(DrawComponent.PROP_ROTATION_X)) { 150 drawComponent.setRotationX(((Integer )value).intValue()); 151 } 152 else if (id.equals(DrawComponent.PROP_ROTATION_Y)) { 153 drawComponent.setRotationY(((Integer )value).intValue()); 154 } 155 } 159 } 160 | Popular Tags |