mxGraph
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Properties
com.mxgraph.mxGdiCanvas2D Class Reference

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. More...

Inheritance diagram for com.mxgraph.mxGdiCanvas2D:
com.mxgraph.mxICanvas2D

List of all members.

Classes

class  CanvasState

Public Member Functions

 mxGdiCanvas2D (Graphics g)
void Save ()
void Restore ()
void Scale (double value)
 Sets the given scale.
void Translate (double dx, double dy)
 Translates the canvas.
void Rotate (double theta, bool flipH, bool flipV, double cx, double cy)
 Rotates the canvas.
void SetShadowOffset (double dx, double dy)
 Prepares the canvas to draw a gradient.
void SetGradient (String color1, String color2, double x, double y, double w, double h, String direction, double alpha1, double alpha2)
 Sets the given gradient.
void Rect (double x, double y, double w, double h)
 Draws a rectangle.
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.
void Image (double x, double y, double w, double h, String src, bool aspect, bool flipH, bool flipV)
 Draws an image.
void Text (double x, double y, double w, double h, string str, string align, string valign, bool wrap, string format, string overflow, bool clip, double rotation)
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 ()

Static Public Member Functions

static StringFormat CreateStringFormat (string align, string valign, bool wrap, bool clip)
 Creates the specified string format.

Protected Member Functions

Color ParseColor (string hex)
 Helper method that uses mxUtils#parseColor(String). Subclassers.
void DrawImage (Image image, Rectangle bounds)
 Implements the call to the graphics API.
Image LoadImage (String src)
 Loads the specified image.
Rectangle GetImageBounds (Image img, double x, double y, double w, double h, bool aspect)
 Returns the bounds for the given image.
Size GetImageSize (Image image)
 Returns the size for the given image.
void ConfigureImageGraphics (double x, double y, double w, double h, bool flipH, bool flipV)
PointF GetMargin (String align, String valign)
void PaintCurrentPath (bool filled, bool stroked)
void PaintShadow (bool filled, bool stroked)
void UpdateFont ()
Font CreateFont (String family, FontStyle style, float size)
String GetFontName (String family)
 Returns a font name for the given font family.
void UpdatePen ()

Protected Attributes

bool matchHtmlAlignment = true
 matchHtmlAlignment
bool htmlAsPlainText = true
 htmlAsPlainText
bool wrapPlainText = true
 htmlAsPlainText
Graphics graphics
CanvasState state = new CanvasState()
Stack< CanvasStatestack = new Stack<CanvasState>()
GraphicsPath currentPath
mxPoint lastPoint
 Holds the last point of a moveTo or lineTo operation to determine if the.
Font lastFont = null
 FontCaching.
FontStyle lastFontStyle = 0
 FontCaching.
float lastFontSize = 0
 FontCaching.
String lastFontFamily = ""
 FontCaching.

Properties

double StrokeWidth [set]
 Sets the strokewidth.
string StrokeColor [set]
bool Dashed [set]
 Specifies if lines are dashed.
string DashPattern [set]
 Sets the dashpattern.
string LineCap [set]
 Sets the linecap.
string LineJoin [set]
 Sets the linejoin.
double MiterLimit [set]
 Sets the miterlimit.
double FontSize [set]
 Sets the fontsize.
string FontColor [set]
 Sets the fontcolor.
string FontBackgroundColor [set]
 Default value 0. See mxConstants#STYLE_FONTSTYLE.
string FontBorderColor [set]
 Default value 0. See mxConstants#STYLE_FONTSTYLE.
string FontFamily [set]
 Sets the font family.
int FontStyle [set]
 Sets the given fontstyle.
double Alpha [set]
 Sets the given alpha.
string FillColor [set]
 Sets the given fillcolor.
bool Shadow [set]
 Default value mxConstants#NONE.
string ShadowColor [set]
 Default value mxConstants#NONE.
double ShadowAlpha [set]
 Default value 1. This method may add rendering overhead and should be used with care.

Detailed Description

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.


Constructor & Destructor Documentation

