jimm.datavision
Class Section

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

public class Section
extends java.util.Observable
implements Writeable, java.util.Observer

A section of a report contains a group of fields and suppression information. Sections include page headers and footers, report headers and footers, group headers and footers, and details. Sections contain elements (fields and lines).

Author:
Jim Menard, jimm@io.com
See Also:
Report, Field, Line

Field Summary
protected  SectionArea area
           
protected static double DEFAULT_HEIGHT
           
protected  java.util.ArrayList fields
           
protected  java.util.ArrayList lines
           
protected  double minHeight
           
protected  boolean pageBreak
           
protected  Report report
           
protected  SuppressionProc suppressionProc
           
 
Constructor Summary
Section(Report r)
          Constructor.
 
Method Summary
 void addField(Field f)
          Adds a field to this section.
 void addLine(Line l)
          Adds a line to this section.
 boolean contains(Field f)
          Returns true if the specified field is inside this section.
 boolean containsReferenceTo(Field f)
          Returns true if the specified field exists within this section either directly (as a field) or indirectly (as a formula used by an aggregate, user column, or formula or by the suppression proc).
 boolean containsReferenceTo(Formula f)
          Returns true if the specified formula exists within this section either directly (as a formula field) or indirectly (as a formula used by an aggregate, user column, or formula or by the suppression proc).
 boolean containsReferenceTo(Parameter p)
          Returns true if the specified parameter exists within this section either directly (as a parameter field) or indirectly (as a parameter used by an aggregate, a formula, or by the suppression proc).
 boolean containsReferenceTo(UserColumn uc)
          Returns true if the specified user column exists within this section either directly (as a user column field) or indirectly (as a user column used by an aggregate, a formula, or by the suppression proc).
 void evaluateFormulas()
          Forces all of the formulas used in this section to be evaluated.
 java.util.Iterator fields()
          Returns an iterator over all fields in this section.
 java.lang.Object[] fieldsSortedBy(java.util.Comparator comp)
          Returns an array of this section's fields sorted by comp.
 Field findField(java.lang.Object id)
          Given an id, returns the field within this section that has that id.
 SectionArea getArea()
          Returns the area this section is contained within.
 double getMinHeight()
          Returns the min height of this section.
 java.lang.String getName()
          Returns the name of this section.
 double getOutputHeight()
          Returns the height of this section: not the minimum height defined when the report was designed but rather the height necessary to output this section.
 Report getReport()
          Returns the report containing this section.
 SuppressionProc getSuppressionProc()
          Returns the supression proc this section uses
 double getWidth()
          Returns the width of this section.
 boolean hasPageBreak()
          Returns the boolean page break flag.
 boolean isDetail()
          Returns true if this is a report detail section.
 boolean isHidden()
           
 boolean isVisibleForCurrentRow()
          Return true if this section should be printed, given this particular row of data and our supressed state and suppression proc.
 java.util.Iterator lines()
          Returns an iterator over all lines in this section.
 int numFields()
          Returns the number of fields in this section.
 void removeField(Field f)
          Removes a field from this section.
 void removeLine(Line f)
          Removes a line from this section.
 void setArea(SectionArea area)
          Sets the area this section is contained within and notifies any observers of the change.
 void setMinHeight(double newMinHeight)
          Sets the min height.
 void setPageBreak(boolean flag)
          Sets the page break flag.
 void update(java.util.Observable o, java.lang.Object arg)
           
 void writeXML(XMLWriter out)
          Writes this section and all it contains 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HEIGHT

protected static final double DEFAULT_HEIGHT
See Also:
Constant Field Values

report

protected Report report

area

protected SectionArea area

minHeight

protected double minHeight

fields

protected java.util.ArrayList fields

lines

protected java.util.ArrayList lines

suppressionProc

protected SuppressionProc suppressionProc

pageBreak

protected boolean pageBreak
Constructor Detail

Section

public Section(Report r)
Constructor.

Parameters:
r - the report containing this section
Method Detail

update

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

getReport

public Report getReport()
Returns the report containing this section.


getMinHeight

public double getMinHeight()
Returns the min height of this section.

Returns:
the min height

setMinHeight

public void setMinHeight(double newMinHeight)
Sets the min height.

