xelem.3.0

nl.fountain.xelem
Class Area

java.lang.Object
  extended by nl.fountain.xelem.Area

public class Area
extends Object

A reference to a rectangular range.

Since:
xelem.2.0

Field Summary
protected  int c1
          The left-most column of this Area.
protected  int c2
          The right-most column of this Area.
protected  int r1
          The top-row of this Area.
protected  int r2
          The bottom-row of this Area.
 
Constructor Summary
Area(Address address1, Address address2)
          Constructs a new Area.
Area(int row1, int column1, int row2, int column2)
          Constructs a new Area.
Area(String a1_ref)
          Constructs a new Area.
 
Method Summary
 String getA1Reference()
          Gets a string in A1-reference style denoting the range of this area.
 String getAbsoluteRange()
          Gets a string in R1C1-reference style denoting the range of this area.
 int getFirstColumn()
          Gets the index of the left-most column of this area.
 int getFirstRow()
          Gets the index of the top row of this area.
 int getLastColumn()
          Gets the index of the right-most column of this area.
 int getLastRow()
          Gets the index of the bottom row of this area.
 boolean isColumnPartOfArea(int columnIndex)
          Specifies whether the given column is within this area.
 boolean isRowPartOfArea(int rowIndex)
          Specifies whether the given row is within this area.
 boolean isWithinArea(Address address)
          Specifies whether the given address is within this area.
 boolean isWithinArea(int rowIndex, int columnIndex)
          Specifies whether the intersection of the given row and column index is within this area.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

r1

protected int r1
The top-row of this Area.


r2

protected int r2
The bottom-row of this Area.


c1

protected int c1
The left-most column of this Area.


c2

protected int c2
The right-most column of this Area.

Constructor Detail

Area

public Area(int row1,
            int column1,
            int row2,
            int column2)
Constructs a new Area.

Parameters:
row1 - the index of the top row
column1 - the index of the left-most column
row2 - the index of the bottom row
column2 - the index of the right-most column

Area

public Area(Address address1,
            Address address2)
Constructs a new Area.

Parameters:
address1 - the address in one corner of the area
address2 - the address in the opposite corner

Area

public Area(String a1_ref)
Constructs a new Area. This constructor takes an A1-reference string as a parameter. For instance "B4:E6" will construct an area delimmited by rows 4 and 6 and columns 2 and 5. Treats the passed string case-insensitive.

Splits the string in the parameter on ":" and calculates row and column numbers with the 2 resulting strings.

Parameters:
a1_ref - a string of A1-reference style
Throws:
IllegalArgumentException - if a1_ref cannot be split in two strings using ":" as breakpoint.
See Also:
Address.calculateColumn(String), Address.calculateRow(String)
Method Detail

getFirstRow

public int getFirstRow()
Gets the index of the top row of this area.

Returns:
the index of the top row.

getLastRow

public int getLastRow()
Gets the index of the bottom row of this area.

Returns:
the index of the bottom row.

getFirstColumn

public int getFirstColumn()
Gets the index of the left-most column of this area.

Returns:
the index of the left-most column.

getLastColumn

public int getLastColumn()
Gets the index of the right-most column of this area.

Returns:
the index of the right-most column

getA1Reference

public String getA1Reference()
Gets a string in A1-reference style denoting the range of this area.

Returns:
a string in A1-reference style

getAbsoluteRange

public String getAbsoluteRange()
Gets a string in R1C1-reference style denoting the range of this area.

Returns:
a string in R1C1-reference style

isWithinArea

public boolean isWithinArea(int rowIndex,
                            int columnIndex)
Specifies whether the intersection of the given row and column index is within this area.

Parameters:
rowIndex - the rownumber
columnIndex - the columnnumber
Returns:
true if the intersection is within this area, fals otherwise.

isWithinArea

public boolean isWithinArea(Address address)
Specifies whether the given address is within this area.

Parameters:
address - the address to be investigated
Returns:
true if the address is within this area, false otherwise.

isRowPartOfArea

public boolean isRowPartOfArea(int rowIndex)
Specifies whether the given row is within this area.

Parameters:
rowIndex - the rownumber
Returns:
true if the row index is part of this area, false otherwise.

isColumnPartOfArea

public boolean isColumnPartOfArea(int columnIndex)
Specifies whether the given column is within this area.

Parameters:
columnIndex - the columnnumber
Returns:
true if the column index is part of this area, false otherwise.

xelem.3.0