com.mxgraph.mxGdiCanvas2D.mxGdiCanvas2D ( Graphics  g) [inline]

Constructs a new graphics export canvas.


Member Function Documentation

Closes the current path.

Implements com.mxgraph.mxICanvas2D.

void com.mxgraph.mxGdiCanvas2D.ConfigureImageGraphics ( double  x,
double  y,
double  w,
double  h,
bool  flipH,
bool  flipV 
) [inline, protected]

Creates a graphic instance for rendering an image.

Font com.mxgraph.mxGdiCanvas2D.CreateFont ( String  family,
FontStyle  style,
float  size 
) [inline, protected]

Hook for subclassers to implement font caching.

static StringFormat com.mxgraph.mxGdiCanvas2D.CreateStringFormat ( string  align,
string  valign,
bool  wrap,
bool  clip 
) [inline, static]

Creates the specified string format.

void com.mxgraph.mxGdiCanvas2D.CurveTo ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
) [inline]
void com.mxgraph.mxGdiCanvas2D.DrawImage ( Image  image,
Rectangle  bounds 
) [inline, protected]

Implements the call to the graphics API.

void com.mxgraph.mxGdiCanvas2D.Ellipse ( double  x,
double  y,
double  w,
double  h 
) [inline]

Draws an ellipse.

Implements com.mxgraph.mxICanvas2D.

void com.mxgraph.mxGdiCanvas2D.Fill ( ) [inline]
String com.mxgraph.mxGdiCanvas2D.GetFontName ( String  family) [inline, protected]

Returns a font name for the given font family.

Rectangle com.mxgraph.mxGdiCanvas2D.GetImageBounds ( Image  img,
double  x,
double  y,
double  w,
double  h,
bool  aspect 
) [inline, protected]

Returns the bounds for the given image.

Size com.mxgraph.mxGdiCanvas2D.GetImageSize ( Image  image) [inline, protected]

Returns the size for the given image.

void com.mxgraph.mxGdiCanvas2D.Image ( double  x,
double  y,
double  w,
double  h,
String  src,
bool  aspect,
bool  flipH,
bool  flipV 
) [inline]

Draws an image.

void com.mxgraph.mxGdiCanvas2D.LineTo ( double  x,
double  y 
) [inline]
Image com.mxgraph.mxGdiCanvas2D.LoadImage ( String  src) [inline, protected]

Loads the specified image.

void com.mxgraph.mxGdiCanvas2D.MoveTo ( double  x,
double  y 
) [inline]
void com.mxgraph.mxGdiCanvas2D.PaintCurrentPath ( bool  filled,
bool  stroked 
) [inline, protected]
Parameters:
value
void com.mxgraph.mxGdiCanvas2D.PaintShadow ( bool  filled,
bool  stroked 
) [inline, protected]
Parameters:
value
Color com.mxgraph.mxGdiCanvas2D.ParseColor ( string  hex) [inline, protected]

Helper method that uses mxUtils#parseColor(String). Subclassers.

can override this to implement caching for frequently used colors.

void com.mxgraph.mxGdiCanvas2D.QuadTo ( double  x1,
double  y1,
double  x2,
double  y2 
) [inline]
void com.mxgraph.mxGdiCanvas2D.Rect ( double  x,
double  y,
double  w,
double  h 
) [inline]

Draws a rectangle.

Implements com.mxgraph.mxICanvas2D.

Restores the last canvas state.

Implements com.mxgraph.mxICanvas2D.

void com.mxgraph.mxGdiCanvas2D.Rotate ( double  theta,
bool  flipH,
bool  flipV,
double  cx,
double  cy 
) [inline]

Rotates the canvas.

Implements com.mxgraph.mxICanvas2D.

void com.mxgraph.mxGdiCanvas2D.Roundrect ( double  x,
double  y,
double  w,
double  h,
double  dx,
double  dy 
) [inline]

Draws a rounded rectangle.

Implements com.mxgraph.mxICanvas2D.

void com.mxgraph.mxGdiCanvas2D.Save ( ) [inline]