Parameters:
newMinHeight - the new min height

getOutputHeight

public double getOutputHeight()
Returns the height of this section: not the minimum height defined when the report was designed but rather the height necessary to output this section. The height returned is the maximum of minHeight and the highest y coordinate of any field.

Returns:
the height this section will need to be output

getWidth

public double getWidth()
Returns the width of this section.

Returns:
the width

getArea

public SectionArea getArea()
Returns the area this section is contained within.

Returns:
the area this section is contained within

setArea

public void setArea(SectionArea area)
Sets the area this section is contained within and notifies any observers of the change.

Parameters:
area - a section area

getName

public java.lang.String getName()
Returns the name of this section.

Returns:
the section name

findField

public Field findField(java.lang.Object id)
Given an id, returns the field within this section that has that id. If no field with the specified id exists, returns null.

Returns:
a field, or null if no field with the specified id exists in this section

addField

public void addField(Field f)
Adds a field to this section.

Parameters:
f - a field

removeField

public void removeField(Field f)
Removes a field from this section.

Parameters:
f - field

fields

public java.util.Iterator fields()
Returns an iterator over all fields in this section.

Returns:
an iterator

fieldsSortedBy

public java.lang.Object[] fieldsSortedBy(java.util.Comparator comp)
Returns an array of this section's fields sorted by comp.

Parameters:
comp - the comparator to use for sorting
Returns:
an array of fields sorted by comp

numFields

public int numFields()
Returns the number of fields in this section.

Returns:
the number of fields in this section

addLine

public void addLine(Line l)
Adds a line to this section.

Parameters:
l - a line

removeLine

public void removeLine(Line f)
Removes a line from this section.

Parameters:
f - line

lines

public java.util.Iterator lines()
Returns an iterator over all lines in this section.

Returns:
an iterator

isHidden

public boolean isHidden()

isDetail

public boolean isDetail()
Returns true if this is a report detail section.

Returns:
true if this is a report detail section

hasPageBreak

public boolean hasPageBreak()
Returns the boolean page break flag.

Returns:
true if we should start a new page before this section.

setPageBreak

public void setPageBreak(boolean flag)
Sets the page break flag.

Parameters:
flag - new value

getSuppressionProc

public SuppressionProc getSuppressionProc()
Returns the supression proc this section uses

Returns:
a suppression proc

contains

public boolean contains(Field f)
Returns true if the specified field is inside this section.

Parameters:
f - a field
Returns:
true if the field is within this section

containsReferenceTo

public boolean containsReferenceTo(Field f)
Returns true if the specified field exists within this section either directly (as a field) or indirectly (as a formula used by an aggregate, user column, or formula or by the suppression proc).

Parameters:
f - a field
Returns:
true if the specified field is referenced within this section

containsReferenceTo

public boolean containsReferenceTo(Formula f)
Returns true if the specified formula exists within this section either directly (as a formula field) or indirectly (as a formula used by an aggregate, user column, or formula or by the suppression proc).

Parameters:
f - a formula
Returns:
true if the specified formula is referenced within this section

containsReferenceTo

public boolean containsReferenceTo(UserColumn uc)
Returns true if the specified user column exists within this section either directly (as a user column field) or indirectly (as a user column used by an aggregate, a formula, or by the suppression proc).

Parameters:
uc - a user column
Returns:
true if the specified formula is referenced within this section

containsReferenceTo

public boolean containsReferenceTo(Parameter p)
Returns true if the specified parameter exists within this section either directly (as a parameter field) or indirectly (as a parameter used by an aggregate, a formula, or by the suppression proc).

Parameters:
p - a parameter
Returns:
true if the specified formula is referenced within this section

evaluateFormulas

public void evaluateFormulas()
Forces all of the formulas used in this section to be evaluated. See the comment for LayoutEngine.groupHeaders for why this method is necessary.

See Also:
LayoutEngine.groupHeaders(boolean)

isVisibleForCurrentRow

public boolean isVisibleForCurrentRow()
Return true if this section should be printed, given this particular row of data and our supressed state and suppression proc.

Returns:
true if the data should be displayed

writeXML

public void writeXML(XMLWriter out)
Writes this section and all it contains as an XML tag.

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