com.frinika.sequencer.model
Class MidiPartGhost

java.lang.Object
  extended by com.frinika.sequencer.model.Part
      extended by com.frinika.sequencer.model.MidiPart
          extended by com.frinika.sequencer.model.MidiPartGhost
All Implemented Interfaces:
Item, CommitListener, EditHistoryRecordable, EditHistoryRecorder<MultiEvent>, Ghost, MenuPlugable, Selectable, java.io.Serializable

public class MidiPartGhost
extends MidiPart
implements Ghost, CommitListener

Ghost ("reference-copy") of a MidiPart. Ghosts appear as Parts in the Tracker-view, but do not contain their own events. Instead, Ghosts are internally linked to the origial Part from which they have been created. They represent the original Part transparently, but are not editable themselves. All changed applied to the original Part will immediately take effect on Ghosts also.

Author:
Jens Gulden
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.frinika.sequencer.model.MidiPart
MidiPart.MidiPartPropertiesPanel
 
Nested classes/interfaces inherited from class com.frinika.sequencer.model.Part
Part.PropertiesPanel
 
Field Summary
 
Fields inherited from class com.frinika.sequencer.model.Part
lane, selected
 
Constructor Summary
MidiPartGhost(MidiPart referredPart, Lane lane)
           
MidiPartGhost(MidiPart referredPart, long deltaTicks)
           
 
Method Summary
 void add(MultiEvent ev)
          Add a MultiEvent to the track.
 void addToModel()
          Add to the model making sure the history is informed
 java.lang.Object clone()
          If restoration from a clone is needed - this method should return a clone otherwise throw the CloneNotSupportedException
protected  MultiEvent commitAddClone(MultiEvent multiEvent)
           
 void commitAddPerformed(MultiEvent event)
          Called when the original MidiPart has undergone changes.
 void commitEventsAdd()
           
 void commitEventsRemove()
          Called when part is removed from the model
protected  void commitRemoveClone(MultiEvent multiEvent)
           
 void commitRemovePerformed(MultiEvent event)
          Called when the original MidiPart has undergone changes.
 void copyBy(double deltaTick, Lane dst)
           
 Selectable deepCopy(Selectable parent)
          Complete copy of object.
 void deepMove(long tick)
          Move object and all children by tick
 void displayStructure(java.lang.String prefix, java.io.PrintStream out)
           
 void drawThumbNail(java.awt.Graphics2D g, java.awt.Rectangle rect, PartView panel)
           
 java.awt.Color getColor()
           
 long getDistance()
           
 long getDurationInTicks()
           
 EditHistoryContainer getEditHistoryContainer()
           
 long getEndTick()
           
 java.awt.Rectangle getEventBounds()
           
 Lane getLane()
           
 int getMidiChannel()
           
 java.util.SortedSet<MultiEvent> getMultiEvents()
          Returns the multievent array.
 java.util.SortedSet<MultiEvent> getMultiEventSubset(long startTick, long endTick)
          Returns a subset of the multievent array including startTick excluding endTick
 java.lang.String getName()
           
 int[] getPitchRange()
          deprecated
 MidiPart getReferredPart()
           
 long getStartTick()
           
 FrinikaTrackWrapper getTrack()
           
 void importFromMidiTrack(long startTickArg, long endTickArg)
          Import Midi events into a Part from a section of track.
 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)
          Moves the part and all it contains by deltaTick.
 void moveContentsBy(double dTick, Lane dstLane)
          move the contents by tick into dstLane
protected  void moveItemsBy(long deltaTick)
          Make sure part is detached before calling this then reattach after This operation does not change the database rep so we do not call setChanged()
 void onLoad()
          Commit the MultiEvents as MidiEvents to a Sequencers Track event list.
 void rebuildMultiEventEndTickComparables()
           
 void remove(MultiEvent multiEvent)
          Remove a MultiEvent from the track
 void removeFromModel()
          Remove from model making sure the history is informed
 void restoreFromClone(EditHistoryRecordable o)
          On removal the EditHistoryContainer will attempt to clone the object - and if restored later it will use the restoreFromClone method to restore the cloned data on the original instance.
 long rightTickForMove()
           
 void setBoundsFromEvents()
          Rebuild the bounds from the multievent startTicks
 void setEndTick(double tick)
           
 void setName(java.lang.String name)
           
 void setReferredPart(MidiPart referredPart)
           
 void setSelected(boolean b)
          used by the GUI
 void setStartTick(double tick)
          NOTE AudioPert overrides these methods Set the start tick.
 
