Class graph.Graph2D
All Packages  Class Hierarchy  This Package  Previous  Next  Index
  Class graph.Graph2D
java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----graph.Graph2D
  -  public class Graph2D
  -  extends Canvas
This is the main plotting class. It partitions the canvas to contain the
specified axes with the remaining space taken with the plotting region.
Axes are packed against the walls of the canvas. The paint and
update methods of this class handle all the drawing operations of the
graph. This means that independent components like Axis and DataSets must be
registered with this class to be incorporated into the plot.
  -  Version:
  
-  1.12, 1996/09/24 05:23:41
  
-  Author:
  
-  Leigh Brookshaw
   
  -   axis axis
-   A vector list of All the axes attached
 
  
-   borderBottom borderBottom
-   The width of the border at the bottom of the canvas.
  
-   borderLeft borderLeft
-   The width of the border at the left of the canvas.
  
-   borderRight borderRight
-   The width of the border at the right of the canvas.
  
-   borderTop borderTop
-   The width of the border at the top of the canvas.
  
-   clearAll clearAll
-   If set true (the default) the canvas will be set to the background
 color (erasing the plot) when the update method is called.
  
-   DataBackground DataBackground
-  The background color for the data window
  
-   datarect datarect
-   The rectangle that the data will be plotted within.
  
-   dataset dataset
-   A vector list of All the DataSets attached
 
  
-   drawgrid drawgrid
-  If set true (the default) a grid will be drawn over the data window.
  
-   drawzero drawzero
-   If set true (the default) a grid line will be drawn 
 across the data window
 at the zeros of the innermost axes.
  
-   frame frame
-   If set true a frame will be drawn around the data window.
  
-   framecolor framecolor
-   The color of the frame to be drawn
  
-   gridcolor gridcolor
-  The color of the grid to be drawn
  
-   lastText lastText
-  Text to be painted Last onto the Graph Canvas.
  
-   load_thread load_thread
-  The blinking "data loading" thread
  
-   loadingData loadingData
-   If this is greater than zero it means that
 data loading threads are active so the message "loading data"
 is flashed on the plot canvas.
  
-   markers markers
-   The markers that may have been loaded
 
  
-   paintAll paintAll
-   If set true (the default) everything associated with the plot
 will be drawn when the update method or paint method are called.
  
-   square square
-   Modify the position of the axis and the range of the axis so that
 the aspect ratio of the major tick marks are 1 and the plot is square
 on the screen
  
-   zerocolor zerocolor
-   The color of the zero grid lines.
   
  -   Graph2D() Graph2D()
-  
   
  -   attachAxis(Axis) attachAxis(Axis)
-   Attach a previously created Axis.
  
-   attachDataSet(DataSet) attachDataSet(DataSet)
-    Attach a DataSet to the graph.
  
-   createAxis(int) createAxis(int)
-     Create and attach an Axis to the graph.
  
-   detachAxes() detachAxes()
-  Detach All attached Axes.
  
-   detachAxis(Axis) detachAxis(Axis)
-  Detach a previously attached Axis.
  
-   detachDataSet(DataSet) detachDataSet(DataSet)
-     Detach the DataSet from the class.
  
-   detachDataSets() detachDataSets()
-     Detach All the DataSets from the class.
  
-   drawAxis(Graphics, Rectangle) drawAxis(Graphics, Rectangle)
-  
 Draw the Axis.
  
-   drawFrame(Graphics, int, int, int, int) drawFrame(Graphics, int, int, int, int)
-  
  
-   finishedloading() finishedloading()
-  Decrement the loading Data counter by one.
  
-   ForceSquare(Graphics, Rectangle) ForceSquare(Graphics, Rectangle)
-   Force the plot to have an aspect ratio of 1 by forcing the
 axes to have the same range.
  
-   getDataRectangle(Graphics, Rectangle) getDataRectangle(Graphics, Rectangle)
-   Calculate the rectangle occupied by the data
  
