mxGraph
|
Used for exporting images. To render to an image from a given XML string, graph size and and background color, the following code is used: More...
Classes | |
class | CanvasState |
Public Member Functions | |
mxGdiCanvas2D (Graphics g) | |
void | Save () |
void | Restore () |
void | Scale (double value) |
Sets the given scale. More... | |
void | Translate (double dx, double dy) |
Translates the canvas. More... | |
void | Rotate (double theta, bool flipH, bool flipV, double cx, double cy) |
Rotates the canvas. More... | |
void | SetGradient (String color1, String color2, double x, double y, double w, double h, String direction) |
Sets the given gradient. More... | |
void | SetGlassGradient (double x, double y, double w, double h) |
Sets the given glass gradient. More... | |
void | Rect (double x, double y, double w, double h) |
Draws a rectangle. More... | |
void | Roundrect (double x, double y, double w, double h, double dx, double dy) |
void | Ellipse (double x, double y, double w, double h) |
Draws an ellipse. More... | |
void | Image (double x, double y, double w, double h, String src, bool aspect, bool flipH, bool flipV) |
Draws an image. More... | |
void | Text (double x, double y, double w, double h, string str, string align, string valign, bool vertical, bool wrap, string format) |
void | Begin () |
void | MoveTo (double x, double y) |
void | LineTo (double x, double y) |
void | QuadTo (double x1, double y1, double x2, double y2) |
void | CurveTo (double x1, double y1, double x2, double y2, double x3, double y3) |
void | Close () |
void | Stroke () |
void | Fill () |
void | FillAndStroke () |
void | Shadow (String value, bool filled) |
void | Clip () |
![]() | |
void | SetGradient (string color1, string color2, double x, double y, double w, double h, string direction) |
Prepares the canvas to draw a gradient. More... | |
void | Image (double x, double y, double w, double h, string src, bool aspect, bool flipH, bool flipV) |
Draws the given image. More... | |
void | Shadow (string value, bool filled) |
Paints the current path as a shadow. More... | |
Static Public Member Functions | |
static StringFormat | CreateStringFormat (string align, string valign, bool wrap) |
Creates the specified string format. More... | |
Protected Member Functions | |
Color | ParseColor (string hex) |
Helper method that uses mxUtils#parseColor(String). Subclassers More... | |
void | DrawImage (Image image, Rectangle bounds) |
Implements the call to the graphics API. More... | |
Image | LoadImage (String src) |
Loads the specified image. More... | |
Rectangle | GetImageBounds (Image img, double x, double y, double w, double h, bool aspect) |
Returns the bounds for the given image. More... | |
Size | GetImageSize (Image image) |
Returns the size for the given image. More... | |
void | ConfigureImageGraphics (double x, double y, double w, double h, bool flipH, bool flipV) |
double | GetTextWidth (double x, double y, double w, double h, string align, string valign, bool vertical, Font font, string text, bool wrap, string format) |
Returns the width to be used to render the specifies text. More... | |
double | GetVerticalTextPosition (double x, double y, double w, double h, string align, string valign, bool vertical, Font font, string text, bool wrap, string format) |
Default alignment is top. More... | |
double | GetHorizontalTextPosition (double x, double y, double w, double h, string align, string valign, bool vertical, Font font, string text, bool wrap, string format) |
Default alignment is left. More... | |
void | UpdateFont () |
Font | CreateFont (String family, FontStyle style, int size) |
String | GetFontName (String family) |
Returns a font name for the given font family. More... | |
void | UpdatePen () |
Protected Attributes | |
Graphics | graphics |
CanvasState | state = new CanvasState() |
Stack< CanvasState > | stack = new Stack<CanvasState>() |
GraphicsPath | currentPath |
mxPoint | lastPoint |
Holds the last point of a moveTo or lineTo operation to determine if the More... | |
string | currentShadowValue |
Holds the current value for the shadow color. This is used to hold the More... | |
Color | currentShadowColor |
Holds the current parsed shadow color. This holds the result of parsing More... | |
Properties | |
double | StrokeWidth [set] |
Sets the strokewidth. More... | |
string | StrokeColor [set] |
bool | Dashed [set] |
Specifies if lines are dashed. More... | |
string | DashPattern [set] |
Sets the dashpattern. More... | |
string | LineCap [set] |
Sets the linecap. More... | |
string | LineJoin [set] |
Sets the linejoin. More... | |
double | MiterLimit [set] |
Sets the miterlimit. More... | |
double | FontSize [set] |
Sets the fontsize. More... | |
string | FontColor [set] |
Sets the fontcolor. More... | |
string | FontFamily [set] |
Sets the font family. More... | |
int | FontStyle [set] |
Sets the given fontstyle. More... | |
double | Alpha [set] |
Sets the given alpha. More... | |
string | FillColor [set] |
Sets the given fillcolor. More... | |
![]() | |
double | StrokeWidth [set] |
Sets the stroke width. This should default to 1 if unset. More... | |
string | StrokeColor [set] |
Sets the stroke color. This should default to mxConstants.NONE if unset. More... | |
bool | Dashed [set] |
Sets the dashed state. This should default to false if unset. More... | |
string | DashPattern [set] |
Sets the dash pattern. This should default to "3 3" if unset. More... | |
string | LineCap [set] |
Sets the linecap. This should default to "flat" if unset. More... | |
string | LineJoin [set] |
Sets the linejoin. This should default to "miter" if unset. More... | |
double | MiterLimit [set] |
Sets the miterlimit. This should default to 10 if unset. More... | |
double | FontSize [set] |
Default value mxConstants.DEFAULT_FONTSIZE. More... | |
string | FontColor [set] |
Default value "#000000". More... | |
string | FontFamily [set] |
Default value mxConstants#DEFAULT_FONTFAMILY. More... | |
int | FontStyle [set] |
Default value 0. See mxConstants#STYLE_FONTSTYLE. More... | |
double | Alpha [set] |
Default value 1. This method may add rendering overhead and should be used with care. More... | |
string | FillColor [set] |
Default value mxConstants#NONE. More... | |
Used for exporting images. To render to an image from a given XML string, graph size and and background color, the following code is used:
Image image = mxUtils.CreateImage(width, height, background); Graphics g = Graphics.FromImage(image); g.SmoothingMode = SmoothingMode.HighQuality; mxSaxOutputHandler handler = new mxSaxOutputHandler(new mxGdiCanvas2D(g)); handler.Read(new XmlTextReader(new StringReader(xml)));
Text rendering is available for plain text only, with optional word wrapping.
|
inline |
Constructs a new graphics export canvas.
|
inline |
Implements com.mxgraph.mxICanvas2D.
|
inline |
Implements com.mxgraph.mxICanvas2D.
|
inline |
Closes the current path.
Implements com.mxgraph.mxICanvas2D.
|
inlineprotected |
Creates a graphic instance for rendering an image.
|
inlineprotected |
Hook for subclassers to implement font caching.
|
inlinestatic |
Creates the specified string format.
References com.mxgraph.mxConstants.ALIGN_BOTTOM, com.mxgraph.mxConstants.ALIGN_CENTER, com.mxgraph.mxConstants.ALIGN_LEFT, com.mxgraph.mxConstants.ALIGN_MIDDLE, com.mxgraph.mxConstants.ALIGN_RIGHT, and com.mxgraph.mxConstants.ALIGN_TOP.
|
inline |
Implements com.mxgraph.mxICanvas2D.
References com.mxgraph.mxPoint.X.
|
inlineprotected |
Implements the call to the graphics API.
|
inline |
Draws an ellipse.
Implements com.mxgraph.mxICanvas2D.
|
inline |
Implements com.mxgraph.mxICanvas2D.
|
inline |
Implements com.mxgraph.mxICanvas2D.
|
inlineprotected |
Returns a font name for the given font family.
|
inlineprotected |
Default alignment is left.
References com.mxgraph.mxConstants.ALIGN_CENTER, and com.mxgraph.mxConstants.ALIGN_RIGHT.
|
inlineprotected |
Returns the bounds for the given image.
|
inlineprotected |
Returns the size for the given image.
|
inlineprotected |
Returns the width to be used to render the specifies text.
|
inlineprotected |
Default alignment is top.
|
inline |
Draws an image.
|
inline |
Implements com.mxgraph.mxICanvas2D.
References com.mxgraph.mxPoint.X.
|
inlineprotected |
Loads the specified image.
|
inline |
Implements com.mxgraph.mxICanvas2D.
|
inlineprotected |
Helper method that uses mxUtils#parseColor(String). Subclassers
can override this to implement caching for frequently used colors.
|
inline |
Implements com.mxgraph.mxICanvas2D.
References com.mxgraph.mxPoint.X.
|
inline |
Draws a rectangle.
Implements com.mxgraph.mxICanvas2D.
|
inline |
Restores the last canvas state.
Implements com.mxgraph.mxICanvas2D.
|
inline |
Rotates the canvas.
Implements com.mxgraph.mxICanvas2D.
|
inline |
Draws a rounded rectangle.
Implements com.mxgraph.mxICanvas2D.
|
inline |
Saves the current canvas state.
Implements com.mxgraph.mxICanvas2D.
|
inline |
|
inline |
Sets the given glass gradient.
Implements com.mxgraph.mxICanvas2D.
|
inline |
Sets the given gradient.
References com.mxgraph.mxConstants.DIRECTION_EAST, com.mxgraph.mxConstants.DIRECTION_NORTH, com.mxgraph.mxConstants.DIRECTION_SOUTH, and com.mxgraph.mxConstants.DIRECTION_WEST.
|
inline |
value |
|
inline |
Implements com.mxgraph.mxICanvas2D.
References com.mxgraph.mxConstants.NONE.
|
inline |
|
inline |
|
inlineprotected |
|
inlineprotected |
|
protected |
Holds the current path.
|
protected |
Holds the current parsed shadow color. This holds the result of parsing
the currentShadowValue, which is an expensive operation.
|
protected |
Holds the current value for the shadow color. This is used to hold the
input value of a shadow operation. The parsing result of this value is cached in the global scope as it should be repeating.
|
protected |
Reference to the graphics instance for painting.
|
protected |
Holds the last point of a moveTo or lineTo operation to determine if the
current path is orthogonal.
|
protected |
Stack of states for save/restore.
|
protected |
Represents the current state of the canvas.
|
set |
Sets the given alpha.
|
set |
Specifies if lines are dashed.
|
set |
Sets the dashpattern.
|
set |
Sets the given fillcolor.
|
set |
Sets the fontcolor.
|
set |
Sets the font family.
|
set |
Sets the fontsize.
|
set |
Sets the given fontstyle.
|
set |
Sets the linecap.
|
set |
Sets the linejoin.
|
set |
Sets the miterlimit.
|
set |
Caches color conversion as it is expensive.
|
set |
Sets the strokewidth.