xelem.3.0

nl.fountain.xelem
Class CellPointer

java.lang.Object
  extended by nl.fountain.xelem.Address
      extended by nl.fountain.xelem.CellPointer
All Implemented Interfaces:
Comparable

public class CellPointer
extends Address

Keeps track of the position of cells being added to the Worksheet.

[The position of the cellpointer is not displayed in the actual Excel worksheet. If you wish to set the active cell in the actual Excel worksheet on a position other then row 1, column 1, you should use WorksheetOptions.setActiveCell(int, int).]

The position of the cellpointer is reflected in it's getRowIndex- and getColumnIndex-values. The cellpointer moves to a new position relative to its old position at a call to move(). In what direction it moves and over how many cells depends on it's settings. The default setting is to step 1 column to the right.


Field Summary
static int MOVE_DOWN
          A constant for the method setMovement(int).
static int MOVE_LEFT
          A constant for the method setMovement(int).
static int MOVE_RIGHT
          A constant for the method setMovement(int).
static int MOVE_UP
          A constant for the method setMovement(int).
 
Fields inherited from class nl.fountain.xelem.Address
c, r
 
Constructor Summary
CellPointer()
          Constructs a new CellPointer.
 
Method Summary
 Address getAddress()
          Gets the address of the cell where this cellpointer is pointing at.
 int getHorizontalStepDistance()
          Gets the horizontalStepDistance.
 int getMovement()
          Gets the direction into which this cellpointer will move.
 int getVerticalStepDistance()
          Gets the verticalStepDistance.
 void move()
          Moves this cellpointer.
 void move(int rows, int columns)
          Moves this cellpointer to a new position relative to it's old position.
 void moveCRLF()
          Moves this cellpointer to the first column of the next row.
 void moveHome()
          Moves this cellpointer to the first column of the present row.
 void moveTo(Address address)
          Moves this cellpointer to the specified address.
 void moveTo(int row, int column)
          Moves this cellpointer to the specified row and column number.
 void moveTo(String a1_ref)
          Moves this cellpointer to the address specified by the given A1-reference string.
 void setHorizontalStepDistance(int distance)
          Sets the number of cells this cellpointer will move in the horizontal axis after a call to move().
 void setMovement(int moveConst)
          Sets the direction this cellpointer will move after a call to move().
 void setVerticalStepDistance(int distance)
          Sets the number of cells this cellpointer will move in the vertical axis after a call to move().
 
Methods inherited from class nl.fountain.xelem.Address
calculateColumn, calculateColumn, calculateRow, compareTo, equals, getA1Reference, getAbsoluteAddress, getAbsoluteRange, getAbsoluteRange, getAbsoluteRange, getColumnIndex, getRefTo, getRefTo, getRefTo, getRefTo, getRefTo, getRefTo, getRowIndex, isWithinSheet, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MOVE_RIGHT

public static final int MOVE_RIGHT
A constant for the method setMovement(int).

See Also:
Constant Field Values

MOVE_LEFT

public static final int MOVE_LEFT
A constant for the method setMovement(int).

See Also:
Constant Field Values

MOVE_DOWN

public static final int MOVE_DOWN
A constant for the method setMovement(int).

See Also:
Constant Field Values

MOVE_UP

public static final int MOVE_UP
A constant for the method setMovement(int).

See Also:
Constant Field Values
Constructor Detail

CellPointer

public CellPointer()
Constructs a new CellPointer. The position of the pointer will be at row 1, column 1. The initial movement of the pointer is MOVE_RIGHT. The initial step distance of the pointer is 1. So the default behavior of this pointer at a call to move() is to move one column to the right.

See Also:
Worksheet.getCellPointer()
Method Detail

getAddress

public Address getAddress()
Gets the address of the cell where this cellpointer is pointing at.

Returns:
A new Address reflecting the momentary row- and column index of this CellPointer.

setHorizontalStepDistance

public void setHorizontalStepDistance(int distance)
Sets the number of cells this cellpointer will move in the horizontal axis after a call to move(). The default is 1.

If the movement of this cellpointer is set to MOVE_DOWN or MOVE_UP the value of horizontalStepDistance has no influence on this pointers move-behavior.

If the horizontalStepDistance is set to a negative value the pointer will move to the left when movement is set to MOVE_RIGHT and to the right when movement is set to MOVE_LEFT.

If the horizontalStepDistance is set to 0, the pointer will not move when movement is set to MOVE_RIGHT or MOVE_LEFT.

Parameters:
distance - The number of cells to move in the horizontal axis.
See Also:
setMovement(int)

getHorizontalStepDistance

public int getHorizontalStepDistance()
Gets the horizontalStepDistance.


setVerticalStepDistance

public void setVerticalStepDistance(int distance)
Sets the number of cells this cellpointer will move in the vertical axis after a call to move(). The default is 1.

If the movement of this cellpointer is set to MOVE_RIGHT or MOVE_LEFT the value of verticalStepDistance has no influence on this pointers move-behavior.

If the verticalStepDistance is set to a negative value the pointer will move up when movement is set to MOVE_DOWN and down when movement is set to MOVE_UP.

If the verticalStepDistance is set to 0, the pointer will not move when movement is set to MOVE_DOWN or MOVE_UP.

Parameters:
distance - The number of cells to move in the vertical axis.
See Also:
setMovement(int)

getVerticalStepDistance

public int getVerticalStepDistance()
Gets the verticalStepDistance.


setMovement

public void setMovement(int moveConst)
Sets the direction this cellpointer will move after a call to move(). The default is MOVE_RIGHT.

Parameters:
moveConst - One of CellPointer's MOVE_RIGHT, MOVE_LEFT, MOVE_DOWN or MOVE_UP values.
Throws:
IllegalArgumentException - at values less than 0 or greater then 3.

getMovement

public int getMovement()
Gets the direction into which this cellpointer will move. The returned int will be equal to one of CellPointer's MOVE_RIGHT, MOVE_LEFT, MOVE_DOWN or MOVE_UP values.


move

public void move()
Moves this cellpointer. The direction of the movement depends on the setting of setMovement(int). How many cells the pointer will move depends on the setting of the step distance.

See Also:
setMovement(int), setHorizontalStepDistance(int), setVerticalStepDistance(int)

move

public void move(int rows,
                 int columns)
Moves this cellpointer to a new position relative to it's old position. If this cellpointer was previously at oldR, oldC, the new position will be at oldR + rows, oldC + columns.

Parameters:
rows - the number of rows to move
columns - the number of columns to move

moveTo

public void moveTo(int row,
                   int column)
Moves this cellpointer to the specified row and column number.

Parameters:
row - the row where this cellpointer should move to
column - the column where this cellpointer should move to

moveTo

public void moveTo(String a1_ref)
Moves this cellpointer to the address specified by the given A1-reference string.

Parameters:
a1_ref - a string of A1-reference type

moveTo

public void moveTo(Address address)
Moves this cellpointer to the specified address.

Parameters:
address - the address where this cellpointer should move to

moveHome

public void moveHome()
Moves this cellpointer to the first column of the present row. The first column is determined by the value of Worksheet.firstColumn.


moveCRLF

public void moveCRLF()
Moves this cellpointer to the first column of the next row. The first column is determined by the value of Worksheet.firstColumn. How many rows the new position will be from the present position is determined by the value of verticalStepDistance.


xelem.3.0