-   getMarkers() getMarkers()
-   Get the markers
 
  
-   getXmax() getXmax()
-  Get the Maximum X value of all attached DataSets.
  
-   getXmin() getXmin()
-  Get the Minimum X value of all attached DataSets.
  
-   getYmax() getYmax()
-  Get the Maximum Y value of all attached DataSets.
  
-   getYmin() getYmin()
-  Get the Minimum Y value of all attached DataSets.
  
-   keyDown(Event, int) keyDown(Event, int)
-  Handle  keyDown events.
  
-   loadDataSet(double[], int) loadDataSet(double[], int)
-   Load and Attach a DataSet from an array.
  
-   loadFile(URL) loadFile(URL)
-   Load and Attach a DataSet from a File.
  
-   loadmessage(String) loadmessage(String)
-  Change the message to be flashed on the canvas
  
-   paint(Graphics) paint(Graphics)
-   This paints the entire plot.
  
-   paintBeforeData(Graphics, Rectangle) paintBeforeData(Graphics, Rectangle)
-   A hook into the Graph2D.paint method.
  
-   paintFirst(Graphics, Rectangle) paintFirst(Graphics, Rectangle)
-   A hook into the Graph2D.paint method.
  
-   paintLast(Graphics, Rectangle) paintLast(Graphics, Rectangle)
-   A hook into the Graph2D.paint method.
  
-   setDataBackground(Color) setDataBackground(Color)
-  Set the background color for the data window.
  
-   setGraphBackground(Color) setGraphBackground(Color)
-  Set the background color for the entire canvas.
  
-   setMarkers(Markers) setMarkers(Markers)
-   Set the markers for the plot.
  
-   startedloading() startedloading()
-   Calling this method pauses the plot and displays a flashing
 message on the screen.
  
-   update(Graphics) update(Graphics)
-  This method is called via the Graph2D.repaint() method.
   
 axis
axis
  protected Vector axis
  -  A vector list of All the axes attached
 @see Graph2d#attachAxis()
 dataset
dataset
  protected Vector dataset
  -  A vector list of All the DataSets attached
 @see Graph2d#attachDataSet()
 @see DataSet
 markers
markers
  protected Markers markers
  -  The markers that may have been loaded
 @see Graph2D#setMarkers()
 load_thread
load_thread
  protected LoadMessage load_thread
  -  The blinking "data loading" thread
   
    -  See Also:
    
-  startedloading
  
 
 DataBackground
DataBackground
  protected Color DataBackground
  -  The background color for the data window
 loadingData
loadingData
  public int loadingData
  -  If this is greater than zero it means that
 data loading threads are active so the message "loading data"
 is flashed on the plot canvas. When it is back to zero the plot
 progresses normally
 borderTop
borderTop
  public int borderTop
  -  The width of the border at the top of the canvas. This allows 
 slopover from axis labels, legends etc.
 borderBottom
borderBottom
  public int borderBottom
  -  The width of the border at the bottom of the canvas. This allows 
 slopover from axis labels, legends etc.
 borderLeft
borderLeft
  public int borderLeft
  -  The width of the border at the left of the canvas. This allows 
 slopover from axis labels, legends etc.
 borderRight
borderRight
  public int borderRight
  -  The width of the border at the right of the canvas. This allows 
 slopover from axis labels, legends etc.
 frame
frame
  public boolean frame
  -  If set true a frame will be drawn around the data window.
 Any axes will overlay this frame.
 framecolor
framecolor
  public Color framecolor
  -  The color of the frame to be drawn
 drawgrid
drawgrid
  public boolean drawgrid
  -  If set true (the default) a grid will be drawn over the data window.
The grid will align with the major tic marks of the Innermost axes.
 gridcolor
gridcolor
  public Color gridcolor
  -  The color of the grid to be drawn
 drawzero
drawzero
  public boolean drawzero
  -  If set true (the default) a grid line will be drawn 
 across the data window
 at the zeros of the innermost axes.
 zerocolor
