Skip to content

Instantly share code, notes, and snippets.

@ulmangt
Last active December 26, 2015 01:59
Show Gist options
  • Save ulmangt/7075508 to your computer and use it in GitHub Desktop.
Save ulmangt/7075508 to your computer and use it in GitHub Desktop.
Demonstrates a possible approach to cloning timeline event rows so that they show the same set of events.
import com.metsci.glimpse.examples.Example;
import com.metsci.glimpse.plot.timeline.StackedTimePlot2D;
import com.metsci.glimpse.plot.timeline.event.EventPlotInfo;
import com.metsci.glimpse.support.settings.OceanLookAndFeel;
public class TimelineCloneEventRowExample extends CollapsibleTimelinePlotExample
{
public static void main( String[] args ) throws Exception
{
Example example = Example.showWithSwing( new TimelineCloneEventRowExample( ) );
// use the ocean look and feel
example.getCanvas( ).setLookAndFeel( new OceanLookAndFeel( ) );
}
@Override
public StackedTimePlot2D getLayout( )
{
StackedTimePlot2D plot = super.getLayout( );
// get a reference to one of the Event plots
EventPlotInfo eventPlot = plot.getEventPlot( "event-2" );
// create a new Event plot
EventPlotInfo newEventPlot = plot.createEventPlot( );
// Get the internal GlimpseLayout that Events are painted on from the first event plot and add it to the second
//
// Note, this call requires adding a method to EventPlotInfo:
//
// public GlimpseAxisLayout1D getEventLayout( )
// {
// return layout1D;
// }
//
// Further note, this isn't a 100% solution. For example, when dragging events, if one event is bumped up to
// a second level, it will only affect the size of the original plot, not the second one.
//
newEventPlot.getEventLayout( ).addLayout( eventPlot.getEventLayout( ) );
return plot;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment