Class NGC
java.lang.Object
org.eclipse.tracecompass.tmf.ui.views.uml2sd.NGC
- All Implemented Interfaces:
IGC
This class implements the graphical context for the sequence diagram widgets.
- Version:
- 1.0
- Author:
- sveyrier
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcontentsToViewX(int x) Translates the given contents x coordinate into view x coordinateintcontentsToViewY(int y) Translates the given contents y coordinate into view y coordinatecreateColor(int r, int g, int b) Creates a color with the given RGB valuesvoiddispose()Disposes all created resources.voiddrawArc(int x, int y, int width, int height, int startAngle, int endAngle) Draws the outline of a circular or elliptical arc within the specified rectangular area.voiddrawFocus(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.voidCopies a the source image into a (potentially different sized) rectangular area in the graphical context.voiddrawLine(int x1, int y1, int x2, int y2) Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).voiddrawPolygon(int[] points) Draws the closed polygon which is defined by the specified array of integer coordinates, using the receiver's foreground color.voiddrawRectangle(int x, int y, int width, int height) Draws the outline of the rectangle specified by the arguments, using the receiver's foreground color.voidDraws the given string, using the receiver's current font and foreground color.voidDraws the given string, using the receiver's current font and foreground color.voiddrawTextTruncated(String name, int xValue, int yValue, 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.voiddrawTextTruncatedCentred(String name, int xValue, int yValue, int width, int height, boolean trans) Draws the given string centered into the given rectangle.voidfillGradientRectangle(int x, int y, int width, int height, boolean isVertical) 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.voidfillOval(int x, int y, int width, int height) Fills the interior of an oval, within the specified rectangular area, with the receiver's background color.voidfillPolygon(int[] points) Fills the interior of the closed polygon which is defined by the specified array of integer coordinates, using the receiver's background color.voidfillRectangle(int x, int y, int width, int height) Fills the interior of the rectangle specified by the arguments, using the receiver's background color.Returns current the background color used in the graphical contextintReturns the contents x coordinate that is at the upper left corner of the viewintReturns the contents y coordinate that is at the upper left corner of the viewintgetFontHeight(IFont font) Returns the font height given fontintgetFontWidth(IFont font) Returns the average character width for the given fontReturns current the background color used in the graphical contextintReturns the LineDash style constantintReturns the LineDotD style constantintReturns the LineSolid style constantintReturns current the line style used in the graphical contextintReturns the current graphical context line width used for drawingintReturns the contents visible heightintReturns the contents visible widthfloatgetZoom()Returns the zoom factor applied in both x and y directions when drawingvoidsetBackground(IColor color) Set the graphical context foreground colorvoidsetDrawTextWithFocusStyle(boolean focus) Draws text with focus style.voidSet the current font used in the graphical contextvoidsetForeground(IColor color) Set the graphical context background colorvoidsetGradientColor(IColor color) Set the color to use when filling regions using gradient.voidsetLineStyle(int style) Set the current line stylevoidsetLineWidth(int width) Set the line width to use for drawinginttextExtent(String name) Returns the given string width in pixels
-
Constructor Details
-
NGC
Default constructor.- Parameters:
scrollView- A sequence diagram view reference.gc- A graphical context.
-
-
Method Details
-
setLineStyle
public void setLineStyle(int style) Description copied from interface:IGCSet the current line style- Specified by:
setLineStylein interfaceIGC- Parameters:
style- the new line style
-
getLineStyle
public int getLineStyle()Description copied from interface:IGCReturns current the line style used in the graphical context- Specified by:
getLineStylein interfaceIGC- Returns:
- the current line style
-
getContentsX
public int getContentsX()Description copied from interface:IGCReturns the contents x coordinate that is at the upper left corner of the view- Specified by:
getContentsXin interfaceIGC- Returns:
- the contents x coordinate
-
getContentsY
public int getContentsY()Description copied from interface:IGCReturns the contents y coordinate that is at the upper left corner of the view- Specified by:
getContentsYin interfaceIGC- Returns:
- the contents y coordinate
-
getVisibleWidth
public int getVisibleWidth()Description copied from interface:IGCReturns the contents visible width- Specified by:
getVisibleWidthin interfaceIGC- Returns:
- the contents width
-
getVisibleHeight
public int getVisibleHeight()Description copied from interface:IGCReturns the contents visible height- Specified by:
getVisibleHeightin interfaceIGC- Returns:
- the contents height
-
contentsToViewX
public int contentsToViewX(int x) Description copied from interface:IGCTranslates the given contents x coordinate into view x coordinate- Specified by:
contentsToViewXin interfaceIGC- Parameters:
x- the x coordinate to translate- Returns:
- the corresponding view x coordinate
-
contentsToViewY
public int contentsToViewY(int y) Description copied from interface:IGCTranslates the given contents y coordinate into view y coordinate- Specified by:
contentsToViewYin interfaceIGC- Parameters:
y- the y coordinate to translate- Returns:
- the corresponding view y coordinate
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2) Description copied from interface:IGCDraws a line, using the foreground color, between the points (x1, y1) and (x2, y2). -
drawRectangle
public void drawRectangle(int x, int y, int width, int height) Description copied from interface:IGCDraws 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.- Specified by:
drawRectanglein interfaceIGC- Parameters:
x- the x coordinate of the rectangle to be drawny- the y coordinate of the rectangle to be drawnwidth- the width of the rectangle to be drawnheight- the height of the rectangle to be drawn
-
drawFocus
public void drawFocus(int x, int y, int width, int height) Description copied from interface:IGCDraws 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. -
fillPolygon
public void fillPolygon(int[] points) Description copied from interface:IGCFills 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.- Specified by:
fillPolygonin interfaceIGC- Parameters:
points- an array of alternating x and y values which are the vertices of the polygon
-
drawPolygon
public void drawPolygon(int[] points) Description copied from interface:IGCDraws 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.- Specified by:
drawPolygonin interfaceIGC- Parameters:
points- an array of alternating x and y values which are the vertices of the polygon
-
fillRectangle
public void fillRectangle(int x, int y, int width, int height) Description copied from interface:IGCFills the interior of the rectangle specified by the arguments, using the receiver's background color.- Specified by:
fillRectanglein interfaceIGC- Parameters:
x- the x coordinate of the rectangle to be filledy- the y coordinate of the rectangle to be filledwidth- the width of the rectangle to be filledheight- the height of the rectangle to be filled
-
fillGradientRectangle
public void fillGradientRectangle(int x, int y, int width, int height, boolean isVertical) Description copied from interface:IGCFills 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.- Specified by:
fillGradientRectanglein interfaceIGC- Parameters:
x- the x coordinate of the rectangle to be filledy- the y coordinate of the rectangle to be filledwidth- the width of the rectangle to be filled, may be negative (inverts direction of gradient if horizontal)height- the height of the rectangle to be filled, may be negative (inverts direction of gradient if horizontal)isVertical- if true sweeps from top to bottom, else sweeps from left to right
-
textExtent
Description copied from interface:IGCReturns the given string width in pixels- Specified by:
textExtentin interfaceIGC- Parameters:
name- the string- Returns:
- the string width
-
drawText
Description copied from interface:IGCDraws 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.- Specified by:
drawTextin interfaceIGC- Parameters:
string- the string to be drawnx- the x coordinate of the top left corner of the rectangular area where the text is to be drawny- the y coordinate of the top left corner of the rectangular area where the text is to be drawnisTrans- if true the background will be transparent, otherwise it will be opaque
-
drawText
Description copied from interface:IGCDraws 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. -
fillOval
public void fillOval(int x, int y, int width, int height) Description copied from interface:IGCFills the interior of an oval, within the specified rectangular area, with the receiver's background color. -
getBackground
Description copied from interface:IGCReturns current the background color used in the graphical context- Specified by:
getBackgroundin interfaceIGC- Returns:
- the background color
-
getForeground
Description copied from interface:IGCReturns current the background color used in the graphical context- Specified by:
getForegroundin interfaceIGC- Returns:
- the background color
-
setBackground
Description copied from interface:IGCSet the graphical context foreground color- Specified by:
setBackgroundin interfaceIGC- Parameters:
color- the foreground color
-
setForeground
Description copied from interface:IGCSet the graphical context background color- Specified by:
setForegroundin interfaceIGC- Parameters:
color- the background color
-
setGradientColor
Description copied from interface:IGCSet the color to use when filling regions using gradient. The color will progess from the given color to the current background color- Specified by:
setGradientColorin interfaceIGC- Parameters:
color- the gardiient color to use
-
setLineWidth
public void setLineWidth(int width) Description copied from interface:IGCSet the line width to use for drawing- Specified by:
setLineWidthin interfaceIGC- Parameters:
width- the line width
-
getLineWidth
public int getLineWidth()Description copied from interface:IGCReturns the current graphical context line width used for drawing- Specified by:
getLineWidthin interfaceIGC- Returns:
- the line width
-
drawTextTruncatedCentred
public void drawTextTruncatedCentred(String name, int xValue, int yValue, int width, int height, boolean trans) Description copied from interface:IGCDraws 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.- Specified by:
drawTextTruncatedCentredin interfaceIGC- Parameters:
name- the string to drawxValue- the x coordinate of the rectangle to draw the stringyValue- the y coordinate of the rectangle to draw the stringwidth- the width of the rectangle to draw the stringheight- the height of the rectangle to draw the stringtrans- if true the background will be transparent, otherwise it will be opaque
-
drawTextTruncated
public void drawTextTruncated(String name, int xValue, int yValue, int width, int height, boolean trans) Description copied from interface:IGCDraws 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.- Specified by:
drawTextTruncatedin interfaceIGC- Parameters:
name- The text to put in the rectanglexValue- the x coordinate of the rectangle to draw the stringyValue- the y coordinate of the rectangle to draw the stringwidth- the width of the rectangle to draw the stringheight- the height of the rectangle to draw the stringtrans- if true the background will be transparent, otherwise it will be opaque
-
drawImage
Description copied from interface:IGCCopies 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.- Specified by:
drawImagein interfaceIGC- Parameters:
image- the image to drawxValue- the x coordinate in the destination to copy toyValue- the y coordinate in the destination to copy tomaxWith- the width in pixels of the destination rectanglemaxHeight- the height in pixels of the destination rectangle
-
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int endAngle) Description copied from interface:IGCDraws 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.- Specified by:
drawArcin interfaceIGC- Parameters:
x- the x coordinate of the upper-left corner of the arc to be drawny- the y coordinate of the upper-left corner of the arc to be drawnwidth- the width of the arc to be drawnheight- the height of the arc to be drawnstartAngle- the beginning angleendAngle- the ending angle
-
setFont
Description copied from interface:IGCSet the current font used in the graphical context -
getFontHeight
Description copied from interface:IGCReturns the font height given font- Specified by:
getFontHeightin interfaceIGC- Parameters:
font- The font to check for- Returns:
- the the font height
-
getFontWidth
Description copied from interface:IGCReturns the average character width for the given font- Specified by:
getFontWidthin interfaceIGC- Parameters:
font- The font to check for- Returns:
- the average width
-
dispose
public void dispose()Disposes all created resources. -
getZoom
public float getZoom()Description copied from interface:IGCReturns the zoom factor applied in both x and y directions when drawing -
getLineDotStyle
public int getLineDotStyle()Description copied from interface:IGCReturns the LineDotD style constant- Specified by:
getLineDotStylein interfaceIGC- Returns:
- the constant value
-
getLineDashStyle
public int getLineDashStyle()Description copied from interface:IGCReturns the LineDash style constant- Specified by:
getLineDashStylein interfaceIGC- Returns:
- the constant
-
getLineSolidStyle
public int getLineSolidStyle()Description copied from interface:IGCReturns the LineSolid style constant- Specified by:
getLineSolidStylein interfaceIGC- Returns:
- the constant
-
createColor
Description copied from interface:IGCCreates a color with the given RGB values- Specified by:
createColorin interfaceIGC- Parameters:
r- the red componentg- the green componentb- the blue component- Returns:
- the color
-
setDrawTextWithFocusStyle
public void setDrawTextWithFocusStyle(boolean focus) Description copied from interface:IGCDraws text with focus style.- Specified by:
setDrawTextWithFocusStylein interfaceIGC- Parameters:
focus-trueif item has focus elsefalse
-