Class MarkerBar

All Implemented Interfaces:
ImageObserver, MenuContainer, 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.
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:
  • Field Details

    • PROPERTY_DATA_MODEL

      public static final String PROPERTY_DATA_MODEL
      The name of a "dataModel" property.
      See Also:
    • PROPERTY_SELECTION_MODEL

      public static final String PROPERTY_SELECTION_MODEL
      The name of a "selectionModel" property.
      See Also:
    • PROPERTY_MUTATION_MODEL

      public static final String PROPERTY_MUTATION_MODEL
      The name of a "mutationModel" property.
      See Also:
    • PROPERTY_ORIENTATION

      public static final String PROPERTY_ORIENTATION
      The name of a "orientation" property.
      See Also:
    • PROPERTY_POSITION_COLUMN

      public static final String PROPERTY_POSITION_COLUMN
      The name of a "positionColumn" property.
      See Also:
    • PROPERTY_COLOR_COLUMN

      public static final String PROPERTY_COLOR_COLUMN
      The name of a "colorColumn" property.
      See Also:
    • PROPERTY_FLIP

      public static final String PROPERTY_FLIP
      The name of a "fliped" property.
      See Also:
  • Constructor Details

    • MarkerBar

      public MarkerBar()
      Constructs a MarkerBar with all models set to a single DefaultMarkerModel.
      See Also:
    • 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:
    • 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:
    • 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:
  • Method Details

    • getUIClassID

      public String getUIClassID()
      Look&Feel UI delegate key (classID). This implementation returns: "MarkerBarUI".
      Overrides:
      getUIClassID in class JComponent
    • getDataModel

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

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

      public void setOrientation(int orientation)
      Re-orientates the component.
      Parameters:
      orientation - new orientation value. Possible values: SwingConstants.HORIZONTAL or SwingConstants.VERTICAL
      See Also:
    • getMutationModel

      public MarkerMutationModel getMutationModel()
      Returns current mutation model.
      Returns:
      current MutationModel.
      See Also:
    • setMutationModel

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

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

      public int getPositionColumn()
      Returns an index of currently used table column to query marker position.
      Returns:
      current position column index.
      See Also:
    • 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:
    • 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

      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:
    • 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:
    • 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.