Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fba8aa7c14550c1dc43868ddcdc7454e7345b1e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
/**********************************************************************
 * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM - Initial API and implementation
 *     Bernd Hufmann - Updated for TMF
 **********************************************************************/

package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings;

/**
 * Interface for a graphical context.
 *
 * @version 1.0
 * @author sveyrier
 *
 */
public interface IGC {

    /**
     * Set the current line style
     *
     * @param style the new line style
     */
    void setLineStyle(int style);

    /**
     * Returns current the line style used in the graphical context
     *
     * @return the current line style
     */
    int getLineStyle();

    /**
     * Returns the contents x coordinate that is at the upper left corner of the view
     *
     * @return the contents x coordinate
     */
    int getContentsX();

    /**
     * Returns the contents y coordinate that is at the upper left corner of the view
     *
     * @return the contents y coordinate
     */
    int getContentsY();

    /**
     * Returns the contents visible width
     *
     * @return the contents width
     */
    int getVisibleWidth();

    /**
     * Returns the contents visible height
     *
     * @return the contents height
     */
    int getVisibleHeight();

    /**
     * Translates the given contents x coordinate into view x coordinate
     *
     * @param x the x coordinate to translate
     * @return the corresponding view x coordinate
     */
    int contentsToViewX(int x);

    /**
     * Translates the given contents y coordinate into view y coordinate
     *
     * @param y the y coordinate to translate
     * @return the corresponding view y coordinate
     */
    int contentsToViewY(int y);

    /**
     * Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).
     *
     * @param x1 the first point's x coordinate
     * @param y1 the first point's y coordinate
     * @param x2 the second point's x coordinate
     * @param y2 the second point's y coordinate
     */
    void drawLine(int x1, int y1, int x2, int y2);

    /**
     * Draws the outline of the rectangle specified by the arguments, using the receiver's foreground color. The left
     * and right edges of the rectangle are at x and x + width. The top and bottom edges are at y and y + height.
     *
     * @param x the x coordinate of the rectangle to be drawn
     * @param y the y coordinate of the rectangle to be drawn
     * @param width the width of the rectangle to be drawn
     * @param height the height of the rectangle to be drawn
     */
    void drawRectangle(int x, int y, int width, int height);

    /**
     * Draws a rectangle, based on the specified arguments, which has the appearance of the platform's focus rectangle
     * if the platform supports such a notion, and otherwise draws a simple rectangle in the receiver's foreground
     * color.
     *
     * @param x the x coordinate of the rectangle
     * @param y the y coordinate of the rectangle
     * @param width the width of the rectangle
     * @param height the height of the rectangle
     */
    void drawFocus(int x, int y, int width, int height);

    /**
     * Fills the interior of the closed polygon which is defined by the specified array of integer coordinates, using
     * the receiver's background color. The array contains alternating x and y values which are considered to represent
     * points which are the vertices of the polygon. Lines are drawn between each consecutive pair, and between the
     * first pair and last pair in the array.
     *
     * @param points an array of alternating x and y values which are the vertices of the polygon
     */
    void fillPolygon(int[] points);

    /**
     * Draws the closed polygon which is defined by the specified array of integer coordinates, using the receiver's
     * foreground color. The array contains alternating x and y values which are considered to represent points which
     * are the vertices of the polygon. Lines are drawn between each consecutive pair, and between the first pair and
     * last pair in the array.
     *
     * @param points an array of alternating x and y values which are the vertices of the polygon
     */
    void drawPolygon(int[] points);

    /**
     * Fills the interior of the rectangle specified by the arguments, using the receiver's background color.
     *
     * @param x the x coordinate of the rectangle to be filled
     * @param y the y coordinate of the rectangle to be filled
     * @param width the width of the rectangle to be filled
     * @param height the height of the rectangle to be filled
     */
    void fillRectangle(int x, int y, int width, int height);

    /**
     * Fills the interior of the specified rectangle with a gradient sweeping from left to right or top to bottom
     * progressing from the graphical context gradient color to its background color.
     *
     * @param x the x coordinate of the rectangle to be filled
     * @param y the y coordinate of the rectangle to be filled
     * @param width the width of the rectangle to be filled, may be negative (inverts direction of gradient if
     *            horizontal)
     * @param height the height of the rectangle to be filled, may be negative (inverts direction of gradient if
     *            horizontal)
     * @param vertical if true sweeps from top to bottom, else sweeps from left to right
     */
    void fillGradientRectangle(int x, int y, int width, int height, boolean vertical);

    /**
     * Returns the given string width in pixels
     *
     * @param name the string
     * @return the string width
     */
    int textExtent(String name);

    /**
     * Draws the given string, using the receiver's current font and foreground color. Tab expansion and carriage return
     * processing are performed. If trans is true, then the background of the rectangular area where the text is being
     * drawn will not be modified, otherwise it will be filled with the receiver's background color.
     *
     * @param string the string to be drawn
     * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
     * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
     * @param trans if true the background will be transparent, otherwise it will be opaque
     */
    void drawText(String string, int x, int y, boolean trans);

    /**
     * Draws the given string, using the receiver's current font and foreground color. Tab expansion and carriage return
     * processing are performed. The background of the rectangular area where the text is being drawn will be filled
     * with the receiver's background color.
     *
     * @param string the string to be drawn
     * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
     * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
     */
    void drawText(String string, int x, int y);

    /**
     * Fills the interior of an oval, within the specified rectangular area, with the receiver's background color.
     *
     * @param x the x coordinate of the upper left corner of the oval to be filled
     * @param y the y coordinate of the upper left corner of the oval to be filled
     * @param width the width of the oval to be filled
     * @param height the width of the oval to be filled
     */
    void fillOval(int x, int y, int width, int height);

    /**
     * Returns current the background color used in the graphical context
     *
     * @return the background color
     */
    IColor getBackground();

    /**
     * Returns current the background color used in the graphical context
     *
     * @return the background color
     */
    IColor getForeground();

    /**
     * Set the graphical context foreground color
     *
     * @param color the foreground color
     */
    void setBackground(IColor color);

    /**
     * Set the graphical context background color
     *
     * @param color the background color
     */
    void setForeground(IColor color);

    /**
     * Set the color to use when filling regions using gradient. The color will progess from the given color to the
     * current background color
     *
     * @param color the gardiient color to use
     */
    void setGradientColor(IColor color);

    /**
     * Set the line width to use for drawing
     *
     * @param width the line width
     */
    void setLineWidth(int width);

    /**
     * Returns the current graphical context line width used for drawing
     *
     * @return the line width
     */
    int getLineWidth();

    /**
     * Returns the LineDotD style constant
     *
     * @return the constant value
     */
    int getLineDotStyle();

    /**
     * Returns the LineDash style constant
     *
     * @return the constant
     */
    int getLineDashStyle();

    /**
     * Returns the LineSolid style constant
     *
     * @return the constant
     */
    int getLineSolidStyle();

    /**
     * Draws the given string centered into the given rectangle. If the string cannot fit in the rectangle area, the
     * string is truncated. If trans is true, then the background of the rectangular area where the text is being drawn
     * will not be modified, otherwise it will be filled with the receiver's background color.
     *
     * @param name the string to draw
     * @param x the x coordinate of the rectangle to draw the string
     * @param y the y coordinate of the rectangle to draw the string
     * @param width the width of the rectangle to draw the string
     * @param height the height of the rectangle to draw the string
     * @param trans if true the background will be transparent, otherwise it will be opaque
     */
    void drawTextTruncatedCentred(String name, int x, int y, int width, int height, boolean trans);

    /**
     * Draws the given string into the given rectangle (left justify) If the string cannot fit in the rectangle area,
     * the string is truncated. If trans is true, then the background of the rectangular area where the text is being
     * drawn will not be modified, otherwise it will be filled with the receiver's background color.
     *
     * @param name The text to put in the rectangle
     * @param x the x coordinate of the rectangle to draw the string
     * @param y the y coordinate of the rectangle to draw the string
     * @param width the width of the rectangle to draw the string
     * @param height the height of the rectangle to draw the string
     * @param trans if true the background will be transparent, otherwise it will be opaque
     */
    void drawTextTruncated(String name, int x, int y, int width, int height, boolean trans);

    /**
     * Copies a the source image into a (potentially different sized) rectangular area in the graphical context. If the
     * source image has smaller sizes, then the source area will be stretched to fit the destination area as it is
     * copied.
     *
     * @param image the image to draw
     * @param x the x coordinate in the destination to copy to
     * @param y the y coordinate in the destination to copy to
     * @param maxWith the width in pixels of the destination rectangle
     * @param maxHeight the height in pixels of the destination rectangle
     */
    void drawImage(IImage image, int x, int y, int maxWith, int maxHeight);

    /**
     * Draws the outline of a circular or elliptical arc within the specified rectangular area. The resulting arc begins
     * at startAngle and extends for arcAngle degrees, using the current color. Angles are interpreted such that 0
     * degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative
     * value indicates a clockwise rotation. The center of the arc is the center of the rectangle whose origin is (x, y)
     * and whose size is specified by the width and height arguments. The resulting arc covers an area width + 1 pixels
     * wide by height + 1 pixels tall.
     *
     * @param x the x coordinate of the upper-left corner of the arc to be drawn
     * @param y the y coordinate of the upper-left corner of the arc to be drawn
     * @param width the width of the arc to be drawn
     * @param height the height of the arc to be drawn
     * @param startAngle the beginning angle
     * @param endAngle the ending angle
     */
    void drawArc(int x, int y, int width, int height, int startAngle, int endAngle);

    /**
     * Set the current font used in the graphical context
     *
     * @param font the font to use
     */
    void setFont(IFont font);

    /**
     * Returns the font height given font
     *
     * @param font The font to check for
     * @return the the font height
     */
    int getFontHeight(IFont font);

    /**
     * Returns the average character width for the given font
     *
     * @param font The font to check for
     * @return the average width
     */
    int getFontWidth(IFont font);

    /**
     * Creates a color with the given RGB values
     *
     * @param r the red component
     * @param g the green component
     * @param b the blue component
     * @return the color
     */
    IColor createColor(int r, int g, int b);

    /**
     * Returns the zoom factor applied in both x and y directions when drawing
     *
     * @return the zoom factor
     */
    float getZoom();

    /**
     * Draws text with focus style.
     *
     * @param focus <code>true</code> if item has focus else <code>false</code>
     */
    void setDrawTextWithFocusStyle(boolean focus);
}

Back to the top