KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > util > FeedbackUtil


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: 27.04.2005 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.util;
9
10 import java.util.Iterator JavaDoc;
11
12 import org.eclipse.draw2d.ColorConstants;
13
14 import com.nightlabs.editor2d.DrawComponent;
15 import com.nightlabs.editor2d.DrawComponentContainer;
16 import com.nightlabs.editor2d.ImageDrawComponent;
17 import com.nightlabs.editor2d.ShapeDrawComponent;
18 import com.nightlabs.editor2d.figures.FeedbackShapeFigure;
19 import com.nightlabs.editor2d.figures.ShapeFigure;
20 import com.nightlabs.editor2d.j2d.GeneralShape;
21 import com.nightlabs.editor2d.j2d.GeneralShapeFactory;
22
23
24 public class FeedbackUtil
25 {
26 // protected static DefaultFeedbackConfigModule defaultFeedbackConfig;
27

28   public FeedbackUtil()
29   {
30     super();
31 // try {
32
// defaultFeedbackConfig = (DefaultFeedbackConfigModule) Config.sharedInstance().createConfigModule(DefaultFeedbackConfigModule.class);
33
// } catch (ConfigException e) {
34
// // TODO Auto-generated catch block
35
// e.printStackTrace();
36
// }
37
}
38   
39   public static ShapeFigure createCustomFeedbackFigure(Object JavaDoc modelPart)
40     {
41       GeneralShape gs = null;
42       if (modelPart instanceof ShapeDrawComponent) {
43         ShapeDrawComponent sdc = (ShapeDrawComponent) modelPart;
44         gs = (GeneralShape)sdc.getGeneralShape().clone();
45       }
46       else if (modelPart instanceof ImageDrawComponent) {
47         ImageDrawComponent idc = (ImageDrawComponent) modelPart;
48         gs = (GeneralShape) idc.getImageShape().clone();
49       }
50       else if (modelPart instanceof DrawComponentContainer)
51       {
52         DrawComponentContainer container = (DrawComponentContainer) modelPart;
53         ShapeFigure containerFigure = new FeedbackShapeFigure();
54         GeneralShape containerShape = GeneralShapeFactory.createRectangle(1,1,1,1);
55         containerFigure.setGeneralShape(containerShape);
56         containerFigure.setXOR(true);
57         containerFigure.setFill(true);
58         containerFigure.setBackgroundColor(ColorConstants.darkGray);
59         containerFigure.setForegroundColor(ColorConstants.white);
60         for (Iterator JavaDoc it = container.getDrawComponents().iterator(); it.hasNext(); ) {
61           DrawComponent dc = (DrawComponent) it.next();
62           ShapeFigure figure = createCustomFeedbackFigure(dc);
63           containerFigure.add(figure);
64         }
65         return containerFigure;
66       }
67       else {
68         gs = GeneralShapeFactory.createRectangle(0, 0, 10, 10);
69       }
70       ShapeFigure shapeFigure = new FeedbackShapeFigure();
71       shapeFigure.setGeneralShape(gs);
72       shapeFigure.setXOR(true);
73       shapeFigure.setFill(true);
74       shapeFigure.setBackgroundColor(ColorConstants.darkGray);
75       shapeFigure.setForegroundColor(ColorConstants.white);
76       return shapeFigure;
77     }
78   
79 //public static ShapeFigure getCustomFeedbackFigure(Object modelPart)
80
//{
81
// GeneralShape gs = null;
82
// if (modelPart instanceof ShapeDrawComponent) {
83
// ShapeDrawComponent sdc = (ShapeDrawComponent) modelPart;
84
// gs = (GeneralShape)sdc.getGeneralShape().clone();
85
// }
86
// else if (modelPart instanceof ImageDrawComponent) {
87
// ImageDrawComponent idc = (ImageDrawComponent) modelPart;
88
// gs = (GeneralShape) idc.getImageShape().clone();
89
// }
90
// else if (modelPart instanceof DrawComponentContainer)
91
// {
92
// DrawComponentContainer container = (DrawComponentContainer) modelPart;
93
// ShapeFigure containerFigure = new FeedbackShapeFigure();
94
// GeneralShape containerShape = GeneralShapeFactory.createRectangle(1,1,1,1);
95
// containerFigure.setGeneralShape(containerShape);
96
// setDefaultFeedback(containerFigure);
97
// for (Iterator it = container.getDrawComponents().iterator(); it.hasNext(); ) {
98
// DrawComponent dc = (DrawComponent) it.next();
99
// ShapeFigure figure = getCustomFeedbackFigure(dc);
100
// containerFigure.add(figure);
101
// }
102
// return containerFigure;
103
// }
104
// else {
105
// gs = GeneralShapeFactory.createRectangle(0, 0, 10, 10);
106
// }
107
// ShapeFigure shapeFigure = new FeedbackShapeFigure();
108
// shapeFigure.setGeneralShape(gs);
109
// setDefaultFeedback(shapeFigure);
110
// return shapeFigure;
111
//}
112

113 // public static void setDefaultFeedback(ShapeFigure sf)
114
// {
115
// sf.setBackgroundColor(J2DUtil.toSWTColor(defaultFeedbackConfig.getBgColor()));
116
// sf.setForegroundColor(J2DUtil.toSWTColor(defaultFeedbackConfig.getFgColor()));
117
// sf.setXOR(defaultFeedbackConfig.isXor());
118
// sf.setFill(defaultFeedbackConfig.isFill());
119
// }
120
}
121
Popular Tags