com.frinika.sequencer.model
Class Part

java.lang.Object
  extended by com.frinika.sequencer.model.Part
All Implemented Interfaces:
Item, EditHistoryRecordable, MenuPlugable, Selectable, java.io.Serializable
Direct Known Subclasses:
AudioPart, MidiPart, TextPart

public abstract class Part
extends java.lang.Object
implements Item, Selectable, EditHistoryRecordable, java.io.Serializable, MenuPlugable

A Part encapsulates what can be displayed in the partview. The startTick and endTick define the range in the display. (These do not need to correspond to the range of any contained items) It's Lane defines the row of display.

Author:
Paul
See Also:
Serialized Form

Nested Class Summary
protected  class Part.PropertiesPanel
          Optionally to be extended by subclass and returned via createProperitesPanel().
 
Field Summary
protected  Lane lane
           
protected  boolean selected
           
 
Constructor Summary
protected Part()
           
  Part(Lane lane)
          Construct a new Part and add it to it's lane.
 
Method Summary
static void addPluginRightButtonMenu(MenuPlugin menuPlugin)
          Allow custom menus to be added.
 void addToModel()
          Add to the model making sure the history is informed
abstract  java.lang.Object clone()
          If restoration from a clone is needed - this method should return a clone otherwise throw the CloneNotSupportedException
abstract  void commitEventsAdd()
           
abstract  void commitEventsRemove()
          Called when part is removed from the model
abstract  void copyBy(double tick, Lane dst)
           
protected  javax.swing.JDialog createPropertiesDialog(ProjectFrame frame)
           
protected  OptionsEditor createPropertiesPanel(ProjectFrame frame)
          Create PropertiesPanel.
 void displayStructure(java.lang.String prefix, java.io.PrintStream out)
           
abstract  void drawThumbNail(java.awt.Graphics2D g, java.awt.Rectangle rect, PartView partView)
           
 java.awt.Color getColor()
           
 double getDuration(boolean sampleBased)
           
 double getDurationInSecs()
           
 long getDurationInTicks()
           
 Part getEditParent()
           
 double getEnd(boolean sampleBased)
           
 double getEndInSecs()
           
 long getEndTick()
           
 java.awt.Rectangle getEventBounds()
           
 Lane getLane()
           
 MultiPart getMultiPart()
           
 java.lang.Long getPartResourceId()
           
 Part getRootPart()
           
 double getStart(boolean sampleBased)
           
 double getStartInSecs()
           
 long getStartTick()
           
 java.awt.Color getTransparentColor()
           
protected  void initContextMenu(ProjectFrame frame, javax.swing.JPopupMenu popup)
          Fills the context menu with part-type specific (or possibly even instance-specific) items.
 boolean isAttached()
           
 boolean isSelected()
          used by the GUI
 long leftTickForMove()
          return the left tick mark for move operations without quantize a move to destTick should move item by destTick - leftTickForMove();
 void moveBy(long deltaTick)
          Deprecated.  
abstract  void moveContentsBy(double tick, Lane dstLane)
          move the contents by tick into dstLane
protected abstract  void moveItemsBy(long deltaTick)
          Deprecated.  
abstract  void onLoad()
           
 void removeFromModel()
          Remove from model making sure the history is informed
 long rightTickForMove()
           
 void setChanged()
          Must be called if structure is changed.
 void setColor(java.awt.Color col)
           
 void setEditParent(Part editParent)
           
 void setEndInSecs(double end)
           
 void setEndTick(double tick)
           
 void setMultiPart(MultiPart multiPart)
           
 void setPartResourceId(java.lang.Long partResourceId)
           
 void setRootPart(Part rootPart)
           
 void setSelected(boolean b)
          used by the GUI
 void setStartInSecs(double start)
           
 void setStartTick(double tick)
          NOTE AudioPert overrides these methods Set the start tick.
 void showContextMenu(ProjectFrame frame, java.awt.Component invoker, int x, int y)
          Shows the right-click context menu of the current component.
 void showPropertiesDialog(ProjectFrame frame)
           
 boolean showRightButtonMenu(java.awt.Component invoker, int x, int y)
          Override to customize the right button popup
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.frinika.sequencer.model.Selectable
deepCopy, deepMove
 
Methods inherited from interface com.frinika.sequencer.model.EditHistoryRecordable
restoreFromClone
 

Field Detail

lane

protected Lane lane

selected

protected transient boolean selected
Constructor Detail

Part

protected Part()

Part

public Part(Lane lane)
Construct a new Part and add it to it's lane.

Parameters:
lane -
Method Detail

getEditParent

public Part getEditParent()

setEditParent

public void setEditParent(Part editParent)

getRootPart

public Part getRootPart()

setRootPart

public void setRootPart(Part rootPart)

getPartResourceId

public java.lang.Long getPartResourceId()

setPartResourceId

public void setPartResourceId(java.lang.Long partResourceId)

getLane

public Lane getLane()
Returns:
the Lane that contains the Part

getDurationInTicks

public long getDurationInTicks()
Returns:
length of the part in ticks

getStartTick

public long getStartTick()
Returns:
start of the part in ticks

getEndTick

