Class MarkerBar
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- com.michaelbaranov.microba.common.MicrobaComponent
-
- 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:
- Single marker selection.
- Respects unmovable marks.
- Mouse marker selection & dragging.
- Hirizontal & verical orientation.
- Supported L&F: Metal, Windows, Motif, Basic for others.
- Data model:
BoundedTableModel - Selection model:
ListSelectionModel - MutationModel model:
MarkerMutationModel - UI delegate:
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
. A marker is considered to be unmovable, if corresponding table cell of the data model is reported to be uneditable.setPositionColumn(int)This implementation determines the only currently selected marker with
of the selection model, so current selection model's selection mode has no effect.ListSelectionModel.getLeadSelectionIndex()- Author:
- Michael Baranov
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROPERTY_COLOR_COLUMNThe name of a "colorColumn" property.static java.lang.StringPROPERTY_DATA_MODELThe name of a "dataModel" property.static java.lang.StringPROPERTY_FLIPThe name of a "fliped" property.static java.lang.StringPROPERTY_MUTATION_MODELThe name of a "mutationModel" property.static java.lang.StringPROPERTY_ORIENTATIONThe name of a "orientation" property.static java.lang.StringPROPERTY_POSITION_COLUMNThe name of a "positionColumn" property.static java.lang.StringPROPERTY_SELECTION_MODELThe 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
-
-
Constructor Summary
Constructors Constructor Description MarkerBar()Constructs aMarkerBarwith all models set to a singleDefaultMarkerModel.MarkerBar(int orientation)Constructs aMarkerBarwith given orientation.MarkerBar(BoundedTableModel dataModel)Constructs aMarkerBarwith given data model, aDefaultListSelectionModelas selection model and no mutation model.MarkerBar(BoundedTableModel dataModel, javax.swing.ListSelectionModel selectionModel)Constructs aMarkerBarwith given data model and selection model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetColorColumn()Returns an index of currently used table column to query marker color.BoundedTableModelgetDataModel()Returns current data model.intgetMarkerSideGap()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.MarkerMutationModelgetMutationModel()Returns current mutation model.intgetOrientation()Returns current component orientation.intgetPositionColumn()Returns an index of currently used table column to query marker position.javax.swing.ListSelectionModelgetSelectionModel()Returns current selection model.java.lang.StringgetUIClassID()Look&Feel UI delegate key (classID).booleanisFliped()Returns current flip flag value.voidsetColorColumn(int colorColumn)Sets the index of the data model table column used to query marker color.voidsetDataModel(BoundedTableModel model)Replaces current data model with specified one.voidsetFliped(boolean flip)Set flip flag value.voidsetMutationModel(MarkerMutationModel mutationModel)Replaces current mutation model with given one.voidsetOrientation(int orientation)Re-orientates the component.voidsetPositionColumn(int positionColumn)Sets the index of the data model table column used to query marker position.voidsetSelectionModel(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, 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, hide, 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, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
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 aMarkerBarwith all models set to a singleDefaultMarkerModel.- See Also:
DefaultMarkerModel
-
MarkerBar
public MarkerBar(int orientation)
Constructs aMarkerBarwith given orientation. All models set to a singleDefaultMarkerModel.- Parameters:
orientation- initial orientation. Possible values:SwingConstants.HORIZONTALorSwingConstants.VERTICAL- See Also:
DefaultMarkerModel
-
MarkerBar
public MarkerBar(BoundedTableModel dataModel)
Constructs aMarkerBarwith given data model, aDefaultListSelectionModelas selection model and no mutation model.- Parameters:
dataModel- initial data model. May benull- See Also:
BoundedTableModel
-
MarkerBar
public MarkerBar(BoundedTableModel dataModel, javax.swing.ListSelectionModel selectionModel)
Constructs aMarkerBarwith given data model and selection model. No mutation model.- Parameters:
dataModel- initial data model. May benull;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:
getUIClassIDin classjavax.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:orSwingConstants.HORIZONTALSwingConstants.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 benull.- 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 usesto determine selected marker.ListSelectionModel.getLeadSelectionIndex()- Parameters:
selectionModel- new selection model. May benull.- 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.
-
-