org.omegahat.Graphics.Primitives
Class GraphicalObject

java.lang.Object
  |
  +--org.omegahat.Graphics.Primitives.GraphicalObject
All Implemented Interfaces:
GraphicalComponentInt
Direct Known Subclasses:
RGO

public abstract class GraphicalObject
extends java.lang.Object
implements GraphicalComponentInt

The class from which all graphical objects must inherit. It carries the concepts of associated graphics parameters and a region within the parent object.

The abstract draw method must be implemented by any actual graphical object.


Field Summary
static int ACTIVE
          Constant used in setting and querying the status flag to indicate whether the component is active or not, and can have events generated for it.
protected  int fontSize
           
protected  OutputDevice lastDevice
          The device instance cached from the previous draw() call.
protected  double lastHeightCM
          Actual height of this component in centimeters cached from last regular draw.
protected  RectRegion lastRegion
          Cached version of the RectRegion in NDC - Normalized Device Coordinates - from the last regular draw, used when drawing an individual child.
protected  double lastWidthCM
          Actual width of this component in centimeters cached from last regular draw.
protected  java.util.Vector parents
           
protected  int status
          Value used to indicate whether the component is active, visible, etc.
static int VISIBLE
          Constant used in setting and querying the status flag to indicate whether the component is visible or not, and so whether it is to be drawn.
 
Constructor Summary
GraphicalObject()
           
 
Method Summary
protected  RectRegion cacheSize(RectRegion rr, ScaleInt sx, ScaleInt sy, int parentOrigin, double widthCM, double heightCM, int fontSizeRect, OutputDevice od, GraphicalContainerInt parentId)
          Compute the current NDC region this object occupies and its absolute dimensions in centimeters and store these in the cached fields.
abstract  Region draw(RectRegion rr, ScaleInt sx, ScaleInt sy, int origin, double widthCM, double heightCM, int fontSize, OutputDevice od, GraphicalContainerInt parentId)
          draw the object in the rectangular region rr, using scales sx and sy.
 int getFontSize()
           
 int getFontSize(int s)
           
 GraphicsParameters getParameters()
          the graphics parameters object associated with this object.
 java.util.Vector getParents()
          Accessor for parents field
 int getStatus()
           
 boolean isActive()
          Determines whether the object can have events generated "about" it.
 boolean isVisible()
          Determines whether the object is drawn as part of the hierarchy.
 double lastHeightCM()
           
 RectRegion lastRegion()
           
 double lastWidthCM()
           
 SimpleGraphicalContainerInt parent()
          Retrieve the (default) parent of this component.
 SimpleGraphicalContainerInt parent(SimpleGraphicalContainerInt p)
          Register the parent container as one of the parents of this object.
 java.util.List parents()
          Return a list of all the containers of which this component is a member/entry.
 boolean setActive(boolean val)
          Sets whether the object can have events generated "about" it.
 void setParameters(GraphicsParameters p)
           
 java.util.Vector setParents(java.util.Vector value)
          Accessor for setting parents field
 boolean setVisible(boolean val)
          Sets whether the object is drawn as part of the hierarchy.
 
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
getRegion, setRegion
 

Field Detail

VISIBLE

public static final int VISIBLE
Constant used in setting and querying the status flag to indicate whether the component is visible or not, and so whether it is to be drawn.

ACTIVE

public static final int ACTIVE
Constant used in setting and querying the status flag to indicate whether the component is active or not, and can have events generated for it.

fontSize

protected int fontSize

parents

protected java.util.Vector parents

status

protected int status
Value used to indicate whether the component is active, visible, etc. This is and'ed and or'ed with the constants ACTIVE, VISIBLE

lastRegion

protected RectRegion lastRegion
Cached version of the RectRegion in NDC - Normalized Device Coordinates - from the last regular draw, used when drawing an individual child.

lastWidthCM

protected double lastWidthCM
Actual width of this component in centimeters cached from last regular draw.
See Also:
GraphicalComponentInt.html

lastHeightCM

protected double lastHeightCM
Actual height of this component in centimeters cached from last regular draw.
See Also:
GraphicalComponentInt.html

lastDevice

protected OutputDevice lastDevice
The device instance cached from the previous draw() call. The information in the other cached fields needs to be stored per device.
Constructor Detail

GraphicalObject

public GraphicalObject()
Method Detail

draw

public abstract Region draw(RectRegion rr,
                            ScaleInt sx,
                            ScaleInt sy,
                            int origin,
                            double widthCM,
                            double heightCM,
                            int fontSize,
                            OutputDevice od,
                            GraphicalContainerInt parentId)
draw the object in the rectangular region rr, using scales sx and sy.
Specified by:
draw in interface GraphicalComponentInt
Following copied from interface: org.omegahat.Graphics.Primitives.GraphicalComponentInt
Parameters:
rr - the parents RectRegion in normalized device coordinates (NDC).
sx - the parent's horizontal scale for transforming between arbitrary units.
sy - the parent's vertical scale for transforming between arbitrary units.
origin - the parent's origin position.

getParameters

public GraphicsParameters getParameters()
the graphics parameters object associated with this object.
Specified by:
getParameters in interface GraphicalComponentInt

setParameters

public void setParameters(GraphicsParameters p)
Specified by:
setParameters in interface GraphicalComponentInt

parent

public SimpleGraphicalContainerInt parent()
Retrieve the (default) parent of this component.
Specified by:
parent in interface GraphicalComponentInt

parent

public SimpleGraphicalContainerInt parent(SimpleGraphicalContainerInt p)
Register the parent container as one of the parents of this object.
Specified by:
parent in interface GraphicalComponentInt

parents

public java.util.List parents()
Return a list of all the containers of which this component is a member/entry.
Specified by:
parents in interface GraphicalComponentInt

getParents

public java.util.Vector getParents()
Accessor for parents field

setParents

public java.util.Vector setParents(java.util.Vector value)
Accessor for setting parents field

getFontSize

public int getFontSize()

getFontSize

public int getFontSize(int s)

lastRegion

public RectRegion lastRegion()

lastWidthCM

public double lastWidthCM()

lastHeightCM

public double lastHeightCM()

isActive

public boolean isActive()
Determines whether the object can have events generated "about" it.
Specified by:
isActive in interface GraphicalComponentInt

setActive

public boolean setActive(boolean val)
Sets whether the object can have events generated "about" it.
Specified by:
setActive in interface GraphicalComponentInt

isVisible

public boolean isVisible()
Determines whether the object is drawn as part of the hierarchy.
Specified by:
isVisible in interface GraphicalComponentInt

setVisible

public boolean setVisible(boolean val)
Sets whether the object is drawn as part of the hierarchy.
Specified by:
setVisible in interface GraphicalComponentInt

getStatus

public int getStatus()

cacheSize

protected RectRegion cacheSize(RectRegion rr,
                               ScaleInt sx,
                               ScaleInt sy,
                               int parentOrigin,
                               double widthCM,
                               double heightCM,
                               int fontSizeRect,
                               OutputDevice od,
                               GraphicalContainerInt parentId)
Compute the current NDC region this object occupies and its absolute dimensions in centimeters and store these in the cached fields. The arguments are the same as draw.