org.utgenome.gwt.utgb.client.track
Class TrackGroup

java.lang.Object
  extended by org.utgenome.gwt.utgb.client.track.TrackGroup
All Implemented Interfaces:
Comparable<TrackGroup>, TrackEntry
Direct Known Subclasses:
OldUTGBTrackGroup

public class TrackGroup
extends Object
implements TrackEntry, Comparable<TrackGroup>

A TrackGroup manages a set of tracks. You can create a track group with several tracks by using addTrack(Track) method. Every TrackGroup can have several child TrackGroups. For example, when a TrackGroup A has a set of tracks [T1, T2, T3], and another TrackGroup B consists of [T4, T5], addTrackGroup(TrackGroup) to the TrackGroup A yields a nested track group: [T1, T2, T3, [T4, T5]].

Broadcasts to this track group are send to all tracks in this group, including T1, T2, T3 and the track group B([T4, T5]). However, T4 and T5 do not recieve this broadcast message directly, since it is subsumed in onParentTrackGroupPropertyChange(TrackGroupPropertyChange) and onParentTrackWindowChange(TrackWindow) method in the track group B. So, whether bypassing broadcast messages into child tracks or not depends on your TrackGroup implementation. In the default implementation of TrackGroup (i.e. TrackGroupBase), onParentTrackGroupPropertyChange(TrackGroupPropertyChange) and onParentTrackWindowChange(TrackWindow) methods just ignore such broadcast messages from the parent group. In order to recieve broadcast messages from the parent group, override onParentTrackGroupPropertyChange(TrackGroupPropertyChange) or onParentTrackWindowChange(TrackWindow) methods as follows: public void onParentTrackGroupPropertyChange(TrackGroupPropertyChange change) { change.apply(getPropertyWriter()); } public void onParentTrackWindowChange(TrackWindow newWindow) { getPropertyWriter().setTrackWindow(newWindow); } Changes to the TrackGroupPropertyWriter are automatically broadcasted to tracks in the group.

TrackGroup has another important role to localize broadcast message within a TrackGroup. For example, a broadcast message within the TrackGroup B is send to the track T4 and T5 only; tracks T1, T2, and T3 do not recieve this localized broadcast message.

When you want to use common variables shared within a track group, extend TrackGroup class and put these variables as field parameters of this extention.

Author:
leo

Nested Class Summary
static class HasFactory.TrackGroupFactory
           
 
Field Summary
protected  TrackLayoutManager _layoutManager
           
protected  boolean _notifyResize
           
protected  TrackGroup _parentTrackGroup
           
protected  ArrayList<TrackUpdateListener> _trackEventListenerList
           
protected  ArrayList<TrackGroup> _trackGroupList
           
protected  String _trackGroupName
           
protected  TrackGroupPropertyImpl _trackGroupProperty
           
protected  ArrayList<Track> _trackList
           
 
Constructor Summary
TrackGroup(String trackGroupName)
           
 
Method Summary
 void addTrack(Track track)
          Add a new track to this group.
 void addTrackGroup(TrackGroup trackGroup)
          Add a track group as a child of this track group.
 void addTrackGroupPropertyChangeListener(TrackGroupPropertyChangeListener listener)
          Add a TrackGroupPropertyChangeListener
 void addTrackUpdateListener(TrackUpdateListener listener)
          Add a TrackUpdateListener
 void broadcastChange(TrackGroupPropertyChange change, TrackWindow newWindow)
          Broadcast the property change to all of the tracks in this track group.
 void broadCastScrollTrackWindow(double scrollPercentage)
           
 void broadCastWindowSizeChange(int scaleDiff)
           
 void clear()
           
 int compareTo(TrackGroup o)
           
static TrackGroup createTrackGroup(TrackView view)
          Create a track group from a given TrackView
static HasFactory.TrackGroupFactory factory()
           
 List<Track> getAllTrackList()
          Get the list of tracks containd in this group, including tracks within the sub groups.
 BrowserServiceAsync getBrowserService()
           
protected  String getClassName()
           
 int getHeight()
           
 String getName()
          Get the entry name
 TrackGroup getParentTrackGroup()
          Return the current parent trackgroup.
 String getProperty(String key)
           
 String getProperty(String key, String defaultValue)
           
 TrackGroupProperty getPropertyReader()
          Get the TrackGroupProperty of this track group
 TrackGroupPropertyWriter getPropertyWriter()
          Get the TrackGroupPropertyWriter of this track group.
 TrackGroup getRootTrackGroup()
          Get the root TrackGroup
 List<TrackEntry> getTrackEntryList()
          Get the list of TrackEntrys, including both of Track and TrackGroup.
 List<TrackGroup> getTrackGroupList()
          Get the list of track groups containd in this group, excluding track groups within the sub groups.
 String getTrackGroupName()
           
 int getTrackIndex(Track track)
          Return the index of the given track in the group.
 List<Track> getTrackList()
          Get the list of tracks containd in this group, excluding tracks within the sub groups.
 TrackWindow getTrackWindow()
          Get the TrackWindow of this track group
 void insertTrack(Track track, int beforeIndex)
          Insert a new track before the specified index
 boolean isTrack()
          Test whether this entry is Track or not.
 boolean isTrackGroup()
          Test whether this entry is TrackGroup or not
 void notifyResize()
          Notify the change of the inner track widget size to this group
 void onParentChange(TrackGroupPropertyChange change, TrackWindow newWindow)
           
 void onParentTrackGroupPropertyChange(TrackGroupPropertyChange change)
          An event handler when the TrackGroupProperty of the parent group has changed.
 void onParentTrackWindowChange(TrackWindow newWindow)
          An event handler when the TrackWindow of this group has changed.
 void redrawAll()
          Redraw all child tracks, including tracks within the sub groups.
protected  void removeParentTrackGroup()
           
 void removeTrack(Track track)
          Remove the specified track from this group.
 void removeTrackGroup(TrackGroup trackGroup)
          Removed the specified track group and its belonging tracks from this group.
 void removeTrackGroupPropertyChangeListener(TrackGroupPropertyChangeListener listener)
          Remove the specified TrackGroupPropertyChangeListener
 void removeTrackUpdateListener(TrackUpdateListener listener)
          Remove the specified TrackUpdateListener
protected  void setParentTrackGroup(TrackGroup parentTrackGroup)
           
 void setResizeNotification(boolean enable)
          enable/disable notification of track frame resizes
 void setTrackGroupName(String newTrackGroupName)
           
protected  void setTrackGroupProperty(TrackGroupProperty trackGroupProperty)
           
protected  void setTrackGroupProperty(TrackGroupPropertyImpl trackGroupProperty)
           
 void setTrackLayoutManager(TrackLayoutManager layout)
           
 void setTrackWindow(TrackWindow newWindow)
          Set the track window (window size, start on genome, end on genome) at once
 void setTrackWindowLocation(int startOnGenome, int endOnGenome)
          Set the window location on the genome.
 void setTrackWindowWidth(int windowWidth)
          Set the width of the track window of this group.
protected  void storeInternalProperties(Properties saveData)
          Save (store) the internal properties of this track group into the given Properties
 void toXML(XMLWriter xmlWriter)
          Output the state of this track group into XMLWriter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_trackList

protected ArrayList<Track> _trackList

_trackGroupList

protected ArrayList<TrackGroup> _trackGroupList

_trackGroupProperty

protected TrackGroupPropertyImpl _trackGroupProperty

_trackEventListenerList

protected ArrayList<TrackUpdateListener> _trackEventListenerList

_layoutManager

protected TrackLayoutManager _layoutManager

_parentTrackGroup

protected TrackGroup _parentTrackGroup

_trackGroupName

protected String _trackGroupName

_notifyResize

protected boolean _notifyResize
Constructor Detail

TrackGroup

public TrackGroup(String trackGroupName)
Method Detail

factory

public static HasFactory.TrackGroupFactory factory()

clear

public void clear()

addTrack

public void addTrack(Track track)
Add a new track to this group.

Parameters:
track -

insertTrack

public void insertTrack(Track track,
                        int beforeIndex)
Insert a new track before the specified index

Parameters:
track -
beforeIndex -

addTrackGroup

public void addTrackGroup(TrackGroup trackGroup)
Add a track group as a child of this track group. Broadcasts to the parent track group will be notified to its child track groups. Note: TrackUpdateListeners added to the parent track group are propagated to the inserted trackGroup.

Parameters:
trackGroup -

broadcastChange

public void broadcastChange(TrackGroupPropertyChange change,
                            TrackWindow newWindow)
Broadcast the property change to all of the tracks in this track group.

Parameters:
change - changes of track properties

broadCastScrollTrackWindow

public void broadCastScrollTrackWindow(double scrollPercentage)

broadCastWindowSizeChange

public void broadCastWindowSizeChange(int scaleDiff)

getPropertyReader

public TrackGroupProperty getPropertyReader()
Get the TrackGroupProperty of this track group

Returns:

getProperty

public String getProperty(String key,
                          String defaultValue)

getProperty

public String getProperty(String key)

getPropertyWriter

public TrackGroupPropertyWriter getPropertyWriter()
Get the TrackGroupPropertyWriter of this track group. Any modification via the setter methods in the TrackGroupPropertyWriter will be broadcasted to this group via #onParentTrackGroupPropertyChange(TrackGroupProperty).

Returns:

getTrackGroupList

public List<TrackGroup> getTrackGroupList()
Get the list of track groups containd in this group, excluding track groups within the sub groups.

Returns:

getTrackList

public List<Track> getTrackList()
Get the list of tracks containd in this group, excluding tracks within the sub groups.

Returns:

getAllTrackList

public List<Track> getAllTrackList()
Get the list of tracks containd in this group, including tracks within the sub groups.

Returns:

getTrackWindow

public TrackWindow getTrackWindow()
Get the TrackWindow of this track group

Returns:

onParentChange

public void onParentChange(TrackGroupPropertyChange change,
                           TrackWindow newWindow)

onParentTrackWindowChange

public void onParentTrackWindowChange(TrackWindow newWindow)
An event handler when the TrackWindow of this group has changed. Override this method to implement your own event handler for this track group.

Parameters:
newWindow -

onParentTrackGroupPropertyChange

public void onParentTrackGroupPropertyChange(TrackGroupPropertyChange change)
An event handler when the TrackGroupProperty of the parent group has changed. Override this method to implement your own event handler for this track group.

Parameters:
change -

redrawAll

public void redrawAll()
Redraw all child tracks, including tracks within the sub groups.


removeTrack

public void removeTrack(Track track)
Remove the specified track from this group.

Parameters:
track -

removeTrackGroup

public void removeTrackGroup(TrackGroup trackGroup)
Removed the specified track group and its belonging tracks from this group. Note: TrackUpdateListeners propagated to the removed track group will be removed.

Parameters:
trackGroup -

setTrackWindowLocation

public void setTrackWindowLocation(int startOnGenome,
                                   int endOnGenome)
Set the window location on the genome. The change will be reported to all of the tracks in this group via the onParentTrackWindowChange(TrackWindow) method.

Parameters:
startOnGenome -
endOnGenome -

setTrackWindowWidth

public void setTrackWindowWidth(int windowWidth)
Set the width of the track window of this group. The change will be notified to all of the tracks in this group via the onParentTrackWindowChange(TrackWindow).

Parameters:
windowWidth -

addTrackUpdateListener

public void addTrackUpdateListener(TrackUpdateListener listener)
Add a TrackUpdateListener

Parameters:
listener -

removeTrackUpdateListener

public void removeTrackUpdateListener(TrackUpdateListener listener)
Remove the specified TrackUpdateListener

Parameters:
listener -

getTrackIndex

public int getTrackIndex(Track track)
Return the index of the given track in the group.

Parameters:
track -
Returns:
track index in the group

setTrackWindow

public void setTrackWindow(TrackWindow newWindow)
Set the track window (window size, start on genome, end on genome) at once

Parameters:
newWindow -

getParentTrackGroup

public TrackGroup getParentTrackGroup()
Return the current parent trackgroup.

Returns:
currentParentTrackGroup

setParentTrackGroup

protected void setParentTrackGroup(TrackGroup parentTrackGroup)

notifyResize

public void notifyResize()
Notify the change of the inner track widget size to this group


setResizeNotification

public void setResizeNotification(boolean enable)
enable/disable notification of track frame resizes

Parameters:
notify - true to enable, false to disable

getHeight

public int getHeight()
Returns:
get the total height of the track group widget

setTrackLayoutManager

public void setTrackLayoutManager(TrackLayoutManager layout)

getTrackGroupName

public String getTrackGroupName()

setTrackGroupName

public void setTrackGroupName(String newTrackGroupName)

setTrackGroupProperty

protected void setTrackGroupProperty(TrackGroupPropertyImpl trackGroupProperty)

getName

public String getName()
Description copied from interface: TrackEntry
Get the entry name

Specified by:
getName in interface TrackEntry
Returns:
the entry name

isTrack

public boolean isTrack()
Description copied from interface: TrackEntry
Test whether this entry is Track or not.

Specified by:
isTrack in interface TrackEntry
Returns:
true if this entry is Track, othewise false.

isTrackGroup

public boolean isTrackGroup()
Description copied from interface: TrackEntry
Test whether this entry is TrackGroup or not

Specified by:
isTrackGroup in interface TrackEntry
Returns:
true if this entyr is TrackGroup, otherwise false.

getTrackEntryList

public List<TrackEntry> getTrackEntryList()
Get the list of TrackEntrys, including both of Track and TrackGroup.

Returns:

addTrackGroupPropertyChangeListener

public void addTrackGroupPropertyChangeListener(TrackGroupPropertyChangeListener listener)
Add a TrackGroupPropertyChangeListener

Parameters:
listener -

removeTrackGroupPropertyChangeListener

public void removeTrackGroupPropertyChangeListener(TrackGroupPropertyChangeListener listener)
Remove the specified TrackGroupPropertyChangeListener

Parameters:
listener -

getRootTrackGroup

public TrackGroup getRootTrackGroup()
Get the root TrackGroup

Returns:

getClassName

protected String getClassName()

removeParentTrackGroup

protected void removeParentTrackGroup()

compareTo

public int compareTo(TrackGroup o)
Specified by:
compareTo in interface Comparable<TrackGroup>
Returns:
See Also:
Comparable.compareTo(Object)

setTrackGroupProperty

protected void setTrackGroupProperty(TrackGroupProperty trackGroupProperty)

toXML

public void toXML(XMLWriter xmlWriter)
Output the state of this track group into XMLWriter

Parameters:
xmlWriter -

storeInternalProperties

protected void storeInternalProperties(Properties saveData)
Save (store) the internal properties of this track group into the given Properties

Parameters:
saveData -

createTrackGroup

public static TrackGroup createTrackGroup(TrackView view)
                                   throws UTGBClientException
Create a track group from a given TrackView

Parameters:
view -
Returns:
Throws:
UTGBClientException

getBrowserService

public BrowserServiceAsync getBrowserService()


Copyright © 2007-2012 utgenome.org. All Rights Reserved.