|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.zaval.util.ValidationObject | +--org.zaval.misc.PosController
This class can be used to organize navigation along an object. The class allows to control
virtual position basing on the navigation object information. The information
should be provided by implementing PosInfo
interface with the object. The interface
defines number of virtual lines, size of the specified virtual line and so on.
Field Summary | |
static int |
BEG
The begining direction type. |
static int |
DOWN
The down direction type. |
static int |
END
The end direction type. |
protected int |
prevCol
|
protected int |
prevLine
|
protected int |
prevOffset
|
static int |
UP
The up direction type. |
Fields inherited from class org.zaval.util.ValidationObject |
isValidFlag |
Constructor Summary | |
PosController()
Constructs the new instance of the class. |
|
PosController(PosInfo pi)
Constructs the new instance of the class with the specified pos info. |
Method Summary | |
void |
addPosListener(PosListener l)
Adds the specified PosListener listener. |
static int |
calcMaxOffset(PosInfo pi)
Calculates and returns the maximal offset for the specified pos info. |
void |
clearPos()
Sets the virtual position to undefined state. |
int |
getCurrentCol()
Gets the current column inside the current line. |
int |
getCurrentLine()
Gets the current line. |
int |
getMaxOffset()
Gets the maximal possible position value. |
int |
getOffset()
Gets the current position. |
static int |
getOffsetByPoint(int row,
int col,
PosController pc)
Gets an offset by the specified text line and column for the specified controller. |
static java.awt.Point |
getPointByOffset(int offset,
PosController pc)
Gets a line number and a column number by the specified text offset for the specified controller. |
PosInfo |
getPosInfo()
Gets the pos info. |
protected void |
perform(PosEvent e)
Fires the specified PosEvent to pos listeners. |
protected void |
recalc()
Invoked with validate method in a case if the object is not valid. |
void |
removePosListener(PosListener l)
Removes the specified PosListener listener. |
void |
seek(int off)
Moves the current position by additing specified value. |
void |
seekLineTo(int t)
Moves the current position to the next line according to the specified direction. |
void |
seekLineTo(int t,
int num)
Moves the current position to the next line according the specified direction and count. |
void |
setOffset(int o)
Sets the specified virtual position. |
void |
setPosInfo(PosInfo p)
Sets the specified pos info. |
void |
setRowCol(int r,
int c)
Sets the current position by the specified row and column. |
Methods inherited from class org.zaval.util.ValidationObject |
invalidate, isValid, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DOWN
public static final int UP
public static final int BEG
public static final int END
protected int prevOffset
protected int prevCol
protected int prevLine
Constructor Detail |
public PosController()
public PosController(PosInfo pi)
pi
- the specified pos info.Method Detail |
public void setPosInfo(PosInfo p)
null
value as
the pos info, in this case the IllegalArgumentException will be thrown.p
- the specified pos info.public void clearPos()
public void setOffset(int o)
o
- the specified virtual position.public void seek(int off)
setOffset
method.off
- the specified value.public void setRowCol(int r, int c)
setOffset
method.r
- the specified row.c
- the specified column.public void seekLineTo(int t)
Direction type | Description |
PosController.DOWN | Moves the current position to the next line below. The controller tries to set the column that has been used for previous line if it is possible, otherwise the new column will be set to the maximal column of the new line. |
PosController.UP | Moves the current position to the next line above. The controller tries to set the column that has been used for previous line if it is possible, otherwise the new column will be set to the maximal column of the new line. | PosController.END | Moves the current position to the end of the current line. | PosController.BEG | Moves the current position at the beginning of the current line. |
t
- the specified direction.public void seekLineTo(int t, int num)
Direction type | Description |
PosController.DOWN | Moves the current position to the next line below. The controller tries to set the column that has been used for previous line if it is possible, otherwise the new column will be set to the maximal column of the new line. |
PosController.UP | Moves the current position to the next line above. The controller tries to set the column that has been used for previous line if it is possible, otherwise the new column will be set to the maximal column of the new line. | PosController.END | Moves the current position to the end of the current line. | PosController.BEG | Moves the current position at the beginning of the current line. |
t
- the specified direction.num
- the specified count.public int getMaxOffset()
getMaxOffset
method. If the pos info
method returns -1
than the method will calculate maximal position
basing on the number of lines and the appropriate lines sizes.public int getCurrentCol()
public int getCurrentLine()
public int getOffset()
protected void recalc()
ValidationObject
validate
method in a case if the object is not valid.recalc
in class ValidationObject
public void addPosListener(PosListener l)
l
- the specified listener.public void removePosListener(PosListener l)
l
- the specified listener.public PosInfo getPosInfo()
protected void perform(PosEvent e)
e
- the specified pos event.public static java.awt.Point getPointByOffset(int offset, PosController pc)
offset
- the specified offset.pc
- the specified position controller.x
field is the line number and the y
field
is the column number.public static int getOffsetByPoint(int row, int col, PosController pc)
row
- the specified text line number.col
- the specified text column number.pc
- the specified position controller.public static int calcMaxOffset(PosInfo pi)
pi
- the specified pos info.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |