org.apache.batik.gvt

Class CompositeGraphicsNode

public class CompositeGraphicsNode extends AbstractGraphicsNode implements List

A CompositeGraphicsNode is a graphics node that can contain graphics nodes.
Note: this class is a 'little bit aware of' other threads, but not really threadsafe.
Field Summary
protected Rectangle2DbackgroundEnableRgn
This flag indicates if this node has BackgroundEnable = 'new'.
protected GraphicsNode[]children
The children of this composite graphics node.
protected intcount
The number of children of this composite graphics node.
protected intmodCount
The number of times the children list has been structurally modified.
static Rectangle2DNULL_RECT
static Rectangle2DVIEWPORT
Constructor Summary
CompositeGraphicsNode()
Constructs a new empty CompositeGraphicsNode.
Method Summary
booleanadd(Object o)
Adds the specified graphics node to this composite graphics node.
voidadd(int index, Object o)
Inserts the specified graphics node at the specified position in this children list.
booleanaddAll(Collection c)
Not supported - Throws UnsupportedOperationException exception.
booleanaddAll(int index, Collection c)
Not supported - Throws UnsupportedOperationException exception.
voidclear()
Not supported - Throws UnsupportedOperationException exception.
booleancontains(Point2D p)
Returns true if the specified Point2D is inside the boundary of this node, false otherwise.
booleancontains(Object node)
Returns true if this composite graphics node contains the specified graphics node, false otherwise.
booleancontainsAll(Collection c)
Returns true if this composite graphics node contains all the graphics node in the specified collection, false otherwise.
voidensureCapacity(int minCapacity)
Increases the capacity of the children list, if necessary, to ensure that it can hold at least the number of graphics nodes specified by the minimum capacity argument.
Objectget(int index)
Returns the graphics node at the specified position in the children list.
Rectangle2DgetBackgroundEnable()
Returns the region defining the background enable property.
ListgetChildren()
Returns the list of children.
Rectangle2DgetGeometryBounds()
Returns the bounds of the area covered by this node, without taking any of its rendering attributes into account.
ShapegetOutline()
Returns the outline of this node.
Rectangle2DgetPrimitiveBounds()
Returns the bounds of the area covered by this node's primitive paint.
Rectangle2DgetSensitiveBounds()
Returns the bounds of the sensitive area covered by this node, This includes the stroked area but does not include the effects of clipping, masking or filtering.
static Rectangle2DgetTransformedBBox(Rectangle2D r2d, AffineTransform t)
Transforms a Rectangle 2D by an affine transform.
Rectangle2DgetTransformedGeometryBounds(AffineTransform txf)
Returns the bounds of the area covered by this node, without taking any of its rendering attribute into accoun.
Rectangle2DgetTransformedPrimitiveBounds(AffineTransform txf)
Returns the bounds of this node's primitivePaint after applying the input transform (if any), concatenated with this node's transform (if any).
Rectangle2DgetTransformedSensitiveBounds(AffineTransform txf)
Returns the bounds of the sensitive area covered by this node, This includes the stroked area but does not include the effects of clipping, masking or filtering.
intindexOf(Object node)
Returns the index in the children list of the specified graphics node or -1 if the children list does not contain this graphics node.
protected voidinvalidateGeometryCache()
Invalidates the cached geometric bounds.
booleanisEmpty()
Returns true if this composite graphics node does not contain graphics node, false otherwise.
Iteratoriterator()
Returns an iterator over the children of this graphics node.
intlastIndexOf(Object node)
Returns the index in this children list of the last occurence of the specified graphics node, or -1 if the list does not contain this graphics node.
ListIteratorlistIterator()
Returns an iterator over the children of this graphics node.
ListIteratorlistIterator(int index)
Returns an iterator over the children of this graphics node, starting at the specified position in the children list.
GraphicsNodenodeHitAt(Point2D p)
Returns the GraphicsNode containing point p if this node or one of its children is sensitive to mouse events at p.
voidprimitivePaint(Graphics2D g2d)
Paints this node without applying Filter, Mask, Composite, and clip.
booleanremove(Object o)
Removes the first instance of the specified graphics node from the children list.
Objectremove(int index)
Removes the graphics node at the specified position in the children list.
booleanremoveAll(Collection c)
Not supported - Throws UnsupportedOperationException exception.
booleanretainAll(Collection c)
Not supported - Throws UnsupportedOperationException exception.
Objectset(int index, Object o)
Replaces the graphics node at the specified position in the children list with the specified graphics node.
voidsetBackgroundEnable(Rectangle2D bgRgn)
Sets the enable background property to the specified rectangle.
protected voidsetRoot(RootGraphicsNode newRoot)
Sets the root node of this grahics node and modify all its children.
voidsetVisible(boolean isVisible)
Sets if this node is visible or not depending on the specified value.
intsize()
Returns the number of children of this composite graphics node.
ListsubList(int fromIndex, int toIndex)
Not supported - Throws UnsupportedOperationException exception.
Object[]toArray()
Returns an array containing all of the graphics node in the children list of this composite graphics node in the correct order.
Object[]toArray(Object[] a)
Returns an array containing all of the graphics node in the children list of this composite graphics node in the correct order.