zerocolor
  public Color zerocolor
  -  The color of the zero grid lines.
 datarect
datarect
  public Rectangle datarect
  -  The rectangle that the data will be plotted within. This is an output
 variable only.
 clearAll
clearAll
  public boolean clearAll
  -  If set true (the default) the canvas will be set to the background
 color (erasing the plot) when the update method is called.
 This would only be changed for special effects.
 paintAll
paintAll
  public boolean paintAll
  -  If set true (the default) everything associated with the plot
 will be drawn when the update method or paint method are called.
 Normally
 only modified for special effects
 square
square
  public boolean square
  -  Modify the position of the axis and the range of the axis so that
 the aspect ratio of the major tick marks are 1 and the plot is square
 on the screen
 lastText
lastText
  public TextLine lastText
  -  Text to be painted Last onto the Graph Canvas.
   
 Graph2D
Graph2D
  public Graph2D()
   
 loadFile
loadFile
  public DataSet loadFile(URL file)
  -  Load and Attach a DataSet from a File. 
 The method loads the data into a DataSet class
 and attaches the class to the graph for plotting.
 The data is assumed to consist
 (at this stage) 2 ASCII columns of numbers x, y. As always blank lines
 are ignored and everything following # is ignored as a comment.
 @param file    The URL of the data file to read.
 @return        The DataSet constructed containing the data read.
 loadDataSet
loadDataSet
  public DataSet loadDataSet(double data[],
                             int n)
  -  Load and Attach a DataSet from an array. 
 The method loads the data into a DataSet class
 and attaches the class to the graph for plotting.
 The data is assumed to be stored
 in the form  x,y,x,y,x,y.... A local copy of the data is made.
 @param  data   The data to be loaded in the form x,y,x,y,...
 @param  n      The number of (x,y) data points. This means that the
                minimum length of the data array is 2*n.
 @return        The DataSet constructed containing the data read.
 attachDataSet
attachDataSet
  public void attachDataSet(DataSet d)
  -  Attach a DataSet to the graph. By attaching the data set the class
  can draw the data through its paint method.
 detachDataSet
detachDataSet
  public void detachDataSet(DataSet d)
  -  Detach the DataSet from the class. Data associated with the DataSet
   will nolonger be plotted.
   @param d    The DataSet to detach.
 detachDataSets
detachDataSets
  public void detachDataSets()
  -  Detach All the DataSets from the class.
 createAxis
createAxis
  public Axis createAxis(int position)
  -  Create and attach an Axis to the graph. The position of the axis
   is one of Axis.TOP, Axis.BOTTOM, Axis.LEFT or Axis.RIGHT.
   @param position   Position of the axis in the drawing window.
 attachAxis
attachAxis
  public void attachAxis(Axis a)
  -  Attach a previously created Axis. Only Axes that have been attached will
 be drawn 
   @param the Axis to attach.
 detachAxis
detachAxis
  public void detachAxis(Axis a)
  -  Detach a previously attached Axis.
   @param the Axis to dettach.
 detachAxes
detachAxes
  public void detachAxes()
  -  Detach All attached Axes.
 getXmax
getXmax
  public double getXmax()
  -  Get the Maximum X value of all attached DataSets.
 @return  The maximum value
 getYmax
getYmax
  public double getYmax()
  -  Get the Maximum Y value of all attached DataSets.
 @return  The maximum value
 getXmin
getXmin
  public double getXmin()
  -  Get the Minimum X value of all attached DataSets.
 @return  The minimum value
 getYmin
getYmin
  public double getYmin()
  -  Get the Minimum Y value of all attached DataSets.
 @return  The minimum value
 setMarkers
setMarkers
  public void setMarkers(Markers m)
  -  Set the markers for the plot.
 @param m  Marker class containing the defined markers
 @see Markers
 getMarkers
getMarkers
  public Markers getMarkers()
  -  Get the markers
 @return defined Marker class
 @see Markers
 setGraphBackground
