Class GraphicsToGraphics2DAdaptor

java.lang.Object
org.eclipse.draw2d.Graphics
org.eclipse.graphiti.export.batik.GraphicsToGraphics2DAdaptor

public class GraphicsToGraphics2DAdaptor extends org.eclipse.draw2d.Graphics
Objects of this class can be used with draw2d to render to a Graphics2D object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Some strings, Asian string in particular, are painted differently between SWT and AWT.

    Fields inherited from class org.eclipse.draw2d.Graphics

    LINE_CUSTOM, LINE_DASH, LINE_DASHDOT, LINE_DASHDOTDOT, LINE_DOT, LINE_SOLID
  • Constructor Summary

    Constructors
    Constructor
    Description
    GraphicsToGraphics2DAdaptor(Graphics2D graphics, org.eclipse.draw2d.geometry.Rectangle viewPort)
    Constructor
    GraphicsToGraphics2DAdaptor(Graphics2D graphics, org.eclipse.swt.graphics.Rectangle viewPort)
    Alternate Constructor that takes an swt Rectangle
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Verifies that the applied state is up to date with the current state and updates the applied state accordingly.
    void
    clipPath(org.eclipse.swt.graphics.Path path)
     
    void
    clipRect(org.eclipse.draw2d.geometry.Rectangle rect)
     
    void
     
    void
    drawArc(int x, int y, int width, int height, int startAngle, int endAngle)
     
    void
    drawFocus(int x, int y, int w, int h)
     
    void
    drawImage(org.eclipse.swt.graphics.Image srcImage, int xpos, int ypos)
     
    void
    drawImage(org.eclipse.swt.graphics.Image srcImage, int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
     
    void
    drawLine(int x1, int y1, int x2, int y2)
     
    void
    drawOval(int x, int y, int w, int h)
     
    void
    drawPath(org.eclipse.swt.graphics.Path path)
     
    void
    drawPolygon(org.eclipse.draw2d.geometry.PointList pointList)
     
    void
    drawPolyline(org.eclipse.draw2d.geometry.PointList pointList)
     
    void
    drawRectangle(int x, int y, int w, int h)
     
    void
    drawRoundRectangle(org.eclipse.draw2d.geometry.Rectangle rect, int arcWidth, int arcHeight)
     
    void
    drawString(String s, int x, int y)
     
    void
    drawText(String s, int x, int y)
     
    void
    drawTextLayout(org.eclipse.swt.graphics.TextLayout layout, int x, int y, int selectionStart, int selectionEnd, org.eclipse.swt.graphics.Color selectionForeground, org.eclipse.swt.graphics.Color selectionBackground)
     
    void
    fillArc(int x, int y, int w, int h, int offset, int length)
     
    void
    fillGradient(int x, int y, int w, int h, boolean vertical)
     
    void
    fillOval(int x, int y, int w, int h)
     
    void
    fillPath(org.eclipse.swt.graphics.Path path)
     
    void
    fillPolygon(org.eclipse.draw2d.geometry.PointList pointList)
     
    void
    fillRectangle(int x, int y, int width, int height)
     
    void
    fillRoundRectangle(org.eclipse.draw2d.geometry.Rectangle rect, int arcWidth, int arcHeight)
     
    void
    fillString(String s, int x, int y)
     
    void
    fillText(String s, int x, int y)
     
    boolean
     
    int
     
    int
     
    org.eclipse.swt.graphics.Color
     
    org.eclipse.draw2d.geometry.Rectangle
    getClip(org.eclipse.draw2d.geometry.Rectangle rect)
     
    protected Color
    getColor(org.eclipse.swt.graphics.Color toConvert)
    This method is used to convert an SWT Color to an AWT Color.
    int
     
    org.eclipse.swt.graphics.Font
     
    org.eclipse.swt.graphics.FontMetrics
     
    org.eclipse.swt.graphics.Color
     
    protected Graphics2D
     
    int
     
    org.eclipse.swt.graphics.LineAttributes
     
    int
     
    int
     
    float
     
    org.eclipse.draw2d.geometry.Dimension
     
    protected BasicStroke
     
    int
     
    protected org.eclipse.draw2d.geometry.Point
    Accessor method to return the translation offset for the graphics object
    boolean
     
    void
     
    void
     
    void
     
    void
    rotate(float degrees)
     
    void
    scale(double amount)
     
    void
    setAdvanced(boolean value)
     
    void
    setAlpha(int alpha)
     
    void
    setAntialias(int value)
     
    void
    setBackgroundColor(org.eclipse.swt.graphics.Color rgb)
     
    void
    setClip(org.eclipse.draw2d.geometry.Rectangle rect)
     
    void
    setClip(org.eclipse.swt.graphics.Path path)
     
    void
    setFillRule(int rule)
     
    void
    setFont(org.eclipse.swt.graphics.Font f)
     
    void
    setForegroundColor(org.eclipse.swt.graphics.Color rgb)
     
    void
    setLineAttributes(org.eclipse.swt.graphics.LineAttributes lineAttributes)
     
    void
    setLineCap(int cap)
    ignored
    void
    setLineDash(float[] dash)
     
    void
    setLineDash(int[] dash)
    Sets the dash pattern when the custom line style is in use.
    void
    setLineJoin(int join)
    ignored
    void
    setLineMiterLimit(float miterLimit)
    ignored
    void
    setLineStyle(int style)
     
    void
    setLineWidth(int width)
     
    void
    setLineWidthFloat(float width)
     
    protected void
     
    void
    setXORMode(boolean xorMode)
     
    boolean
     
    void
    translate(int dx, int dy)
     

    Methods inherited from class org.eclipse.draw2d.Graphics

    drawArc, drawFocus, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPoint, drawPolygon, drawPolyline, drawRectangle, drawString, drawText, drawText, drawText, drawTextLayout, fillArc, fillGradient, fillOval, fillPolygon, fillRectangle, fillString, fillText, getAbsoluteScale, getLineCap, getLineJoin, getLineMiterLimit, scale, setBackgroundPattern, setForegroundPattern, setInterpolation, setLineDashOffset, setTextAntialias, shear, translate, translate

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • paintNotCompatibleStringsAsBitmaps

      protected boolean paintNotCompatibleStringsAsBitmaps
      Some strings, Asian string in particular, are painted differently between SWT and AWT. SWT falls back to some default locale font if Asian string cannot be painted with the current font - this is done via the platform. AWT, unlike platform biased SWT, does not. Hence, Asian string widths are very different between SWT and AWT. To workaround the issue, if the flag below is set to true then once SWT and AWT string width are not equal, a bitmap of the SWT string will be painted. Otherwise the string is always painted with AWT Graphics 2D string rendering.
  • Constructor Details

    • GraphicsToGraphics2DAdaptor

      public GraphicsToGraphics2DAdaptor(Graphics2D graphics, org.eclipse.draw2d.geometry.Rectangle viewPort)
      Constructor
      Parameters:
      graphics - the Graphics2D object that this object is delegating calls to.
      viewPort - the Rectangle that defines the logical area being rendered by the graphics object.
    • GraphicsToGraphics2DAdaptor

      public GraphicsToGraphics2DAdaptor(Graphics2D graphics, org.eclipse.swt.graphics.Rectangle viewPort)
      Alternate Constructor that takes an swt Rectangle
      Parameters:
      graphics - the Graphics2D object that this object is delegating calls to.
      viewPort - the org.eclipse.swt.graphics.Rectangle that defines the logical area being rendered by the graphics object.
  • Method Details

    • checkState

      protected void checkState()
      Verifies that the applied state is up to date with the current state and updates the applied state accordingly.
    • clipRect

      public void clipRect(org.eclipse.draw2d.geometry.Rectangle rect)
      Specified by:
      clipRect in class org.eclipse.draw2d.Graphics
    • dispose

      public void dispose()
      Specified by:
      dispose in class org.eclipse.draw2d.Graphics
    • getColor

      protected Color getColor(org.eclipse.swt.graphics.Color toConvert)
      This method is used to convert an SWT Color to an AWT Color.
      Parameters:
      toConvert - SWT Color to convert
      Returns:
      AWT Color
    • drawArc

      public void drawArc(int x, int y, int width, int height, int startAngle, int endAngle)
      Specified by:
      drawArc in class org.eclipse.draw2d.Graphics
    • fillArc

      public void fillArc(int x, int y, int w, int h, int offset, int length)
      Specified by:
      fillArc in class org.eclipse.draw2d.Graphics
    • drawFocus

      public void drawFocus(int x, int y, int w, int h)
      Specified by:
      drawFocus in class org.eclipse.draw2d.Graphics
    • drawTextLayout

      public void drawTextLayout(org.eclipse.swt.graphics.TextLayout layout, int x, int y, int selectionStart, int selectionEnd, org.eclipse.swt.graphics.Color selectionForeground, org.eclipse.swt.graphics.Color selectionBackground)
      Overrides:
      drawTextLayout in class org.eclipse.draw2d.Graphics
    • getInterpolation

      public int getInterpolation()
      Overrides:
      getInterpolation in class org.eclipse.draw2d.Graphics
    • getLineAttributes

      public org.eclipse.swt.graphics.LineAttributes getLineAttributes()
      Overrides:
      getLineAttributes in class org.eclipse.draw2d.Graphics
    • getTextAntialias

      public int getTextAntialias()
      Overrides:
      getTextAntialias in class org.eclipse.draw2d.Graphics
    • drawImage

      public void drawImage(org.eclipse.swt.graphics.Image srcImage, int xpos, int ypos)
      Specified by:
      drawImage in class org.eclipse.draw2d.Graphics
    • drawImage

      public void drawImage(org.eclipse.swt.graphics.Image srcImage, int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
      Specified by:
      drawImage in class org.eclipse.draw2d.Graphics
    • drawLine

      public void drawLine(int x1, int y1, int x2, int y2)
      Specified by:
      drawLine in class org.eclipse.draw2d.Graphics
    • drawOval

      public void drawOval(int x, int y, int w, int h)
      Specified by:
      drawOval in class org.eclipse.draw2d.Graphics
    • fillOval

      public void fillOval(int x, int y, int w, int h)
      Specified by:
      fillOval in class org.eclipse.draw2d.Graphics
    • drawPolygon

      public void drawPolygon(org.eclipse.draw2d.geometry.PointList pointList)
      Specified by:
      drawPolygon in class org.eclipse.draw2d.Graphics
    • fillPolygon

      public void fillPolygon(org.eclipse.draw2d.geometry.PointList pointList)
      Specified by:
      fillPolygon in class org.eclipse.draw2d.Graphics
    • drawPolyline

      public void drawPolyline(org.eclipse.draw2d.geometry.PointList pointList)
      Specified by:
      drawPolyline in class org.eclipse.draw2d.Graphics
    • drawRectangle

      public void drawRectangle(int x, int y, int w, int h)
      Specified by:
      drawRectangle in class org.eclipse.draw2d.Graphics
    • fillRectangle

      public void fillRectangle(int x, int y, int width, int height)
      Specified by:
      fillRectangle in class org.eclipse.draw2d.Graphics
    • drawRoundRectangle

      public void drawRoundRectangle(org.eclipse.draw2d.geometry.Rectangle rect, int arcWidth, int arcHeight)
      Specified by:
      drawRoundRectangle in class org.eclipse.draw2d.Graphics
    • fillRoundRectangle

      public void fillRoundRectangle(org.eclipse.draw2d.geometry.Rectangle rect, int arcWidth, int arcHeight)
      Specified by:
      fillRoundRectangle in class org.eclipse.draw2d.Graphics
    • drawText

      public void drawText(String s, int x, int y)
      Specified by:
      drawText in class org.eclipse.draw2d.Graphics
    • drawString

      public void drawString(String s, int x, int y)
      Specified by:
      drawString in class org.eclipse.draw2d.Graphics
    • fillString

      public void fillString(String s, int x, int y)
      Specified by:
      fillString in class org.eclipse.draw2d.Graphics
    • fillText

      public void fillText(String s, int x, int y)
      Specified by:
      fillText in class org.eclipse.draw2d.Graphics
    • getBackgroundColor

      public org.eclipse.swt.graphics.Color getBackgroundColor()
      Specified by:
      getBackgroundColor in class org.eclipse.draw2d.Graphics
    • getClip

      public org.eclipse.draw2d.geometry.Rectangle getClip(org.eclipse.draw2d.geometry.Rectangle rect)
      Specified by:
      getClip in class org.eclipse.draw2d.Graphics
    • getFont

      public org.eclipse.swt.graphics.Font getFont()
      Specified by:
      getFont in class org.eclipse.draw2d.Graphics
    • getFontMetrics

      public org.eclipse.swt.graphics.FontMetrics getFontMetrics()
      Specified by:
      getFontMetrics in class org.eclipse.draw2d.Graphics
    • getForegroundColor

      public org.eclipse.swt.graphics.Color getForegroundColor()
      Specified by:
      getForegroundColor in class org.eclipse.draw2d.Graphics
    • getLineStyle

      public int getLineStyle()
      Specified by:
      getLineStyle in class org.eclipse.draw2d.Graphics
    • getLineWidth

      public int getLineWidth()
      Specified by:
      getLineWidth in class org.eclipse.draw2d.Graphics
    • getLineWidthFloat

      public float getLineWidthFloat()
      Specified by:
      getLineWidthFloat in class org.eclipse.draw2d.Graphics
    • getXORMode

      public boolean getXORMode()
      Specified by:
      getXORMode in class org.eclipse.draw2d.Graphics
    • popState

      public void popState()
      Specified by:
      popState in class org.eclipse.draw2d.Graphics
    • pushState

      public void pushState()
      Specified by:
      pushState in class org.eclipse.draw2d.Graphics
    • restoreState

      public void restoreState()
      Specified by:
      restoreState in class org.eclipse.draw2d.Graphics
    • scale

      public void scale(double amount)
      Specified by:
      scale in class org.eclipse.draw2d.Graphics
    • setBackgroundColor

      public void setBackgroundColor(org.eclipse.swt.graphics.Color rgb)
      Specified by:
      setBackgroundColor in class org.eclipse.draw2d.Graphics
    • setClip

      public void setClip(org.eclipse.draw2d.geometry.Rectangle rect)
      Specified by:
      setClip in class org.eclipse.draw2d.Graphics
    • setFont

      public void setFont(org.eclipse.swt.graphics.Font f)
      Specified by:
      setFont in class org.eclipse.draw2d.Graphics
    • setForegroundColor

      public void setForegroundColor(org.eclipse.swt.graphics.Color rgb)
      Specified by:
      setForegroundColor in class org.eclipse.draw2d.Graphics
    • setLineDash

      public void setLineDash(int[] dash)
      Sets the dash pattern when the custom line style is in use. Because this feature is rarely used, the dash pattern may not be preserved when calling pushState() and popState().
      Overrides:
      setLineDash in class org.eclipse.draw2d.Graphics
      Parameters:
      dash - the pixel pattern
    • setLineDash

      public void setLineDash(float[] dash)
      Overrides:
      setLineDash in class org.eclipse.draw2d.Graphics
    • setLineStyle

      public void setLineStyle(int style)
      Specified by:
      setLineStyle in class org.eclipse.draw2d.Graphics
    • setLineMiterLimit

      public void setLineMiterLimit(float miterLimit)
      ignored
      Specified by:
      setLineMiterLimit in class org.eclipse.draw2d.Graphics
    • setLineCap

      public void setLineCap(int cap)
      ignored
      Overrides:
      setLineCap in class org.eclipse.draw2d.Graphics
    • setLineJoin

      public void setLineJoin(int join)
      ignored
      Overrides:
      setLineJoin in class org.eclipse.draw2d.Graphics
    • setLineWidth

      public void setLineWidth(int width)
      Specified by:
      setLineWidth in class org.eclipse.draw2d.Graphics
    • setLineWidthFloat

      public void setLineWidthFloat(float width)
      Specified by:
      setLineWidthFloat in class org.eclipse.draw2d.Graphics
    • setLineAttributes

      public void setLineAttributes(org.eclipse.swt.graphics.LineAttributes lineAttributes)
      Overrides:
      setLineAttributes in class org.eclipse.draw2d.Graphics
    • setXORMode

      public void setXORMode(boolean xorMode)
      Specified by:
      setXORMode in class org.eclipse.draw2d.Graphics
    • translate

      public void translate(int dx, int dy)
      Specified by:
      translate in class org.eclipse.draw2d.Graphics
    • getGraphics2D

      protected Graphics2D getGraphics2D()
      Returns:
      the Graphics2D that this is delegating to.
    • fillGradient

      public void fillGradient(int x, int y, int w, int h, boolean vertical)
      Specified by:
      fillGradient in class org.eclipse.draw2d.Graphics
    • drawPath

      public void drawPath(org.eclipse.swt.graphics.Path path)
      Overrides:
      drawPath in class org.eclipse.draw2d.Graphics
    • fillPath

      public void fillPath(org.eclipse.swt.graphics.Path path)
      Overrides:
      fillPath in class org.eclipse.draw2d.Graphics
    • setClip

      public void setClip(org.eclipse.swt.graphics.Path path)
      Overrides:
      setClip in class org.eclipse.draw2d.Graphics
    • getFillRule

      public int getFillRule()
      Overrides:
      getFillRule in class org.eclipse.draw2d.Graphics
    • setFillRule

      public void setFillRule(int rule)
      Overrides:
      setFillRule in class org.eclipse.draw2d.Graphics
    • shouldAllowDelayRender

      public boolean shouldAllowDelayRender()
    • getMaximumRenderSize

      public org.eclipse.draw2d.geometry.Dimension getMaximumRenderSize()
    • getTranslationOffset

      protected org.eclipse.draw2d.geometry.Point getTranslationOffset()
      Accessor method to return the translation offset for the graphics object
      Returns:
      Point x coordinate for graphics translation
    • getAntialias

      public int getAntialias()
      Overrides:
      getAntialias in class org.eclipse.draw2d.Graphics
    • setAntialias

      public void setAntialias(int value)
      Overrides:
      setAntialias in class org.eclipse.draw2d.Graphics
    • getAlpha

      public int getAlpha()
      Overrides:
      getAlpha in class org.eclipse.draw2d.Graphics
    • setAlpha

      public void setAlpha(int alpha)
      Overrides:
      setAlpha in class org.eclipse.draw2d.Graphics
    • getStroke

      protected BasicStroke getStroke()
    • setStroke

      protected void setStroke(BasicStroke stroke)
    • getAdvanced

      public boolean getAdvanced()
      Overrides:
      getAdvanced in class org.eclipse.draw2d.Graphics
    • setAdvanced

      public void setAdvanced(boolean value)
      Overrides:
      setAdvanced in class org.eclipse.draw2d.Graphics
    • clipPath

      public void clipPath(org.eclipse.swt.graphics.Path path)
      Overrides:
      clipPath in class org.eclipse.draw2d.Graphics
    • rotate

      public void rotate(float degrees)
      Overrides:
      rotate in class org.eclipse.draw2d.Graphics