Methods inherited from class com.frinika.sequencer.model.MidiPart
addCommitListener, createPropertiesPanel, importFromMidiTrack, initContextMenu, removeCommitListener
 
Methods inherited from class com.frinika.sequencer.model.Part
addPluginRightButtonMenu, createPropertiesDialog, getDuration, getDurationInSecs, getEditParent, getEnd, getEndInSecs, getMultiPart, getPartResourceId, getRootPart, getStart, getStartInSecs, getTransparentColor, isAttached, setChanged, setColor, setEditParent, setEndInSecs, setMultiPart, setPartResourceId, setRootPart, setStartInSecs, showContextMenu, showPropertiesDialog, showRightButtonMenu
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MidiPartGhost

public MidiPartGhost(MidiPart referredPart,
                     Lane lane)

MidiPartGhost

public MidiPartGhost(MidiPart referredPart,
                     long deltaTicks)
Method Detail

getReferredPart

public MidiPart getReferredPart()
Specified by:
getReferredPart in interface Ghost

setReferredPart

public void setReferredPart(MidiPart referredPart)

getDistance

public long getDistance()

add

public void add(MultiEvent ev)
Description copied from class: MidiPart
Add a MultiEvent to the track. The client is responsible for adjusting the Part bounds is need be.

Specified by:
add in interface EditHistoryRecorder<MultiEvent>
Overrides:
add in class MidiPart

clone

public 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 MidiPart
Returns:
Throws:
java.lang.CloneNotSupportedException

commitEventsAdd

public void commitEventsAdd()
Overrides:
commitEventsAdd in class MidiPart

commitEventsRemove

public void commitEventsRemove()
Description copied from class: Part
Called when part is removed from the model

Overrides:
commitEventsRemove in class MidiPart

commitAddPerformed

public void commitAddPerformed(MultiEvent event)
Called when the original MidiPart has undergone changes.

Specified by:
commitAddPerformed in interface CommitListener
Parameters:
event - note that MultiEvent is not a subclass of Java's Event class, here the source-object is directly passed as parameter to the listener-method without being wrapped in an Event

commitRemovePerformed

public void commitRemovePerformed(MultiEvent event)
Called when the original MidiPart has undergone changes.

Specified by:
commitRemovePerformed in interface CommitListener
Parameters:
event - note that MultiEvent is not a subclass of Java's Event class, here the source-object is directly passed as parameter to the listener-method without being wrapped in an Event

commitAddClone

protected MultiEvent commitAddClone(MultiEvent multiEvent)

commitRemoveClone

protected void commitRemoveClone(MultiEvent multiEvent)

copyBy

public void copyBy(double deltaTick,
                   Lane dst)
Overrides:
copyBy in class MidiPart

deepCopy

public Selectable deepCopy(Selectable parent)
Description copied from interface: Selectable
Complete copy of object.

Specified by:
deepCopy in interface Selectable
Overrides:
deepCopy in class MidiPart
Parameters:
parent - owner of the new object;
Returns:

deepMove

public void deepMove(long tick)
Description copied from interface: Selectable
Move object and all children by tick

Specified by:
deepMove in interface Selectable
Overrides:
deepMove in class MidiPart

drawThumbNail

public void drawThumbNail(java.awt.Graphics2D g,
                          java.awt.Rectangle rect,
                          PartView panel)
Overrides:
drawThumbNail in class MidiPart

getEditHistoryContainer

public EditHistoryContainer getEditHistoryContainer()
Overrides:
getEditHistoryContainer in class MidiPart

getMidiChannel

public int getMidiChannel()
Overrides:
getMidiChannel in class MidiPart

getMultiEvents

public java.util.SortedSet<MultiEvent> getMultiEvents()
Description copied from class: MidiPart
Returns the multievent array.

Overrides:
getMultiEvents in class MidiPart
Returns:

getMultiEventSubset

public java.util.SortedSet<MultiEvent> getMultiEventSubset(long startTick,
                                                           long endTick)
Description copied from class: MidiPart
Returns a subset of the multievent array including startTick excluding endTick

Overrides:
getMultiEventSubset in class MidiPart
Returns:

