KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > model > ImagePropertySource


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * Project author: Daniel Mazurek <Daniel.Mazurek [at] nightlabs [dot] org> *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin St, Fifth Floor, *
20  * Boston, MA 02110-1301 USA *
21  * *
22  * Or get it online : *
23  * http://www.gnu.org/copyleft/lesser.html *
24  * *
25  * *
26  ******************************************************************************/

27
28 package org.nightlabs.editor2d.model;
29
30 import java.util.List JavaDoc;
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 JavaDoc createPropertyDescriptors()
47     {
48         List JavaDoc descriptors = getDescriptors();
49         
50 // // Name
51
// PropertyDescriptor desc = new NamePropertyDescriptor(drawComponent,
52
// DrawComponent.PROP_NAME,
53
// EditorPlugin.getResourceString("property.name.label"));
54
// desc.setCategory(CATEGORY_NAME);
55
// descriptors.add(desc);
56

57         // X
58
PropertyDescriptor desc = new IntPropertyDescriptor(DrawComponent.PROP_X,
59                 EditorPlugin.getResourceString("property.x.label"));
60         desc.setCategory(CATEGORY_GEOM);
61         descriptors.add(desc);
62         
63         // Y
64
desc = new IntPropertyDescriptor(DrawComponent.PROP_Y,
65                 EditorPlugin.getResourceString("property.y.label"));
66         desc.setCategory(CATEGORY_GEOM);
67         descriptors.add(desc);
68         
69         // Width
70
desc = new IntPropertyDescriptor(DrawComponent.PROP_WIDTH,
71                 EditorPlugin.getResourceString("property.width.label"));
72         desc.setCategory(CATEGORY_GEOM);
73         descriptors.add(desc);
74         
75         // Height
76
desc = new IntPropertyDescriptor(DrawComponent.PROP_HEIGHT,
77                 EditorPlugin.getResourceString("property.height.label"));
78         desc.setCategory(CATEGORY_GEOM);
79         descriptors.add(desc);
80         
81         // Rotation
82
desc = new RotationPropertyDescriptor(DrawComponent.PROP_ROTATION,
83                 EditorPlugin.getResourceString("property.rotation.label"));
84         desc.setCategory(CATEGORY_ROTATION);
85         descriptors.add(desc);
86         
87         // RotationX
88
desc = new IntPropertyDescriptor(DrawComponent.PROP_ROTATION_X,
89                 EditorPlugin.getResourceString("property.rotationx.label"));
90         desc.setCategory(CATEGORY_ROTATION);
91         descriptors.add(desc);
92         
93         // RotationY
94
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 JavaDoc getPropertyValue(Object JavaDoc id)
103     {
104         if (id.equals(DrawComponent.PROP_X)) {
105             return new Integer JavaDoc(drawComponent.getX());
106         }
107         else if (id.equals(DrawComponent.PROP_Y)) {
108             return new Integer JavaDoc(drawComponent.getY());
109         }
110         else if (id.equals(DrawComponent.PROP_WIDTH)) {
111             return new Integer JavaDoc(drawComponent.getWidth());
112         }
113         else if (id.equals(DrawComponent.PROP_HEIGHT)) {
114             return new Integer JavaDoc(drawComponent.getHeight());
115         }
116         else if (id.equals(DrawComponent.PROP_ROTATION)) {
117             return new Double JavaDoc(drawComponent.getRotation());
118         }
119         else if (id.equals(DrawComponent.PROP_ROTATION_X)) {
120             return new Integer JavaDoc(drawComponent.getRotationX());
121         }
122         else if (id.equals(DrawComponent.PROP_ROTATION_Y)) {
123             return new Integer JavaDoc(drawComponent.getRotationY());
124         }
125 // else if (id.equals(DrawComponent.PROP_NAME)) {
126
// return drawComponent.getI18nText().getText(nameLangMan.getCurrentLanguageID());
127
// }
128

129         return null;
130     }
131     
132     public void setPropertyValue(Object JavaDoc id, Object JavaDoc value)
133     {
134         if (id.equals(DrawComponent.PROP_X)) {
135             drawComponent.setX(((Integer JavaDoc)value).intValue());
136         }
137         else if (id.equals(DrawComponent.PROP_Y)) {
138             drawComponent.setY(((Integer JavaDoc)value).intValue());
139         }
140         else if (id.equals(DrawComponent.PROP_WIDTH)) {
141             drawComponent.setWidth(((Integer JavaDoc)value).intValue());
142         }
143         else if (id.equals(DrawComponent.PROP_HEIGHT)) {
144             drawComponent.setHeight(((Integer JavaDoc)value).intValue());
145         }
146         else if (id.equals(DrawComponent.PROP_ROTATION)) {
147             drawComponent.setRotation(((Double JavaDoc)value).doubleValue());
148         }
149         else if (id.equals(DrawComponent.PROP_ROTATION_X)) {
150             drawComponent.setRotationX(((Integer JavaDoc)value).intValue());
151         }
152         else if (id.equals(DrawComponent.PROP_ROTATION_Y)) {
153             drawComponent.setRotationY(((Integer JavaDoc)value).intValue());
154         }
155 // else if (id.equals(DrawComponent.PROP_NAME)) {
156
// drawComponent.setName((String)value);
157
// }
158
}
159 }
160
Popular Tags