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
FieldsModifier and TypeFieldDescriptionprotected booleanSome 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
ConstructorsConstructorDescriptionGraphicsToGraphics2DAdaptor(Graphics2D graphics, org.eclipse.draw2d.geometry.Rectangle viewPort) ConstructorGraphicsToGraphics2DAdaptor(Graphics2D graphics, org.eclipse.swt.graphics.Rectangle viewPort) Alternate Constructor that takes an swt Rectangle -
Method Summary
Modifier and TypeMethodDescriptionprotected voidVerifies that the applied state is up to date with the current state and updates the applied state accordingly.voidclipPath(org.eclipse.swt.graphics.Path path) voidclipRect(org.eclipse.draw2d.geometry.Rectangle rect) voiddispose()voiddrawArc(int x, int y, int width, int height, int startAngle, int endAngle) voiddrawFocus(int x, int y, int w, int h) voiddrawImage(org.eclipse.swt.graphics.Image srcImage, int xpos, int ypos) voiddrawImage(org.eclipse.swt.graphics.Image srcImage, int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) voiddrawLine(int x1, int y1, int x2, int y2) voiddrawOval(int x, int y, int w, int h) voiddrawPath(org.eclipse.swt.graphics.Path path) voiddrawPolygon(org.eclipse.draw2d.geometry.PointList pointList) voiddrawPolyline(org.eclipse.draw2d.geometry.PointList pointList) voiddrawRectangle(int x, int y, int w, int h) voiddrawRoundRectangle(org.eclipse.draw2d.geometry.Rectangle rect, int arcWidth, int arcHeight) voiddrawString(String s, int x, int y) voidvoiddrawTextLayout(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) voidfillArc(int x, int y, int w, int h, int offset, int length) voidfillGradient(int x, int y, int w, int h, boolean vertical) voidfillOval(int x, int y, int w, int h) voidfillPath(org.eclipse.swt.graphics.Path path) voidfillPolygon(org.eclipse.draw2d.geometry.PointList pointList) voidfillRectangle(int x, int y, int width, int height) voidfillRoundRectangle(org.eclipse.draw2d.geometry.Rectangle rect, int arcWidth, int arcHeight) voidfillString(String s, int x, int y) voidbooleanintgetAlpha()intorg.eclipse.swt.graphics.Colororg.eclipse.draw2d.geometry.RectanglegetClip(org.eclipse.draw2d.geometry.Rectangle rect) protected ColorgetColor(org.eclipse.swt.graphics.Color toConvert) This method is used to convert an SWT Color to an AWT Color.intorg.eclipse.swt.graphics.FontgetFont()org.eclipse.swt.graphics.FontMetricsorg.eclipse.swt.graphics.Colorprotected Graphics2Dintorg.eclipse.swt.graphics.LineAttributesintintfloatorg.eclipse.draw2d.geometry.Dimensionprotected BasicStrokeintprotected org.eclipse.draw2d.geometry.PointAccessor method to return the translation offset for the graphics objectbooleanvoidpopState()voidvoidvoidrotate(float degrees) voidscale(double amount) voidsetAdvanced(boolean value) voidsetAlpha(int alpha) voidsetAntialias(int value) voidsetBackgroundColor(org.eclipse.swt.graphics.Color rgb) voidsetClip(org.eclipse.draw2d.geometry.Rectangle rect) voidsetClip(org.eclipse.swt.graphics.Path path) voidsetFillRule(int rule) voidsetFont(org.eclipse.swt.graphics.Font f) voidsetForegroundColor(org.eclipse.swt.graphics.Color rgb) voidsetLineAttributes(org.eclipse.swt.graphics.LineAttributes lineAttributes) voidsetLineCap(int cap) ignoredvoidsetLineDash(float[] dash) voidsetLineDash(int[] dash) Sets the dash pattern when the custom line style is in use.voidsetLineJoin(int join) ignoredvoidsetLineMiterLimit(float miterLimit) ignoredvoidsetLineStyle(int style) voidsetLineWidth(int width) voidsetLineWidthFloat(float width) protected voidsetStroke(BasicStroke stroke) voidsetXORMode(boolean xorMode) booleanvoidtranslate(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
-
Field Details
-
paintNotCompatibleStringsAsBitmaps
protected boolean paintNotCompatibleStringsAsBitmapsSome 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 totruethen 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- theGraphics2Dobject that this object is delegating calls to.viewPort- theRectanglethat 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- theGraphics2Dobject that this object is delegating calls to.viewPort- theorg.eclipse.swt.graphics.Rectanglethat 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:
clipRectin classorg.eclipse.draw2d.Graphics
-
dispose
public void dispose()- Specified by:
disposein classorg.eclipse.draw2d.Graphics
-
getColor
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:
drawArcin classorg.eclipse.draw2d.Graphics
-
fillArc
public void fillArc(int x, int y, int w, int h, int offset, int length) - Specified by:
fillArcin classorg.eclipse.draw2d.Graphics
-
drawFocus
public void drawFocus(int x, int y, int w, int h) - Specified by:
drawFocusin classorg.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:
drawTextLayoutin classorg.eclipse.draw2d.Graphics
-
getInterpolation
public int getInterpolation()- Overrides:
getInterpolationin classorg.eclipse.draw2d.Graphics
-
getLineAttributes
public org.eclipse.swt.graphics.LineAttributes getLineAttributes()- Overrides:
getLineAttributesin classorg.eclipse.draw2d.Graphics
-
getTextAntialias
public int getTextAntialias()- Overrides:
getTextAntialiasin classorg.eclipse.draw2d.Graphics
-
drawImage
public void drawImage(org.eclipse.swt.graphics.Image srcImage, int xpos, int ypos) - Specified by:
drawImagein classorg.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:
drawImagein classorg.eclipse.draw2d.Graphics
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2) - Specified by:
drawLinein classorg.eclipse.draw2d.Graphics
-
drawOval
public void drawOval(int x, int y, int w, int h) - Specified by:
drawOvalin classorg.eclipse.draw2d.Graphics
-
fillOval
public void fillOval(int x, int y, int w, int h) - Specified by:
fillOvalin classorg.eclipse.draw2d.Graphics
-
drawPolygon
public void drawPolygon(org.eclipse.draw2d.geometry.PointList pointList) - Specified by:
drawPolygonin classorg.eclipse.draw2d.Graphics
-
fillPolygon
public void fillPolygon(org.eclipse.draw2d.geometry.PointList pointList) - Specified by:
fillPolygonin classorg.eclipse.draw2d.Graphics
-
drawPolyline
public void drawPolyline(org.eclipse.draw2d.geometry.PointList pointList) - Specified by:
drawPolylinein classorg.eclipse.draw2d.Graphics
-
drawRectangle
public void drawRectangle(int x, int y, int w, int h) - Specified by:
drawRectanglein classorg.eclipse.draw2d.Graphics
-
fillRectangle
public void fillRectangle(int x, int y, int width, int height) - Specified by:
fillRectanglein classorg.eclipse.draw2d.Graphics
-
drawRoundRectangle
public void drawRoundRectangle(org.eclipse.draw2d.geometry.Rectangle rect, int arcWidth, int arcHeight) - Specified by:
drawRoundRectanglein classorg.eclipse.draw2d.Graphics
-
fillRoundRectangle
public void fillRoundRectangle(org.eclipse.draw2d.geometry.Rectangle rect, int arcWidth, int arcHeight) - Specified by:
fillRoundRectanglein classorg.eclipse.draw2d.Graphics
-
drawText
- Specified by:
drawTextin classorg.eclipse.draw2d.Graphics
-
drawString
- Specified by:
drawStringin classorg.eclipse.draw2d.Graphics
-
fillString
- Specified by:
fillStringin classorg.eclipse.draw2d.Graphics
-
fillText
- Specified by:
fillTextin classorg.eclipse.draw2d.Graphics
-
getBackgroundColor
public org.eclipse.swt.graphics.Color getBackgroundColor()- Specified by:
getBackgroundColorin classorg.eclipse.draw2d.Graphics
-
getClip
public org.eclipse.draw2d.geometry.Rectangle getClip(org.eclipse.draw2d.geometry.Rectangle rect) - Specified by:
getClipin classorg.eclipse.draw2d.Graphics
-
getFont
public org.eclipse.swt.graphics.Font getFont()- Specified by:
getFontin classorg.eclipse.draw2d.Graphics
-
getFontMetrics
public org.eclipse.swt.graphics.FontMetrics getFontMetrics()- Specified by:
getFontMetricsin classorg.eclipse.draw2d.Graphics
-
getForegroundColor
public org.eclipse.swt.graphics.Color getForegroundColor()- Specified by:
getForegroundColorin classorg.eclipse.draw2d.Graphics
-
getLineStyle
public int getLineStyle()- Specified by:
getLineStylein classorg.eclipse.draw2d.Graphics
-
getLineWidth
public int getLineWidth()- Specified by:
getLineWidthin classorg.eclipse.draw2d.Graphics
-
getLineWidthFloat
public float getLineWidthFloat()- Specified by:
getLineWidthFloatin classorg.eclipse.draw2d.Graphics
-
getXORMode
public boolean getXORMode()- Specified by:
getXORModein classorg.eclipse.draw2d.Graphics
-
popState
public void popState()- Specified by:
popStatein classorg.eclipse.draw2d.Graphics
-
pushState
public void pushState()- Specified by:
pushStatein classorg.eclipse.draw2d.Graphics
-
restoreState
public void restoreState()- Specified by:
restoreStatein classorg.eclipse.draw2d.Graphics
-
scale
public void scale(double amount) - Specified by:
scalein classorg.eclipse.draw2d.Graphics
-
setBackgroundColor
public void setBackgroundColor(org.eclipse.swt.graphics.Color rgb) - Specified by:
setBackgroundColorin classorg.eclipse.draw2d.Graphics
-
setClip
public void setClip(org.eclipse.draw2d.geometry.Rectangle rect) - Specified by:
setClipin classorg.eclipse.draw2d.Graphics
-
setFont
public void setFont(org.eclipse.swt.graphics.Font f) - Specified by:
setFontin classorg.eclipse.draw2d.Graphics
-
setForegroundColor
public void setForegroundColor(org.eclipse.swt.graphics.Color rgb) - Specified by:
setForegroundColorin classorg.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 callingpushState()andpopState().- Overrides:
setLineDashin classorg.eclipse.draw2d.Graphics- Parameters:
dash- the pixel pattern
-
setLineDash
public void setLineDash(float[] dash) - Overrides:
setLineDashin classorg.eclipse.draw2d.Graphics
-
setLineStyle
public void setLineStyle(int style) - Specified by:
setLineStylein classorg.eclipse.draw2d.Graphics
-
setLineMiterLimit
public void setLineMiterLimit(float miterLimit) ignored- Specified by:
setLineMiterLimitin classorg.eclipse.draw2d.Graphics
-
setLineCap
public void setLineCap(int cap) ignored- Overrides:
setLineCapin classorg.eclipse.draw2d.Graphics
-
setLineJoin
public void setLineJoin(int join) ignored- Overrides:
setLineJoinin classorg.eclipse.draw2d.Graphics
-
setLineWidth
public void setLineWidth(int width) - Specified by:
setLineWidthin classorg.eclipse.draw2d.Graphics
-
setLineWidthFloat
public void setLineWidthFloat(float width) - Specified by:
setLineWidthFloatin classorg.eclipse.draw2d.Graphics
-
setLineAttributes
public void setLineAttributes(org.eclipse.swt.graphics.LineAttributes lineAttributes) - Overrides:
setLineAttributesin classorg.eclipse.draw2d.Graphics
-
setXORMode
public void setXORMode(boolean xorMode) - Specified by:
setXORModein classorg.eclipse.draw2d.Graphics
-
translate
public void translate(int dx, int dy) - Specified by:
translatein classorg.eclipse.draw2d.Graphics
-
getGraphics2D
- Returns:
- the
Graphics2Dthat this is delegating to.
-
fillGradient
public void fillGradient(int x, int y, int w, int h, boolean vertical) - Specified by:
fillGradientin classorg.eclipse.draw2d.Graphics
-
drawPath
public void drawPath(org.eclipse.swt.graphics.Path path) - Overrides:
drawPathin classorg.eclipse.draw2d.Graphics
-
fillPath
public void fillPath(org.eclipse.swt.graphics.Path path) - Overrides:
fillPathin classorg.eclipse.draw2d.Graphics
-
setClip
public void setClip(org.eclipse.swt.graphics.Path path) - Overrides:
setClipin classorg.eclipse.draw2d.Graphics
-
getFillRule
public int getFillRule()- Overrides:
getFillRulein classorg.eclipse.draw2d.Graphics
-
setFillRule
public void setFillRule(int rule) - Overrides:
setFillRulein classorg.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:
Pointx coordinate for graphics translation
-
getAntialias
public int getAntialias()- Overrides:
getAntialiasin classorg.eclipse.draw2d.Graphics
-
setAntialias
public void setAntialias(int value) - Overrides:
setAntialiasin classorg.eclipse.draw2d.Graphics
-
getAlpha
public int getAlpha()- Overrides:
getAlphain classorg.eclipse.draw2d.Graphics
-
setAlpha
public void setAlpha(int alpha) - Overrides:
setAlphain classorg.eclipse.draw2d.Graphics
-
getStroke
-
setStroke
-
getAdvanced
public boolean getAdvanced()- Overrides:
getAdvancedin classorg.eclipse.draw2d.Graphics
-
setAdvanced
public void setAdvanced(boolean value) - Overrides:
setAdvancedin classorg.eclipse.draw2d.Graphics
-
clipPath
public void clipPath(org.eclipse.swt.graphics.Path path) - Overrides:
clipPathin classorg.eclipse.draw2d.Graphics
-
rotate
public void rotate(float degrees) - Overrides:
rotatein classorg.eclipse.draw2d.Graphics
-