public long getEndTick()
Returns:
end tick of the part

getDurationInSecs

public double getDurationInSecs()
Returns:
length of the part in samples

getStartInSecs

public double getStartInSecs()
Returns:
start of the part in samples

getEndInSecs

public double getEndInSecs()
Returns:
end samples of the part

getDuration

public double getDuration(boolean sampleBased)
Returns:
length of the part

getStart

public double getStart(boolean sampleBased)
Returns:
start of the part

getEnd

public double getEnd(boolean sampleBased)
Returns:
end of the part

isSelected

public boolean isSelected()
used by the GUI

Specified by:
isSelected in interface Item

setSelected

public void setSelected(boolean b)
used by the GUI

Specified by:
setSelected in interface Item
Specified by:
setSelected in interface Selectable

setStartTick

public void setStartTick(double tick)
NOTE AudioPert overrides these methods Set the start tick. This does not effect any items contained in the part. Purely for display.

Parameters:
tick - new start tick

setEndTick

public void setEndTick(double tick)
Parameters:
tick - new end tick for display purpose only

setStartInSecs

public void setStartInSecs(double start)

setEndInSecs

public void setEndInSecs(double end)

moveBy

public void moveBy(long deltaTick)
Deprecated. 

Moves the part and all it contains by deltaTick. Concrete subclasses implement moveItemsBy method to move the contents of the Part.

Parameters:
tick -

moveItemsBy

protected abstract void moveItemsBy(long deltaTick)
Deprecated. 


clone

public abstract java.lang.Object clone()
                                throws java.lang.CloneNotSupportedException
Description copied from interface: EditHistoryRecordable
If restoration from a clone is needed - this method should return a clone otherwise throw the CloneNotSupportedException

Specified by:
clone in interface EditHistoryRecordable
Overrides:
clone in class java.lang.Object
Returns:
Throws:
java.lang.CloneNotSupportedException

commitEventsAdd

public abstract void commitEventsAdd()

commitEventsRemove

public abstract void commitEventsRemove()
Called when part is removed from the model


copyBy

public abstract void copyBy(double tick,
                            Lane dst)

moveContentsBy

public abstract void moveContentsBy(double tick,
                                    Lane dstLane)
move the contents by tick into dstLane

Parameters:
tick -

removeFromModel

public void removeFromModel()
Description copied from interface: Selectable
Remove from model making sure the history is informed

Specified by:
removeFromModel in interface Selectable

isAttached

public boolean isAttached()
Returns:
if part is part of the model.

addToModel

public void addToModel()
Description copied from interface: Selectable
Add to the model making sure the history is informed

Specified by:
addToModel in interface Selectable

leftTickForMove

public long leftTickForMove()
Description copied from interface: Selectable
return the left tick mark for move operations without quantize a move to destTick should move item by destTick - leftTickForMove();

Specified by:
leftTickForMove in interface Selectable
Returns:

rightTickForMove

public long rightTickForMove()
Specified by:
rightTickForMove in interface Selectable

getEventBounds

public java.awt.Rectangle getEventBounds()

onLoad

public abstract void onLoad()
                     throws java.lang.Exception
Throws:
java.lang.Exception

drawThumbNail

public abstract void drawThumbNail(java.awt.Graphics2D g,
                                   java.awt.Rectangle rect,
                                   PartView partView)

displayStructure

public void displayStructure(java.lang.String prefix,
                             java.io.PrintStream out)

showRightButtonMenu

public boolean showRightButtonMenu(java.awt.Component invoker,
                                   int x,
                                   int y)
Override to customize the right button popup

Parameters:
invoker -
x -
y -
Returns:

addPluginRightButtonMenu

public static void addPluginRightButtonMenu(MenuPlugin menuPlugin)
Allow custom menus to be added. This will appear at the top of the right button popup menu.

Parameters:
menuPlugin -

showContextMenu

public void showContextMenu(ProjectFrame frame,
                            java.awt.Component invoker,
                            int x,
                            int y)
Shows the right-click context menu of the current component.

Parameters:
frame -
invoker -
x -
y -

initContextMenu

protected void initContextMenu(ProjectFrame frame,
                               javax.swing.JPopupMenu popup)
Fills the context menu with part-type specific (or possibly even instance-specific) items. TO BE EXTENDED BY SUBCLASSES.

Parameters:
popup -

getTransparentColor

public java.awt.Color getTransparentColor()

getColor

public java.awt.Color getColor()

setColor

public void setColor(java.awt.Color col)

showPropertiesDialog

public void showPropertiesDialog(ProjectFrame frame)

createPropertiesDialog

protected javax.swing.JDialog createPropertiesDialog(ProjectFrame frame)

createPropertiesPanel

protected OptionsEditor createPropertiesPanel(ProjectFrame frame)
Create PropertiesPanel. Optionally overwritten by subclass, returning a subclass-instance of PropertiesPanel.

Parameters:
frame -
Returns:

getMultiPart

public MultiPart getMultiPart()

setMultiPart

public void setMultiPart(MultiPart multiPart)

setChanged

public void setChanged()
Must be called if structure is changed. - the database partResourceID is set to null (flag for new) - rootPart is set to this. - if we have edited a copied part then