org.rosuda.ibase.toolkit
Class PlotObject

java.lang.Object
  extended by org.rosuda.ibase.toolkit.PlotObject
Direct Known Subclasses:
PlotImage, PlotLine, PlotPolygon, PlotText

public class PlotObject
extends java.lang.Object

Plot objects are basic building blocks to add graphical objects to iPlots. This class provides an basis on which all other plot objects must be based.

Some important notes for developers designing plot objects:


Field Summary
static int CS_ABS
          coordinates system: absolute display coordinates (i.e. no transformation)
static int CS_REL
          coordinates system: relative. 0 corresponds to the left/top edge of the data space and 1 corresponds to the right/bottom edge.
static int CS_VAR
          coordinates system: variable space (i.e.
 
Constructor Summary
PlotObject(PlotManager p)
           
 
Method Summary
 void dispose()
           
 void draw(PoGraSS g)
          all subclasses should override this method.
 PlotColor gerDrawColor()
          get drawing color
 PlotColor gerFillColor()
          get fill color
 int getLayer()
           
 int getXPos(double v)
          maps plot object X coordinate to a graphical coordinate which can be used in the draw(org.rosuda.pograss.PoGraSS) method.
 int getYPos(double v)
          maps plot object Y coordinate to a graphical coordinate which can be used in the draw(org.rosuda.pograss.PoGraSS) method.
 boolean isVisible()
          visibility
 void setClip(boolean cl)
          set clipping flag. if set to true then the object shouldn't plot outside the data area.
 void setCoordinates(int ct)
          set a common coordinate system for both axes (see CS_xxx constants for details)
 void setCoordinates(int cx, int cy)
          set one coordinate system for each axis separately
 void setDrawColor(PlotColor c)
          set draw color of the object.
 void setFillColor(PlotColor c)
          set fill color of the object.
 void setLayer(int l)
          move the object to another layer
 void setVisible(boolean vis)
          set visibility. if set to false the object won't be painted
 java.lang.String toString()
          toString is rather useful for debugging purposes
 void update()
          causes the entire plot object system to be updated (redraws only the layer of this object and above). by default is simply calls the PlotManager.update() method with the layer of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CS_ABS

public static final int CS_ABS
coordinates system: absolute display coordinates (i.e. no transformation)

See Also:
Constant Field Values

CS_VAR

public static final int CS_VAR
coordinates system: variable space (i.e. Axis objects are used for direct transformation)

See Also:
Constant Field Values

CS_REL

public static final int CS_REL
coordinates system: relative. 0 corresponds to the left/top edge of the data space and 1 corresponds to the right/bottom edge.

See Also:
Constant Field Values
Constructor Detail

PlotObject

public PlotObject(PlotManager p)
Method Detail

dispose

public void dispose()

draw

public void draw(PoGraSS g)
all subclasses should override this method.
Some points to keep in mind when implementing new objects:

Parameters:
g - graphics context for painting

setDrawColor

public void setDrawColor(PlotColor c)
set draw color of the object. The interpretation of the color is object-dependent, but simple objects should adhere to the reasoning that this color is used for drawing lines.

Parameters:
c - color to use

setFillColor

public void setFillColor(PlotColor c)
set fill color of the object. The interpretation of the color is object-dependent, but simnple objects should adhere to the reasoning that this color is used for area filling.

Parameters:
c - color to use

isVisible

public boolean isVisible()
visibility


setVisible

public void setVisible(boolean vis)
set visibility. if set to false the object won't be painted


setCoordinates

public void setCoordinates(int ct)
set a common coordinate system for both axes (see CS_xxx constants for details)

Parameters:
ct - coordinate system specification - one of the CS_xxx constants

setCoordinates

public void setCoordinates(int cx,
                           int cy)
set one coordinate system for each axis separately

Parameters:
cx - coordinate system specification for the X axis - must be one of the CS_xxx constants
cy - coordinate system specification for the Y axis - must be one of the CS_xxx constants

getXPos

public int getXPos(double v)
maps plot object X coordinate to a graphical coordinate which can be used in the draw(org.rosuda.pograss.PoGraSS) method.

Parameters:
v - value to convert
Returns:
corresponding value of the graphical X coordinate

getYPos

public int getYPos(double v)
maps plot object Y coordinate to a graphical coordinate which can be used in the draw(org.rosuda.pograss.PoGraSS) method.

Parameters:
v - value to convert
Returns:
corresponding value of the graphical X coordinate

setClip

public void setClip(boolean cl)
set clipping flag. if set to true then the object shouldn't plot outside the data area.

Parameters:
cl - clipping flag

gerDrawColor

public PlotColor gerDrawColor()
get drawing color

Returns:
drawing color of the object

gerFillColor

public PlotColor gerFillColor()
get fill color

Returns:
fill color of the object

setLayer

public void setLayer(int l)
move the object to another layer


getLayer

public int getLayer()

update

public void update()
causes the entire plot object system to be updated (redraws only the layer of this object and above). by default is simply calls the PlotManager.update() method with the layer of the object.


toString

public java.lang.String toString()
toString is rather useful for debugging purposes

Overrides:
toString in class java.lang.Object