Skip to content

Commit

Permalink
topcat: add plot2 window specifically for histograms
Browse files Browse the repository at this point in the history
You can already plot histograms in the plane plot, but having a separate
window can set up some defaults in a more convenient way if a histogram
is what you want to plot.
  • Loading branch information
mbtaylor authored and mmpcn committed Nov 27, 2014
1 parent 0b1a5b8 commit 773122e
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
6 changes: 6 additions & 0 deletions topcat/src/main/uk/ac/starlink/topcat/ControlWindow.java
Expand Up @@ -119,6 +119,7 @@
import uk.ac.starlink.topcat.plot.SphereWindow;
import uk.ac.starlink.topcat.plot2.Control;
import uk.ac.starlink.topcat.plot2.CubePlotWindow;
import uk.ac.starlink.topcat.plot2.HistogramPlotWindow;
import uk.ac.starlink.topcat.plot2.PlanePlotWindow;
import uk.ac.starlink.topcat.plot2.SkyPlotWindow;
import uk.ac.starlink.topcat.plot2.SpherePlotWindow;
Expand Down Expand Up @@ -437,6 +438,11 @@ public void stateChanged( ChangeEvent evt ) {
"3D plotting window"
+ " using spherical polar coordinates",
SpherePlotWindow.class ),
new Plot2WindowAction( "Histogram Layer Plot",
ResourceIcon.PLOT2_HISTOGRAM,
"Plane plotting window configured for "
+ "convenience for histogram plotting",
HistogramPlotWindow.class ),
new Plot2WindowAction( "Time Layer Plot",
ResourceIcon.PLOT2_TIME,
"Time series plotting window",
Expand Down
1 change: 1 addition & 0 deletions topcat/src/main/uk/ac/starlink/topcat/ResourceIcon.java
Expand Up @@ -239,6 +239,7 @@ public class ResourceIcon implements Icon {
PLOT2_CUBE = makeIcon( "plot2cube.gif" ),
PLOT2_SPHERE = makeIcon( "plot2sphere.gif" ),
PLOT2_TIME = makeIcon( "plot2time.gif" ),
PLOT2_HISTOGRAM = makeIcon( "plot2hist.gif" ),

/* Datanode (hierarchy browser) icons. */
COLLAPSED = makeIcon( "handle1.gif" ),
Expand Down
@@ -0,0 +1,79 @@
package uk.ac.starlink.topcat.plot2;

import java.awt.Component;
import uk.ac.starlink.ttools.plot2.DataGeom;
import uk.ac.starlink.ttools.plot2.PlotType;
import uk.ac.starlink.ttools.plot2.Plotter;
import uk.ac.starlink.ttools.plot2.SurfaceFactory;
import uk.ac.starlink.ttools.plot2.geom.PlaneAspect;
import uk.ac.starlink.ttools.plot2.geom.PlaneDataGeom;
import uk.ac.starlink.ttools.plot2.geom.PlanePlotType;
import uk.ac.starlink.ttools.plot2.geom.PlaneSurfaceFactory;
import uk.ac.starlink.ttools.plot2.layer.FunctionPlotter;
import uk.ac.starlink.ttools.plot2.layer.HistogramPlotter;
import uk.ac.starlink.ttools.plot2.paper.PaperTypeSelector;

/**
* Layer plot window for histograms.
* This is a slight variant of PlanePlotWindow, with a restricted set
* of plotters and modified axis controls. It's here for convenience
* and easy start of a histogram - it is also possible to draw histograms
* in a normal plane plot.
*
* @author Mark Taylor
* @since 21 Jan 2014
*/
public class HistogramPlotWindow
extends StackPlotWindow<PlaneSurfaceFactory.Profile,PlaneAspect> {
private static final PlotType PLOT_TYPE = new HistogramPlotType();
private static final PlotTypeGui PLOT_GUI = new HistogramPlotTypeGui();

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

/**
* Variant of PlanePlotType for histograms; has a different set of plotters.
*/
private static class HistogramPlotType implements PlotType {
private final PaperTypeSelector ptSelector_ =
PlanePlotType.getInstance().getPaperTypeSelector();
private final SurfaceFactory surfFact_ = new PlaneSurfaceFactory();
public PaperTypeSelector getPaperTypeSelector() {
return ptSelector_;
}
public DataGeom[] getPointDataGeoms() {
return new DataGeom[] { PlaneDataGeom.INSTANCE };
}
public SurfaceFactory getSurfaceFactory() {
return surfFact_;
}
public Plotter[] getPlotters() {
return new Plotter[] {
new HistogramPlotter( PlaneDataGeom.X_COORD, true ),
FunctionPlotter.PLANE,
};
}
}

/**
* Defines GUI features specific to histogram plot.
*/
private static class HistogramPlotTypeGui
implements PlotTypeGui<PlaneSurfaceFactory.Profile,PlaneAspect> {
public AxisControl<PlaneSurfaceFactory.Profile,PlaneAspect>
createAxisControl( ControlStack stack ) {
return new PlaneAxisControl( stack );
}
public PositionCoordPanel createPositionCoordPanel( int npos ) {
return SimplePositionCoordPanel
.createPanel( PLOT_TYPE.getPointDataGeoms()[ 0 ], npos );
}
}
}
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 773122e

Please sign in to comment.