Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
df0b8ff4 BH |
2 | * Copyright (c) 2005, 2006 IBM Corporation and others. |
3 | * Copyright (c) 2011, 2012 Ericsson. | |
4 | * | |
73005152 BH |
5 | * All rights reserved. This program and the accompanying materials |
6 | * are made available under the terms of the Eclipse Public License v1.0 | |
7 | * which accompanies this distribution, and is available at | |
8 | * http://www.eclipse.org/legal/epl-v10.html | |
73005152 BH |
9 | * |
10 | * Contributors: | |
11 | * IBM - Initial API and implementation | |
12 | * Bernd Hufmann - Updated for TMF | |
13 | **********************************************************************/ | |
14 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings; | |
15 | ||
16 | /** | |
df0b8ff4 BH |
17 | * Interface for a graphical context. |
18 | * | |
19 | * @version 1.0 | |
73005152 BH |
20 | * @author sveyrier |
21 | * | |
22 | */ | |
23 | public interface IGC { | |
24 | ||
25 | /** | |
26 | * Set the current line style | |
27 | * | |
28 | * @param style the new line style | |
29 | */ | |
30 | public abstract void setLineStyle(int style); | |
31 | ||
32 | /** | |
33 | * Returns current the line style used in the graphical context | |
34 | * | |
35 | * @return the current line style | |
36 | */ | |
37 | public abstract int getLineStyle(); | |
38 | ||
39 | /** | |
40 | * Returns the contents x coordinate that is at the upper left corner of the view | |
41 | * | |
42 | * @return the contents x coordinate | |
43 | */ | |
44 | public abstract int getContentsX(); | |
45 | ||
46 | /** | |
47 | * Returns the contents y coordinate that is at the upper left corner of the view | |
48 | * | |
49 | * @return the contents y coordinate | |
50 | */ | |
51 | public abstract int getContentsY(); | |
52 | ||
53 | /** | |
54 | * Returns the contents visible width | |
55 | * | |
56 | * @return the contents width | |
57 | */ | |
58 | public abstract int getVisibleWidth(); | |
59 | ||
60 | /** | |
61 | * Returns the contents visible height | |
62 | * | |
63 | * @return the contents height | |
64 | */ | |
65 | public abstract int getVisibleHeight(); | |
66 | ||
67 | /** | |
68 | * Translates the given contents x coordinate into view x coordinate | |
69 | * | |
70 | * @param x the x coordinate to translate | |
71 | * @return the corresponding view x coordinate | |
72 | */ | |
73 | public abstract int contentsToViewX(int x); | |
74 | ||
75 | /** | |
76 | * Translates the given contents y coordinate into view y coordinate | |
77 | * | |
78 | * @param y the y coordinate to translate | |
79 | * @return the corresponding view y coordinate | |
80 | */ | |
81 | public abstract int contentsToViewY(int y); | |
82 | ||
83 | /** | |
84 | * Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2). | |
85 | * | |
86 | * @param x1 the first point's x coordinate | |
87 | * @param y1 the first point's y coordinate | |
88 | * @param x2 the second point's x coordinate | |
89 | * @param y2 the second point's y coordinate | |
90 | */ | |
91 | public abstract void drawLine(int x1, int y1, int x2, int y2); | |
92 | ||
93 | /** | |
94 | * Draws the outline of the rectangle specified by the arguments, using the receiver's foreground color. The left | |
95 | * and right edges of the rectangle are at x and x + width. The top and bottom edges are at y and y + height. | |
96 | * | |
97 | * @param x the x coordinate of the rectangle to be drawn | |
98 | * @param y the y coordinate of the rectangle to be drawn | |
99 | * @param width the width of the rectangle to be drawn | |
100 | * @param height the height of the rectangle to be drawn | |
101 | */ | |
102 | public abstract void drawRectangle(int x, int y, int width, int height); | |
103 | ||
104 | /** | |
105 | * Draws a rectangle, based on the specified arguments, which has the appearance of the platform's focus rectangle | |
106 | * if the platform supports such a notion, and otherwise draws a simple rectangle in the receiver's foreground | |
107 | * color. | |
108 | * | |
109 | * @param x the x coordinate of the rectangle | |
110 | * @param y the y coordinate of the rectangle | |
111 | * @param width the width of the rectangle | |
112 | * @param height the height of the rectangle | |
113 | */ | |
114 | public abstract void drawFocus(int x, int y, int width, int height); | |
115 | ||
116 | /** | |
117 | * Fills the interior of the closed polygon which is defined by the specified array of integer coordinates, using | |
118 | * the receiver's background color. The array contains alternating x and y values which are considered to represent | |
119 | * points which are the vertices of the polygon. Lines are drawn between each consecutive pair, and between the | |
120 | * first pair and last pair in the array. | |
121 | * | |
122 | * @param points an array of alternating x and y values which are the vertices of the polygon | |
123 | */ | |
124 | public abstract void fillPolygon(int[] points); | |
125 | ||
126 | /** | |
127 | * Draws the closed polygon which is defined by the specified array of integer coordinates, using the receiver's | |
128 | * foreground color. The array contains alternating x and y values which are considered to represent points which | |
129 | * are the vertices of the polygon. Lines are drawn between each consecutive pair, and between the first pair and | |
130 | * last pair in the array. | |
131 | * | |
132 | * @param points an array of alternating x and y values which are the vertices of the polygon | |
133 | */ | |
134 | public abstract void drawPolygon(int[] points); | |
135 | ||
136 | /** | |
137 | * Fills the interior of the rectangle specified by the arguments, using the receiver's background color. | |
138 | * | |
139 | * @param x the x coordinate of the rectangle to be filled | |
140 | * @param y the y coordinate of the rectangle to be filled | |
141 | * @param width the width of the rectangle to be filled | |
142 | * @param height the height of the rectangle to be filled | |
143 | */ | |
144 | public abstract void fillRectangle(int x, int y, int width, int height); | |
145 | ||
146 | /** | |
147 | * Fills the interior of the specified rectangle with a gradient sweeping from left to right or top to bottom | |
148 | * progressing from the graphical context gradient color to its background color. | |
149 | * | |
150 | * @param x the x coordinate of the rectangle to be filled | |
151 | * @param y the y coordinate of the rectangle to be filled | |
152 | * @param width the width of the rectangle to be filled, may be negative (inverts direction of gradient if | |
153 | * horizontal) | |
154 | * @param height the height of the rectangle to be filled, may be negative (inverts direction of gradient if | |
155 | * horizontal) | |
156 | * @param vertical if true sweeps from top to bottom, else sweeps from left to right | |
157 | */ | |
158 | public abstract void fillGradientRectangle(int x, int y, int width, int height, boolean vertical); | |
159 | ||
160 | /** | |
161 | * Returns the given string width in pixels | |
162 | * | |
163 | * @param name the string | |
164 | * @return the string width | |
165 | */ | |
166 | public abstract int textExtent(String name); | |
167 | ||
168 | /** | |
169 | * Draws the given string, using the receiver's current font and foreground color. Tab expansion and carriage return | |
170 | * processing are performed. If trans is true, then the background of the rectangular area where the text is being | |
171 | * drawn will not be modified, otherwise it will be filled with the receiver's background color. | |
172 | * | |
173 | * @param string the string to be drawn | |
174 | * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn | |
175 | * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn | |
176 | * @param trans if true the background will be transparent, otherwise it will be opaque | |
177 | */ | |
178 | public abstract void drawText(String string, int x, int y, boolean trans); | |
179 | ||
180 | /** | |
181 | * Draws the given string, using the receiver's current font and foreground color. Tab expansion and carriage return | |
182 | * processing are performed. The background of the rectangular area where the text is being drawn will be filled | |
183 | * with the receiver's background color. | |
184 | * | |
185 | * @param string the string to be drawn | |
186 | * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn | |
187 | * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn | |
188 | */ | |
189 | public abstract void drawText(String string, int x, int y); | |
190 | ||
191 | /** | |
192 | * Fills the interior of an oval, within the specified rectangular area, with the receiver's background color. | |
193 | * | |
194 | * @param x the x coordinate of the upper left corner of the oval to be filled | |
195 | * @param y the y coordinate of the upper left corner of the oval to be filled | |
196 | * @param width the width of the oval to be filled | |
197 | * @param height the width of the oval to be filled | |
198 | */ | |
199 | public abstract void fillOval(int x, int y, int width, int height); | |
200 | ||
201 | /** | |
202 | * Returns current the background color used in the graphical context | |
203 | * | |
204 | * @return the background color | |
205 | */ | |
206 | public abstract IColor getBackground(); | |
207 | ||
208 | /** | |
209 | * Returns current the background color used in the graphical context | |
210 | * | |
211 | * @return the background color | |
212 | */ | |
213 | public abstract IColor getForeground(); | |
214 | ||
215 | /** | |
216 | * Set the graphical context foreground color | |
217 | * | |
218 | * @param color the foreground color | |
219 | */ | |
220 | public abstract void setBackground(IColor color); | |
221 | ||
222 | /** | |
223 | * Set the graphical context background color | |
224 | * | |
225 | * @param color the background color | |
226 | */ | |
227 | public abstract void setForeground(IColor color); | |
228 | ||
229 | /** | |
230 | * Set the color to use when filling regions using gradient. The color will progess from the given color to the | |
231 | * current background color | |
232 | * | |
233 | * @param color the gardiient color to use | |
234 | */ | |
235 | public abstract void setGradientColor(IColor color); | |
236 | ||
237 | /** | |
238 | * Set the line width to use for drawing | |
239 | * | |
240 | * @param width the line width | |
241 | */ | |
242 | public abstract void setLineWidth(int width); | |
243 | ||
244 | /** | |
245 | * Returns the current graphical context line width used for drawing | |
246 | * | |
247 | * @return the line width | |
248 | */ | |
249 | public abstract int getLineWidth(); | |
250 | ||
251 | /** | |
252 | * Returns the LineDotD style constant | |
253 | * | |
254 | * @return the constant value | |
255 | */ | |
256 | public abstract int getLineDotStyle(); | |
257 | ||
258 | /** | |
259 | * Returns the LineDash style constant | |
260 | * | |
261 | * @return the constant | |
262 | */ | |
263 | public abstract int getLineDashStyle(); | |
264 | ||
265 | /** | |
266 | * Returns the LineSolid style constant | |
267 | * | |
268 | * @return the constant | |
269 | */ | |
270 | public abstract int getLineSolidStyle(); | |
271 | ||
272 | /** | |
273 | * Draws the given string centered into the given rectangle. If the string cannot fit in the rectangle area, the | |
274 | * string is truncated. If trans is true, then the background of the rectangular area where the text is being drawn | |
275 | * will not be modified, otherwise it will be filled with the receiver's background color. | |
276 | * | |
277 | * @param name the string to draw | |
eb63f5ff BH |
278 | * @param x the x coordinate of the rectangle to draw the string |
279 | * @param y the y coordinate of the rectangle to draw the string | |
73005152 BH |
280 | * @param width the width of the rectangle to draw the string |
281 | * @param height the height of the rectangle to draw the string | |
282 | * @param trans if true the background will be transparent, otherwise it will be opaque | |
283 | */ | |
eb63f5ff | 284 | public abstract void drawTextTruncatedCentred(String name, int x, int y, int width, int height, boolean trans); |
73005152 BH |
285 | |
286 | /** | |
287 | * Draws the given string into the given rectangle (left justify) If the string cannot fit in the rectangle area, | |
288 | * the string is truncated. If trans is true, then the background of the rectangular area where the text is being | |
289 | * drawn will not be modified, otherwise it will be filled with the receiver's background color. | |
290 | * | |
eb63f5ff BH |
291 | * @param x the x coordinate of the rectangle to draw the string |
292 | * @param y the y coordinate of the rectangle to draw the string | |
73005152 BH |
293 | * @param width the width of the rectangle to draw the string |
294 | * @param height the height of the rectangle to draw the string | |
295 | * @param trans if true the background will be transparent, otherwise it will be opaque | |
296 | */ | |
eb63f5ff | 297 | public abstract void drawTextTruncated(String name, int x, int y, int width, int height, boolean trans); |
73005152 BH |
298 | |
299 | /** | |
300 | * Copies a the source image into a (potentially different sized) rectangular area in the graphical context. If the | |
301 | * source image has smaller sizes, then the source area will be stretched to fit the destination area as it is | |
302 | * copied. | |
303 | * | |
304 | * @param image the image to draw | |
eb63f5ff BH |
305 | * @param x the x coordinate in the destination to copy to |
306 | * @param y the y coordinate in the destination to copy to | |
73005152 BH |
307 | * @param maxWith the width in pixels of the destination rectangle |
308 | * @param maxHeight the height in pixels of the destination rectangle | |
309 | */ | |
eb63f5ff | 310 | public abstract void drawImage(IImage image, int x, int y, int maxWith, int maxHeight); |
73005152 BH |
311 | |
312 | /** | |
313 | * Draws the outline of a circular or elliptical arc within the specified rectangular area. The resulting arc begins | |
314 | * at startAngle and extends for arcAngle degrees, using the current color. Angles are interpreted such that 0 | |
315 | * degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative | |
316 | * value indicates a clockwise rotation. The center of the arc is the center of the rectangle whose origin is (x, y) | |
317 | * and whose size is specified by the width and height arguments. The resulting arc covers an area width + 1 pixels | |
318 | * wide by height + 1 pixels tall. | |
319 | * | |
320 | * @param x the x coordinate of the upper-left corner of the arc to be drawn | |
321 | * @param y the y coordinate of the upper-left corner of the arc to be drawn | |
322 | * @param width the width of the arc to be drawn | |
323 | * @param height the height of the arc to be drawn | |
324 | * @param startAngle the beginning angle | |
325 | * @param endAngle the ending angle | |
326 | */ | |
327 | public abstract void drawArc(int x, int y, int width, int height, int startAngle, int endAngle); | |
328 | ||
329 | /** | |
330 | * Set the current font used in the graphical context | |
331 | * | |
332 | * @param font the font to use | |
333 | */ | |
334 | public abstract void setFont(IFont font); | |
335 | ||
336 | /** | |
337 | * Returns the font height given font | |
338 | * | |
339 | * @param font | |
340 | * @return the the font height | |
341 | */ | |
342 | public abstract int getFontHeight(IFont font); | |
343 | ||
344 | /** | |
345 | * Returns the average character width for the given font | |
346 | * | |
347 | * @param font | |
348 | * @return the average width | |
349 | */ | |
350 | public abstract int getFontWidth(IFont font); | |
351 | ||
352 | /** | |
353 | * Creates a color with the given RGB values | |
354 | * | |
355 | * @param r the red component | |
356 | * @param g the green component | |
357 | * @param b the blue component | |
358 | * @return the color | |
359 | */ | |
360 | public abstract IColor createColor(int r, int g, int b); | |
361 | ||
362 | /** | |
363 | * Returns the zoom factor applied in both x and y directions when drawing | |
364 | * | |
365 | * @return the zoom factor | |
366 | */ | |
367 | public abstract float getZoom(); | |
368 | ||
df0b8ff4 BH |
369 | /** |
370 | * Draws text with focus style. | |
371 | * | |
372 | * @param focus <code>true</code> if item has focus else <code>false</code> | |
373 | */ | |
73005152 BH |
374 | public abstract void setDrawTextWithFocusStyle(boolean focus); |
375 | } |