Package com.mxgraph.canvas
Class mxGraphics2DCanvas
- java.lang.Object
-
- com.mxgraph.canvas.mxBasicCanvas
-
- com.mxgraph.canvas.mxGraphics2DCanvas
-
- All Implemented Interfaces:
mxICanvas
- Direct Known Subclasses:
mxInteractiveCanvas
public class mxGraphics2DCanvas extends mxBasicCanvas
An implementation of a canvas that uses Graphics2D for painting.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Graphics2DgGlobal graphics handle to the image.static intIMAGE_SCALINGSpecifies the image scaling quality.protected javax.swing.CellRendererPanerendererPaneOptional renderer pane to be used for HTML label rendering.protected static java.util.Map<java.lang.String,mxIShape>shapesMaps from names to mxIVertexShape instances.static java.lang.StringTEXT_SHAPE_DEFAULTstatic java.lang.StringTEXT_SHAPE_HTMLprotected static java.util.Map<java.lang.String,mxITextShape>textShapesMaps from names to mxITextShape instances.-
Fields inherited from class com.mxgraph.canvas.mxBasicCanvas
DEFAULT_IMAGEBASEPATH, drawLabels, imageBasePath, imageCache, PRESERVE_IMAGE_ASPECT, scale, translate
-
-
Constructor Summary
Constructors Constructor Description mxGraphics2DCanvas()Constructs a new graphics canvas with an empty graphics object.mxGraphics2DCanvas(java.awt.Graphics2D g)Constructs a new graphics canvas for the given graphics object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.PaintcreateFillPaint(mxRectangle bounds, java.util.Map<java.lang.String,java.lang.Object> style)java.awt.StrokecreateStroke(java.util.Map<java.lang.String,java.lang.Object> style)java.awt.Graphics2DcreateTemporaryGraphics(java.util.Map<java.lang.String,java.lang.Object> style, float opacity, mxRectangle bounds)java.lang.ObjectdrawCell(mxCellState state)Draws the given cell.voiddrawImage(java.awt.Rectangle bounds, java.lang.String imageUrl)voiddrawImage(java.awt.Rectangle bounds, java.lang.String imageUrl, boolean preserveAspect, boolean flipH, boolean flipV)protected voiddrawImageImpl(java.awt.Image image, int x, int y)Implements the actual graphics call.java.lang.ObjectdrawLabel(java.lang.String text, mxCellState state, boolean html)Draws the given label.voidfillShape(java.awt.Shape shape)voidfillShape(java.awt.Shape shape, boolean shadow)java.awt.Graphics2DgetGraphics()Returns the graphics object for this canvas.protected java.awt.DimensiongetImageSize(java.awt.Image image)Returns the size for the given image.javax.swing.CellRendererPanegetRendererPane()mxIShapegetShape(java.util.Map<java.lang.String,java.lang.Object> style)mxITextShapegetTextShape(java.util.Map<java.lang.String,java.lang.Object> style, boolean html)voidpaintPolyline(mxPoint[] points, boolean rounded)voidpaintRectangle(java.awt.Rectangle bounds, java.awt.Color background, java.awt.Color border)static voidputShape(java.lang.String name, mxIShape shape)static voidputTextShape(java.lang.String name, mxITextShape shape)voidsetGraphics(java.awt.Graphics2D g)Sets the graphics object for this canvas.-
Methods inherited from class com.mxgraph.canvas.mxBasicCanvas
flushImageCache, getImageBasePath, getImageForStyle, getScale, getTranslate, isDrawLabels, loadImage, setDrawLabels, setImageBasePath, setScale, setTranslate
-
-
-
-
Field Detail
-
TEXT_SHAPE_DEFAULT
public static final java.lang.String TEXT_SHAPE_DEFAULT
- See Also:
- Constant Field Values
-
TEXT_SHAPE_HTML
public static final java.lang.String TEXT_SHAPE_HTML
- See Also:
- Constant Field Values
-
IMAGE_SCALING
public static int IMAGE_SCALING
Specifies the image scaling quality. Default is Image.SCALE_SMOOTH.
-
shapes
protected static java.util.Map<java.lang.String,mxIShape> shapes
Maps from names to mxIVertexShape instances.
-
textShapes
protected static java.util.Map<java.lang.String,mxITextShape> textShapes
Maps from names to mxITextShape instances. There are currently three different hardcoded text shapes available here: default, html and wrapped.
-
rendererPane
protected javax.swing.CellRendererPane rendererPane
Optional renderer pane to be used for HTML label rendering.
-
g
protected java.awt.Graphics2D g
Global graphics handle to the image.
-
-
Method Detail
-
putShape
public static void putShape(java.lang.String name, mxIShape shape)
-
getShape
public mxIShape getShape(java.util.Map<java.lang.String,java.lang.Object> style)
-
putTextShape
public static void putTextShape(java.lang.String name, mxITextShape shape)
-
getTextShape
public mxITextShape getTextShape(java.util.Map<java.lang.String,java.lang.Object> style, boolean html)
-
getRendererPane
public javax.swing.CellRendererPane getRendererPane()
-
getGraphics
public java.awt.Graphics2D getGraphics()
Returns the graphics object for this canvas.
-
setGraphics
public void setGraphics(java.awt.Graphics2D g)
Sets the graphics object for this canvas.
-
drawCell
public java.lang.Object drawCell(mxCellState state)
Description copied from interface:mxICanvasDraws the given cell.- Parameters:
state- State of the cell to be painted.- Returns:
- Object that represents the cell.
-
drawLabel
public java.lang.Object drawLabel(java.lang.String text, mxCellState state, boolean html)Description copied from interface:mxICanvasDraws the given label.- Parameters:
text- String that represents the label.state- State of the cell whose label is to be painted.html- Specifies if the label contains HTML markup.- Returns:
- Object that represents the label.
-
drawImage
public void drawImage(java.awt.Rectangle bounds, java.lang.String imageUrl)
-
drawImage
public void drawImage(java.awt.Rectangle bounds, java.lang.String imageUrl, boolean preserveAspect, boolean flipH, boolean flipV)
-
drawImageImpl
protected void drawImageImpl(java.awt.Image image, int x, int y)Implements the actual graphics call.
-
getImageSize
protected java.awt.Dimension getImageSize(java.awt.Image image)
Returns the size for the given image.
-
paintPolyline
public void paintPolyline(mxPoint[] points, boolean rounded)
-
paintRectangle
public void paintRectangle(java.awt.Rectangle bounds, java.awt.Color background, java.awt.Color border)
-
fillShape
public void fillShape(java.awt.Shape shape)
-
fillShape
public void fillShape(java.awt.Shape shape, boolean shadow)
-
createStroke
public java.awt.Stroke createStroke(java.util.Map<java.lang.String,java.lang.Object> style)
-
createFillPaint
public java.awt.Paint createFillPaint(mxRectangle bounds, java.util.Map<java.lang.String,java.lang.Object> style)
-
createTemporaryGraphics
public java.awt.Graphics2D createTemporaryGraphics(java.util.Map<java.lang.String,java.lang.Object> style, float opacity, mxRectangle bounds)
-
-