Skip to content

Instantly share code, notes, and snippets.

@ulmangt
Last active December 26, 2015 01:59
Show Gist options
  • Save ulmangt/7074975 to your computer and use it in GitHub Desktop.
Save ulmangt/7074975 to your computer and use it in GitHub Desktop.
Example of nesting timeline groups.
import com.metsci.glimpse.examples.Example;
import com.metsci.glimpse.painter.info.SimpleTextPainter.VerticalPosition;
import com.metsci.glimpse.plot.timeline.CollapsibleTimePlot2D;
import com.metsci.glimpse.plot.timeline.StackedTimePlot2D;
import com.metsci.glimpse.plot.timeline.group.GroupInfo;
import com.metsci.glimpse.support.settings.OceanLookAndFeel;
public class TimelineNestingExample extends CollapsibleTimelinePlotExample
{
public static void main( String[] args ) throws Exception
{
Example example = Example.showWithSwing( new TimelineNestingExample( ) );
// use the ocean look and feel
example.getCanvas( ).setLookAndFeel( new OceanLookAndFeel( ) );
}
@Override
public StackedTimePlot2D getLayout( )
{
CollapsibleTimePlot2D plot = ( CollapsibleTimePlot2D ) super.getLayout( );
// create a new group out of all the previously created groups
GroupInfo overallGroup = plot.createGroup( "overall-group", plot.getAllGroups( ) );
overallGroup.setLabelText( "Overall Group" );
// turn on group indentation
plot.setIndentSubplots( true );
// set the size of the indentation in pixels
plot.setIndentSize( 10 );
// set the data plots to a fixed size so that they do not grow when other plots are collapsed
plot.getTimePlot( "speed-plot-1-id" ).setSize( 200 );
plot.getTimePlot( "viscosity-plot-2-id" ).setSize( 200 );
// set the default timeline to grow to take up the available space
plot.getDefaultTimeline( ).setGrow( true );
// place the time zone marker at the top of the timeline
plot.getDefaultTimeline( ).getTimeZonePainter( ).setVerticalPosition( VerticalPosition.Top );
return plot;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment