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