uk.ac.starlink.ttools.example
Class PlotGenerator<P,A>

java.lang.Object
  extended by uk.ac.starlink.ttools.example.PlotGenerator<P,A>

public class PlotGenerator<P,A>
extends Object

Convenience class for generating plots. This allows you to set up the basic parameters of a plot, and use the same object to construct either a JComponent for live display, or a static Icon, or to export the graphics to a file in a graphic file format.

Although this class gives quite a lot of configurability, there are some options it does not provide, for instance related to the details of autoranging plot limits based on the data. To take full advantage of these, you can go back to the lower-level API taking the implementations here as a starting point.

Since:
27 Jun 2014
Author:
Mark Taylor

Constructor Summary
PlotGenerator(PlotLayer[] layers, SurfaceFactory<P,A> surfFact, P profile, A aspect, Icon legend, float[] legPos, String title, ShadeAxisFactory shadeFact, Range shadeFixRange, PaperTypeSelector ptSel, Compositor compositor, DataStore dataStore, int xpix, int ypix, Insets dataInsets)
          Constructor.
 
Method Summary
 Icon createIcon(boolean forceBitmap)
          Returns a static icon that can be used to paint the plot.
 PlotDisplay createPlotDisplay(Navigator<A> navigator, boolean surfaceAuxRange, boolean caching)
          Returns a JComponent containing a live plot.
 void exportPlot(GraphicExporter exporter, OutputStream out)
          Exports a plot to an output stream in a supported graphics format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlotGenerator

public PlotGenerator(PlotLayer[] layers,
                     SurfaceFactory<P,A> surfFact,
                     P profile,
                     A aspect,
                     Icon legend,
                     float[] legPos,
                     String title,
                     ShadeAxisFactory shadeFact,
                     Range shadeFixRange,
                     PaperTypeSelector ptSel,
                     Compositor compositor,
                     DataStore dataStore,
                     int xpix,
                     int ypix,
                     Insets dataInsets)
Constructor.

Parameters:
layers - layers constituting plot content
surfFact - surface factory
profile - surface profile
aspect - initial surface aspect (may get changed by zooming etc)
legend - legend icon, or null if none required
legPos - 2-element array giving x,y fractional legend placement position within plot (elements in range 0..1), or null for external legend
title - plot title, or null if not required
shadeFact - creates shader axis, or null if not required
shadeFixRange - fixed shader range, or null for auto-range where required
ptSel - paper type selector
compositor - compositor for pixel composition
dataStore - data storage object
xpix - initial horizontal size in pixels (may get changed by window resizing)
ypix - initial vertical size in pixels (may get changed by window resizing)
dataInsets - extent of region outside plot data box, used for axis labels etc; if null, will be calculated automatically
Method Detail

createPlotDisplay

public PlotDisplay createPlotDisplay(Navigator<A> navigator,
                                     boolean surfaceAuxRange,
                                     boolean caching)
Returns a JComponent containing a live plot.

Parameters:
surfaceAuxRange - determines whether aux ranges are recalculated when the surface changes
navigator - user gesture navigation controller, or null for a non-interactive plot
caching - if true, plot image will be cached where applicable, if false it will be regenerated from the data on every repaint
Returns:
plot display component

exportPlot

public void exportPlot(GraphicExporter exporter,
                       OutputStream out)
                throws IOException
Exports a plot to an output stream in a supported graphics format.

Parameters:
exporter - defines a graphics output format
out - destination stream; this method buffers it, but doesn't close it
Throws:
IOException

createIcon

public Icon createIcon(boolean forceBitmap)
Returns a static icon that can be used to paint the plot. The assumption is that the plot will only be painted once; the image is not cached for repeated painting.

Parameters:
forceBitmap - true iff the plot layers should be forced to a pixel map grid rather than (perhaps) being drawn using vector graphics; usually not necessary
Returns:
icon to paint plot; it may be painted in a headless context


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.