Saves the current canvas state.

Implements com.mxgraph.mxICanvas2D.

void com.mxgraph.mxGdiCanvas2D.Scale ( double  value) [inline]

Sets the given scale.

Parameters:
value

Implements com.mxgraph.mxICanvas2D.

void com.mxgraph.mxGdiCanvas2D.SetGradient ( String  color1,
String  color2,
double  x,
double  y,
double  w,
double  h,
String  direction,
double  alpha1,
double  alpha2 
) [inline]

Sets the given gradient.

void com.mxgraph.mxGdiCanvas2D.SetShadowOffset ( double  dx,
double  dy 
) [inline]

Prepares the canvas to draw a gradient.

Implements com.mxgraph.mxICanvas2D.

void com.mxgraph.mxGdiCanvas2D.Text ( double  x,
double  y,
double  w,
double  h,
string  str,
string  align,
string  valign,
bool  wrap,
string  format,
string  overflow,
bool  clip,
double  rotation 
) [inline]

Draws the given text.

Implements com.mxgraph.mxICanvas2D.

void com.mxgraph.mxGdiCanvas2D.Translate ( double  dx,
double  dy 
) [inline]

Translates the canvas.

Parameters:
dx
dy

Implements com.mxgraph.mxICanvas2D.

void com.mxgraph.mxGdiCanvas2D.UpdateFont ( ) [inline, protected]
void com.mxgraph.mxGdiCanvas2D.UpdatePen ( ) [inline, protected]

Member Data Documentation

GraphicsPath com.mxgraph.mxGdiCanvas2D.currentPath [protected]

Holds the current path.

Graphics com.mxgraph.mxGdiCanvas2D.graphics [protected]

Reference to the graphics instance for painting.

htmlAsPlainText

Font com.mxgraph.mxGdiCanvas2D.lastFont = null [protected]

FontCaching.

FontCaching.

FontCaching.

FontCaching.

Holds the last point of a moveTo or lineTo operation to determine if the.

current path is orthogonal.

matchHtmlAlignment

Stack<CanvasState> com.mxgraph.mxGdiCanvas2D.stack = new Stack<CanvasState>() [protected]

Stack of states for save/restore.

Represents the current state of the canvas.

bool com.mxgraph.mxGdiCanvas2D.wrapPlainText = true [protected]

htmlAsPlainText


Property Documentation

Sets the given alpha.

Implements com.mxgraph.mxICanvas2D.

Specifies if lines are dashed.

Implements com.mxgraph.mxICanvas2D.

Sets the dashpattern.

Implements com.mxgraph.mxICanvas2D.

Sets the given fillcolor.

Implements com.mxgraph.mxICanvas2D.

Default value 0. See mxConstants#STYLE_FONTSTYLE.

Implements com.mxgraph.mxICanvas2D.

Default value 0. See mxConstants#STYLE_FONTSTYLE.

Implements com.mxgraph.mxICanvas2D.

Sets the fontcolor.

Implements com.mxgraph.mxICanvas2D.

Sets the font family.

Implements com.mxgraph.mxICanvas2D.

Sets the fontsize.

Implements com.mxgraph.mxICanvas2D.

Sets the given fontstyle.

Implements com.mxgraph.mxICanvas2D.

Sets the linecap.

Implements com.mxgraph.mxICanvas2D.

Sets the linejoin.

Implements com.mxgraph.mxICanvas2D.

Sets the miterlimit.

Implements com.mxgraph.mxICanvas2D.

Default value mxConstants#NONE.

Implements com.mxgraph.mxICanvas2D.

Default value 1. This method may add rendering overhead and should be used with care.

Implements com.mxgraph.mxICanvas2D.

Default value mxConstants#NONE.

Implements com.mxgraph.mxICanvas2D.

Caches color conversion as it is expensive.

Implements com.mxgraph.mxICanvas2D.

Sets the strokewidth.

Implements com.mxgraph.mxICanvas2D.


The documentation for this class was generated from the following file: