From 773122e03584fec828615d67221788e35df153e1 Mon Sep 17 00:00:00 2001 From: Mark Taylor Date: Tue, 21 Jan 2014 13:27:58 +0000 Subject: [PATCH] topcat: add plot2 window specifically for histograms 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. --- .../uk/ac/starlink/topcat/ControlWindow.java | 6 ++ .../uk/ac/starlink/topcat/ResourceIcon.java | 1 + .../topcat/plot2/HistogramPlotWindow.java | 79 ++++++++++++++++++ .../ac/starlink/topcat/images/plot2hist.gif | Bin 0 -> 157 bytes 4 files changed, 86 insertions(+) create mode 100644 topcat/src/main/uk/ac/starlink/topcat/plot2/HistogramPlotWindow.java create mode 100644 topcat/src/resources/uk/ac/starlink/topcat/images/plot2hist.gif diff --git a/topcat/src/main/uk/ac/starlink/topcat/ControlWindow.java b/topcat/src/main/uk/ac/starlink/topcat/ControlWindow.java index 375d8766a7..a9dc02f6a5 100644 --- a/topcat/src/main/uk/ac/starlink/topcat/ControlWindow.java +++ b/topcat/src/main/uk/ac/starlink/topcat/ControlWindow.java @@ -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; @@ -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", diff --git a/topcat/src/main/uk/ac/starlink/topcat/ResourceIcon.java b/topcat/src/main/uk/ac/starlink/topcat/ResourceIcon.java index f78af2fc21..17a20bc38a 100644 --- a/topcat/src/main/uk/ac/starlink/topcat/ResourceIcon.java +++ b/topcat/src/main/uk/ac/starlink/topcat/ResourceIcon.java @@ -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" ), diff --git a/topcat/src/main/uk/ac/starlink/topcat/plot2/HistogramPlotWindow.java b/topcat/src/main/uk/ac/starlink/topcat/plot2/HistogramPlotWindow.java new file mode 100644 index 0000000000..0a0763918d --- /dev/null +++ b/topcat/src/main/uk/ac/starlink/topcat/plot2/HistogramPlotWindow.java @@ -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 { + 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 { + public AxisControl + createAxisControl( ControlStack stack ) { + return new PlaneAxisControl( stack ); + } + public PositionCoordPanel createPositionCoordPanel( int npos ) { + return SimplePositionCoordPanel + .createPanel( PLOT_TYPE.getPointDataGeoms()[ 0 ], npos ); + } + } +} diff --git a/topcat/src/resources/uk/ac/starlink/topcat/images/plot2hist.gif b/topcat/src/resources/uk/ac/starlink/topcat/images/plot2hist.gif new file mode 100644 index 0000000000000000000000000000000000000000..7d4982227c7a42fe32199b3f541a007cbe5593c3 GIT binary patch literal 157 zcmZ?wbhEHblwgoxIK<2V1U^1K1qB8FQGw!57Dg@x76u)V3Xoa`<|L0@cg`uE^2}CX z>^Zyp|HN;-$sY6OcJeg^q&>R1Z{wS$o2Ty0>pExQkjwJsX~*`YS3elFEbaOyZx>NA wKkr-8wbW_m?sXP79=0_b7ME@C-E}-?!>_edFP|-3Sa<$Cw{Alt3nzm$0N3zJi2wiq literal 0 HcmV?d00001