TinyLine
v2.0

com.tinyline.svg
Class SVGNode

java.lang.Object
  extended bycom.tinyline.svg.SVGNode
Direct Known Subclasses:
SVGAnimationElem, SVGFontElem, SVGFontFaceElem, SVGGlyphElem, SVGGradientElem, SVGGroupElem, SVGImageElem, SVGMPathElem, SVGPathElem, SVGStopElem, SVGTextElem, SVGUnknownElem

public abstract class SVGNode
extends java.lang.Object

The SVGNode class implements the base class for all elements in the SVG language.

All of the SVG classes that correspond directly to elements in the SVG language (e.g., the SVGPathElem class corresponds directly to the 'path' element in the language) are derivative from this base class SVGNode.

Version:
1.10

Author:
Andrew Girow

Field Summary
 TinyVector animatedVals
          The animated values for this node.
 TinyRect bounds
          The bounding box of the path in USER SPACE.
 TinyVector children
          The children in this node.
 TinyColor color
          The 'color' property is used to provide a potential indirect value (currentColor) for the 'fill' and 'stroke'properties.
 int display
          A value of display: SVG.NONE indicates that the given element and its children shall not be rendered directly (i.e., those elements are not present in the rendering tree).
 TinyColor fill
          The 'fill' property paints the interior of the given graphical element.
 int fillOpacity
          The 'fill-opacity' specifies the opacity of the painting operation used to paint the interior the current object.
 int fillRule
          The 'fill-rule' property indicates the algorithm which is to be used to determine what parts of the canvas are included inside the shape.
 TinyString fontFamily
          The 'font-family' property specifies a font family name.
 int fontSize
          The 'font-size' property describes the size of the font.
 int fontStyle
          The 'font-style' property describes the style of the font.
 int fontWeight
          The 'font-weight' property describes the weight of the font.
 int helem
          The SVG element handler - an integer indicating which type of node this is.
 TinyString id
          The value of the id attribute on the given node.
 int opacity
          The 'opacity' specifies the object/group opacity.
 boolean outlined
          True is the node is outlined, false otherwise.
 SVGDocument ownerDocument
          The document to which this node belongs.
 SVGNode parent
          The node's parent
 TinyColor stopColor
          The 'stop-color' property indicates what color to use at that gradient stop.
 int stopOpacity
          The 'stop-opacity' property defines the opacity of a given gradient stop
 TinyColor stroke
          The 'stroke' property paints along the outline of the given graphical element.
 int[] strokeDashArray
          The 'stroke-dasharray' controls the pattern of dashes and gaps used to stroke paths.
 int strokeDashOffset
          The 'stroke-dashoffset' specifies the distance into the dash pattern to start the dash.
 int strokeLineCap
          The 'stroke-linecap' specifies the shape to be used at the end of open subpaths when they are stroked.
 int strokeLineJoin
          The 'stroke-linejoin' specifies the shape to be used at the corners of paths or basic shapes when they are stroked.
 int strokeMiterLimit
          The 'stroke-miterlimit' imposes a limit on the ratio of the miter length to the 'stroke-linewidth'.
 int strokeOpacity
          The 'stroke-opacity' specifies the opacity of the painting operation used to stroke the current object.
 int strokeWidth
          The width of the stroke on the current object.
 int textAnchor
          The 'text-anchor' property is used to align (start-, middle- or end-alignment) a string of text relative to a given point.
 TinyMatrix transform
          The Transformation matrix which defines the mathematical mapping from one coordinate system into another.
 int visibility
          The 'visibility' property specifies whether the current object is to be rendered.
 int xmlSpace
          Specifies the handling of white space characters
 
Constructor Summary
SVGNode()
          Creates an element.
SVGNode(SVGNode src)
          Creates an element.
 
Method Summary
 void addChild(SVGNode child, int index)
          Adds the specified child to this container node at the specified index.
 boolean contains(SVGRaster renderer, TinyPoint p)
          Returns true if the specified TinyPoint is inside the device boundary of this SVGNode, false otherwise.
abstract  SVGNode copyNode()
          Constructs a copy of the given node.
