Skip to content

Commit

Permalink
topcat: add time plot type.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbtaylor committed Aug 15, 2013
1 parent d4e7f72 commit 73a08f4
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 0 deletions.
5 changes: 5 additions & 0 deletions topcat/src/main/uk/ac/starlink/topcat/ControlWindow.java
Expand Up @@ -122,6 +122,7 @@
import uk.ac.starlink.topcat.plot2.SkyPlotWindow;
import uk.ac.starlink.topcat.plot2.SpherePlotWindow;
import uk.ac.starlink.topcat.plot2.StackPlotWindow;
import uk.ac.starlink.topcat.plot2.TimePlotWindow;
import uk.ac.starlink.topcat.vizier.VizierTableLoadDialog;
import uk.ac.starlink.util.DataSource;
import uk.ac.starlink.util.Loader;
Expand Down Expand Up @@ -435,6 +436,10 @@ public void stateChanged( ChangeEvent evt ) {
"3D plotting window"
+ " using spherical polar coordinates",
SpherePlotWindow.class ),
new TopcatWindowAction( "Time Layer Plot",
ResourceIcon.PLOT2_TIME,
"Time series plotting window",
TimePlotWindow.class ),
};

matchActs_ = new Action[] {
Expand Down
1 change: 1 addition & 0 deletions topcat/src/main/uk/ac/starlink/topcat/ResourceIcon.java
Expand Up @@ -234,6 +234,7 @@ public class ResourceIcon implements Icon {
PLOT2_SKY = makeIcon( "plot2sky.gif" ),
PLOT2_CUBE = makeIcon( "plot2cube.gif" ),
PLOT2_SPHERE = makeIcon( "plot2sphere.gif" ),
PLOT2_TIME = makeIcon( "plot2time.gif" ),

/* Datanode (hierarchy browser) icons. */
COLLAPSED = makeIcon( "handle1.gif" ),
Expand Down
77 changes: 77 additions & 0 deletions topcat/src/main/uk/ac/starlink/topcat/plot2/TimeAxisControl.java
@@ -0,0 +1,77 @@
package uk.ac.starlink.topcat.plot2;

import java.util.ArrayList;
import java.util.List;
import uk.ac.starlink.ttools.plot2.SurfaceFactory;
import uk.ac.starlink.ttools.plot2.config.ConfigKey;
import uk.ac.starlink.ttools.plot2.config.StyleKeys;
import uk.ac.starlink.ttools.plot2.geom.TimeAspect;
import uk.ac.starlink.ttools.plot2.geom.TimeSurfaceFactory;

/**
* Axis control for plot with a horizontal time axis.
*
* @author Mark Taylor
* @since 24 Jul 2013
*/
public class TimeAxisControl
extends CartesianAxisControl<TimeSurfaceFactory.Profile,TimeAspect> {

/**
* Constructor.
*
* @param stack control stack
*/
public TimeAxisControl( ControlStack stack ) {
super( new TimeSurfaceFactory(), createAxisLabelKeys(), stack );
SurfaceFactory surfFact = getSurfaceFactory();

/* Log/flip tab. */
addSpecifierTab( "Coords", new ConfigSpecifier( new ConfigKey[] {
TimeSurfaceFactory.YLOG_KEY,
TimeSurfaceFactory.YFLIP_KEY,
} ) );

/* Range tab. */
addAspectConfigTab( "Range",
new ConfigSpecifier( surfFact.getAspectKeys() ) );

/* Grid tab. */
addSpecifierTab( "Grid", new ConfigSpecifier( new ConfigKey[] {
TimeSurfaceFactory.TFORMAT_KEY,
TimeSurfaceFactory.GRID_KEY,
StyleKeys.MINOR_TICKS,
TimeSurfaceFactory.TCROWD_KEY,
TimeSurfaceFactory.YCROWD_KEY,
} ) );

/* Labels tab. */
addLabelsTab();

/* Font tab. */
addSpecifierTab( "Font",
new ConfigSpecifier( StyleKeys.getCaptionerKeys() ) );

assert assertHasKeys( surfFact.getProfileKeys() );
}

@Override
protected boolean logChanged( TimeSurfaceFactory.Profile prof1,
TimeSurfaceFactory.Profile prof2 ) {
return prof1.getYLog() != prof2.getYLog();
}

/**
* Returns the config keys for axis labelling.
*
* @return T, Y axis label config keys
*/
private static ConfigKey<String>[] createAxisLabelKeys() {
List<ConfigKey<String>> list = new ArrayList<ConfigKey<String>>();
list.add( TimeSurfaceFactory.TLABEL_KEY );
list.add( TimeSurfaceFactory.YLABEL_KEY );
@SuppressWarnings("unchecked")
ConfigKey<String>[] keys = list.toArray( new ConfigKey[ 0 ] );
return keys;
}
}
45 changes: 45 additions & 0 deletions topcat/src/main/uk/ac/starlink/topcat/plot2/TimePlotWindow.java
@@ -0,0 +1,45 @@
package uk.ac.starlink.topcat.plot2;

import java.awt.Component;
import uk.ac.starlink.ttools.plot2.PlotType;
import uk.ac.starlink.ttools.plot2.geom.TimeAspect;
import uk.ac.starlink.ttools.plot2.geom.TimePlotType;
import uk.ac.starlink.ttools.plot2.geom.TimeSurfaceFactory;

/**
* Layer plot window for plots with a horizontal time axis.
*
* @author Mark Taylor
* @since 24 Jul 2013
*/
public class TimePlotWindow
extends StackPlotWindow<TimeSurfaceFactory.Profile,TimeAspect> {
private static final TimePlotType PLOT_TYPE = TimePlotType.getInstance();
private static final TimePlotTypeGui PLOT_GUI = new TimePlotTypeGui();

/**
* Constructor.
*
* @param parent parent component
*/
public TimePlotWindow( Component parent ) {
super( "Time", parent, PLOT_TYPE, PLOT_GUI );
addHelp( "TimePlotWindow" );
}

/**
* Defines GUI features specific to time plot.
*/
private static class TimePlotTypeGui
implements PlotTypeGui<TimeSurfaceFactory.Profile,TimeAspect> {
public AxisControl<TimeSurfaceFactory.Profile,TimeAspect>
createAxisControl( ControlStack stack ) {
return new TimeAxisControl( stack );
}
public PositionCoordPanel createPositionCoordPanel() {
return new SimplePositionCoordPanel( PLOT_TYPE
.getPointDataGeoms()[ 0 ],
true );
}
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 73a08f4

Please sign in to comment.