setGraphBackground
  public void setGraphBackground(Color c)
  -  Set the background color for the entire canvas.
  
    -  Parameters:
    
-  s - c The color to set the canvas
  
 
 setDataBackground
setDataBackground
  public void setDataBackground(Color c)
  -  Set the background color for the data window.
  
    -  Parameters:
    
-  s - c The color to set the data window.
  
 
 paint
paint
  public void paint(Graphics g)
  -  This paints the entire plot. It calls the draw methods of all the
 attached axis and data sets.
 The order of drawing is - Axis first, data legends next, data last.
 @params g Graphics state.
  
    -  Overrides:
    
-  paint in class Canvas
  
 
 paintFirst
paintFirst
  public void paintFirst(Graphics g,
                         Rectangle r)
  -  A hook into the Graph2D.paint method. This is called before
 anything is plotted. The rectangle passed is the dimension of
 the canvas minus the border dimensions.
 @params g Graphics state
 @params r Rectangle containing the graph
 paintBeforeData
paintBeforeData
  public void paintBeforeData(Graphics g,
                              Rectangle r)
  -  A hook into the Graph2D.paint method. This is called before
 the data is drawn but after the axis. 
 The rectangle passed is the dimension of
 the data window.
 @params g Graphics state
 @params r Rectangle containing the data
 paintLast
paintLast
  public void paintLast(Graphics g,
                        Rectangle r)
  -  A hook into the Graph2D.paint method. This is called after
 everything has been drawn. 
 The rectangle passed is the dimension of
 the data window.
 @params g Graphics state
 @params r Rectangle containing the data
 update
update
  public void update(Graphics g)
  -  This method is called via the Graph2D.repaint() method.
All it does is blank the canvas (with the background color)
before calling paint.
  
    -  Overrides:
    
-  update in class Component
  
 
 keyDown
keyDown
  public boolean keyDown(Event e,
                         int key)
  -  Handle  keyDown events. Only one event is handled the pressing
of the key 'r' - this will repaint the canvas.
  
    -  Overrides:
    
-  keyDown in class Component
  
 
 startedloading
startedloading
  public void startedloading()
  -  Calling this method pauses the plot and displays a flashing
 message on the screen. Mainly used when data is being loaded across the
 net. Everytime this routine is called a counter is incremented
 the method Graph2D.finishedloading() decrements the counter. When the
 counter is back to zero the plotting resumes.
 @see Graph2D#finishedloading()
 @see Graph2D#loadmessage()
 @see LoadMessage
 finishedloading
finishedloading
  public void finishedloading()
  -  Decrement the loading Data counter by one. When it is zero resume
plotting.
 @see Graph2D#startedloading()
 @see Graph2D#loadmessage()
 @see LoadMessage
 loadmessage
loadmessage
  public void loadmessage(String s)
  -  Change the message to be flashed on the canvas
  
    -  Parameters:
    
-  s - String contining the new message.
    
-  See Also:
    
-  startedloading, finishedloading, LoadMessage
  
 
 ForceSquare
ForceSquare
  protected Rectangle ForceSquare(Graphics g,
                                  Rectangle r)
  -  Force the plot to have an aspect ratio of 1 by forcing the
 axes to have the same range. If the range of the axes
 are very different some extremely odd things can occur. All axes are
 forced to have the same range, so more than 2 axis is pointless.
 getDataRectangle
getDataRectangle
  protected Rectangle getDataRectangle(Graphics g,
                                       Rectangle r)
  -  Calculate the rectangle occupied by the data
 drawAxis
drawAxis
  protected Rectangle drawAxis(Graphics g,
                               Rectangle r)
  -  Draw the Axis. As each axis is drawn and aligned less of the canvas
 is avaliable to plot the data. The returned Rectangle is the canvas
 area that the data is plotted in.
 drawFrame
drawFrame
  protected void drawFrame(Graphics g,
                           int x,
                           int y,
                           int width,
                           int height)
All Packages  Class Hierarchy  This Package  Previous  Next  Index