view
Class PlotData

java.lang.Object
  extended by view.PlotData
All Implemented Interfaces:
Cloneable

public class PlotData
extends Object
implements Cloneable

Abstract class contains data for plot programs. Nr is an unique integer used for internal identification, the double array cor[] contains the raw coordinate data, while Xcor and Ycor are the on screen coordinates. Coordinate errors go into err[], length of error-bar in x (y) direction is Xerr, Yerr. The class is constructed with the cor[] (and err[]). Abstract static method calcCoordinates knows how to convert cor[] into xcor, ycor; it expects the drawable canvas size (Dimension object) as an argument. The approbiate method calcErrorBars can convert err[] into error bar sizes. Null values in Pixel or Error codes a necesarry update. Zeros in errorbars mean no errorbar present The boolean isActive, isChosen, onScreen default to t f f and code wether a point is active, is highlighted, and is visible on the Canvas. If the Vector lineWith is given, a desired straight line connection with the plotData objects identified with its elements is indicated. A point is added to the Vector via a call to the connectWith(plotData) method. Method filter sets this Object inactive, if its coordinates are outside a given range. Method getDistance(Point) returns the (rectangular) pixel distance between this object and the given point.


Field Summary
 double[] cor
           
static Color DEFAULT
           
static Color DEFLINE
           
static int DEFSIZE
           
 double[] err
           
 Dimension ErrorBar
           
protected  Color Highlight
           
 boolean isActive
           
 boolean isChosen
           
protected  Color LineColor
           
protected  boolean lineVisible
           
protected  Vector lineWith
           
protected  int Number
           
 boolean onScreen
           
 Point Pixel
           
protected  ScreenPixel screen
           
protected  Color Simple
           
 int Size
           
 
Constructor Summary
protected PlotData()
           
protected PlotData(int num)
           
  PlotData(int num, double[] x)
           
  PlotData(int num, double[] x, double[] error)
           
 
Method Summary
 Object clone()
           
 void connectWith(PlotData neighbour)
          Adds a point to the lineWith vector.
 void decrease()
          A method defined by the Zoomable interface.
 void draw(Graphics dis)
          Basic method for drawing the pixel to the screen.
 PlotData duplicate()
           
 boolean equals(Object test)
          Two plotDatas are equal if their Number is equal.
 boolean filter(double[] cormin, double[] validrange)
          Decides wether this plotData is within the bounds defined by the two arguments in the following way: If validrange[i] is < 0, no bounds are applied to coordinate i, otherwise this can only be active, if it i'th coordinate >= cormin[i] && <= cormin[i]+validrange[i].
static PlotData getClosest(Vector alldata, Point click)
          Returns the plotData object located closest to the click point.
 ScreenPixel getConverter()
           
 double getDistance(Point click)
          Returns the distance in pixel between this object and the querried point.
 Color getHighlightColor()
           
 boolean getLine()
          A method defined by the Lineable interface.
 Color getLineColor()
           
 int getNumber()
          Returns the unique number of the plotdata.
 Color getSimpleColor()
           
 void increase()
          A method defined by the Zoomable interface.
static boolean isInside(Point pix, Dimension canvas)
          Returns true, if the point pix is within the box canvas.
 void line(Graphics dis)
          Method that connnects this point with the ones stored in lineWith.
 void print(Graphics dis)
          Overrride this, if your printout should differ from the on-screen image.
 void setActive()
           
 void setChosen()
           
 void setColor(Color simple, Color highlight)
           
 void setConverter(ScreenPixel calc)
           
 void setCoordinate(double[] coord)
           
 void setError(double[] error)
           
 void setInactive()
           
 void setLine(boolean line)
          A method defined by the Lineable interface.
 void setLineColor(Color linecol)
           
 void symbol(Graphics dis)
          Draws the specific symbol on position Pixel.
 boolean toggle()
           
 boolean toggleChosen()
           
 void toggleLine()
          A method defined by the Lineable interface.
 String toMessage()
          Returns a message representation of this plotData.
 String toString()
          The base class returns only the screen coordinates.
 void unsetChosen()
           
 void updateCoordinates(Dimension canvassize)
          Calls the methods of screen to convert cor, err into pixel values.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final Color DEFAULT

DEFLINE

public static final Color DEFLINE

DEFSIZE

public static final int DEFSIZE
See Also:
Constant Field Values

