jimm.datavision.field
Class Border

java.lang.Object
  extended by java.util.Observable
      extended by jimm.datavision.field.Border
All Implemented Interfaces:
java.lang.Cloneable, java.util.Observer, Writeable

public class Border
extends java.util.Observable
implements Writeable, java.lang.Cloneable, java.util.Observer

A border is a visual decoration around a report field. Each of its four edges (top, left, bottom, and right) is a BorderEdge and may be null.

Author:
Jim Menard, jimm@io.com

Field Summary
protected static int BORDER_LINE_SPACE_MULT
           
protected  BorderEdge bottom
           
protected  java.awt.Color color
           
protected static java.awt.Color DEFAULT_COLOR
           
protected  Field field
           
protected  BorderEdge left
           
protected  BorderEdge right
           
protected  BorderEdge top
           
 
Constructor Summary
Border(Field field)
          Constructs a new border for the specified field.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this border.
 void eachLine(LineDrawer ld, java.lang.Object arg)
          For each edge, hand the lines that make up that edge to the specified line drawer's drawLine method.
 boolean equals(java.lang.Object obj)
          For testing only.
protected  void finalize()
           
 BorderEdge getBottom()
          Returns the border's bottom edge.
 java.awt.Color getColor()
          Retrieves the border color.
 BorderEdge getLeft()
          Returns the border's left edge.
 BorderEdge getRight()
          Returns the border's right edge.
 BorderEdge getTop()
          Returns the border's top edge.
 int hashCode()
           
 boolean isEmpty()
          Returns true if this border's edges are all null or have zero count or width.
protected  boolean isEmptyEdge(BorderEdge edge)
          Returns true if edge is null or has zero count or width.
 void setBottom(BorderEdge newBottom)
          Sets the bottom edge.
 void setColor(java.awt.Color c)
          Sets the border color.
 void setField(Field f)
          Used only when cloning a field, this sets our field.
 void setLeft(BorderEdge newLeft)
          Sets the left edge.
 void setRight(BorderEdge newRight)
          Sets the right edge.
 void setTop(BorderEdge newTop)
          Sets the top edge.
 void update(java.util.Observable o, java.lang.Object arg)
           
 void writeXML(XMLWriter out)
          Writes this border as an XML tag.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BORDER_LINE_SPACE_MULT

protected static final int BORDER_LINE_SPACE_MULT
See Also:
Constant Field Values

DEFAULT_COLOR

protected static final java.awt.Color DEFAULT_COLOR

field

protected Field field

top

protected BorderEdge top

left

protected BorderEdge left

bottom

protected BorderEdge bottom

right

protected BorderEdge right

color

protected java.awt.Color color
Constructor Detail

Border

public Border(Field field)
Constructs a new border for the specified field.

Parameters:
field - a report field
Method Detail

clone

public java.lang.Object clone()
Returns a clone of this border. All edges are cloned as well.

Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
For testing only. Checks color and edges but not field.

Overrides:
equals in class java.lang.Object
See Also:
ReportTest.testCloning()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

setField

public void setField(Field f)
Used only when cloning a field, this sets our field. Otherwise, don't call this.

Parameters:
f - the new field

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

getTop

public BorderEdge getTop()
Returns the border's top edge. May return null.

Returns:
the top edge

setTop

public void setTop(BorderEdge newTop)
Sets the top edge. newTop may be null.

Parameters:
newTop - the new edge

getLeft

public BorderEdge getLeft()
Returns the border's left edge. May return null.

Returns:
the left edge

setLeft

public void setLeft(BorderEdge newLeft)
Sets the left edge. newLeft may be null.

Parameters:
newLeft - the new edge

getBottom

public BorderEdge getBottom()
Returns the border's bottom edge. May return null.

Returns:
the bottom edge

setBottom

public void setBottom(BorderEdge newBottom)
Sets the bottom edge. newBottom may be null.

Parameters:
newBottom - the new edge

getRight

public BorderEdge getRight()
Returns the border's right edge. May return null.

Returns:
the right edge

setRight

public void setRight(BorderEdge newRight)
Sets the right edge. newRight may be null.

Parameters:
newRight - the new edge

getColor

public java.awt.Color getColor()
Retrieves the border color.

Returns:
the border color

setColor

public void setColor(java.awt.Color c)
Sets the border color.

Parameters:
c - the new color

eachLine

public void eachLine(LineDrawer ld,
                     java.lang.Object arg)
For each edge, hand the lines that make up that edge to the specified line drawer's drawLine method.

Parameters:
ld - a line drawer

isEmpty

public boolean isEmpty()
Returns true if this border's edges are all null or have zero count or width.

Returns:
true if this border's edges are all null or have zero count or width

isEmptyEdge

protected boolean isEmptyEdge(BorderEdge edge)
Returns true if edge is null or has zero count or width.

Returns:
true if edge is null or has zero count or width

writeXML

public void writeXML(XMLWriter out)
Writes this border as an XML tag. Asks each edge to write itself as well. If isEmpty() returns true, returns without writing anything.

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