org.omegahat.Graphics.Primitives
Class GraphicalContainer

java.lang.Object
  |
  +--org.omegahat.Graphics.Primitives.GraphicalObject
        |
        +--org.omegahat.Graphics.Primitives.RGO
              |
              +--org.omegahat.Graphics.Primitives.GraphicalContainer
All Implemented Interfaces:
Addable, Copyable, GraphicalComponentInt, GraphicalContainerInt, MathOperable, ScaledComponentInt, SimpleGraphicalContainerInt, Subsettable, Tree
Direct Known Subclasses:
Axis, BoxWhiskers, DataPlot, DynamicGraphicalContainer, DynamicTimeSeriesStack, FemaleSymbol, MaleSymbol

public class GraphicalContainer
extends RGO
implements GraphicalContainerInt, Addable, Subsettable, Copyable

Graphical objects that can contain other graphical objects.

This class adds to the rectangular graphical object several concepts to help in the construction of general objects:


Field Summary
protected  RegionAllocator allocator
           
protected  java.util.List children
           
protected  int origin
           
protected  SimpleGraphicalContainerInt parent
           
protected  ScaleInt scaleX
           
protected  ScaleInt scaleY
           
 
Fields inherited from class org.omegahat.Graphics.Primitives.RGO
region
 
Fields inherited from class org.omegahat.Graphics.Primitives.GraphicalObject
ACTIVE, fontSize, lastDevice, lastHeightCM, lastRegion, lastWidthCM, parents, status, VISIBLE
 
Fields inherited from interface org.omegahat.Environment.DataStructures.MathOperable
DIVIDE, MINUS, MULTIPLY, PLUS
 
Constructor Summary
GraphicalContainer()
           
GraphicalContainer(double x, double y, double width, double height, int unit)
           
GraphicalContainer(GraphicalContainer el)
           
GraphicalContainer(GraphicalContainer el, boolean deep)
           
GraphicalContainer(ScaleInt xscale, ScaleInt yscale)
           
GraphicalContainer(UDouble x, UDouble y, UDouble width, UDouble height)
           
 
Method Summary
 boolean add(java.lang.Object go)
          Add an entry to the list of children.
 void addGraphicalObject(GraphicalComponentInt go)
          Simplest version of the addition of a graphical component to a container, using the default region and layer.
 void addGraphicalObject(GraphicalComponentInt go, boolean withAllocators)
           
 void addGraphicalObject(GraphicalComponentInt go, boolean withAllocators, int layer)
           
 void addGraphicalObject(GraphicalComponentInt go, int inRegion)
          Add the specified graphical component to this container with in the given region.
 void addGraphicalObject(GraphicalComponentInt go, int regionId, int layer)
          Add the specified graphical component to this container in the region identified by region and draw it in the given layer.
 void addGraphicalObject(GraphicalComponentInt go, java.lang.Object regionId)
           
 void addGraphicalObject(GraphicalComponentInt go, java.lang.Object regionId, int layer)
           
 void addGraphicalObject(GraphicalComponentInt go, java.lang.String regionId)
          Add the specified graphical component to this container with in the given region identified by name.
 void addGraphicalObject(GraphicalComponentInt go, java.lang.String regionId, int layer)
          Add the graphical componen to the specified region within this container, drawing it in the given layer.
 void addGraphicalObject(java.lang.Object go)
           
 java.lang.Object addValue(java.lang.Object rhs, boolean inPlace)
           
 java.lang.Object copy()
          Create a shallow copy of this object.
 java.lang.Object copy(boolean deep)
          Create a copy of this object, controlling whether its contents are shared with the copy or also copied.
 Region draw(RectRegion rr, ScaleInt sx, ScaleInt sy, int parentOrigin, double widthCM, double heightCM, int fontSize, OutputDevice od, GraphicalContainerInt parentId)
          This iterates over its children, having them draw themselves relative to this container's dimensions and using the primitives in the OutputDevice.
 void drawChildren(RectRegion rr, double widthCM, double heightCM, OutputDevice od)
           
 java.lang.Object get(int which)
          Get the ith child.
 GraphicalComponentInt getChild(int which)
           
 int getChildCount()
          Get the number of children currently contained in this node.
 java.util.List getChildren()
          Return the entire collection of children.
 OutputDevice getDevice()
           
 int getOrigin()
          Accessor for the origin field.
 RegionAllocator getRegionAllocator()
          Get the current region allocator used by this container.
 ScaleInt getXScale()
          Retrieve the ScaleInt of the horizontal/X dimension.
 ScaleInt getYScale()
          Retrieve the ScaleInt of the vertical/Y dimension.
 SimpleGraphicalContainerInt parent()
          Retrieve the parent of this component, if it has one.
 SimpleGraphicalContainerInt parent(SimpleGraphicalContainerInt o)
          Set the parent of this container.
 java.lang.Object remove(int which)
          Remove the ith child from the list of children.
 void removeGraphicalObject(GraphicalComponentInt go)
           
 void removeGraphicalObject(GraphicalComponentInt go, int layer)
           
 void setOrigin(int o)
          Accessor for setting the origin field.
 void setRegionAllocator(RegionAllocator ra)
          Set the object that will control the creation of the different regions within the container to house sub-groups of components.
 void setXScale(ScaleInt s)
          Set the ScaleInt of the horizontal/X dimension.
 void setYScale(ScaleInt s)
          Set the ScaleInt of the vertical/Y dimension.
 java.lang.Object subset(List indeces, boolean keepStructure)
          Method providing subsetting overloading for the GraphicalContainerInt
 java.lang.Object subset(java.lang.Object index, boolean keepStructure)
           
 Tree transform(GraphicalContainerInt c, NodeMap mapper)
          Apply the methods of the specified map recursively to the specified container and its elements.
 Tree transform(NodeMap mapper)
          Apply the methods of the specified map recursively to this container and its elements.
 