Field Detail

backgroundEnableRgn

protected Rectangle2D backgroundEnableRgn
This flag indicates if this node has BackgroundEnable = 'new'. If so traversal of the gvt tree can halt here.

children

protected GraphicsNode[] children
The children of this composite graphics node.

count

protected volatile int count
The number of children of this composite graphics node.

modCount

protected volatile int modCount
The number of times the children list has been structurally modified.

NULL_RECT

public static final Rectangle2D NULL_RECT

VIEWPORT

public static final Rectangle2D VIEWPORT

Constructor Detail

CompositeGraphicsNode

public CompositeGraphicsNode()
Constructs a new empty CompositeGraphicsNode.

Method Detail

add

public boolean add(Object o)
Adds the specified graphics node to this composite graphics node.

Parameters: o the graphics node to add

Returns: true (as per the general contract of Collection.add)

Throws: IllegalArgumentException if the node is not an instance of GraphicsNode

add

public void add(int index, Object o)
Inserts the specified graphics node at the specified position in this children list. Shifts the graphics node currently at that position (if any) and any subsequent graphics nodes to the right (adds one to their indices).

Parameters: index the position at which the specified graphics node is to be inserted. o the graphics node to be inserted.

Throws: IndexOutOfBoundsException if the index is out of range IllegalArgumentException if the node is not an instance of GraphicsNode

addAll

public boolean addAll(Collection c)
Not supported - Throws UnsupportedOperationException exception.

addAll

public boolean addAll(int index, Collection c)
Not supported - Throws UnsupportedOperationException exception.

clear

public void clear()
Not supported - Throws UnsupportedOperationException exception.

contains

public boolean contains(Point2D p)
Returns true if the specified Point2D is inside the boundary of this node, false otherwise.

Parameters: p the specified Point2D in the user space

contains

public boolean contains(Object node)
Returns true if this composite graphics node contains the specified graphics node, false otherwise.

Parameters: node the node to check

containsAll

public boolean containsAll(Collection c)
Returns true if this composite graphics node contains all the graphics node in the specified collection, false otherwise.

Parameters: c the collection to be checked for containment

ensureCapacity

public void ensureCapacity(int minCapacity)
Increases the capacity of the children list, if necessary, to ensure that it can hold at least the number of graphics nodes specified by the minimum capacity argument.

Parameters: minCapacity the desired minimum capacity.

get

public Object get(int index)
Returns the graphics node at the specified position in the children list.

Parameters: index the index of the graphics node to return

Throws: IndexOutOfBoundsException if the index is out of range

getBackgroundEnable

public Rectangle2D getBackgroundEnable()
Returns the region defining the background enable property.

getChildren

public List getChildren()
Returns the list of children.

getGeometryBounds

public Rectangle2D getGeometryBounds()
Returns the bounds of the area covered by this node, without taking any of its rendering attributes into account. That is, exclusive of any clipping, masking, filtering or stroking, for example.

getOutline

public Shape getOutline()
Returns the outline of this node.

getPrimitiveBounds

public Rectangle2D getPrimitiveBounds()
Returns the bounds of the area covered by this node's primitive paint.

getSensitiveBounds

public Rectangle2D getSensitiveBounds()
Returns the bounds of the sensitive area covered by this node, This includes the stroked area but does not include the effects of clipping, masking or filtering.

getTransformedBBox

public static Rectangle2D getTransformedBBox(Rectangle2D r2d, AffineTransform t)
Transforms a Rectangle 2D by an affine transform. It assumes the transform is only scale/translate so there is no loss of precision over transforming the source geometry.

getTransformedGeometryBounds

public Rectangle2D getTransformedGeometryBounds(AffineTransform txf)
Returns the bounds of the area covered by this node, without taking any of its rendering attribute into accoun. That is, exclusive of any clipping, masking, filtering or stroking, for example. The returned value is transformed by the concatenation of the input transform and this node's transform.