Number

protected int Number

cor

public double[] cor

err

public double[] err

Pixel

public Point Pixel

ErrorBar

public Dimension ErrorBar

Size

public int Size

isActive

public boolean isActive

isChosen

public boolean isChosen

onScreen

public boolean onScreen

lineVisible

protected boolean lineVisible

lineWith

protected Vector lineWith

LineColor

protected Color LineColor

Simple

protected Color Simple

Highlight

protected Color Highlight

screen

protected ScreenPixel screen
Constructor Detail

PlotData

protected PlotData()

PlotData

protected PlotData(int num)

PlotData

public PlotData(int num,
                double[] x)

PlotData

public PlotData(int num,
                double[] x,
                double[] error)
Method Detail

duplicate

public PlotData duplicate()

clone

public Object clone()
Overrides:
clone in class Object

getConverter

public ScreenPixel getConverter()

setConverter

public void setConverter(ScreenPixel calc)

setError

public void setError(double[] error)

setCoordinate

public void setCoordinate(double[] coord)

toggle

public boolean toggle()

setActive

public void setActive()

setInactive

public void setInactive()

toggleChosen

public boolean toggleChosen()

setChosen

public void setChosen()

unsetChosen

public void unsetChosen()

setColor

public void setColor(Color simple,
                     Color highlight)

setLineColor

public void setLineColor(Color linecol)

getSimpleColor

public Color getSimpleColor()

getHighlightColor

public Color getHighlightColor()

getLineColor

public Color getLineColor()

getNumber

public int getNumber()
Returns the unique number of the plotdata.


isInside

public static boolean isInside(Point pix,
                               Dimension canvas)
Returns true, if the point pix is within the box canvas.


filter

public boolean filter(double[] cormin,
                      double[] validrange)
Decides wether this plotData is within the bounds defined by the two arguments in the following way: If validrange[i] is < 0, no bounds are applied to coordinate i, otherwise this can only be active, if it i'th coordinate >= cormin[i] && <= cormin[i]+validrange[i].


getDistance

public double getDistance(Point click)
Returns the distance in pixel between this object and the querried point. The name should indicate a frequent use of this method: Derive the distance to a mouse click.


updateCoordinates

public void updateCoordinates(Dimension canvassize)
Calls the methods of screen to convert cor, err into pixel values.


draw

public void draw(Graphics dis)
Basic method for drawing the pixel to the screen. subclasses should override this method.


print

public void print(Graphics dis)
Overrride this, if your printout should differ from the on-screen image. Defaulting to draw.


symbol

public void symbol(Graphics dis)
Draws the specific symbol on position Pixel.


line

public void line(Graphics dis)
Method that connnects this point with the ones stored in lineWith. A line is drawn only if the plotData in the Vector isActive, onScreen Pixel != null and its Number < this.Number.


connectWith

public void connectWith(PlotData neighbour)
Adds a point to the lineWith vector.


getClosest

public static PlotData getClosest(Vector alldata,
                                  Point click)
Returns the plotData object located closest to the click point. click is normally a mouse click position, so care must be taken by the calling routine to properly translate the origin.


equals

public boolean equals(Object test)
Two plotDatas are equal if their Number is equal.

Overrides:
equals in class Object

toString

public String toString()
The base class returns only the screen coordinates.

Overrides:
toString in class Object

toMessage

public String toMessage()
Returns a message representation of this plotData. Defaults to getString in the base class.

Returns:
A message representation of this object as a String.

increase

public void increase()
A method defined by the Zoomable interface. Subclasses that want to implement this interface can simply implement it without supplying a body to it if this implementation suits their need.


decrease

public void decrease()
A method defined by the Zoomable interface. Subclasses that want to implement this interface can simply implement it without supplying a body to it if this implementation suits their need.


setLine

public void setLine(boolean line)
A method defined by the Lineable interface. Subclasses that want to implement this interface can simply implement it without supplying a body to it if this implementation suits their need.


getLine

public boolean getLine()
A method defined by the Lineable interface. Subclasses that want to implement this interface can simply implement it without supplying a body to it if this implementation suits their need.

Returns:
True, if the line is visible.

toggleLine

public void toggleLine()
A method defined by the Lineable interface. Subclasses that want to implement this interface can simply implement it without supplying a body to it if this implementation suits their need.