Methods inherited from class org.omegahat.Graphics.Primitives.RGO
center, centre, createRegionDescription, createRegionDescription, getRegion, height, height, setHJust, setRegion, setVJust, width, width, x, x, y, y
 
Methods inherited from class org.omegahat.Graphics.Primitives.GraphicalObject
cacheSize, getFontSize, getFontSize, getParameters, getParents, getStatus, isActive, isVisible, lastHeightCM, lastRegion, lastWidthCM, parents, setActive, setParameters, setParents, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.omegahat.Graphics.Primitives.GraphicalComponentInt
getParameters, getRegion, isActive, isVisible, parents, setActive, setParameters, setRegion, setVisible
 

Field Detail

children

protected java.util.List children

parent

protected SimpleGraphicalContainerInt parent

allocator

protected RegionAllocator allocator

scaleX

protected ScaleInt scaleX

scaleY

protected ScaleInt scaleY

origin

protected int origin
Constructor Detail

GraphicalContainer

public GraphicalContainer()

GraphicalContainer

public GraphicalContainer(double x,
                          double y,
                          double width,
                          double height,
                          int unit)

GraphicalContainer

public GraphicalContainer(UDouble x,
                          UDouble y,
                          UDouble width,
                          UDouble height)

GraphicalContainer

public GraphicalContainer(ScaleInt xscale,
                          ScaleInt yscale)

GraphicalContainer

public GraphicalContainer(GraphicalContainer el)

GraphicalContainer

public GraphicalContainer(GraphicalContainer el,
                          boolean deep)
Method Detail

addGraphicalObject

public void addGraphicalObject(GraphicalComponentInt go)
Description copied from interface: GraphicalContainerInt
Simplest version of the addition of a graphical component to a container, using the default region and layer.
Specified by:
addGraphicalObject in interface GraphicalContainerInt

addGraphicalObject

public void addGraphicalObject(java.lang.Object go)

add

public boolean add(java.lang.Object go)
Description copied from interface: Tree
Add an entry to the list of children.
Specified by:
add in interface Tree

