Class BarBox

All Implemented Interfaces:
FocusListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible

public class BarBox extends JPanel implements FocusListener, PropertyChangeListener
This object groups several BarRenderers in a "stack view" that represent one leadSheet bar.
See Also:
  • Constructor Details

    • BarBox

      public BarBox(CL_Editor editor, int bbIndex, int modelBarIndex, ChordLeadSheet model, BarBoxConfig config, BarBoxSettings settings, BarRendererFactory brf, Object groupKey)
      Construct a BarBox.
      Parameters:
      editor - Can be null
      bbIndex - The index of this BarBox.
      modelBarIndex - Use -1 if this BarBox does not represent model data.
      model -
      config -
      settings -
      brf -
      groupKey -
  • Method Details

    • setModel

      public final void setModel(int modelBarIndex, ChordLeadSheet model)
      Set the model for this BarBox.
      Parameters:
      modelBarIndex - If < 0, it means this BarBox does not represent a valid bar for model.
      model -
    • addItem

      public List<ItemRenderer> addItem(ChordLeadSheetItem<?> item)
      Add an item in the BarBox.

      The operation requests each BarRenderer to create ItemRenderers if appropriate.

      Parameters:
      item -
      Returns:
      List The created ItemRenderers.
    • removeItem

      public List<ItemRenderer> removeItem(ChordLeadSheetItem<?> item)
      Remove an item from the BarBox.

      The operation requests each BarRenderer to remove the ItemRenderer if appropriate.

      Parameters:
      item -
      Returns:
      List The removed ItemRenderers. Can be an empty list.
    • setFocusOnItem

      public void setFocusOnItem(ChordLeadSheetItem<?> item, IR_Type irType)
      Set the focus on an ItemRenderer for item.
      Parameters:
      item -
      irType - The irType to search for. If null set focus on the first ItemRenderer found.
    • selectItem

      public void selectItem(ChordLeadSheetItem<?> item, boolean b)
      The operation requests each BarRenderer to select the ItemRenderers of item.
      Parameters:
      item -
      b -
    • isSelected

      public boolean isSelected()
    • setSelected

      public void setSelected(boolean b)
      Set the Component selected or not, forward to BarRenderers as well.
      Parameters:
      b -
    • setEnabled

      public void setEnabled(boolean b)
      Overrides:
      setEnabled in class JComponent
    • setZoomVFactor

      public void setZoomVFactor(int factor)
      Vertical zoom factor.
      Parameters:
      factor - 0=min zoom (bird's view), 100=max zoom
    • getZoomVFactor

      public int getZoomVFactor()
    • getDisplayQuantizationValue

      public Quantization getDisplayQuantizationValue()
    • setDisplayQuantizationValue

      public void setDisplayQuantizationValue(Quantization q)
      Set how chords positions are quantized for display.
      Parameters:
      q -
    • getModelBarIndex

      public int getModelBarIndex()
      The bar index in the chordleadsheet model.
      Returns:
      -1 if BarBox is past the end of chord leadsheet.
    • getBarIndex

      public int getBarIndex()
    • setBarIndex

      public void setBarIndex(int bar)
      Set the barIndex of this BarBox.

      Parameters:
      bar - A zero or positive value
    • setModelBarIndex

      public void setModelBarIndex(int bar)
      Set the barIndex within the model. Forward to BarRenderers.
      Parameters:
      bar - If < 0, it means information from model is not available (for example because the barIndex is past the end of the model.)
      Throws:
      IllegalArgumentException - If bar is > or equals to model's size.
    • getPositionFromPoint

      public Position getPositionFromPoint(Point barboxPoint)
      Return the position (bar, beat) which corresponds to a given point in the BarBox.
      Parameters:
      barboxPoint - A point in the BarBox coordinates.
      Returns:
      Null if point does not correspond to a valid bar.
    • moveItem

      public void moveItem(ChordLeadSheetItem<?> item)
      Request BarRenderers to update after an item has moved within the bar.
      Parameters:
      item -
    • getSection

      public CLI_Section getSection()
      Get the section this BarBox belongs to.
      Returns:
      Can be null if modelBarIndex==-1
    • setSection

      public void setSection(CLI_Section section)
      Request BarRenderers to update if the section they belong to has changed.
      Parameters:
      section -
    • getConfig

      public BarBoxConfig getConfig()
    • setConfig

      public final boolean setConfig(BarBoxConfig bbConfig)
      Set the BarBoxConfig of this BarBox.

      There must be at least 1 active BarRenderer.

      Parameters:
      bbConfig -
      Returns:
      boolean true if BarBoxConfig has been really changed, false otherwise (e.g. same value)
    • showInsertionPoint

      public void showInsertionPoint(boolean b, ChordLeadSheetItem<?> item, Position pos, boolean copyMode)
    • showPlaybackPoint

      public void showPlaybackPoint(boolean b, Position pos)
      Change background to represent the playback point in this bar. Then delegate to BarRenderers to render the point.
      Parameters:
      b -
      pos -
    • cleanup

      public void cleanup()
      Clean up everything so this object can be garbaged.
    • getBarRenderers

      public List<BarRenderer> getBarRenderers()
    • toString

      public String toString()
      Overrides:
      toString in class Component
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Specified by:
      propertyChange in interface PropertyChangeListener
    • focusGained

      public void focusGained(FocusEvent e)
      Specified by:
      focusGained in interface FocusListener
    • focusLost

      public void focusLost(FocusEvent e)
      Specified by:
      focusLost in interface FocusListener