abstract  int createOutline()
          Creates an outline of this node.
 java.lang.Object getAttribute(int hattr)
          Returns the value object for the given attribute, or null object otherwise.
 TinyRect getBounds()
          Returns the user bounding box for this SVGNode.
 int getCapStyle()
          Gets the stroke cap style for this SVGNode node.
 TinyColor getCurrentColor()
          Gets the current color of this SVGNode node.
 int[] getDashArray()
          Gets the stroke dash array for this SVGNode node.
 int getDashOffset()
          Gets the stroke dash offset for this SVGNode node.
 TinyRect getDevBounds(SVGRaster renderer)
          Returns the device bounding box for this SVGNode.
 int getDisplay()
          Gets the display property for this SVGNode node.
 TinyColor getFillColor()
          Gets the fill color of this SVGNode node.
 int getFillOpacity()
          Gets the fill opacity for this SVGNode node.
 int getFillRule()
          Gets the fill rule for this SVGNode node.
 TinyString getFontFamily()
          Returns the font family of this SVGNode.
 int getFontSize()
          Returns the font size of this SVGNode.
 TinyMatrix getGlobalTransform()
          Returns the concatenated transform of this SVGNode.
 int getJoinStyle()
          Gets the stroke join style for this SVGNode node.
 int getLineThickness()
          Gets the line thickness for this SVGNode node.
 int getMiterLimit()
          Gets the stroke miter limit for this SVGNode node.
static SVGNode getNodeById(SVGDocument doc, TinyString key)
          Returns the node that has the specified Id or null object otherwise.
 int getOpacity()
          Gets the object opacity for this SVGNode node.
 TinyColor getStopColor()
          Gets the stop color of this SVGNode node.
 int getStopOpacity()
          Gets the stop opacity for this SVGNode node.
 TinyColor getStrokeColor()
          Gets the stroke color of this SVGNode node.
 int getStrokeOpacity()
          Gets the stroke opacity for this SVGNode node.
 int getTextAnchor()
          Gets the text anchor style of this SVGNode.
 int getVisibility()
          Gets the visibility propery for this SVGNode node.
 boolean intersects(SVGRaster renderer, TinyRect r)
          Returns true if the interior of this SVGNode intersects the interior of a specified TinyRect, false otherwise.
 boolean isDisplay()
          Returns true if this SVGNode is dislplayable, false otherwise.
 boolean isVisible()
          Returns true if this SVGNode is visible, false otherwise.
 boolean matchUserAgent()
          Tests whether or not the given this SVGNode match a specified user agent.
 SVGNode nodeHitAt(SVGRaster renderer, TinyPoint p)
          Returns the SVGNode node containing TinyPoint p.
abstract  void paint(SVGRaster renderer)
          Draws this node.
 int removeChild(int index)
          Removes the child, specified by index, from this parent node.
 TinyColor resolveColor(TinyColor c)
          Gets the dereferred color of this TinyColor c.
 SVGNode seekAElem()
          Returns the container 'a' element that has this SVGNode as a child or null.
 int setAttribute(int hattr, java.lang.Object value)
          Assigns or modifies the value of the specified attribute.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

helem

public int helem
The SVG element handler - an integer indicating which type of node this is.


ownerDocument

public SVGDocument ownerDocument
The document to which this node belongs.


parent

public SVGNode parent
The node's parent


children

public TinyVector children
The children in this node.


animatedVals

public TinyVector animatedVals
The animated values for this node.


id

public TinyString id
The value of the id attribute on the given node.


xmlSpace

public int xmlSpace
Specifies the handling of white space characters


color

public TinyColor color
The 'color' property is used to provide a potential indirect value (currentColor) for the 'fill' and 'stroke'properties.

Value: ( TinyColor | TinyColor.INHERIT )

Animatable: Yes

Init: black


fill

public TinyColor fill
The 'fill' property paints the interior of the given graphical element.

Value: ( TinyColor.NONE | TinyColor.CURRENT | TinyColor | TinyColor.INHERIT )

Animatable: Yes

Init: black


fillRule

public int fillRule
The 'fill-rule' property indicates the algorithm which is to be used to determine what parts of the canvas are included inside the shape.

Value: (SVG.VAL_NONZERO | SVG.VAL_EVENODD | SVG.VAL_INHERIT)

Animatable: Yes

Init: SVG.NONZERO


stroke

public TinyColor stroke
The 'stroke' property paints along the outline of the given graphical element.

Value: ( TinyColor.NONE | TinyColor.CURRENT | TinyColor | TinyColor.INHERIT )

Animatable: Yes

Init: TinyColor.NONE


strokeDashArray

public int[] strokeDashArray
The 'stroke-dasharray' controls the pattern of dashes and gaps used to stroke paths.

