public class SelectionModel extends java.lang.Object
AlignmentArea
. Stores the cursor position and height as well as the selected area.AlignmentArea
Constructor and Description |
---|
SelectionModel(AlignmentArea owner)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addSelectionListener(SelectionListener<info.bioinfweb.commons.events.GenericEventObject<SelectionModel>> listener)
Adds a lister to this object that will be informed about future changes of the selection.
|
void |
adoptFromOther(SelectionModel otherModel)
Adopts the selection from another instance.
|
void |
clear()
Clears the current selection.
|
protected void |
fireSelectionChanged()
Informs all listeners that the selection changed.
|
int |
getCursorColumn()
Returns the current column position of the alignment cursor.
|
int |
getCursorHeight()
Returns the current height of the alignment cursor (which is equal to the height of a possible selection).
|
int |
getCursorRow()
Returns the topmost row included in the current alignment cursor.
|
int |
getFirstColumn()
Returns the index of the first column that is contained in the selection.
|
int |
getFirstRow()
Returns the index of the the first row that is contained in the selection.
|
int |
getLastColumn()
Returns the index of the the last column that is contained in the selection.
|
int |
getLastRow()
Returns the index of the the last row that is contained in the selection.
|
AlignmentArea |
getOwner()
Returns the alignment content area that uses this selection object.
|
int |
getStartColumn()
Returns the column where the current selection was started.
|
int |
getStartRow()
Returns the row where the current selection was started.
|
SelectionType |
getType()
Returns the currently used selection pattern.
|
int |
getWidth()
Returns the number of columns that are currently part of the selection.
|
boolean |
isEmpty()
Checks if any columns or rows are currently selected.
|
boolean |
isSelected(int column,
int row)
Checks if the specified cell is contained in this selection.
|
boolean |
removeSelectionListener(SelectionListener<info.bioinfweb.commons.events.GenericEventObject<SelectionModel>> listener)
Removes the specified listener from this objects list.
|
void |
selectAll()
Selects all cells in the alignment.
|
void |
setNewCursorColumn(int column)
Moves the cursor to a new column, leaving its row and height unchanged.
|
void |
setNewCursorPosition(int column,
int row)
Specifies a new location of the cursor.
|
void |
setNewCursorPosition(int column,
int row,
int height)
Specifies a new location and height for the cursor.
|
void |
setNewCursorRow(int row)
Specifies a new row position of the cursor.
|
void |
setSelectionEnd(int column,
int row)
Extends the current selection to include the specified cell and positions the cursor there.
|
void |
setType(SelectionType type)
Switches the selection type.
|
public SelectionModel(AlignmentArea owner)
owner
- the alignment content area that will be using this selection objectpublic AlignmentArea getOwner()
public SelectionType getType()
public void setType(SelectionType type)
If a change from SelectionType.CELLS
to SelectionType.COLUMN_ONLY
is done,
all rows become automatically selected, if the column selection is not empty.
If a change from SelectionType.CELLS
to SelectionType.ROW_ONLY
is done,
all columns become automatically selected, if the row selection is not empty.
type
- the new selection typepublic int getCursorColumn()
public int getCursorRow()
public int getCursorHeight()
getWidth()
public int getStartColumn()
public int getStartRow()
public void setNewCursorColumn(int column)
The selection will always be empty after calling this method.
column
- the new column where the cursor shall be locatedpublic void setNewCursorRow(int row)
The selection will always be empty after calling this method.
row
- the new top most row of the cursorpublic void setNewCursorPosition(int column, int row)
The selection will always be empty after calling this method.
column
- the column where the cursor shall be locatedrow
- the new top most row of the cursorpublic void adoptFromOther(SelectionModel otherModel)
otherModel
- another selection model instancepublic void setNewCursorPosition(int column, int row, int height)
column
- the column where the cursor shall be locatedrow
- the new top most row of the cursorheight
- the new height of the cursor (must be >= 1)public void setSelectionEnd(int column, int row)
The end of the selection does not necessarily have to be on the bottom right side of the selected rectangle, but can be at any side.
column
- the new cursor positionrow
- the new cursor positionpublic void selectAll()
public boolean isSelected(int column, int row)
If the selection type is SelectionType.COLUMN_ONLY
(or SelectionType.ROW_ONLY
)
and the selection is not empty all row (or columns) are considered as selected.
column
- the column index of the cell to be checkedrow
- the row index of the cell to be checkedtrue
if the specified cell is contained in the selection, false
otherwisepublic int getFirstColumn()
public int getLastColumn()
public int getFirstRow()
public int getLastRow()
public int getWidth()
getCursorHeight()
public void clear()
public boolean isEmpty()
true
if no cells are currently contained in the selection, false
otherwisepublic boolean addSelectionListener(SelectionListener<info.bioinfweb.commons.events.GenericEventObject<SelectionModel>> listener)
listener
- the listener object to be notified in the futuretrue
(as specified by Collection.add(Object)
)public boolean removeSelectionListener(SelectionListener<info.bioinfweb.commons.events.GenericEventObject<SelectionModel>> listener)
listener
- the listener to be removedtrue
if this list contained the specified elementprotected void fireSelectionChanged()