getName

public java.lang.String getName()
Overrides:
getName in class MidiPart

getPitchRange

public int[] getPitchRange()
Description copied from class: MidiPart
deprecated

Overrides:
getPitchRange in class MidiPart

getTrack

public FrinikaTrackWrapper getTrack()
Overrides:
getTrack in class MidiPart

importFromMidiTrack

public void importFromMidiTrack(long startTickArg,
                                long endTickArg)
Description copied from class: MidiPart
Import Midi events into a Part from a section of track. Notes with start ticks in the range and inserted and the end events will be found and added. (So end events may be outside the bounds)

Overrides:
importFromMidiTrack in class MidiPart
Parameters:
startTickArg - start tick (inclusive)
endTickArg - end tick (exclusive)

moveContentsBy

public void moveContentsBy(double dTick,
                           Lane dstLane)
Description copied from class: Part
move the contents by tick into dstLane

Overrides:
moveContentsBy in class MidiPart

moveItemsBy

protected void moveItemsBy(long deltaTick)
Description copied from class: MidiPart
Make sure part is detached before calling this then reattach after This operation does not change the database rep so we do not call setChanged()

Overrides:
moveItemsBy in class MidiPart

onLoad

public void onLoad()
Description copied from class: MidiPart
Commit the MultiEvents as MidiEvents to a Sequencers Track event list.

Overrides:
onLoad in class MidiPart

rebuildMultiEventEndTickComparables

public void rebuildMultiEventEndTickComparables()
Overrides:
rebuildMultiEventEndTickComparables in class MidiPart

remove

public void remove(MultiEvent multiEvent)
Description copied from class: MidiPart
Remove a MultiEvent from the track

Specified by:
remove in interface EditHistoryRecorder<MultiEvent>
Overrides:
remove in class MidiPart

restoreFromClone

public void restoreFromClone(EditHistoryRecordable o)
Description copied from interface: EditHistoryRecordable
On removal the EditHistoryContainer will attempt to clone the object - and if restored later it will use the restoreFromClone method to restore the cloned data on the original instance.

Specified by:
restoreFromClone in interface EditHistoryRecordable
Overrides:
restoreFromClone in class MidiPart

setBoundsFromEvents

public void setBoundsFromEvents()
Description copied from class: MidiPart
Rebuild the bounds from the multievent startTicks

Overrides:
setBoundsFromEvents in class MidiPart

setName

public void setName(java.lang.String name)
Overrides:
setName in class MidiPart

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
Overrides:
addToModel in class Part

displayStructure

public void displayStructure(java.lang.String prefix,
                             java.io.PrintStream out)
Overrides:
displayStructure in class Part

getColor

public java.awt.Color getColor()
Overrides:
getColor in class Part

getDurationInTicks

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

getEndTick

public long getEndTick()
Overrides:
getEndTick in class Part
Returns:
end tick of the part

getEventBounds

public java.awt.Rectangle getEventBounds()
Overrides:
getEventBounds in class Part

getLane

public Lane getLane()
Specified by:
getLane in interface Ghost
Overrides:
getLane in class Part
Returns:
the Lane that contains the Part

getStartTick

public long getStartTick()
Specified by:
getStartTick in interface Ghost
Overrides:
getStartTick in class Part
Returns:
start of the part in ticks

isSelected

public boolean isSelected()
Description copied from class: Part
used by the GUI

Specified by:
isSelected in interface Item
Overrides:
isSelected in class Part

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
Overrides:
leftTickForMove in class Part
Returns:

moveBy

public void moveBy(long deltaTick)
Description copied from class: Part
Moves the part and all it contains by deltaTick. Concrete subclasses implement moveItemsBy method to move the contents of the Part.

Overrides:
moveBy in class Part

removeFromModel

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

Specified by:
removeFromModel in interface Selectable
Overrides:
removeFromModel in class Part

rightTickForMove

public long rightTickForMove()
Specified by:
rightTickForMove in interface Selectable
Overrides:
rightTickForMove in class Part

setEndTick

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

setSelected

public void setSelected(boolean b)
Description copied from class: Part
used by the GUI

Specified by:
setSelected in interface Item
Specified by:
setSelected in interface Selectable
Overrides:
setSelected in class Part

setStartTick

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

Overrides:
setStartTick in class Part
Parameters:
tick - new start tick