KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > edit > EllipseEditPart


1 /**
2  * <p> Project: com.nightlabs.editor2d </p>
3  * <p> Copyright: Copyright (c) 2004 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 08.12.2004 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.edit;
9
10 import java.beans.PropertyChangeEvent JavaDoc;
11
12 import org.eclipse.ui.views.properties.IPropertySource;
13
14 import com.nightlabs.editor2d.EllipseDrawComponent;
15 import com.nightlabs.editor2d.model.EllipsePropertySource;
16
17
18 public class EllipseEditPart
19 extends ShapeDrawComponentEditPart
20 {
21   /**
22    * @param drawComponent
23    */

24   public EllipseEditPart(EllipseDrawComponent drawComponent) {
25     super(drawComponent);
26   }
27
28     protected EllipseDrawComponent getEllipseDrawComponent() {
29         return (EllipseDrawComponent) getModel();
30     }
31     
32   protected IPropertySource getPropertySource()
33   {
34     if (propertySource == null)
35     {
36       propertySource =
37         new EllipsePropertySource(getEllipseDrawComponent());
38     }
39     return propertySource;
40   }
41   
42     protected void propertyChanged(PropertyChangeEvent JavaDoc evt)
43     {
44         super.propertyChanged(evt);
45         String JavaDoc propertyName = evt.getPropertyName();
46         if (propertyName.equals(EllipseDrawComponent.PROP_END_ANGLE)) {
47             LOGGER.debug(propertyName +" changed!");
48             refreshVisuals();
49         }
50         else if (propertyName.equals(EllipseDrawComponent.PROP_START_ANGLE)) {
51             LOGGER.debug(propertyName +" changed!");
52             refreshVisuals();
53         }
54     }
55   
56   /* (non-Javadoc)
57    * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
58    */

59 // protected IFigure createFigure()
60
// {
61
// EllipseFigure ellipse = new EllipseFigure();
62
// EllipseDrawComponent edc = (EllipseDrawComponent)getModel();
63
// ellipse.setGeneralShape(edc.getGeneralShape());
64
// setShapeProperties(edc, ellipse);
65
// return ellipse;
66
// }
67

68 // public void notifyChanged(Notification notification)
69
// {
70
// int type = notification.getEventType();
71
// int featureId = notification.getFeatureID(Editor2DPackage.class);
72
//
73
// if (type == Notification.SET)
74
// {
75
// switch (featureId)
76
// {
77
// case Editor2DPackage.ELLIPSE_DRAW_COMPONENT__END_ANGLE :
78
// LOGGER.debug("ELLIPSE_DRAW_COMPONENT__END_ANGLE Notified!");
79
// refreshVisuals();
80
// break;
81
// case Editor2DPackage.ELLIPSE_DRAW_COMPONENT__START_ANGLE :
82
// LOGGER.debug("ELLIPSE_DRAW_COMPONENT__START_ANGLE Notified!");
83
// refreshVisuals();
84
// break;
85
// case Editor2DPackage.ELLIPSE_DRAW_COMPONENT__CONNECT :
86
// LOGGER.debug("ELLIPSE_DRAW_COMPONENT__CONNECT Notified!");
87
// refreshVisuals();
88
// break;
89
// }
90
// }
91
// super.notifyChanged(notification);
92
// }
93

94 // protected void setShapeProperties(ShapeDrawComponent sdc, ShapeFigure sf)
95
// {
96
// super.setShapeProperties(sdc, sf);
97
// EllipseDrawComponent edc = (EllipseDrawComponent) sdc;
98
// EllipseFigure ef = (EllipseFigure) sf;
99
// ef.setStartAngle(edc.getStartAngle());
100
// ef.setEndAngle(edc.getEndAngle());
101
// }
102

103 }
104
Popular Tags