org.jfree.workbook
Class StyleRegion

java.lang.Object
  |
  +--org.jfree.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 startRow, int startColumn, int endRow, int endColumn)
          Constructs a style region.
 
Method Summary
 boolean contains(int row, int column)
          Returns true if the region include the cell at the specified row and column.
 int getEndColumn()
          Returns the end column of the region.
 int getEndRow()
          Returns the end row of the region.
 int getIntersectCase(int r1, int c1, int r2, int c2)
          Returns an integer denoting one of the 17 cases of intersection.
 StyleRegion getIntersectionStyleRegion(int r1, int c1, int r2, int c2, StyleModifier modifier)
          Returns a StyleRegion representing the portion of this region that intersects with the specified region.
 java.util.List getNonIntersectionStyleRegionList(int row1, int col1, int row2, int col2)
          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 row1, int col1, int row2, int col2)
          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.
 
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.


startRow

protected int startRow
The start row.


startColumn

protected int startColumn
The start column.


endRow

protected int endRow
The end row.


endColumn

protected int endColumn
The end column.

Constructor Detail

StyleRegion

public StyleRegion(Style style,
                   int startRow,
                   int startColumn,
                   int endRow,
                   int endColumn)
Constructs a style region.

Parameters:
style - the style.
startRow - the start row for the region.
startColumn - the start column for the region.
endRow - the end row for the region.
endColumn - the end column 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.

getStartRow

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

Returns:
The start row of the region.

getStartColumn

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

Returns:
The start column of the region.

getEndRow

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

Returns:
The end row of the region.

getEndColumn

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

Returns:
The end column of the region.

contains

public boolean contains(int row,
                        int column)
Returns true if the region include the cell at the specified row and column.

Parameters:
row - the row.
column - the column.
Returns:
A boolean.

intersects

public boolean intersects(int row1,
                          int col1,
                          int row2,
                          int col2)
Returns true if the specified range intersects with this region, and false otherwise.

Parameters:
row1 - the start row of the range.
col1 - the start column of the range.
row2 - the end row of the range.
col2 - the end column of the range.
Returns:
A boolean.

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.
Returns:
A boolean.

getIntersectionStyleRegion

public StyleRegion getIntersectionStyleRegion(int r1,
                                              int c1,
                                              int r2,
                                              int c2,
                                              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:
r1 - the start row of the region.
c1 - the start column of the region.
r2 - the end row of the region.
c2 - the end column of the region.
modifier - an optional style modifier that will be applied to the style before returning the intersecting region.
Returns:
The style 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 row1,
                                                        int col1,
                                                        int row2,
                                                        int col2)
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:
row1 - the start row.
col1 - the start column.
row2 - the end row.
col2 - the end column.
Returns:
A list of style regions equivalent to the non-intersection with the specified range.

getIntersectCase

public int getIntersectCase(int r1,
                            int c1,
                            int r2,
                            int c2)
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.
Returns:
The case number.