Value: ( SVG.VAL_STROKEDASHARRAYNONE | | SVG.VAL_STROKEDASHARRAYINHERIT )

Animatable: Yes

Init: SVG.STROKEDASHARRAYNONE


strokeDashOffset

public int strokeDashOffset
The 'stroke-dashoffset' specifies the distance into the dash pattern to start the dash.

Value: ( | TinyNumber.INHERIT )

Animatable: Yes

Init: 0


strokeLineCap

public int strokeLineCap
The 'stroke-linecap' specifies the shape to be used at the end of open subpaths when they are stroked.

Value: (SVG.VAL_BUTT | SVG.VAL_ROUND | SVG.VAL_SQUARE | SVG.VAL_INHERIT )

Animatable: Yes

Init: SVG.VAL_BUTT


strokeLineJoin

public int strokeLineJoin
The 'stroke-linejoin' specifies the shape to be used at the corners of paths or basic shapes when they are stroked.

Value: (SVG.VAL_MITER | SVG.VAL_ROUND | SVG.VAL_BEVEL | SVG.VAL_INHERIT )

Animatable: Yes

Init: SVG.VAL_MITER


strokeMiterLimit

public int strokeMiterLimit
The 'stroke-miterlimit' imposes a limit on the ratio of the miter length to the 'stroke-linewidth'.

Value: ( | TinyNumber.INHERIT )

Animatable: Yes

Init: 4


strokeWidth

public int strokeWidth
The width of the stroke on the current object.

Value: ( | TinyNumber.INHERIT )

Animatable: Yes

Init: 1


visibility

public int visibility
The 'visibility' property specifies whether the current object is to be rendered.

Value: (SVG.VAL_VISIBLE | SVG.VAL_HIDDEN | SVG.VAL_COLLAPSE | SVG.VAL_INHERIT)

Animatable: Yes

Init: SVG.VAL_VISIBLE


display

public int display
A value of display: SVG.NONE indicates that the given element and its children shall not be rendered directly (i.e., those elements are not present in the rendering tree). Any value other than SVG.NONE or SVG.INHERIT indicates that the given element shall be rendered.

Value: (SVG.VAL_INLINE | SVG.VAL_NONE | SVG.VAL_INHERIT)

Animatable: Yes

Init: SVG.VAL_INLINE


fontFamily

public TinyString fontFamily
The 'font-family' property specifies a font family name.

Value: ( | null), here null means 'inherit'

Animatable: Yes

Init: Helvetica


fontSize

public int fontSize
The 'font-size' property describes the size of the font.

Value: ( | TinyNumber.INHERIT)

Animatable: Yes

Init: 12


fontStyle

public int fontStyle
The 'font-style' property describes the style of the font.

Value: ( SVG.VAL_NORMAL | SVG.VAL_ITALIC | SVG.VAL_OBLIQUE | SVG.VAL_INHERIT)

Animatable: Yes

Init: SVG.VAL_NORMAL


fontWeight

public int fontWeight
The 'font-weight' property describes the weight of the font.

Value: SVG.VAL_NORMAL | SVG.VAL_BOLD | SVG.VAL_BOLDER | SVG.VAL_LIGHTER | SVG.VAL_100 | SVG.VAL_200 | SVG.VAL_300 | SVG.VAL_400 | SVG.VAL_500 | SVG.VAL_600 | SVG.VAL_700 | SVG.VAL_800 | SVG.VAL_900 | SVG.VAL_INHERIT)

Animatable: Yes

Init: SVG.VAL_NORMAL


textAnchor

public int textAnchor
The 'text-anchor' property is used to align (start-, middle- or end-alignment) a string of text relative to a given point.

Value: (SVG.VAL_START | SVG.VAL_MIDDLE | SVG.VAL_END | SVG.VAL_INHERIT)

Animatable: Yes

Init: SVG.VAL_START


fillOpacity

public int fillOpacity
The 'fill-opacity' specifies the opacity of the painting operation used to paint the interior the current object.

Value: (TinyNumer | TinyNumer.INHERIT)

Animatable: Yes

Init: 1


stopOpacity

public int stopOpacity
The 'stop-opacity' property defines the opacity of a given gradient stop

Value: (TinyNumer | TinyNumer.INHERIT)

Animatable: Yes

Init: 1


strokeOpacity

public int strokeOpacity
The 'stroke-opacity' specifies the opacity of the painting operation used to stroke the current object.

