com.michaelbaranov.microba.marker
Class MarkerBar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.michaelbaranov.microba.common.MicrobaComponent
                  extended by com.michaelbaranov.microba.marker.MarkerBar
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

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
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
static java.lang.String PROPERTY_COLOR_COLUMN
          The name of a "colorColumn" property.
static java.lang.String PROPERTY_DATA_MODEL
          The name of a "dataModel" property.
static java.lang.String PROPERTY_FLIP
          The name of a "fliped" property.
static java.lang.String PROPERTY_MUTATION_MODEL
          The name of a "mutationModel" property.
static java.lang.String PROPERTY_ORIENTATION
          The name of a "orientation" property.
static java.lang.String PROPERTY_POSITION_COLUMN
          The name of a "positionColumn" property.
static java.lang.String PROPERTY_SELECTION_MODEL
          The name of a "selectionModel" property.
 
Fields inherited from class com.michaelbaranov.microba.common.MicrobaComponent
PROPERTY_NAME_COLOR_OVERRIDE_MAP
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
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, javax.swing.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.
 javax.swing.ListSelectionModel getSelectionModel()
          Returns current selection model.
 java.lang.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(javax.swing.ListSelectionModel selectionModel)
          Replaces current selection model with given one.
 
Methods inherited from class com.michaelbaranov.microba.common.MicrobaComponent
getColorOverrideMap, getUI, setColorOverrideMap, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_DATA_MODEL

public static final java.lang.String PROPERTY_DATA_MODEL
The name of a "dataModel" property.

See Also:
Constant Field Values

PROPERTY_SELECTION_MODEL

public static final java.lang.String PROPERTY_SELECTION_MODEL
The name of a "selectionModel" property.

See Also:
Constant Field Values

PROPERTY_MUTATION_MODEL

public static final java.lang.String PROPERTY_MUTATION_MODEL
The name of a "mutationModel" property.

See Also:
Constant Field Values

PROPERTY_ORIENTATION

public static final java.lang.String PROPERTY_ORIENTATION
The name of a "orientation" property.

See Also:
Constant Field Values

PROPERTY_POSITION_COLUMN

public static final java.lang.String PROPERTY_POSITION_COLUMN
The name of a "positionColumn" property.

See Also:
Constant Field Values

PROPERTY_COLOR_COLUMN

public static final java.lang.String PROPERTY_COLOR_COLUMN
The name of a "colorColumn" property.

See Also:
Constant Field Values

PROPERTY_FLIP

public static final java.lang.String PROPERTY_FLIP
The name of a "fliped" property.

See Also:
Constant Field Values
Constructor Detail

MarkerBar

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

See Also:
DefaultMarkerModel

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

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,
                 javax.swing.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
Method Detail

getUIClassID

public java.lang.String getUIClassID()
Look&Feel UI delegate key (classID). This implementation returns: "MarkerBarUI".

Overrides:
getUIClassID in class javax.swing.JComponent

getDataModel

public BoundedTableModel getDataModel()
Returns current data model.

Returns:
current BoundedTableModel.
See Also:
setDataModel(BoundedTableModel), BoundedTableModel

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.
See Also:
getDataModel(), getPositionColumn(), BoundedTableModel

getOrientation

public int getOrientation()
Returns current component orientation.

Returns:
current component orientation.
See Also:
setOrientation(int)

setOrientation

public void setOrientation(int orientation)
Re-orientates the component.

Parameters:
orientation - new orientation value. Possible values: SwingConstants.HORIZONTAL or SwingConstants.VERTICAL
See Also:
getOrientation()

getMutationModel

public MarkerMutationModel getMutationModel()
Returns current mutation model.

Returns:
current MutationModel.
See Also:
setMutationModel(MarkerMutationModel), MarkerMutationModel

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

getSelectionModel

public javax.swing.ListSelectionModel getSelectionModel()
Returns current selection model.

Returns:
current ListSelectionModel.
See Also:
setSelectionModel(ListSelectionModel)

setSelectionModel

public void setSelectionModel(javax.swing.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.
See Also:
getSelectionModel()

getPositionColumn

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

Returns:
current position column index.
See Also:
setPositionColumn(int)

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.
See Also:
getPositionColumn()

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.
See Also:
setColorColumn(int)

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.
See Also:
getColorColumn()

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

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.

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.