jimm.datavision
Class Line

java.lang.Object
  extended by java.util.Observable
      extended by jimm.datavision.Element
          extended by jimm.datavision.Line
All Implemented Interfaces:
java.util.Observer, Writeable

public class Line
extends Element

A line is a visual report element. Lines are used in field Borders and independently.

Note that currently, line thickness is ignored in the Java GUI (but not in layout engines such as the LaTeXLE).

Author:
Jim Menard, jimm@io.com

Field Summary
protected  java.awt.Color color
           
protected static java.awt.Color DEFAULT_COLOR
           
protected  Point[] points
           
protected  double thickness
           
 
Fields inherited from class jimm.datavision.Element
report, section, visible
 
Constructor Summary
Line(Report report, Section section, double thickness, java.awt.Color color, boolean visible)
          Constructor.
Line(Report report, Section section, double thickness, java.awt.Color color, boolean visible, Point p0, Point p1)
          Constructor.
 
Method Summary
 void addEndPoint(double x, double y)
          Adds an end point to the line.
 java.awt.Color getColor()
          Returns the line's color.
 Point getPoint(int index)
          Returns one of the two end points of the line.
 double getThickness()
          Returns the line thickness.
 double length()
          Returns the length of the line.
 void setColor(java.awt.Color c)
          Sets the line's color.
 void setPoint(Point newPoint, int index)
          Sets one of the two end points.
 void setThickness(double newThickness)
          Sets the line thickness.
 java.lang.String toString()
          Returns a string representation of this line.
 void writeXML(XMLWriter out)
          Writes this line as an XML tag.
 
Methods inherited from class jimm.datavision.Element
getReport, getSection, isVisible, setSection, setVisible, update
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_COLOR

protected static final java.awt.Color DEFAULT_COLOR

thickness

protected double thickness

points

protected Point[] points

color

protected java.awt.Color color
Constructor Detail

Line

public Line(Report report,
            Section section,
            double thickness,
            java.awt.Color color,
            boolean visible)
Constructor.

Parameters:
report - the report containing this line
section - the section containing this line
thickness - the line thickness
color - may be null
visible - show/hide flag

Line

public Line(Report report,
            Section section,
            double thickness,
            java.awt.Color color,
            boolean visible,
            Point p0,
            Point p1)
Constructor.

Parameters:
report - the report containing this line
section - the section containing this line
thickness - the line thickness
color - may be null
visible - show/hide flag
p0 - one end point of the line
p1 - the other end point of the line
Method Detail

addEndPoint

public void addEndPoint(double x,
                        double y)
Adds an end point to the line. Used when constructing a line from XML, where we don't see the point until after creating this line.

Parameters:
x - the x coordinate
y - the y coordinate

getThickness

public double getThickness()
Returns the line thickness.

Returns:
the line thickness

setThickness

public void setThickness(double newThickness)
Sets the line thickness.

Parameters:
newThickness - the new line thickness

getPoint

public Point getPoint(int index)
Returns one of the two end points of the line.

Parameters:
index - either 0 or 1
Returns:
a point

setPoint

public void setPoint(Point newPoint,
                     int index)
Sets one of the two end points.

Parameters:
newPoint - a point
index - either 0 or 1

length

public double length()
Returns the length of the line.

Returns:
the distance between the two end points

toString

public java.lang.String toString()
Returns a string representation of this line.

Overrides:
toString in class java.lang.Object
Returns:
a string representing this line

getColor

public java.awt.Color getColor()
Returns the line's color. The return value will never be null.

Returns:
the line's color

setColor

public void setColor(java.awt.Color c)
Sets the line's color. If c is null, then the color is set to DEFAULT_COLOR.

Parameters:
c - new line color; if null, color is set to DEFAULT_COLOR

writeXML

public void writeXML(XMLWriter out)
Writes this line as an XML tag.

Specified by:
writeXML in interface Writeable
Specified by:
writeXML in class Element
Parameters:
out - a writer that knows how to write XML