java.lang.Object
org.eclipse.tracecompass.tmf.ui.views.uml2sd.NGC
All Implemented Interfaces:
IGC

public class NGC extends Object implements IGC

This class implements the graphical context for the sequence diagram widgets.

Version:
1.0
Author:
sveyrier
  • Constructor Summary

    Constructors
    Constructor
    Description
    NGC(SDWidget scrollView, org.eclipse.swt.graphics.GC gc)
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Translates the given contents x coordinate into view x coordinate
    int
    Translates the given contents y coordinate into view y coordinate
    createColor(int r, int g, int b)
    Creates a color with the given RGB values
    void
    Disposes all created resources.
    void
    drawArc(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.
    void
    drawFocus(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.
    void
    drawImage(IImage image, int xValue, int yValue, int maxWith, int maxHeight)
    Copies a the source image into a (potentially different sized) rectangular area in the graphical context.
    void
    drawLine(int x1, int y1, int x2, int y2)
    Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).
    void
    drawPolygon(int[] points)
    Draws the closed polygon which is defined by the specified array of integer coordinates, using the receiver's foreground color.
    void
    drawRectangle(int x, int y, int width, int height)
    Draws the outline of the rectangle specified by the arguments, using the receiver's foreground color.
    void
    drawText(String string, int x, int y)
    Draws the given string, using the receiver's current font and foreground color.
    void
    drawText(String string, int x, int y, boolean isTrans)
    Draws the given string, using the receiver's current font and foreground color.
    void
    drawTextTruncated(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.
    void
    drawTextTruncatedCentred(String name, int xValue, int yValue, int width, int height, boolean trans)
    Draws the given string centered into the given rectangle.
    void
    fillGradientRectangle(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.
    void
    fillOval(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.
    void
    fillPolygon(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.
    void
    fillRectangle(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 context
    int
    Returns the contents x coordinate that is at the upper left corner of the view
    int
    Returns the contents y coordinate that is at the upper left corner of the view
    int
    Returns the font height given font
    int
    Returns the average character width for the given font
    Returns current the background color used in the graphical context
    int
    Returns the LineDash style constant
    int
    Returns the LineDotD style constant
    int
    Returns the LineSolid style constant
    int
    Returns current the line style used in the graphical context
    int
    Returns the current graphical context line width used for drawing
    int
    Returns the contents visible height
    int
    Returns the contents visible width
    float
    Returns the zoom factor applied in both x and y directions when drawing
    void
    Set the graphical context foreground color
    void
    Draws text with focus style.
    void
    setFont(IFont font)
    Set the current font used in the graphical context
    void
    Set the graphical context background color
    void
    Set the color to use when filling regions using gradient.
    void
    setLineStyle(int style)
    Set the current line style
    void
    setLineWidth(int width)
    Set the line width to use for drawing
    int
    Returns the given string width in pixels

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NGC

      public NGC(SDWidget scrollView, org.eclipse.swt.graphics.GC gc)
      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: IGC
      Set the current line style
      Specified by:
      setLineStyle in interface IGC
      Parameters:
      style - the new line style
    • getLineStyle

      public int getLineStyle()
      Description copied from interface: IGC
      Returns current the line style used in the graphical context
      Specified by:
      getLineStyle in interface IGC
      Returns:
      the current line style
    • getContentsX

      public int getContentsX()
      Description copied from interface: IGC
      Returns the contents x coordinate that is at the upper left corner of the view
      Specified by:
      getContentsX in interface IGC
      Returns:
      the contents x coordinate
    • getContentsY

      public int getContentsY()
      Description copied from interface: IGC
      Returns the contents y coordinate that is at the upper left corner of the view
      Specified by:
      getContentsY in interface IGC
      Returns:
      the contents y coordinate
    • getVisibleWidth

      public int getVisibleWidth()
      Description copied from interface: IGC
      Returns the contents visible width
      Specified by:
      getVisibleWidth in interface IGC
      Returns:
      the contents width
    • getVisibleHeight

      public int getVisibleHeight()
      Description copied from interface: IGC
      Returns the contents visible height
      Specified by:
      getVisibleHeight in interface IGC
      Returns:
      the contents height
    • contentsToViewX

      public int contentsToViewX(int x)
      Description copied from interface: IGC
      Translates the given contents x coordinate into view x coordinate
      Specified by:
      contentsToViewX in interface IGC
      Parameters:
      x - the x coordinate to translate
      Returns:
      the corresponding view x coordinate
    • contentsToViewY

      public int contentsToViewY(int y)
      Description copied from interface: IGC
      Translates the given contents y coordinate into view y coordinate
      Specified by:
      contentsToViewY in interface IGC
      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: IGC
      Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).
      Specified by:
      drawLine in interface IGC
      Parameters:
      x1 - the first point's x coordinate
      y1 - the first point's y coordinate
      x2 - the second point's x coordinate
      y2 - the second point's y coordinate
    • drawRectangle

      public void drawRectangle(int x, int y, int width, int height)
      Description copied from interface: IGC
      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.
      Specified by:
      drawRectangle in interface IGC
      Parameters:
      x - the x coordinate of the rectangle to be drawn
      y - the y coordinate of the rectangle to be drawn
      width - the width of the rectangle to be drawn
      height - the height of the rectangle to be drawn
    • drawFocus

      public void drawFocus(int x, int y, int width, int height)
      Description copied from interface: IGC
      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.
      Specified by:
      drawFocus in interface IGC
      Parameters:
      x - the x coordinate of the rectangle
      y - the y coordinate of the rectangle
      width - the width of the rectangle
      height - the height of the rectangle
    • fillPolygon

      public void fillPolygon(int[] points)
      Description copied from interface: IGC
      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.
      Specified by:
      fillPolygon in interface IGC
      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: IGC
      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.
      Specified by:
      drawPolygon in interface IGC
      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: IGC
      Fills the interior of the rectangle specified by the arguments, using the receiver's background color.
      Specified by:
      fillRectangle in interface IGC
      Parameters:
      x - the x coordinate of the rectangle to be filled
      y - the y coordinate of the rectangle to be filled
      width - the width of the rectangle to be filled
      height - 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: IGC
      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.
      Specified by:
      fillGradientRectangle in interface IGC
      Parameters:
      x - the x coordinate of the rectangle to be filled
      y - the y coordinate of the rectangle to be filled
      width - 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

      public int textExtent(String name)
      Description copied from interface: IGC
      Returns the given string width in pixels
      Specified by:
      textExtent in interface IGC
      Parameters:
      name - the string
      Returns:
      the string width
    • drawText

      public void drawText(String string, int x, int y, boolean isTrans)
      Description copied from interface: IGC
      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.
      Specified by:
      drawText in interface IGC
      Parameters:
      string - the string to be drawn
      x - the x coordinate of the top left corner of the rectangular area where the text is to be drawn
      y - the y coordinate of the top left corner of the rectangular area where the text is to be drawn
      isTrans - if true the background will be transparent, otherwise it will be opaque
    • drawText

      public void drawText(String string, int x, int y)
      Description copied from interface: IGC
      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.
      Specified by:
      drawText in interface IGC
      Parameters:
      string - the string to be drawn
      x - the x coordinate of the top left corner of the rectangular area where the text is to be drawn
      y - the y coordinate of the top left corner of the rectangular area where the text is to be drawn
    • fillOval

      public void fillOval(int x, int y, int width, int height)
      Description copied from interface: IGC
      Fills the interior of an oval, within the specified rectangular area, with the receiver's background color.
      Specified by:
      fillOval in interface IGC
      Parameters:
      x - the x coordinate of the upper left corner of the oval to be filled
      y - the y coordinate of the upper left corner of the oval to be filled
      width - the width of the oval to be filled
      height - the width of the oval to be filled
    • getBackground

      public IColor getBackground()
      Description copied from interface: IGC
      Returns current the background color used in the graphical context
      Specified by:
      getBackground in interface IGC
      Returns:
      the background color
    • getForeground

      public IColor getForeground()
      Description copied from interface: IGC
      Returns current the background color used in the graphical context
      Specified by:
      getForeground in interface IGC
      Returns:
      the background color
    • setBackground

      public void setBackground(IColor color)
      Description copied from interface: IGC
      Set the graphical context foreground color
      Specified by:
      setBackground in interface IGC
      Parameters:
      color - the foreground color
    • setForeground

      public void setForeground(IColor color)
      Description copied from interface: IGC
      Set the graphical context background color
      Specified by:
      setForeground in interface IGC
      Parameters:
      color - the background color
    • setGradientColor

      public void setGradientColor(IColor color)
      Description copied from interface: IGC
      Set the color to use when filling regions using gradient. The color will progess from the given color to the current background color
      Specified by:
      setGradientColor in interface IGC
      Parameters:
      color - the gardiient color to use
    • setLineWidth

      public void setLineWidth(int width)
      Description copied from interface: IGC
      Set the line width to use for drawing
      Specified by:
      setLineWidth in interface IGC
      Parameters:
      width - the line width
    • getLineWidth

      public int getLineWidth()
      Description copied from interface: IGC
      Returns the current graphical context line width used for drawing
      Specified by:
      getLineWidth in interface IGC
      Returns:
      the line width
    • drawTextTruncatedCentred

      public void drawTextTruncatedCentred(String name, int xValue, int yValue, int width, int height, boolean trans)
      Description copied from interface: IGC
      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.
      Specified by:
      drawTextTruncatedCentred in interface IGC
      Parameters:
      name - the string to draw
      xValue - the x coordinate of the rectangle to draw the string
      yValue - the y coordinate of the rectangle to draw the string
      width - the width of the rectangle to draw the string
      height - the height of the rectangle to draw the string
      trans - 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: IGC
      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.
      Specified by:
      drawTextTruncated in interface IGC
      Parameters:
      name - The text to put in the rectangle
      xValue - the x coordinate of the rectangle to draw the string
      yValue - the y coordinate of the rectangle to draw the string
      width - the width of the rectangle to draw the string
      height - the height of the rectangle to draw the string
      trans - if true the background will be transparent, otherwise it will be opaque
    • drawImage

      public void drawImage(IImage image, int xValue, int yValue, int maxWith, int maxHeight)
      Description copied from interface: IGC
      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.
      Specified by:
      drawImage in interface IGC
      Parameters:
      image - the image to draw
      xValue - the x coordinate in the destination to copy to
      yValue - the y coordinate in the destination to copy to
      maxWith - the width in pixels of the destination rectangle
      maxHeight - 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: IGC
      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.
      Specified by:
      drawArc in interface IGC
      Parameters:
      x - the x coordinate of the upper-left corner of the arc to be drawn
      y - the y coordinate of the upper-left corner of the arc to be drawn
      width - the width of the arc to be drawn
      height - the height of the arc to be drawn
      startAngle - the beginning angle
      endAngle - the ending angle
    • setFont

      public void setFont(IFont font)
      Description copied from interface: IGC
      Set the current font used in the graphical context
      Specified by:
      setFont in interface IGC
      Parameters:
      font - the font to use
    • getFontHeight

      public int getFontHeight(IFont font)
      Description copied from interface: IGC
      Returns the font height given font
      Specified by:
      getFontHeight in interface IGC
      Parameters:
      font - The font to check for
      Returns:
      the the font height
    • getFontWidth

      public int getFontWidth(IFont font)
      Description copied from interface: IGC
      Returns the average character width for the given font
      Specified by:
      getFontWidth in interface IGC
      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: IGC
      Returns the zoom factor applied in both x and y directions when drawing
      Specified by:
      getZoom in interface IGC
      Returns:
      the zoom factor
    • getLineDotStyle

      public int getLineDotStyle()
      Description copied from interface: IGC
      Returns the LineDotD style constant
      Specified by:
      getLineDotStyle in interface IGC
      Returns:
      the constant value
    • getLineDashStyle

      public int getLineDashStyle()
      Description copied from interface: IGC
      Returns the LineDash style constant
      Specified by:
      getLineDashStyle in interface IGC
      Returns:
      the constant
    • getLineSolidStyle

      public int getLineSolidStyle()
      Description copied from interface: IGC
      Returns the LineSolid style constant
      Specified by:
      getLineSolidStyle in interface IGC
      Returns:
      the constant
    • createColor

      public IColor createColor(int r, int g, int b)
      Description copied from interface: IGC
      Creates a color with the given RGB values
      Specified by:
      createColor in interface IGC
      Parameters:
      r - the red component
      g - the green component
      b - the blue component
      Returns:
      the color
    • setDrawTextWithFocusStyle

      public void setDrawTextWithFocusStyle(boolean focus)
      Description copied from interface: IGC
      Draws text with focus style.
      Specified by:
      setDrawTextWithFocusStyle in interface IGC
      Parameters:
      focus - true if item has focus else false