Class BarRenderer

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

public abstract class BarRenderer extends JPanel implements PropertyChangeListener
Base class for BarRenderer.

A BarRenderer is a container for ItemRenderers. A BarRenderer has a barIndex and a modelBarIndex (the barIndex within the model). Both values are equal when showing bars within the model, but if showing a bar past the end of the model, modelBarIndex = -1.

See Also:
  • Constructor Details

    • BarRenderer

      public BarRenderer(CL_Editor editor, int barIndex, BarRendererSettings settings, ItemRendererFactory irf, Object groupKey)
      Construct a BarRenderer.
      Parameters:
      editor - Can be null
      barIndex - The barIndex of this BarRenderer.
      settings -
      irf -
      groupKey - A key object that allow several BarRenderer instances to share common objects
  • Method Details

    • setModel

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

      public ChordLeadSheet getModel()
    • getSettings

      public BarRendererSettings getSettings()
    • getCLI_Section

      public CLI_Section getCLI_Section()
      Get the current CLI_Section for this BarRenderer.
      Returns:
      Can be null if getModelBarIndex() == -1. The CLI_Section can be on this bar or a previous one.
    • getItemRendererFactory

      public ItemRendererFactory getItemRendererFactory()
    • getItemRenderers

      public List<ItemRenderer> getItemRenderers()
      Get all child components which are ItemRenderers.
      Returns:
    • addItemRenderer

      public ItemRenderer addItemRenderer(ChordLeadSheetItem<?> item)
      Add one ItemRenderer for item e.
      Parameters:
      item -
      Returns:
      ItemRenderer The object that has been created and added.
    • removeItemRenderer

      public ItemRenderer removeItemRenderer(ChordLeadSheetItem<?> item)
      Remove an ItemRenderer from this bar.
      Parameters:
      item -
      Returns:
      ItemRenderer The ItemRenderer that has been removed, or null if ItemRenderer was not found.
    • selectItem

      public void selectItem(ChordLeadSheetItem<?> item, boolean b)
    • setSelected

      public final void setSelected(boolean b)
      Set the Component selected or not.
      Parameters:
      b - Select the Component if b is true.
    • isSelected

      public final boolean isSelected()
    • setEnabled

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

      public abstract void setDisplayQuantizationValue(Quantization q)
    • getDisplayQuantizationValue

      public abstract Quantization getDisplayQuantizationValue()
    • setZoomVFactor

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

      public abstract int getZoomVFactor()
    • setBarIndex

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

      Some BarRenderer might use this information when rendering the bar.

      Parameters:
      bar - A zero or positive value
    • setModelBarIndex

      public void setModelBarIndex(int bar)
      Set the barIndex within the model.

      All items shown in this BarRenderer will belong to this bar.

      Parameters:
      bar - If < 0, it means information from model is not available (for example because the barIndex is past the end of the leadsheet.)
      Throws:
      IllegalArgumentException - If bar is > or equals to model's size.
    • moveItemRenderer

      public abstract void moveItemRenderer(ChordLeadSheetItem<?> item)
      Move one item of this bar.

      The new position is also within this bar.

      Parameters:
      item -
    • setSection

      public abstract void setSection(CLI_Section section)
      Set the section for this bar.
      Parameters:
      section -
    • isRegisteredItemClass

      public abstract boolean isRegisteredItemClass(ChordLeadSheetItem<?> item)
      Return True if this item's class is supported by this BarRenderer.
      Parameters:
      item -
      Returns:
    • showInsertionPoint

      public abstract void showInsertionPoint(boolean b, ChordLeadSheetItem<?> item, Position pos, boolean copyMode)
      Show or hide an insertion point for the specified item.
      Parameters:
      b - Show if true, hide if false.
      item -
      pos - The position of the insertion point
      copyMode -
    • showPlaybackPoint

      public abstract void showPlaybackPoint(boolean b, Position pos)
      Show or hide the playback point at specified position.
      Parameters:
      b - Show if true, hide if false.
      pos -
    • cleanup

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

      Model is set to null.

    • getItemRenderer

      public ItemRenderer getItemRenderer(ChordLeadSheetItem<?> item)
      Get the ItemRenderer of the specified item.
      Parameters:
      item -
      Returns:
      Can be null.
    • getBarIndex

      public int getBarIndex()
    • getModelBarIndex

      public int getModelBarIndex()
      The bar index in the chordleadsheet model.
      Returns:
      -1 if we're past the end of chord leadsheet.
    • getDrawingArea

      public Rectangle getDrawingArea()
      Get the available drawing area of the Bar.

      This implementation returns an area corresponding to getInsets() except the width is slightly reduced.

      Returns:
      A Rectangle object representing the available drawing area.
    • getEditor

      public CL_Editor getEditor()
      The editor to which this BarRenderer belongs to.
      Returns:
      Can be null
    • getGroupKey

      public Object getGroupKey()
      Get the group key to which this BarRenderer is linked.

      The groupKey can be used by BarRenderer instances to share objects between BarRenderer that belong to a same groupKey. It is used for example by getFontMetricsDialog() and BR_Chords.getPrefSizePanelSharedInstance().

      Returns:
      See Also:
    • toString

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

      public JDialog getFontMetricsDialog()
      Return a shared instance of a hidden JDialog used to get dimensions of Font-based objects.

      JDialog instances are shared between BarRenderers which have the same groupKey.

      Returns:
    • propertyChange

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