1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.devaki.nextobjects.workspace.models.styles;
22
23 import java.awt.Color;
24 import java.awt.datatransfer.DataFlavor;
25 import java.awt.datatransfer.Transferable;
26 import java.awt.datatransfer.UnsupportedFlavorException;
27 import java.io.Serializable;
28 import org.devaki.nextobjects.constants.CstGraphics;
29 import org.devaki.nextobjects.workspace.models.graphics.AssociationLinkView;
30 import org.devaki.nextobjects.workspace.models.graphics.ConstraintView;
31 import org.devaki.nextobjects.workspace.models.graphics.ObjectView;
32
33
34 /***
35 * This class defines the style of all line-like objects
36 */
37 public class LineStyle implements Transferable, Serializable
38 {
39
40 protected Color lineColor;
41
42
43 protected ObjectView myObjectView;
44
45
46 public static DataFlavor fieldFlavor
47 = new DataFlavor(LineStyle.class, "LineStyle");
48 private DataFlavor[] supportedFlavors = { fieldFlavor };
49
50
51 /***
52 * Construct a new 'LineStyle' object with default properties
53 * @param pObjectView the context object view
54 */
55 public LineStyle(ObjectView pObjectView)
56 {
57 this.myObjectView = pObjectView;
58 if (pObjectView instanceof AssociationLinkView)
59 this.lineColor = CstGraphics.DEFAULT_ASSOCIATIONLINK_COLOR;
60 else if (pObjectView instanceof ConstraintView)
61 this.lineColor = CstGraphics.DEFAULT_CONSTRAINT_COLOR;
62 else
63 this.lineColor = CstGraphics.DEFAULT_INHERITANCELINK_COLOR;
64 }
65
66
67 /***
68 * Construct a new 'LineStyle' object
69 * @param pObjectView the context object
70 * @param pLineColor the line color
71 */
72 public LineStyle(ObjectView pObjectView, Color pLineColor)
73 {
74 this.myObjectView = pObjectView;
75 this.lineColor = pLineColor;
76 }
77
78
79 /***
80 * Construct a new 'LineStyle' object from an other
81 * @param pLineStyle the context line style
82 */
83 public LineStyle(LineStyle pLineStyle)
84 {
85 this.myObjectView = pLineStyle.getMyObjectView();
86 this.lineColor = pLineStyle.getLineColor();
87 }
88
89
90 /***
91 * Return the object view to which the style is applied
92 * @return the object view
93 */
94 public ObjectView getMyObjectView()
95 {
96 return this.myObjectView;
97 }
98
99
100 /***
101 * Define the object view to which the style is applied
102 * @param pObjectView the object view
103 */
104 public void setMyObjectView(ObjectView pObjectView)
105 {
106 this.myObjectView = pObjectView;
107 }
108
109
110 /***
111 * Get the line color
112 * @return the line color
113 */
114 public Color getLineColor()
115 {
116 return this.lineColor;
117 }
118
119
120 /***
121 * Set the line color
122 * @param pLineColor the line color
123 */
124 public void setLineColor(Color pLineColor)
125 {
126 this.lineColor = pLineColor;
127 }
128
129
130
131
132
133
134 /***
135 * Return the flavors
136 * @return a table of DataFlavor
137 */
138 public synchronized DataFlavor[] getTransferDataFlavors()
139 {
140 return this.supportedFlavors;
141 }
142
143
144 /***
145 * Is the data supported by this class?
146 * @param parFlavor
147 * @return a boolean
148 */
149 public boolean isDataFlavorSupported(DataFlavor parFlavor)
150 {
151 return (parFlavor.equals(fieldFlavor));
152 }
153
154
155 /***
156 * Return the object to be used by the clipboard
157 * @param parFlavor
158 * @return an Object
159 * @throws UnsupportedFlavorException
160 */
161 public synchronized Object getTransferData(DataFlavor parFlavor)
162 throws UnsupportedFlavorException
163 {
164 if (parFlavor.equals(fieldFlavor))
165 {
166 return (this);
167 }
168 else
169 {
170 throw new UnsupportedFlavorException(fieldFlavor);
171 }
172 }
173
174 /***
175 * Need to be defined
176 * @param parClipboard
177 * @param parTransferable
178 */
179
180
181
182
183 }