addGraphicalObject

public void addGraphicalObject(GraphicalComponentInt go,
                               int inRegion)
Description copied from interface: GraphicalContainerInt
Add the specified graphical component to this container with in the given region. This is an alternative method to adding the component to the region directly and usually amounts to regionAllocator().get(inRegion).addGraphicalObject(go)
Specified by:
addGraphicalObject in interface GraphicalContainerInt

addGraphicalObject

public void addGraphicalObject(GraphicalComponentInt go,
                               java.lang.String regionId)
Description copied from interface: GraphicalContainerInt
Add the specified graphical component to this container with in the given region identified by name. This is an alternative method to adding the component to the region directly and usually amounts to regionAllocator().get(inRegion).addGraphicalObject(go)
Specified by:
addGraphicalObject in interface GraphicalContainerInt

addGraphicalObject

public void addGraphicalObject(GraphicalComponentInt go,
                               java.lang.String regionId,
                               int layer)
Description copied from interface: GraphicalContainerInt
Add the graphical componen to the specified region within this container, drawing it in the given layer.
Specified by:
addGraphicalObject in interface GraphicalContainerInt

addGraphicalObject

public void addGraphicalObject(GraphicalComponentInt go,
                               int regionId,
                               int layer)
Description copied from interface: GraphicalContainerInt
Add the specified graphical component to this container in the region identified by region and draw it in the given layer.
Specified by:
addGraphicalObject in interface GraphicalContainerInt

addGraphicalObject

public void addGraphicalObject(GraphicalComponentInt go,
                               java.lang.Object regionId)
                        throws java.lang.Exception
Specified by:
addGraphicalObject in interface GraphicalContainerInt

addGraphicalObject

public void addGraphicalObject(GraphicalComponentInt go,
                               java.lang.Object regionId,
                               int layer)
                        throws java.lang.Exception
Specified by:
addGraphicalObject in interface GraphicalContainerInt

addGraphicalObject

public void addGraphicalObject(GraphicalComponentInt go,
                               boolean withAllocators)
Specified by:
addGraphicalObject in interface GraphicalContainerInt

addGraphicalObject

public void addGraphicalObject(GraphicalComponentInt go,
                               boolean withAllocators,
                               int layer)
Specified by:
addGraphicalObject in interface GraphicalContainerInt

parent

public SimpleGraphicalContainerInt parent()
Description copied from interface: GraphicalComponentInt
Retrieve the parent of this component, if it has one. If the component is in two or more containers, this returns the default parent.
Specified by:
parent in interface GraphicalComponentInt
Overrides:
parent in class GraphicalObject

parent

public SimpleGraphicalContainerInt parent(SimpleGraphicalContainerInt o)
Description copied from interface: SimpleGraphicalContainerInt
Set the parent of this container.
Specified by:
parent in interface GraphicalComponentInt
Overrides:
parent in class GraphicalObject

getXScale

public ScaleInt getXScale()
Description copied from interface: ScaledComponentInt
Retrieve the ScaleInt of the horizontal/X dimension.
Specified by:
getXScale in interface ScaledComponentInt

getYScale

public ScaleInt getYScale()
Description copied from interface: ScaledComponentInt
Retrieve the ScaleInt of the vertical/Y dimension.
Specified by:
getYScale in interface ScaledComponentInt

setXScale

public void setXScale(ScaleInt s)
Description copied from interface: ScaledComponentInt
Set the ScaleInt of the horizontal/X dimension.
Specified by:
setXScale in interface ScaledComponentInt

setYScale

public void setYScale(ScaleInt s)
Description copied from interface: ScaledComponentInt
Set the ScaleInt of the vertical/Y dimension.
Specified by:
setYScale in interface ScaledComponentInt

setOrigin

public void setOrigin(int o)
Accessor for setting the origin field.
Specified by:
setOrigin in interface GraphicalContainerInt

getOrigin

public int getOrigin()
Accessor for the origin field.
Specified by:
getOrigin in interface GraphicalContainerInt

