de.bsd.x2svg
Class Container

java.lang.Object
  extended by de.bsd.x2svg.Container

public class Container
extends java.lang.Object

This class holds all information about an element and its children. The paint() method is used to draw them on screen.

Author:
hwr@pilhuhn.de

Field Summary
 java.util.List<java.lang.String> attributes
          Attributes of this element
 Cardinality cardinality
          The cardinality of this element.
 java.util.List<Container> children
          The children of this container
 java.lang.String comment
          A comment for this element
 ContentModel content
          The content model of the children of this container
 boolean isAbstract
          Is this an abstract element (XSD use)
 boolean isAny
           
 boolean isEmpty
          Can the element NOT contain children (is it marked as EMPTY)?
 boolean isPcData
          Can the element contain text?
 boolean isReference
          Is this a real element or a references to one already defined somewhere up the hierarchy?
 boolean isSubstitution
          Is this a substitutionGroup (XSD use)
 boolean isType
          Is this a named (complex) type (XSD use)
 int localHeight
          Height of the element plus its surrounding content box
 int localWidth
          Width of the element plus its surrounding content box
 java.lang.String name
          Name of this element.
 Container parent
          A link to the parent container or null if this is the root of the tree
 int totalHeight
          Height of this element and enclosed ones
 int totalWidth
          Width of this element including the with of included elements
 int xPos
          Top left position of this container
 int yPos
          Top left position of this container
 
Constructor Summary
Container()
           
 
Method Summary
private  void drawContentModel(org.apache.batik.svggen.SVGGraphics2D svg, int x, int y)
          Helper to draw the content model if the container has children
static boolean hasChildren(Container rootCont)
          Safely determine if the passed container has children
 boolean isElementInHierarchy(java.lang.String elementName)
          See if an item with the passed name already exists on our way to the root of the container tree.
 int paint(org.apache.batik.svggen.SVGGraphics2D svg, int startX, int startY)
          Paints a container and its children.
private  void setStroke(org.apache.batik.svggen.SVGGraphics2D svg, java.awt.Stroke stroke)
          Set the stroke to dashed if the container is optional.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public java.lang.String name
Name of this element. Yields label in the container


totalWidth

public int totalWidth
Width of this element including the with of included elements


totalHeight

public int totalHeight
Height of this element and enclosed ones


localWidth

public int localWidth
Width of the element plus its surrounding content box


localHeight

public int localHeight
Height of the element plus its surrounding content box


children

public java.util.List<Container> children
The children of this container


isPcData

public boolean isPcData
Can the element contain text?


isAny

public boolean isAny

isEmpty

public boolean isEmpty
Can the element NOT contain children (is it marked as EMPTY)?


content

public ContentModel content
The content model of the children of this container


parent

public Container parent
A link to the parent container or null if this is the root of the tree


cardinality

public Cardinality cardinality
The cardinality of this element. Default is the optional empty cardinality


xPos

public int xPos
Top left position of this container


yPos

public int yPos
Top left position of this container


isReference

public boolean isReference
Is this a real element or a references to one already defined somewhere up the hierarchy?


isAbstract

public boolean isAbstract
Is this an abstract element (XSD use)


isSubstitution

public boolean isSubstitution
Is this a substitutionGroup (XSD use)


isType

public boolean isType
Is this a named (complex) type (XSD use)


attributes

public java.util.List<java.lang.String> attributes
Attributes of this element


comment

public java.lang.String comment
A comment for this element

Constructor Detail

Container

public Container()
Method Detail

paint

public int paint(org.apache.batik.svggen.SVGGraphics2D svg,
                 int startX,
                 int startY)
Paints a container and its children. Does this by recursively calling itself.

Parameters:
svg - a svg canvas to draw on
startX - top left corner of the area to draw in
startY - top left corner of the area to draw in
Returns:
the y coordinate of the little tail on the left side of the element box

drawContentModel

private void drawContentModel(org.apache.batik.svggen.SVGGraphics2D svg,
                              int x,
                              int y)
Helper to draw the content model if the container has children

Parameters:
svg - svg canvas to draw on
x - top left corner of the content model box
y - top left corner of the content model box

setStroke

private void setStroke(org.apache.batik.svggen.SVGGraphics2D svg,
                       java.awt.Stroke stroke)
Set the stroke to dashed if the container is optional.

Parameters:
svg - svg canvas
stroke - alternate stroke if the container is not optional

hasChildren

public static boolean hasChildren(Container rootCont)
Safely determine if the passed container has children

Parameters:
rootCont - Container to examine
Returns:
true if rootCont has children.

isElementInHierarchy

public boolean isElementInHierarchy(java.lang.String elementName)
See if an item with the passed name already exists on our way to the root of the container tree.

Parameters:
elementName - Name of an Element
Returns:
true if it is found, false otherwise

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


x2svg version 1.2.1