com.michaelbaranov.microba.marker

Class MarkerBar


public class MarkerBar
extends MicrobaComponent

A bar with multiple draggable position marks.

Features:

Implementation details:

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.

Author:
Michael Baranov

Field Summary

static String
PROPERTY_COLOR_COLUMN
The name of a "colorColumn" property.
static String
PROPERTY_DATA_MODEL
The name of a "dataModel" property.
static String
PROPERTY_FLIP
The name of a "fliped" property.
static String
PROPERTY_MUTATION_MODEL
The name of a "mutationModel" property.
static String
PROPERTY_ORIENTATION
The name of a "orientation" property.
static String
PROPERTY_POSITION_COLUMN
The name of a "positionColumn" property.
static String
PROPERTY_SELECTION_MODEL
The name of a "selectionModel" property.

Constructor Summary

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.

Method Summary

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.

Field Details

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.

Constructor Details

MarkerBar

public MarkerBar()
Constructs a MarkerBar with all models set to a single DefaultMarkerModel.
See Also:
DefaultMarkerModel

MarkerBar

public MarkerBar(BoundedTableModel dataModel)
Constructs a MarkerBar with given data model, a DefaultListSelectionModel as selection model and no mutation model.
Parameters:
dataModel - initial data model. May be null
See Also:
BoundedTableModel

MarkerBar

public MarkerBar(BoundedTableModel dataModel,
                 ListSelectionModel selectionModel)
Constructs a MarkerBar with given data model and selection model. No mutation model.
Parameters:
dataModel - initial data model. May be null;
selectionModel - initial selection model.
See Also:
BoundedTableModel

MarkerBar

public MarkerBar(int orientation)
Constructs a MarkerBar with given orientation. All models set to a single DefaultMarkerModel.
Parameters:
orientation - initial orientation. Possible values: SwingConstants.HORIZONTAL or SwingConstants.VERTICAL
See Also:
DefaultMarkerModel

Method Details

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.
Returns:
current color column index.

getDataModel

public BoundedTableModel getDataModel()
Returns current data model.
Returns:
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.
Returns:
Gap value.
See Also:
MarkerBarUI

getMutationModel

public MarkerMutationModel getMutationModel()
Returns current mutation model.
Returns:
current MutationModel.

getOrientation

public int getOrientation()
Returns current component orientation.
Returns:
current component orientation.

getPositionColumn

public int getPositionColumn()
Returns an index of currently used table column to query marker position.
Returns:
current position column index.

getSelectionModel

public ListSelectionModel getSelectionModel()
Returns current selection model.
Returns:
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.

Returns:
current flip value.

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.
Parameters:
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.
Parameters:
model - new data model.

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.

Parameters:
flip - new flip flag value.

setMutationModel

public void setMutationModel(MarkerMutationModel mutationModel)
Replaces current mutation model with given one.
Parameters:
mutationModel - new mutation model. May be null.
See Also:
getMutationModel(), MarkerMutationModel

setOrientation

public void setOrientation(int orientation)
Re-orientates the component.
Parameters:
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.
Parameters:
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.
Parameters:
selectionModel - new selection model. May be null.