dguitar.gui
Class Bar

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bydguitar.gui.Bar
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, OptionsDisplay, java.io.Serializable
Direct Known Subclasses:
BarMTP

public abstract class Bar
extends javax.swing.JPanel
implements OptionsDisplay

This class represents a musicl bar (it contains a musical measure)

Author:
Mauricio Gracia Gutiérrez
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  java.awt.Color backGround
           
protected  BarPanel BP
           
private  java.lang.String denominator
          The denominator of the KeySignature
private  DisplayOptions displayOptions
           
protected  boolean displayTimeSignature
          is the Time Signature displayed
private  java.awt.Color foreGround
           
protected  boolean isFirst
          is this the first bar of a track
protected  boolean isLast
          is the last bar of a track
protected  GPMeasure measure
          If the Bar is link to a GPMeasure, this field is NOT null
protected  int minx
          the minimun X position to start drawing ;
private  java.lang.String numerator
          The numerator of the KeySignature
 int TS
          The width increased if the Time Signature is being displayed
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
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
Bar(DisplayOptions currentDisplayOptions, BarPanel bp)
          Creates a new instance of Bar based on a BarPanel
 
Method Summary
private  int calculateTS(java.awt.Graphics g)
           
protected abstract  int calculateWidth(int inc)
           
private  int calculateWidthInc()
          Calculate how mucho to INCrease the WIDTH of a bar because of repeteations
private  void commonConstructor()
           
 boolean equals(java.lang.Object o)
           
 boolean equalTimeSignature(Bar bar)
          This method returns true if This Time signature is equal to the Bar
 int getBottomOffset()
           
 DisplayOptions getDisplayOptions()
           
 boolean getExtendBottom()
           
 boolean getExtendTop()
           
 int getHeight()
          Returns the current height of this component.
 java.awt.Dimension getMaximumSize()
          if the maximum size has been set to a non-null value just returns it.
 GPMeasure getMeasure()
           
 java.awt.Dimension getMinimumSize()
           
abstract  MusicCursorPosition getMusicCursorPosition(int beat)
           
abstract  MusicCursorPosition getMusicCursorPosition(MusicCursor musicCursor)
           
 java.awt.Dimension getPreferredSize()
           
 int getTopOffset()
           
 int getWidth()
          Returns the current width of this component.
protected  void paintComponent(java.awt.Graphics gg)
          Calls the UI delegate's paint method, if the UI delegate is non-null.
protected  void paintMeasure(java.awt.Graphics g)
           
 void setBottomOffset(int bottomOffset)
           
 void setDisplayOptions(DisplayOptions displayOptions)
           
 void setExtendBottom(boolean value)
           
 void setExtendTop(boolean value)
           
 void setMeasure(GPMeasure m)
           
 void setTopOffset(int topOffset)
           
abstract  MusicCursorPosition snapX(int x, MusicCursor musicCursor)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TS

public int TS
The width increased if the Time Signature is being displayed


isFirst

protected boolean isFirst
is this the first bar of a track


isLast

protected boolean isLast
is the last bar of a track


displayOptions

private DisplayOptions displayOptions

displayTimeSignature

protected boolean displayTimeSignature
is the Time Signature displayed


minx

protected int minx
the minimun X position to start drawing ;


numerator

private java.lang.String numerator
The numerator of the KeySignature


denominator

private java.lang.String denominator
The denominator of the KeySignature


measure

protected GPMeasure measure
If the Bar is link to a GPMeasure, this field is NOT null


BP

protected BarPanel BP

backGround

private final java.awt.Color backGround

foreGround

private final java.awt.Color foreGround
Constructor Detail

Bar

public Bar(DisplayOptions currentDisplayOptions,
           BarPanel bp)
Creates a new instance of Bar based on a BarPanel

Method Detail

commonConstructor

private void commonConstructor()

setDisplayOptions

public void setDisplayOptions(DisplayOptions displayOptions)
Specified by:
setDisplayOptions in interface OptionsDisplay
Parameters:
displayOptions - The displayOptions to set.

getDisplayOptions

public DisplayOptions getDisplayOptions()
Specified by:
getDisplayOptions in interface OptionsDisplay
Returns:
Returns the displayOptions.

equalTimeSignature

public boolean equalTimeSignature(Bar bar)
This method returns true if This Time signature is equal to the Bar


equals

public boolean equals(java.lang.Object o)

getTopOffset

public int getTopOffset()

setTopOffset

public void setTopOffset(int topOffset)

getBottomOffset

public int getBottomOffset()

setBottomOffset

public void setBottomOffset(int bottomOffset)

getExtendTop

public boolean getExtendTop()

setExtendTop

public void setExtendTop(boolean value)

getExtendBottom

public boolean getExtendBottom()

setExtendBottom

public void setExtendBottom(boolean value)

getMeasure

public GPMeasure getMeasure()

setMeasure

public void setMeasure(GPMeasure m)

calculateTS

private int calculateTS(java.awt.Graphics g)

calculateWidthInc

private int calculateWidthInc()
Calculate how mucho to INCrease the WIDTH of a bar because of repeteations


paintMeasure

protected void paintMeasure(java.awt.Graphics g)

getHeight

public int getHeight()
Returns the current height of this component. this method is preferable to writing component.getBounds().height, or component.getSize().height because it doesn't cause any heap allocations.

Returns:
the current height of this component

calculateWidth

protected abstract int calculateWidth(int inc)

getMusicCursorPosition

public abstract MusicCursorPosition getMusicCursorPosition(int beat)

getMusicCursorPosition

public abstract MusicCursorPosition getMusicCursorPosition(MusicCursor musicCursor)

snapX

public abstract MusicCursorPosition snapX(int x,
                                          MusicCursor musicCursor)

getWidth

public int getWidth()
Returns the current width of this component. this method is preferable to writing component.getBounds().width, or component.getSize().width because it doesn't cause any heap allocations.

Returns:
the current width of this component

getMinimumSize

public java.awt.Dimension getMinimumSize()

getPreferredSize

public java.awt.Dimension getPreferredSize()

paintComponent

protected void paintComponent(java.awt.Graphics gg)
Calls the UI delegate's paint method, if the UI delegate is non-null. We pass the delegate a copy of the Graphics object to protect the rest of the paint code from irrevocable changes (for example, Graphics.translate).

if you override this in a subclass you should not make permanent changes to the passed in Graphics. for example, you should not alter the clip Rectangle or modify the transform. if you need to do these operations you may find it easier to create a new Graphics from the passed in Graphics and manipulate it. Further, if you do not invoker super's implementation you must honor the opaque property, that is if this component is opaque, you must completely fill in the background in a non-opaque color. if you do not honor the opaque property you will likely see visual artifacts.

Parameters:
gg - the Graphics object to protect
See Also:
Component.paint(java.awt.Graphics)

getMaximumSize

public java.awt.Dimension getMaximumSize()
if the maximum size has been set to a non-null value just returns it. if the UI delegate's getMaximumSize method returns a non-null value then return that; otherwise defer to the component's layout manager.

Returns:
the value of the maximumSize property