Class DrawMLShape


public class DrawMLShape
extends Object

A DrawMLShape is used by an XML renderer as specified in the DrawML specification.

A DrawMLShape is an abstract class. An actual shape, e.g. a rectangle, should extend this class and define methods to draw the shape, etc.

See Also:
DrawMLPainter

Constructor Summary
DrawMLShape()

                    Constructs a DrawMLShape instance.

Abstract methods called from the renderer
void CalcSize()

                    Method called when a shape should calculate its total size.

void DefineHooks()

                    Method called when a shape should define all its hook positions.

void DrawShape()

                    Method called whenever a shape needs to be redrawn.

void SetChildStart()

                    Method called when the shape should calculate the start position for its children.

 
Methods for updating shape properties
void SetChildX(double x)

                    Sets the start X coordinate for child objects.

void SetChildY(double y)

                    Sets the start Y coordinate for child objects.

void SetWidth(double width)

                    Reports the total width for the shape.

void SetHeight(double height)

                    Reports the total height for the shape.

Methods for obtaining shape properties
double GetAreaW()
double GetAreaH()
double MyW()
double MyWMin()
double MyWMax()
double MyWPad()
double MyH()
double MyHMin()
double MyHPad()
double ShadowX()
double ShadowY()
boolean IHaveW()
boolean IHaveH()
double GetWChild()
double GetHChild()
double GetLineWidth()
String GetShadowColor()
String GetLineColor()
String GetFillColor()
boolean DoShadow()
boolean DoFill()
boolean DoArrow()
boolean DoHide()

Constructor Detail

DrawMLShape

public 

DrawMLShape

()

Constructs a DrawMLShape instance.

Method Detail

DrawShape

public abstract 

DrawShape

()

This method will be called from the renderer whenever the shape needs to be redrawn.

The DrawMLPainter class is used to draw the shape. DrawMLShape has a data member Painter of class DrawMLPainter used for this purpose.

Basically there are no limits associated with how the shape is drawn.

Every shape should be sensitive to the attributes associated with it when drawing. To assure that the necessary attributes are processed a developer can use the method StdDraw(). The renderer then has the responsibility to handle new attributes added to the standard.

Examples
// rectangle version 1 handles attributes by itself

public void DrawShape() 

{

   Painter.NewPath();

   Painter.MoveTo(0,0);

   Painter.LineTo(width,0);

   Painter.LineTo(width,height);

   Painter.LineTo(0,height);

   Painter.ClosePath();

   

   if (DoFill()) {

      Painter.FillColor(GetFillColor());

      Painter.Fill();

   }

}

// rectangle version 2

public void DrawShape() {

   Painter.NewPath();

   Painter.MoveTo(0,0);

   Painter.LineTo(width,0);

   Painter.LineTo(width,height);

   Painter.LineTo(0,height);

   Painter.ClosePath();

   

   StdDraw();  // Handles attributes

}

Parameters:
(none)

SetChildX

native public 

SetChildX

(double)

Sets the start X coordinate for child objects.