1 /**********************************************************************
2 * Copyright (c) 2005, 2006 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
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
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
;
17 * Interface for a graphical context.
23 public interface IGC
{
26 * Set the current line style
28 * @param style the new line style
30 public abstract void setLineStyle(int style
);
33 * Returns current the line style used in the graphical context
35 * @return the current line style
37 public abstract int getLineStyle();
40 * Returns the contents x coordinate that is at the upper left corner of the view
42 * @return the contents x coordinate
44 public abstract int getContentsX();
47 * Returns the contents y coordinate that is at the upper left corner of the view
49 * @return the contents y coordinate
51 public abstract int getContentsY();
54 * Returns the contents visible width
56 * @return the contents width
58 public abstract int getVisibleWidth();
61 * Returns the contents visible height
63 * @return the contents height
65 public abstract int getVisibleHeight();
68 * Translates the given contents x coordinate into view x coordinate
70 * @param x the x coordinate to translate
71 * @return the corresponding view x coordinate
73 public abstract int contentsToViewX(int x
);
76 * Translates the given contents y coordinate into view y coordinate
78 * @param y the y coordinate to translate
79 * @return the corresponding view y coordinate
81 public abstract int contentsToViewY(int y
);
84 * Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).
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
91 public abstract void drawLine(int x1
, int y1
, int x2
, int y2
);
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.
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
102 public abstract void drawRectangle(int x
, int y
, int width
, int height
);
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
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
114 public abstract void drawFocus(int x
, int y
, int width
, int height
);
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.
122 * @param points an array of alternating x and y values which are the vertices of the polygon
124 public abstract void fillPolygon(int[] points
);
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.
132 * @param points an array of alternating x and y values which are the vertices of the polygon
134 public abstract void drawPolygon(int[] points
);
137 * Fills the interior of the rectangle specified by the arguments, using the receiver's background color.
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
144 public abstract void fillRectangle(int x
, int y
, int width
, int height
);
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.
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
154 * @param height the height of the rectangle to be filled, may be negative (inverts direction of gradient if
156 * @param vertical if true sweeps from top to bottom, else sweeps from left to right
158 public abstract void fillGradientRectangle(int x
, int y
, int width
, int height
, boolean vertical
);
161 * Returns the given string width in pixels
163 * @param name the string
164 * @return the string width
166 public abstract int textExtent(String name
);
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.
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
178 public abstract void drawText(String string
, int x
, int y
, boolean trans
);
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.
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
189 public abstract void drawText(String string
, int x
, int y
);
192 * Fills the interior of an oval, within the specified rectangular area, with the receiver's background color.
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
199 public abstract void fillOval(int x
, int y
, int width
, int height
);
202 * Returns current the background color used in the graphical context
204 * @return the background color
206 public abstract IColor
getBackground();
209 * Returns current the background color used in the graphical context
211 * @return the background color
213 public abstract IColor
getForeground();
216 * Set the graphical context foreground color
218 * @param color the foreground color
220 public abstract void setBackground(IColor color
);
223 * Set the graphical context background color
225 * @param color the background color
227 public abstract void setForeground(IColor color
);
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
233 * @param color the gardiient color to use
235 public abstract void setGradientColor(IColor color
);
238 * Set the line width to use for drawing
240 * @param width the line width
242 public abstract void setLineWidth(int width
);
245 * Returns the current graphical context line width used for drawing
247 * @return the line width
249 public abstract int getLineWidth();
252 * Returns the LineDotD style constant
254 * @return the constant value
256 public abstract int getLineDotStyle();
259 * Returns the LineDash style constant
261 * @return the constant
263 public abstract int getLineDashStyle();
266 * Returns the LineSolid style constant
268 * @return the constant
270 public abstract int getLineSolidStyle();
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.
277 * @param name the string to draw
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
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
284 public abstract void drawTextTruncatedCentred(String name
, int x
, int y
, int width
, int height
, boolean trans
);
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.
291 * @param name The text to put in the rectangle
292 * @param x the x coordinate of the rectangle to draw the string
293 * @param y the y coordinate of the rectangle to draw the string
294 * @param width the width of the rectangle to draw the string
295 * @param height the height of the rectangle to draw the string
296 * @param trans if true the background will be transparent, otherwise it will be opaque
298 public abstract void drawTextTruncated(String name
, int x
, int y
, int width
, int height
, boolean trans
);
301 * Copies a the source image into a (potentially different sized) rectangular area in the graphical context. If the
302 * source image has smaller sizes, then the source area will be stretched to fit the destination area as it is
305 * @param image the image to draw
306 * @param x the x coordinate in the destination to copy to
307 * @param y the y coordinate in the destination to copy to
308 * @param maxWith the width in pixels of the destination rectangle
309 * @param maxHeight the height in pixels of the destination rectangle
311 public abstract void drawImage(IImage image
, int x
, int y
, int maxWith
, int maxHeight
);
314 * Draws the outline of a circular or elliptical arc within the specified rectangular area. The resulting arc begins
315 * at startAngle and extends for arcAngle degrees, using the current color. Angles are interpreted such that 0
316 * degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative
317 * value indicates a clockwise rotation. The center of the arc is the center of the rectangle whose origin is (x, y)
318 * and whose size is specified by the width and height arguments. The resulting arc covers an area width + 1 pixels
319 * wide by height + 1 pixels tall.
321 * @param x the x coordinate of the upper-left corner of the arc to be drawn
322 * @param y the y coordinate of the upper-left corner of the arc to be drawn
323 * @param width the width of the arc to be drawn
324 * @param height the height of the arc to be drawn
325 * @param startAngle the beginning angle
326 * @param endAngle the ending angle
328 public abstract void drawArc(int x
, int y
, int width
, int height
, int startAngle
, int endAngle
);
331 * Set the current font used in the graphical context
333 * @param font the font to use
335 public abstract void setFont(IFont font
);
338 * Returns the font height given font
340 * @param font The font to check for
341 * @return the the font height
343 public abstract int getFontHeight(IFont font
);
346 * Returns the average character width for the given font
348 * @param font The font to check for
349 * @return the average width
351 public abstract int getFontWidth(IFont font
);
354 * Creates a color with the given RGB values
356 * @param r the red component
357 * @param g the green component
358 * @param b the blue component
361 public abstract IColor
createColor(int r
, int g
, int b
);
364 * Returns the zoom factor applied in both x and y directions when drawing
366 * @return the zoom factor
368 public abstract float getZoom();
371 * Draws text with focus style.
373 * @param focus <code>true</code> if item has focus else <code>false</code>
375 public abstract void setDrawTextWithFocusStyle(boolean focus
);
This page took 0.058899 seconds and 6 git commands to generate.