openpiano.notes
Class Blocks

java.lang.Object
  extended by openpiano.notes.Blocks

public class Blocks
extends Object

The Blocks class is a data-structure to handle single notes

Version:
1.0, 07/30/08
Author:
Sascha Westermann

Constructor Summary
Blocks(Controller controller, Settings settings, int keys, int tracks)
          Constructs a data structure for single notes
 
Method Summary
 void addNote(MidiNote midiNote, int key, int track, float refTicks, Boolean flatnote, float position)
          Adds a single note/block to the list
 int getNumKeys()
          Returns the number of used keys
 int getNumTracks()
          Return the number of used tracks
 void handleKeyPressed(LinkedList<Boolean> isVisualOn, LinkedList<Boolean> isAudioOn)
          Handles the keys pressed by the user according to the available notes
 void handleLateCleanup()
          Handle the blocks marked for late cleanup
 void setAwaitNotes(Boolean awaitNotes)
          Set the status of the await notes function
 void setCurrentPosition(float position)
          Sets the current position in the 3D environment
 void setCurrentTick(long tick)
          Sets the current tick
 void setKeyPressed(int key)
          Set a key on all tracks to status pressed
 void setKeyReleased(int key)
          Sets a key on all tracks to status released
 void setLastVisibleTick(long tick)
          Sets the distance of visible ticks
 void setMarkKeys(Boolean markKeys)
          Sets the status of the mark key function
 void setReverse(Boolean reverse)
          Sets the reverse status
 void showBlocks(int key, int track, Boolean useable, Boolean audio, Boolean visual, Boolean markKeys)
          Draw the blocks
 void updateBlocks(int key, int track, Boolean audio, Boolean visual)
          Updates the pointer to the current block
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Blocks

public Blocks(Controller controller,
              Settings settings,
              int keys,
              int tracks)
Constructs a data structure for single notes

Parameters:
controller - the main controller of the application
settings - the settings object
keys - the amount of keys of the piano
tracks - the amount of tracks in the MIDI file
Method Detail

addNote

public void addNote(MidiNote midiNote,
                    int key,
                    int track,
                    float refTicks,
                    Boolean flatnote,
                    float position)
Adds a single note/block to the list

Parameters:
midiNote - the note according to the MIDI file
key - the key as defined by the note
track - the track according to the MIDI file
refTicks - a reference for the displayed size
flatnote - true if note is a flat note
position - the position in 3d space according to the start tick of the note

getNumKeys

public int getNumKeys()
Returns the number of used keys

Returns:
the number of used keys

getNumTracks

public int getNumTracks()
Return the number of used tracks

Returns:
the number of used tracks

handleKeyPressed

public void handleKeyPressed(LinkedList<Boolean> isVisualOn,
                             LinkedList<Boolean> isAudioOn)
Handles the keys pressed by the user according to the available notes

Parameters:
isVisualOn - List of tracks, true if the track's video function is selected
isAudioOn - List of tracks, true if the track's audio function is selected

handleLateCleanup

public void handleLateCleanup()
Handle the blocks marked for late cleanup


setAwaitNotes

public void setAwaitNotes(Boolean awaitNotes)
Set the status of the await notes function

Parameters:
awaitNotes - true if await notes function should be enabled

setKeyPressed

public void setKeyPressed(int key)
Set a key on all tracks to status pressed

Parameters:
key - the relevant key

setKeyReleased

public void setKeyReleased(int key)
Sets a key on all tracks to status released

Parameters:
key - the relevant key

setCurrentPosition

public void setCurrentPosition(float position)
Sets the current position in the 3D environment

Parameters:
position - the current position

setCurrentTick

public void setCurrentTick(long tick)
Sets the current tick

Parameters:
tick - the current tick

setLastVisibleTick

public void setLastVisibleTick(long tick)
Sets the distance of visible ticks

Parameters:
tick - the visible ticks

setMarkKeys

public void setMarkKeys(Boolean markKeys)
Sets the status of the mark key function

Parameters:
markKeys - true if mark keys function should be enabled

setReverse

public void setReverse(Boolean reverse)
Sets the reverse status

Parameters:
reverse - true to set the reverse status

showBlocks

public void showBlocks(int key,
                       int track,
                       Boolean useable,
                       Boolean audio,
                       Boolean visual,
                       Boolean markKeys)
Draw the blocks

Parameters:
key - the relevant key
track - the relevant track
useable - true if corresponding key is playable
audio - true if audio function is selected
visual - true if video function is selected
markKeys - true if mark keys function is selected

updateBlocks

public void updateBlocks(int key,
                         int track,
                         Boolean audio,
                         Boolean visual)
Updates the pointer to the current block

Parameters:
key - the relevant key
track - the relevant track
audio - true if audio function is selected
visual - true if video function is selected