Class Plotter2

java.lang.Object
  |
  +--Plotter
        |
        +--Plotter2

class Plotter2
extends Plotter

A plotter augmented with extra methods to facilitate common tasks. This plotter can remember a viewport (a rectangle on the screen), and automatically supply the position and dimensions, simplifying coordinate transformations.


Field Summary
protected  java.awt.Color graphCol
          The colour to use when plotting the actual graph
protected  int h
           
protected  int hSpace
           
protected  int vSpace
           
protected  int w
           
protected  int x
           
protected  int y
           
 
Fields inherited from class Plotter
ABS_MAX, ABS_MIN, axes, bottomMargin, eqn, fold, foldSize, foldSym, infY, interpolate, log, majorTickSize, maxX, maxY, minorTickSize, minX, minY, noUnitsX, noUnitsY, rangeX, rangeY, soln, tickRatio, topMargin, viewLeft, viewRange, viewRight, xLabel, xScale, yLabel, yScale
 
Constructor Summary
Plotter2(Solvable eqn)
          Creates a new plotter, with an empty (0,0,0,0) viewport
Plotter2(Solvable eqn, int x, int y, int w, int h)
          Creates a new plotter
 
Method Summary
 double fromScreenX(int i)
          Converts an x value from screen space to graph space
 double fromScreenY(int i)
          Converts a y value from screen space to graph space
 java.awt.Color getGraphColor()
          Returns the colour used when plotting the actual graph
 void paint(java.awt.Graphics g)
          Paints this graph, with axes and scales (if appropriate) inside the viewport.
 void setGraphColor(java.awt.Color c)
          Sets the colour to use when plotting the actual graph
 void setMaxX(double d)
          Adjusts the maximum x value
 void setMaxY(double d)
          Adjusts the maximum y value
 void setMinX(double d)
          Adjusts the minimum x value
 void setMinY(double d)
          Adjusts the minimum y value
 void setRect(int x, int y, int w, int h)
          Sets the viewport for this plotter.
 int toScreenX(double d)
          Converts an x value from graph space to screen space
 int toScreenY(double d)
          Converts a y value from graph space to screen space
 void updateSolution(java.awt.Graphics g)
          Fills the cache with solution data.
 
Methods inherited from class Plotter
chooseTickSize, copyScale, fold, fromScreenX, fromScreenY, getMax, getMin, getSpaceX, getSpaceY, isInterpolated, isLogarithmic, labelAxisX, labelAxisY, paint, paintAxes, paintGraph, paintGraphFolded, paintLabelBelow, paintLabelToLeft, paintVerticalMarkers, scaleToFit, scaleToFit, setAxes, setFold, setFold, setFold, setInterpolated, setLabels, setLogarithmic, setRangeX, setRangeY, setScalesEnabled, setView, setViewAndRange, snap, squareValues, toScreenX, toScreenY, toString, updateSolution
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

graphCol

protected java.awt.Color graphCol
The colour to use when plotting the actual graph

x

protected int x

y

protected int y

w

protected int w

h

protected int h

hSpace

protected int hSpace

vSpace

protected int vSpace
Constructor Detail

Plotter2

public Plotter2(Solvable eqn,
                int x,
                int y,
                int w,
                int h)
Creates a new plotter
Parameters:
eqn - The Solvable object to obtain solution data from
x - The x coordinate of the viewport
y - The y coordinate of the viewport
w - The width of the viewport
h - The height of the viewport

Plotter2

public Plotter2(Solvable eqn)
Creates a new plotter, with an empty (0,0,0,0) viewport
Parameters:
eqn - The Solvable object to obtain solution data from
Method Detail

paint

public void paint(java.awt.Graphics g)
Paints this graph, with axes and scales (if appropriate) inside the viewport.
Parameters:
g - The Graphics surface on which to paint

updateSolution

public void updateSolution(java.awt.Graphics g)
Fills the cache with solution data. The number of samples taken is equal to the width of the viewport, minus the width overhead for the vertical axis.

setRect

public void setRect(int x,
                    int y,
                    int w,
                    int h)
Sets the viewport for this plotter.
Parameters:
x - The x coordinate of the viewport
y - The y coordinate of the viewport
w - The width of the viewport
h - The height of the viewport

setMinY

public void setMinY(double d)
Adjusts the minimum y value

setMaxY

public void setMaxY(double d)
Adjusts the maximum y value

setMinX

public void setMinX(double d)
Adjusts the minimum x value

setMaxX

public void setMaxX(double d)
Adjusts the maximum x value

toScreenX

public int toScreenX(double d)
Converts an x value from graph space to screen space

toScreenY

public int toScreenY(double d)
Converts a y value from graph space to screen space

fromScreenX

public double fromScreenX(int i)
Converts an x value from screen space to graph space

fromScreenY

public double fromScreenY(int i)
Converts a y value from screen space to graph space

getGraphColor

public java.awt.Color getGraphColor()
Returns the colour used when plotting the actual graph

setGraphColor

public void setGraphColor(java.awt.Color c)
Sets the colour to use when plotting the actual graph