Value: (TinyNumer | TinyNumer.INHERIT)

Animatable: Yes

Init: 1


opacity

public int opacity
The 'opacity' specifies the object/group opacity.

Value: (TinyNumer | TinyNumer.INHERIT)

Animatable: Yes

Init: 1


stopColor

public TinyColor stopColor
The 'stop-color' property indicates what color to use at that gradient stop.

Value: ( TinyColor.CURRENT | TinyColor | TinyColor.INHERIT )

Animatable: Yes

Init: black


transform

public TinyMatrix transform
The Transformation matrix which defines the mathematical mapping from one coordinate system into another.


bounds

public TinyRect bounds
The bounding box of the path in USER SPACE.


outlined

public boolean outlined
True is the node is outlined, false otherwise.

Constructor Detail

SVGNode

public SVGNode()
Creates an element.


SVGNode

public SVGNode(SVGNode src)
Creates an element.

Method Detail

addChild

public void addChild(SVGNode child,
                     int index)
Adds the specified child to this container node at the specified index.

Parameters:
child - the child to be added.
index - the position in the container's list at which to insert the child, where -1 means insert at the end.

removeChild

public int removeChild(int index)
Removes the child, specified by index, from this parent node.

Parameters:
index - the index of the child to be removed.

paint

public abstract void paint(SVGRaster renderer)
Draws this node.

Parameters:
renderer - The SVGRaster object that does the drawing.

createOutline

public abstract int createOutline()
Creates an outline of this node.


copyNode

public abstract SVGNode copyNode()
Constructs a copy of the given node.


setAttribute

public int setAttribute(int hattr,
                        java.lang.Object value)
                 throws java.lang.Exception
Assigns or modifies the value of the specified attribute.

Parameters:
hattr - The attribute handle.
value - The value of the attribute.
Returns:
The error code that could be one of the following: SVG.ERR_OK, SVG.ERR_NUMBER_FORMAT, SVG.ERR_INVALID_ARG, SVG.ERR_NOT_FOUND, SVG.ERR_NOT_SUPPORTED, SVG.ERR_HIERARCHY_REQUEST
Throws:
java.lang.Exception - if the value type doesn not match to the attribute handle.

getAttribute

public java.lang.Object getAttribute(int hattr)
Returns the value object for the given attribute, or null object otherwise.

Parameters:
hattr - The attribute handle.
Returns:
The value of the attribute or null.

matchUserAgent

public boolean matchUserAgent()
Tests whether or not the given this SVGNode match a specified user agent.


getCurrentColor

public TinyColor getCurrentColor()
Gets the current color of this SVGNode node.

Returns:
This SVGNode's current color. If this SVGNode does not have a current color, the current color of its parent is returned.

getFillColor

public TinyColor getFillColor()
Gets the fill color of this SVGNode node.

Returns:
This SVGNode's fill color. If this SVGNode does not have a fill color, the fill color of its parent is returned.

getFillRule

public int getFillRule()
Gets the fill rule for this SVGNode node.

Returns:
This SVGNode's fill rule. If this SVGNode does not have a fill rule, the fill rule of its parent is returned.

getStrokeColor

public TinyColor getStrokeColor()
Gets the stroke color of this SVGNode node.

Returns:
This SVGNode's stroke color. If this SVGNode does not have a stroke color, the stroke color of its parent is returned.

resolveColor

public TinyColor resolveColor(TinyColor c)
Gets the dereferred color of this TinyColor c.

Returns:
The dereferred color.

getDashArray

public int[] getDashArray()
Gets the stroke dash array for this SVGNode node.

Returns:
This SVGNode's stroke dash array. If this SVGNode does not have a stroke dash array, the stroke dash array of its parent is returned.

getDashOffset

public int getDashOffset()
Gets the stroke dash offset for this SVGNode node.

Returns:
This SVGNode's stroke dash offset. If this SVGNode does not have a stroke dash offset, the stroke dash offset of its parent is returned.

getCapStyle

public int getCapStyle()
Gets the stroke cap style for this SVGNode node.

Returns:
This SVGNode's stroke cap style. If this SVGNode does not have a stroke cap style, the stroke cap style of its parent is returned.

getJoinStyle

public int getJoinStyle()
Gets the stroke join style for this SVGNode node.

Returns:
This SVGNode's stroke join style. If this SVGNode does not have a stroke join style, the stroke join style of its parent is returned.

getMiterLimit

