Skip to content

Instantly share code, notes, and snippets.

View ulmangt's full-sized avatar

Geoffrey Ulman ulmangt

View GitHub Profile
@ulmangt
ulmangt / SwtLandPlotExample.java
Created May 24, 2012 19:39
LandPlotExample using SWT
/*
* Copyright (c) 2012, Metron, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@ulmangt
ulmangt / GshhsLandPlotExample.java
Created May 24, 2012 20:09
LandPlotExample modified to display GSHHS data
/*
* Copyright (c) 2012, Metron, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
@ulmangt
ulmangt / StayOpenMenuManager.java
Created September 6, 2012 18:56
A SWT/RCP/JFace MenuManager subclass which stays open when one of its MenuItems is clicked
import java.lang.reflect.Field;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.swt.events.MenuDetectEvent;
import org.eclipse.swt.events.MenuDetectListener;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.events.MenuListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
@ulmangt
ulmangt / ClickDragExample.java
Created September 7, 2012 21:48
A Glimpse example demonstrating dragging IconPainter icons
import java.io.IOException;
import java.util.Collection;
import com.metsci.glimpse.axis.Axis1D;
import com.metsci.glimpse.axis.Axis2D;
import com.metsci.glimpse.event.mouse.GlimpseMouseAdapter;
import com.metsci.glimpse.event.mouse.GlimpseMouseEvent;
import com.metsci.glimpse.event.mouse.GlimpseMouseMotionListener;
import com.metsci.glimpse.examples.Example;
import com.metsci.glimpse.examples.basic.HeatMapExample;
@ulmangt
ulmangt / PolygonDragExample.java
Created September 13, 2012 02:41
A Glimpse example demonstrating dragging PolygonPainter polygons
/*
* Copyright (c) 2012, Metron, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@ulmangt
ulmangt / TaggedAxisConstraintsExample.java
Last active December 14, 2015 13:38
Glimpse CollapsibleTimelinePlotExample extension demonstrating use of TaggedAxis Constraints
// replace the default StackedTimePlot2D mouse listener behavior with
// the default tagged axis behavior (the selected area will not follow
// the mouse, but the user can move it by clicking and dragging inside
// the selected area)
plot.setTimeAxisMouseListener( new TaggedAxisMouseListener1D( ) );
// lock the timeline at the current max selection value
plot.setCurrentTimeLocked( true );
// add a constraint which prevents the max selection value
@ulmangt
ulmangt / ConstrainTimelineSelectedRegion.java
Last active December 14, 2015 13:39
Constrain CollapsibleTimelinePlotExample selected region to not extend past a particular time.
final TimeStamp maxTimeStamp = t0.add( Time.fromMinutes( 300 ) );
final double maxTime = plot.fromTimeStamp( maxTimeStamp );
// add a constraint which prevents the max selection value
// from moving past the max timeline value
plot.getTimeAxis( ).addConstraint( new Constraint( )
{
@Override
public String getName( )
{
@ulmangt
ulmangt / LabelTimelinePointExample.java
Last active December 26, 2015 01:49
Demonstrates one approach to adding a simple text annotation to a timeline plot.
import com.metsci.glimpse.examples.Example;
import com.metsci.glimpse.layout.GlimpseAxisLayout2D;
import com.metsci.glimpse.painter.info.AnnotationPainter;
import com.metsci.glimpse.painter.info.AnnotationPainter.AnnotationFont;
import com.metsci.glimpse.plot.timeline.StackedTimePlot2D;
import com.metsci.glimpse.plot.timeline.layout.TimePlotInfo;
import com.metsci.glimpse.support.color.GlimpseColor;
import com.metsci.glimpse.support.settings.OceanLookAndFeel;
import com.metsci.glimpse.util.units.time.Time;
import com.metsci.glimpse.util.units.time.TimeStamp;
@ulmangt
ulmangt / CustomAxisTicksExample.java
Last active December 26, 2015 01:49
Demonstrates creating a custom GridAxisLabelHandler to customize how tick marks appear on a Y axis.
import com.metsci.glimpse.axis.Axis1D;
import com.metsci.glimpse.axis.painter.label.GridAxisLabelHandler;
import com.metsci.glimpse.examples.Example;
import com.metsci.glimpse.plot.timeline.StackedTimePlot2D;
import com.metsci.glimpse.plot.timeline.layout.TimePlotInfo;
import com.metsci.glimpse.support.settings.OceanLookAndFeel;
public class CustomAxisTicksExample extends CollapsibleTimelinePlotExample
{
public static void main( String[] args ) throws Exception
@ulmangt
ulmangt / TimelineShapeDrawingExample.java
Last active December 26, 2015 01:58
Example of using PolygonPainter with a StackedTimePlot2D.
import com.metsci.glimpse.examples.Example;
import com.metsci.glimpse.layout.GlimpseAxisLayout2D;
import com.metsci.glimpse.painter.shape.PolygonPainter;
import com.metsci.glimpse.plot.timeline.StackedTimePlot2D;
import com.metsci.glimpse.plot.timeline.data.Epoch;
import com.metsci.glimpse.plot.timeline.layout.TimePlotInfo;
import com.metsci.glimpse.support.color.GlimpseColor;
import com.metsci.glimpse.support.settings.OceanLookAndFeel;
import com.metsci.glimpse.util.units.time.Time;
import com.metsci.glimpse.util.units.time.TimeStamp;