com.michaelbaranov.microba.marker
Class MarkerBar
MicrobaComponent
com.michaelbaranov.microba.marker.MarkerBar
public class MarkerBar
extends MicrobaComponent
A bar with multiple draggable position marks.
Features:
- Single marker selection.
- Respects unmovable marks.
- Mouse marker selection & dragging.
- Hirizontal & verical orientation.
- Supported L&F: Metal, Windows, Motif, Basic for others.
Implementation details:
- Data model:
com.michaelbaranov.microba.common.BoundedTableModel
- Selection model:
javax.swing.ListSelectionModel
- MutationModel model:
MarkerMutationModel
- UI delegate:
com.michaelbaranov.microba.marker.ui.MarkerBarUI
This implementation queries marker positions from a single table column of
the data model. The index defaults to 0, but you can specify it with
setPositionColumn(int)
.
A marker is considered to be unmovable, if corresponding table cell of the
data model is reported to be uneditable.
This implementation determines the only currently selected marker with
ListSelectionModel.getLeadSelectionIndex()
of the selection model, so current selection model's selection mode has no
effect.
MarkerBar() - Constructs a
MarkerBar with all models set to a single
DefaultMarkerModel.
|
MarkerBar(BoundedTableModel dataModel) - Constructs a
MarkerBar with given data model, a
DefaultListSelectionModel as selection model and no mutation model.
|
MarkerBar(BoundedTableModel dataModel, ListSelectionModel selectionModel) - Constructs a
MarkerBar with given data model and selection
model.
|
MarkerBar(int orientation) - Constructs a
MarkerBar with given orientation.
|
int | getColorColumn() - Returns an index of currently used table column to query marker color.
|
BoundedTableModel | getDataModel() - Returns current data model.
|
int | getMarkerSideGap() - Returns a distance in pixeld between the edge of the component (left &
right edge for horizontal orientation, top & bottom edge for vertical)
and a marker beak point in outermost position.
|
MarkerMutationModel | getMutationModel() - Returns current mutation model.
|
int | getOrientation() - Returns current component orientation.
|
int | getPositionColumn() - Returns an index of currently used table column to query marker position.
|
ListSelectionModel | getSelectionModel() - Returns current selection model.
|
String | getUIClassID() - Look&Feel UI delegate key (classID).
|
boolean | isFliped() - Returns current flip flag value.
|
void | setColorColumn(int colorColumn) - Sets the index of the data model table column used to query marker color.
|
void | setDataModel(BoundedTableModel model) - Replaces current data model with specified one.
|
void | setFliped(boolean flip) - Set flip flag value.
|
void | setMutationModel(MarkerMutationModel mutationModel) - Replaces current mutation model with given one.
|
void | setOrientation(int orientation) - Re-orientates the component.
|
void | setPositionColumn(int positionColumn) - Sets the index of the data model table column used to query marker
position.
|
void | setSelectionModel(ListSelectionModel selectionModel) - Replaces current selection model with given one.
|
PROPERTY_COLOR_COLUMN
public static final String PROPERTY_COLOR_COLUMN
The name of a "colorColumn" property.
PROPERTY_DATA_MODEL
public static final String PROPERTY_DATA_MODEL
The name of a "dataModel" property.
PROPERTY_FLIP
public static final String PROPERTY_FLIP
The name of a "fliped" property.
PROPERTY_MUTATION_MODEL
public static final String PROPERTY_MUTATION_MODEL
The name of a "mutationModel" property.
PROPERTY_ORIENTATION
public static final String PROPERTY_ORIENTATION
The name of a "orientation" property.
PROPERTY_POSITION_COLUMN
public static final String PROPERTY_POSITION_COLUMN
The name of a "positionColumn" property.
PROPERTY_SELECTION_MODEL
public static final String PROPERTY_SELECTION_MODEL
The name of a "selectionModel" property.
MarkerBar
public MarkerBar()
Constructs a MarkerBar
with all models set to a single
DefaultMarkerModel.
MarkerBar
public MarkerBar(BoundedTableModel dataModel)
Constructs a MarkerBar
with given data model, a
DefaultListSelectionModel
as selection model and no mutation model.
dataModel
- initial data model. May be null
MarkerBar
public MarkerBar(BoundedTableModel dataModel,
ListSelectionModel selectionModel)
Constructs a MarkerBar
with given data model and selection
model. No mutation model.
dataModel
- initial data model. May be null
;
selectionModel
- initial selection model.
MarkerBar
public MarkerBar(int orientation)
Constructs a MarkerBar
with given orientation. All models
set to a single DefaultMarkerModel
.
orientation
- initial orientation. Possible values:
SwingConstants.HORIZONTAL
or
SwingConstants.VERTICAL
getColorColumn
public int getColorColumn()
Returns an index of currently used table column to query marker color.
Defaults to -1, which means not to query data model for color.
- current color column index.
getDataModel
public BoundedTableModel getDataModel()
Returns current data model.
- current BoundedTableModel.
getMarkerSideGap
public int getMarkerSideGap()
Returns a distance in pixeld between the edge of the component (left &
right edge for horizontal orientation, top & bottom edge for vertical)
and a marker beak point in outermost position. The value is actually
queried from current UI delegate.
getMutationModel
public MarkerMutationModel getMutationModel()
Returns current mutation model.
getOrientation
public int getOrientation()
Returns current component orientation.
- current component orientation.
getPositionColumn
public int getPositionColumn()
Returns an index of currently used table column to query marker position.
- current position column index.
getSelectionModel
public ListSelectionModel getSelectionModel()
Returns current selection model.
- current ListSelectionModel.
getUIClassID
public String getUIClassID()
Look&Feel UI delegate key (classID). This implementation returns:
"MarkerBarUI"
.
isFliped
public boolean isFliped()
Returns current flip flag value.
The flip flag defines where marker bicks are pointed:
true
: down for horizontal orientation, left for vertical.
false
: up for horizontal orientation, right for vertical.
setColorColumn
public void setColorColumn(int colorColumn)
Sets the index of the data model table column used to query marker color.
Set to -1 in order not to query data model for color data.
colorColumn
- new color column index.
setDataModel
public void setDataModel(BoundedTableModel model)
Replaces current data model with specified one. This implementation uses
current position column index to query marker positions.
setFliped
public void setFliped(boolean flip)
Set flip flag value.
The flip flag defines where marker bicks are pointed:
true
: down for horizontal orientation, left for vertical.
false
: up for horizontal orientation, right for vertical.
flip
- new flip flag value.
setMutationModel
public void setMutationModel(MarkerMutationModel mutationModel)
Replaces current mutation model with given one.
mutationModel
- new mutation model. May be null
.
setOrientation
public void setOrientation(int orientation)
Re-orientates the component.
orientation
- new orientation value. Possible values:
SwingConstants.HORIZONTAL
or
SwingConstants.VERTICAL
setPositionColumn
public void setPositionColumn(int positionColumn)
Sets the index of the data model table column used to query marker
position.
positionColumn
- new position column index.
setSelectionModel
public void setSelectionModel(ListSelectionModel selectionModel)
Replaces current selection model with given one. This implementation uses
ListSelectionModel.getLeadSelectionIndex()
to
determine selected marker.
selectionModel
- new selection model. May be null
.