com.jrefinery.workbook
Class StyleRegion

java.lang.Object
  |
  +--com.jrefinery.workbook.StyleRegion

public class StyleRegion
extends java.lang.Object

Represents a region and its associated style.

Note that the style can be changed, but the region is immutable. This is done because the regions form part of a non-overlapping collection that completely cover a worksheet. If you could change the region, that would potentially break the collection.


Field Summary
protected  int endColumn
          The end column.
protected  int endRow
          The end row.
protected  int startColumn
          The start column.
protected  int startRow
          The start row.
protected  Style style
          The style.
 
Constructor Summary
StyleRegion(Style style, int startColumn, int startRow, int endColumn, int endRow)
          Standard constructor.
 
Method Summary
 int getEndColumn()
          Returns the end column of the region.
 int getEndRow()
          Returns the end row of the region.
 int getIntersectCase(int c1, int r1, int c2, int r2)
          Returns an integer denoting one of the 17 cases of intersection.
 StyleRegion getIntersectionStyleRegion(int c1, int r1, int c2, int r2, StyleModifier modifier)
          Returns a StyleRegion representing the portion of this region that intersects with the specified region.
 java.util.List getNonIntersectionStyleRegionList(int col1, int row1, int col2, int row2)
          Returns a list of StyleRegions equivalent to the non-intersection with the specified range.
 java.util.List getNonIntersectionStyleRegionList(StyleRegion region)
          Returns a list of style regions that cover the non-intersecting part of this region.
 int getStartColumn()
          Returns the start column of the region.
 int getStartRow()
          Returns the start row of the region.
 Style getStyle()
          Returns the style for this region.
 boolean intersects(int col1, int row1, int col2, int row2)
          Returns true if the specified range intersects with this region, and false otherwise.
 boolean intersects(StyleRegion region)
          Returns true if the specified region intersects with this region, and false otherwise.
 void setStyle(Style style)
          Sets the style for this region.
 void writeStyleRegion(java.io.PrintStream out, java.lang.String indent)
          Writes a style region element to the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

style

protected Style style
The style.

startColumn

protected int startColumn
The start column.

startRow

protected int startRow
The start row.

endColumn

protected int endColumn
The end column.

endRow

protected int endRow
The end row.
Constructor Detail

StyleRegion

public StyleRegion(Style style,
                   int startColumn,
                   int startRow,
                   int endColumn,
                   int endRow)
Standard constructor.
Parameters:
style - The style.
startColumn - The start column for the region.
startRow - The start row for the region.
endColumn - The end column for the region.
endRow - The end row for the region.
Method Detail

getStyle

public Style getStyle()
Returns the style for this region.
Returns:
The style for this region.

setStyle

public void setStyle(Style style)
Sets the style for this region.
Parameters:
style - The new style.

getStartColumn

public int getStartColumn()
Returns the start column of the region.
Returns:
The start column of the region.

getStartRow

public int getStartRow()
Returns the start row of the region.
Returns:
The start row of the region.

getEndColumn

public int getEndColumn()
Returns the end column of the region.
Returns:
The end column of the region.

getEndRow

public int getEndRow()
Returns the end row of the region.
Returns:
The end row of the region.

intersects

public boolean intersects(int col1,
                          int row1,
                          int col2,
                          int row2)
Returns true if the specified range intersects with this region, and false otherwise.
Parameters:
col1 - The start column of the range.
row1 - The start row of the range.
col2 - The end column of the range.
row2 - The end row of the range.

intersects

public boolean intersects(StyleRegion region)
Returns true if the specified region intersects with this region, and false otherwise.
Parameters:
region - The region being tested.

getIntersectionStyleRegion

public StyleRegion getIntersectionStyleRegion(int c1,
                                              int r1,
                                              int c2,
                                              int r2,
                                              StyleModifier modifier)
Returns a StyleRegion representing the portion of this region that intersects with the specified region. If there is no intersection, returns null.
Parameters:
c1 - The start column of the region.
r1 - The start row of the region.
c2 - The end column of the region.
r2 - The end row of the region.
modifier - An optional style modifier that will be applied to the style before returning the intersecting region.

getNonIntersectionStyleRegionList

public java.util.List getNonIntersectionStyleRegionList(StyleRegion region)
Returns a list of style regions that cover the non-intersecting part of this region.
Parameters:
region - The region to calculate the intersection against.
Returns:
A list of style regions that cover the non-intersecting part of this region.

getNonIntersectionStyleRegionList

public java.util.List getNonIntersectionStyleRegionList(int col1,
                                                        int row1,
                                                        int col2,
                                                        int row2)
Returns a list of StyleRegions equivalent to the non-intersection with the specified range.

There are 17 cases to deal with, one of which entirely obliterates the existing StyleRegion.

Parameters:
col1 - The start column.
row1 - The start row.
col2 - The end column.
row2 - The end row.
Returns:
A list of style regions equivalent to the non-intersection with the specified range.

getIntersectCase

public int getIntersectCase(int c1,
                            int r1,
                            int c2,
                            int r2)
Returns an integer denoting one of the 17 cases of intersection. Each case represents a general type of intersection from which it is straightforward to calculate the subregions that make up either the intersection or the non-intersection regions.

The 17 cases to deal with are: 0: no intersection; 1: top left corner; 2: top section; 3: top right corner; 4: left section; 5: all; 6: right section; 7: bottom left corner; 8: bottom section; 9: bottom right corner; 10: top "bite"; 11: right "bite"; 12: bottom "bite"; 13: left "bite"; 14: central "bite"; 15: vertical section; 16: horizontal section;

Parameters:
c1 - The start column.
r1 - The start row.
c2 - The end column.
r2 - The end row.

writeStyleRegion

public void writeStyleRegion(java.io.PrintStream out,
                             java.lang.String indent)
Writes a style region element to the stream.
Parameters:
out - The output stream.
indent - The indentation.