Package com.mxgraph.canvas
Class mxSvgCanvas
java.lang.Object
com.mxgraph.canvas.mxBasicCanvas
com.mxgraph.canvas.mxSvgCanvas
- All Implemented Interfaces:
mxICanvas
An implementation of a canvas that uses SVG for painting. This canvas
ignores the STYLE_LABEL_BACKGROUNDCOLOR and
STYLE_LABEL_BORDERCOLOR styles due to limitations of SVG.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Element
protected Document
Holds the HTML document that represents the canvas.protected boolean
Specifies if images should be embedded as base64 encoded strings.Fields inherited from class com.mxgraph.canvas.mxBasicCanvas
DEFAULT_IMAGEBASEPATH, drawLabels, imageBasePath, imageCache, PRESERVE_IMAGE_ASPECT, scale, translate
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new SVG canvas for the specified dimension and scale.mxSvgCanvas
(Document document) Constructs a new SVG canvas for the specified bounds, scale and background color. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendSvgElement
(Element node) protected String
createDataUrl
(String src) protected Element
createGradientElement
(String start, String end, String direction) protected Element
createImageElement
(double x, double y, double w, double h, String src, boolean aspect, boolean flipH, boolean flipV, boolean embedded) drawCell
(mxCellState state) Draws the given cell.drawLabel
(String label, mxCellState state, boolean html) Draws the given label.Draws the given lines as segments between all points of the given list of mxPoints.drawMarker
(Element parent, Object type, mxPoint p0, mxPoint pe, float size, float strokeWidth, String color) Draws the specified marker as a child path in the given parent.Draws the shape specified with the STYLE_SHAPE key in the given style.Draws the specified text either using drawHtmlString or using drawString.protected Element
Returns a reference to the document that represents the canvas.protected Element
getGradientElement
(String start, String end, String direction) getGradientId
(String start, String end, String direction) protected InputStream
getResource
(String src) boolean
protected boolean
isImageResource
(String src) Returns true if the given string ends with .png, .jpg or .gif.void
setDocument
(Document document) void
setEmbedded
(boolean value) Methods inherited from class com.mxgraph.canvas.mxBasicCanvas
flushImageCache, getImageBasePath, getImageForStyle, getScale, getTranslate, isDrawLabels, loadImage, setDrawLabels, setImageBasePath, setScale, setTranslate
-
Field Details
-
document
Holds the HTML document that represents the canvas. -
defs
-
embedded
protected boolean embeddedSpecifies if images should be embedded as base64 encoded strings. Default is false.
-
-
Constructor Details
-
mxSvgCanvas
public mxSvgCanvas()Constructs a new SVG canvas for the specified dimension and scale. -
mxSvgCanvas
Constructs a new SVG canvas for the specified bounds, scale and background color.
-
-
Method Details
-
appendSvgElement
-
getDefsElement
-
getGradientElement
-
getGlassGradientElement
-
createGradientElement
-
getGradientId
-
isImageResource
Returns true if the given string ends with .png, .jpg or .gif. -
getResource
-
createDataUrl
- Throws:
IOException
-
getEmbeddedImageElement
-
createImageElement
-
setDocument
-
getDocument
Returns a reference to the document that represents the canvas.- Returns:
- Returns the document.
-
setEmbedded
public void setEmbedded(boolean value) -
isEmbedded
public boolean isEmbedded() -
drawCell
Description copied from interface:mxICanvas
Draws the given cell.- Parameters:
state
- State of the cell to be painted.- Returns:
- Object that represents the cell.
-
drawLabel
Description copied from interface:mxICanvas
Draws the given label.- Parameters:
label
- 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.
-
drawShape
Draws the shape specified with the STYLE_SHAPE key in the given style.- Parameters:
x
- X-coordinate of the shape.y
- Y-coordinate of the shape.w
- Width of the shape.h
- Height of the shape.style
- Style of the the shape.
-
drawLine
Draws the given lines as segments between all points of the given list of mxPoints.- Parameters:
pts
- List of points that define the line.style
- Style to be used for painting the line.
-
drawMarker
public mxPoint drawMarker(Element parent, Object type, mxPoint p0, mxPoint pe, float size, float strokeWidth, String color) Draws the specified marker as a child path in the given parent. -
drawText
Draws the specified text either using drawHtmlString or using drawString.- Parameters:
text
- Text to be painted.x
- X-coordinate of the text.y
- Y-coordinate of the text.w
- Width of the text.h
- Height of the text.style
- Style to be used for painting the text.
-