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 SetGradient (String color1, String color2, double x, double y, double w, double h, String direction)
 Sets the given gradient.
void SetGlassGradient (double x, double y, double w, double h)
 Sets the given glass 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 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 ()

Static Public Member Functions

static StringFormat CreateStringFormat (string align, string valign, bool wrap)
 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)
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.
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.
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.
void UpdateFont ()
Font CreateFont (String family, FontStyle style, int size)
void UpdatePen ()

Protected Attributes

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.
string currentShadowValue
 Holds the current value for the shadow color. This is used to hold the.
Color currentShadowColor
 Holds the current parsed shadow color. This holds the result of parsing.

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

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

void com::mxgraph::mxGdiCanvas2D::Begin (  )  [inline]
void com::mxgraph::mxGdiCanvas2D::Clip (  )  [inline]
void com::mxgraph::mxGdiCanvas2D::Close (  )  [inline]

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,
int  size 
) [inline, protected]

Hook for subclassers to implement font caching.

static StringFormat com::mxgraph::mxGdiCanvas2D::CreateStringFormat ( string  align,
string  valign,
bool  wrap 
) [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]
void com::mxgraph::mxGdiCanvas2D::FillAndStroke (  )  [inline]
double com::mxgraph::mxGdiCanvas2D::GetHorizontalTextPosition ( double  x,
double  y,
double  w,
double  h,
string  align,
string  valign,
bool  vertical,
Font  font,
string  text,
bool  wrap,
string  format 
) [inline, protected]

Default alignment is left.

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.

double com::mxgraph::mxGdiCanvas2D::GetTextWidth ( double  x,
double  y,
double  w,
double  h,
string  align,
string  valign,
bool  vertical,
Font  font,
string  text,
bool  wrap,
string  format 
) [inline, protected]

Returns the width to be used to render the specifies text.

double com::mxgraph::mxGdiCanvas2D::GetVerticalTextPosition ( double  x,
double  y,
double  w,
double  h,
string  align,
string  valign,
bool  vertical,
Font  font,
string  text,
bool  wrap,
string  format 
) [inline, protected]

Default alignment is top.

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

void com::mxgraph::mxGdiCanvas2D::Restore (  )  [inline]

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::SetGlassGradient ( double  x,
double  y,
double  w,
double  h 
) [inline]

Sets the given glass gradient.

Implements com::mxgraph::mxICanvas2D.

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

Sets the given gradient.

void com::mxgraph::mxGdiCanvas2D::Shadow ( String  value,
bool  filled 
) [inline]
Parameters:
value 
void com::mxgraph::mxGdiCanvas2D::Stroke (  )  [inline]
void com::mxgraph::mxGdiCanvas2D::Text ( double  x,
double  y,
double  w,
double  h,
string  str,
string  align,
string  valign,
bool  vertical,
bool  wrap,
string  format 
) [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.

Holds the current parsed shadow color. This holds the result of parsing.

the currentShadowValue, which is an expensive operation.

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.

Reference to the graphics instance for painting.

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

current path is orthogonal.

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

Stack of states for save/restore.

Represents the current state of the canvas.


Property Documentation

double com::mxgraph::mxGdiCanvas2D::Alpha [set]

Sets the given alpha.

Implements com::mxgraph::mxICanvas2D.

bool com::mxgraph::mxGdiCanvas2D::Dashed [set]

Specifies if lines are dashed.

Implements com::mxgraph::mxICanvas2D.

string com::mxgraph::mxGdiCanvas2D::DashPattern [set]

Sets the dashpattern.

Implements com::mxgraph::mxICanvas2D.

string com::mxgraph::mxGdiCanvas2D::FillColor [set]

Sets the given fillcolor.

Implements com::mxgraph::mxICanvas2D.

string com::mxgraph::mxGdiCanvas2D::FontColor [set]

Sets the fontcolor.

Implements com::mxgraph::mxICanvas2D.

string com::mxgraph::mxGdiCanvas2D::FontFamily [set]

Sets the font family.

Implements com::mxgraph::mxICanvas2D.

double com::mxgraph::mxGdiCanvas2D::FontSize [set]

Sets the fontsize.

Implements com::mxgraph::mxICanvas2D.

int com::mxgraph::mxGdiCanvas2D::FontStyle [set]

Sets the given fontstyle.

Implements com::mxgraph::mxICanvas2D.

string com::mxgraph::mxGdiCanvas2D::LineCap [set]

Sets the linecap.

Implements com::mxgraph::mxICanvas2D.

string com::mxgraph::mxGdiCanvas2D::LineJoin [set]

Sets the linejoin.

Implements com::mxgraph::mxICanvas2D.

double com::mxgraph::mxGdiCanvas2D::MiterLimit [set]

Sets the miterlimit.

Implements com::mxgraph::mxICanvas2D.

string com::mxgraph::mxGdiCanvas2D::StrokeColor [set]

Caches color conversion as it is expensive.

Implements com::mxgraph::mxICanvas2D.

double com::mxgraph::mxGdiCanvas2D::StrokeWidth [set]

Sets the strokewidth.

Implements com::mxgraph::mxICanvas2D.


The documentation for this class was generated from the following file:
Generated on Mon Oct 29 20:11:49 2012 for mxGraph by  doxygen 1.6.3