1 /**********************************************************************
2 * Copyright (c) 2005, 2012 IBM Corporation, Ericsson
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
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
;
16 * Interface for a graphical context.
22 public interface IGC
{
25 * Set the current line style
27 * @param style the new line style
29 public abstract void setLineStyle(int style
);
32 * Returns current the line style used in the graphical context
34 * @return the current line style
36 public abstract int getLineStyle();
39 * Returns the contents x coordinate that is at the upper left corner of the view
41 * @return the contents x coordinate
43 public abstract int getContentsX();
46 * Returns the contents y coordinate that is at the upper left corner of the view
48 * @return the contents y coordinate
50 public abstract int getContentsY();
53 * Returns the contents visible width
55 * @return the contents width
57 public abstract int getVisibleWidth();
60 * Returns the contents visible height
62 * @return the contents height
64 public abstract int getVisibleHeight();
67 * Translates the given contents x coordinate into view x coordinate
69 * @param x the x coordinate to translate
70 * @return the corresponding view x coordinate
72 public abstract int contentsToViewX(int x
);
75 * Translates the given contents y coordinate into view y coordinate
77 * @param y the y coordinate to translate
78 * @return the corresponding view y coordinate
80 public abstract int contentsToViewY(int y
);
83 * Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).
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
90 public abstract void drawLine(int x1
, int y1
, int x2
, int y2
);
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.
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
101 public abstract void drawRectangle(int x
, int y
, int width
, int height
);
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
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
113 public abstract void drawFocus(int x
, int y
, int width
, int height
);
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.
121 * @param points an array of alternating x and y values which are the vertices of the polygon
123 public abstract void fillPolygon(int[] points
);
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.
131 * @param points an array of alternating x and y values which are the vertices of the polygon
133 public abstract void drawPolygon(int[] points
);
136 * Fills the interior of the rectangle specified by the arguments, using the receiver's background color.
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
143 public abstract void fillRectangle(int x
, int y
, int width
, int height
);
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.
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
153 * @param height the height of the rectangle to be filled, may be negative (inverts direction of gradient if
155 * @param vertical if true sweeps from top to bottom, else sweeps from left to right
157 public abstract void fillGradientRectangle(int x
, int y
, int width
, int height
, boolean vertical
);
160 * Returns the given string width in pixels
162 * @param name the string
163 * @return the string width
165 public abstract int textExtent(String name
);
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.
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
177 public abstract void drawText(String string
, int x
, int y
, boolean trans
);
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.
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
188 public abstract void drawText(String string
, int x
, int y
);
191 * Fills the interior of an oval, within the specified rectangular area, with the receiver's background color.
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
198 public abstract void fillOval(int x
, int y
, int width
, int height
);
201 * Returns current the background color used in the graphical context
203 * @return the background color
205 public abstract IColor
getBackground();
208 * Returns current the background color used in the graphical context
210 * @return the background color
212 public abstract IColor
getForeground();
215 * Set the graphical context foreground color
217 * @param color the foreground color
219 public abstract void setBackground(IColor color
);
222 * Set the graphical context background color
224 * @param color the background color
226 public abstract void setForeground(IColor color
);
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
232 * @param color the gardiient color to use
234 public abstract void setGradientColor(IColor color
);
237 * Set the line width to use for drawing
239 * @param width the line width
241 public abstract void setLineWidth(int width
);
244 * Returns the current graphical context line width used for drawing
246 * @return the line width
248 public abstract int getLineWidth();
251 * Returns the LineDotD style constant
253 * @return the constant value
255 public abstract int getLineDotStyle();
258 * Returns the LineDash style constant
260 * @return the constant
262 public abstract int getLineDashStyle();
265 * Returns the LineSolid style constant
267 * @return the constant
269 public abstract int getLineSolidStyle();
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.
276 * @param name the string to draw
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
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
283 public abstract void drawTextTruncatedCentred(String name
, int x
, int y
, int width
, int height
, boolean trans
);
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.
290 * @param name The text to put in the rectangle
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
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
297 public abstract void drawTextTruncated(String name
, int x
, int y
, int width
, int height
, boolean trans
);
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
304 * @param image the image to draw
305 * @param x the x coordinate in the destination to copy to
306 * @param y the y coordinate in the destination to copy to
307 * @param maxWith the width in pixels of the destination rectangle
308 * @param maxHeight the height in pixels of the destination rectangle
310 public abstract void drawImage(IImage image
, int x
, int y
, int maxWith
, int maxHeight
);
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.
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
327 public abstract void drawArc(int x
, int y
, int width
, int height
, int startAngle
, int endAngle
);
330 * Set the current font used in the graphical context
332 * @param font the font to use
334 public abstract void setFont(IFont font
);
337 * Returns the font height given font
339 * @param font The font to check for
340 * @return the the font height
342 public abstract int getFontHeight(IFont font
);
345 * Returns the average character width for the given font
347 * @param font The font to check for
348 * @return the average width
350 public abstract int getFontWidth(IFont font
);
353 * Creates a color with the given RGB values
355 * @param r the red component
356 * @param g the green component
357 * @param b the blue component
360 public abstract IColor
createColor(int r
, int g
, int b
);
363 * Returns the zoom factor applied in both x and y directions when drawing
365 * @return the zoom factor
367 public abstract float getZoom();
370 * Draws text with focus style.
372 * @param focus <code>true</code> if item has focus else <code>false</code>
374 public abstract void setDrawTextWithFocusStyle(boolean focus
);
This page took 0.039324 seconds and 6 git commands to generate.