public int getMiterLimit()
Gets the stroke miter limit for this SVGNode node.

Returns:
This SVGNode's stroke miter limit. If this SVGNode does not have a stroke miter limit, the stroke miter limit of its parent is returned.

getLineThickness

public int getLineThickness()
Gets the line thickness for this SVGNode node.

Returns:
This SVGNode's line thickness. If this SVGNode does not have a line thickness, the line thickness of its parent is returned.

getFillOpacity

public int getFillOpacity()
Gets the fill opacity for this SVGNode node.

Returns:
This SVGNode's fill opacity. If this SVGNode does not have a fill opacity, the fill opacity of its parent is returned.

getStrokeOpacity

public int getStrokeOpacity()
Gets the stroke opacity for this SVGNode node.

Returns:
This SVGNode's stroke opacity. If this SVGNode does not have a stroke opacity, the stroke opacity of its parent is returned.

getOpacity

public int getOpacity()
Gets the object opacity for this SVGNode node.

Returns:
This SVGNode's object opacity. If this SVGNode does not have a object opacity, the object opacity of its parent is returned.

getStopColor

public TinyColor getStopColor()
Gets the stop color of this SVGNode node.

Returns:
This SVGNode's stop color. If this SVGNode does not have a stop color, the stop color of its parent is returned.

getStopOpacity

public int getStopOpacity()
Gets the stop opacity for this SVGNode node.

Returns:
This SVGNode's stop opacity. If this SVGNode does not have a stop opacity, the stop opacity of its parent is returned.

getDisplay

public int getDisplay()
Gets the display property for this SVGNode node.

Returns:
This SVGNode's display property. If this SVGNode does not have a display property, the display property of its parent is returned.

getVisibility

public int getVisibility()
Gets the visibility propery for this SVGNode node.

Returns:
This SVGNode's visibility property. If this SVGNode does not have a visibility property, the visibility property of its parent is returned.

getFontSize

public int getFontSize()
Returns the font size of this SVGNode.

Returns:
the font size of this SVGNode If this parameter is 0 then this node will inherit the font size of its parent.

getFontFamily

public TinyString getFontFamily()
Returns the font family of this SVGNode.

Returns:
the font family of this SVGNode If this parameter is null then this node will inherit the font size of its parent.

getTextAnchor

public int getTextAnchor()
Gets the text anchor style of this SVGNode. If this parameter is 0 then this node will inherit the text anchor style of its parent.


isVisible

public boolean isVisible()
Returns true if this SVGNode is visible, false otherwise.


isDisplay

public boolean isDisplay()
Returns true if this SVGNode is dislplayable, false otherwise.


contains

public boolean contains(SVGRaster renderer,
                        TinyPoint p)
Returns true if the specified TinyPoint is inside the device boundary of this SVGNode, false otherwise.

Parameters:
p - the specified TinyPoint in DEVICE SPACE

intersects

public boolean intersects(SVGRaster renderer,
                          TinyRect r)
Returns true if the interior of this SVGNode intersects the interior of a specified TinyRect, false otherwise.

Parameters:
r - the specified TinyRect in DEVICE SPACE

nodeHitAt

public SVGNode nodeHitAt(SVGRaster renderer,
                         TinyPoint p)
Returns the SVGNode node containing TinyPoint p.

Parameters:
p - the specified TinyPoint in DEVICE SPACE

seekAElem

public SVGNode seekAElem()
Returns the container 'a' element that has this SVGNode as a child or null.


getGlobalTransform

public TinyMatrix getGlobalTransform()
Returns the concatenated transform of this SVGNode. I.e., this SVGNode's transform preconcatenated with it's parent's transforms.


getBounds

public TinyRect getBounds()
Returns the user bounding box for this SVGNode. COORDINATES ARE IN USER SPACE. If this SVGNode doesnt have its own geometry, the getBounds() returns null.


getDevBounds

public TinyRect getDevBounds(SVGRaster renderer)
Returns the device bounding box for this SVGNode. COORDINATES ARE IN DEVICE SPACE. If this SVGNode doesnt have its own geometry, the getDevBounds() returns null.

Parameters:
renderer - Handle to the SVGRaster object that does the drawing.

getNodeById

public static SVGNode getNodeById(SVGDocument doc,
                                  TinyString key)
Returns the node that has the specified Id or null object otherwise.

Parameters:
key - The specified Id.

TinyLine
v2.0

Provided under the terms of the TinyLine License Agreement that has been included with this distribution