Parameters: txf the affine transform with which this node's transform should be concatenated. Should not be null.

getTransformedPrimitiveBounds

public Rectangle2D getTransformedPrimitiveBounds(AffineTransform txf)
Returns the bounds of this node's primitivePaint after applying the input transform (if any), concatenated with this node's transform (if any).

Parameters: txf the affine transform with which this node's transform should be concatenated. Should not be null.

getTransformedSensitiveBounds

public Rectangle2D getTransformedSensitiveBounds(AffineTransform txf)
Returns the bounds of the sensitive area covered by this node, This includes the stroked area but does not include the effects of clipping, masking or filtering. The returned value is transformed by the concatenation of the input transform and this node's transform.

Parameters: txf the affine transform with which this node's transform should be concatenated. Should not be null.

indexOf

public int indexOf(Object node)
Returns the index in the children list of the specified graphics node or -1 if the children list does not contain this graphics node.

Parameters: node the graphics node to search for

invalidateGeometryCache

protected void invalidateGeometryCache()
Invalidates the cached geometric bounds. This method is called each time an attribute that affects the bounds of this node changed.

isEmpty

public boolean isEmpty()
Returns true if this composite graphics node does not contain graphics node, false otherwise.

iterator

public Iterator iterator()
Returns an iterator over the children of this graphics node.

lastIndexOf

public int lastIndexOf(Object node)
Returns the index in this children list of the last occurence of the specified graphics node, or -1 if the list does not contain this graphics node.

Parameters: node the graphics node to search for

listIterator

public ListIterator listIterator()
Returns an iterator over the children of this graphics node.

listIterator

public ListIterator listIterator(int index)
Returns an iterator over the children of this graphics node, starting at the specified position in the children list.

Parameters: index the index of the first graphics node to return from the children list

nodeHitAt

public GraphicsNode nodeHitAt(Point2D p)
Returns the GraphicsNode containing point p if this node or one of its children is sensitive to mouse events at p.

Parameters: p the specified Point2D in the user space

primitivePaint

public void primitivePaint(Graphics2D g2d)
Paints this node without applying Filter, Mask, Composite, and clip.

Parameters: g2d the Graphics2D to use

remove

public boolean remove(Object o)
Removes the first instance of the specified graphics node from the children list.

Parameters: o the node the remove

Returns: true if the children list contains the specified graphics node

Throws: IllegalArgumentException if the node is not an instance of GraphicsNode IndexOutOfBoundsException when o is not in children list

remove

public Object remove(int index)
Removes the graphics node at the specified position in the children list. Shifts any subsequent graphics nodes to the left (subtracts one from their indices).

Parameters: index the position of the graphics node to remove

Returns: the graphics node that was removed

Throws: IndexOutOfBoundsException if index out of range

removeAll

public boolean removeAll(Collection c)
Not supported - Throws UnsupportedOperationException exception.

retainAll

public boolean retainAll(Collection c)
Not supported - Throws UnsupportedOperationException exception.

set

public Object set(int index, Object o)
Replaces the graphics node at the specified position in the children list with the specified graphics node.

Parameters: index the index of the graphics node to replace o the graphics node to be stored at the specified position

Returns: the graphics node previously at the specified position

Throws: IndexOutOfBoundsException if the index is out of range IllegalArgumentException if the node is not an instance of GraphicsNode

setBackgroundEnable

public void setBackgroundEnable(Rectangle2D bgRgn)
Sets the enable background property to the specified rectangle.

Parameters: bgRgn the region that defines the background enable property

setRoot

protected void setRoot(RootGraphicsNode newRoot)
Sets the root node of this grahics node and modify all its children.

setVisible

public void setVisible(boolean isVisible)
Sets if this node is visible or not depending on the specified value. Don't fire a graphicsNodeChange event because this doesn't really effect us (it effects our children through CSS inheritence).

Parameters: isVisible If true this node is visible

size

public int size()
Returns the number of children of this composite graphics node.

subList

public List subList(int fromIndex, int toIndex)
Not supported - Throws UnsupportedOperationException exception.

toArray

public Object[] toArray()
Returns an array containing all of the graphics node in the children list of this composite graphics node in the correct order.

toArray

public Object[] toArray(Object[] a)
Returns an array containing all of the graphics node in the children list of this composite graphics node in the correct order. If the children list fits in the specified array, it is returned therein. Otherwise, a new array is allocated.

Parameters: a the array to fit if possible

Copyright B) 2008 Apache Software Foundation. All Rights Reserved.