setRegionAllocator

public void setRegionAllocator(RegionAllocator ra)
Description copied from interface: GraphicalContainerInt
Set the object that will control the creation of the different regions within the container to house sub-groups of components.
Specified by:
setRegionAllocator in interface GraphicalContainerInt

getRegionAllocator

public RegionAllocator getRegionAllocator()
Description copied from interface: GraphicalContainerInt
Get the current region allocator used by this container.
Specified by:
getRegionAllocator in interface GraphicalContainerInt

getChild

public GraphicalComponentInt getChild(int which)
Specified by:
getChild in interface GraphicalContainerInt

get

public java.lang.Object get(int which)
Description copied from interface: Tree
Get the ith child.
Specified by:
get in interface Tree

getChildCount

public int getChildCount()
Description copied from interface: Tree
Get the number of children currently contained in this node.
Specified by:
getChildCount in interface Tree

getChildren

public java.util.List getChildren()
Description copied from interface: Tree
Return the entire collection of children.
Specified by:
getChildren in interface Tree

removeGraphicalObject

public void removeGraphicalObject(GraphicalComponentInt go)
Specified by:
removeGraphicalObject in interface GraphicalContainerInt

removeGraphicalObject

public void removeGraphicalObject(GraphicalComponentInt go,
                                  int layer)
Specified by:
removeGraphicalObject in interface GraphicalContainerInt

remove

public java.lang.Object remove(int which)
Description copied from interface: Tree
Remove the ith child from the list of children.
Specified by:
remove in interface Tree

draw

public Region draw(RectRegion rr,
                   ScaleInt sx,
                   ScaleInt sy,
                   int parentOrigin,
                   double widthCM,
                   double heightCM,
                   int fontSize,
                   OutputDevice od,
                   GraphicalContainerInt parentId)
            throws DrawChildException
This iterates over its children, having them draw themselves relative to this container's dimensions and using the primitives in the OutputDevice.
Specified by:
draw in interface GraphicalComponentInt
Overrides:
draw in class GraphicalObject
Parameters:
rr - is the region given to this graphical component by this graphical component's parent in Normalized Device Coordinates (NDC)- e.g. pixels/dimension.
sx - native x coordinate scale for the parent
sy - native y coordinate scale for the parent
widthCM - absolue size of the parent's width in centimetres.
heigthCM - absolue size of the parent's height in centimetres.
fontsize - font size used by the parent in points
od - output device, eg window, page, providing primitives, graphics parameters, etc, and onto which elements are drawn.

drawChildren

public void drawChildren(RectRegion rr,
                         double widthCM,
                         double heightCM,
                         OutputDevice od)
                  throws DrawChildException

addValue

public java.lang.Object addValue(java.lang.Object rhs,
                                 boolean inPlace)
Specified by:
addValue in interface Addable

copy

public java.lang.Object copy(boolean deep)
Create a copy of this object, controlling whether its contents are shared with the copy or also copied.
Specified by:
copy in interface Copyable
Following copied from interface: org.omegahat.Environment.DataStructures.Copyable
Parameters:
deepCopy - controls whether the contents of the object are also recursively copied or shared by reference with the new object.

copy

public java.lang.Object copy()
Create a shallow copy of this object.
Specified by:
copy in interface Copyable

subset

public java.lang.Object subset(List indeces,
                               boolean keepStructure)
Method providing subsetting overloading for the GraphicalContainerInt

subset

public java.lang.Object subset(java.lang.Object index,
                               boolean keepStructure)
Specified by:
subset in interface Subsettable

getDevice

public OutputDevice getDevice()

transform

public Tree transform(NodeMap mapper)
Apply the methods of the specified map recursively to this container and its elements.
See Also:
transform(org.omegahat.Graphics.Primitives.GraphicalContainerInt, NodeMap)

transform

public Tree transform(GraphicalContainerInt c,
                      NodeMap mapper)
Apply the methods of the specified map recursively to the specified container and its elements.