uk.ac.starlink.ttools.plot2.task
Class AbstractPlot2Task

java.lang.Object
  extended by uk.ac.starlink.ttools.plot2.task.AbstractPlot2Task
All Implemented Interfaces:
Task, DynamicTask
Direct Known Subclasses:
GenericPlot2Task, TypedPlot2Task

public abstract class AbstractPlot2Task
extends Object
implements Task, DynamicTask

Abstract superclass for tasks performing plot2 plots using STILTS. Concrete subclasses must supply the PlotType (perhaps from the environment), and may customise the visible task parameter set.

Since:
22 Aug 2014
Author:
Mark Taylor

Field Summary
static String EXAMPLE_LAYER_SUFFIX
           
static String LAYER_PREFIX
           
 
Constructor Summary
protected AbstractPlot2Task()
          Constructor with default animation capability.
protected AbstractPlot2Task(boolean allowAnimate)
          Constructor with explicit animation capability.
 
Method Summary
protected abstract
<T> ConfigParameter
createConfigParameter(Environment env, ConfigKey<T> key, String[] suffixes)
          Returns a config parameter for a given config key that may be sensitive to the content of the execution environment.
static StringParameter createDataParameter(Input input, String suffix, boolean fullDetail)
          Returns a parameter for acquiring a column of data.
 Executable createExecutable(Environment env)
          Creates an executable object which will do the work of this task in the given Environment.
static FilterParameter createFilterParameter(String suffix, InputTableParameter tableParam)
          Returns a parameter for acquiring a filter applied to the table input for a given layer.
static Parameter<String> createLabelParameter(String suffix)
          Returns a parameter to get a textual label corresponding to the layer identified by a given layer suffix.
static LayerTypeParameter createLayerTypeParameter(String suffix, PlotContext context)
          Returns a parameter for acquiring a plotter.
 PlotDisplay createPlotComponent(Environment env, boolean caching)
          Returns a graphical component that displays an interactive view of the plot described by a value-bearing execution environment.
 Icon createPlotIcon(Environment env)
          Returns an Icon that paints the plot described by a value-bearing execution environment.
static
<P,A> Icon
createPlotIcon(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 insets, boolean forceBitmap)
          Creates an icon which will paint the content of a plot.
static InputTableParameter createTableParameter(String suffix)
          Returns a parameter for acquiring a data table.
 Parameter[] getBasicParameters()
          Returns the list of parameters supplied by the AbstractPlot2Task implementation.
 Parameter[] getContextParameters(Environment env)
          Returns the parameters for this task in the context of a given execution environment.
static List<Parameter> getKeyParams(ConfigKey[] keys)
          Returns a list of non-suffixed parameters based on a list of ConfigKeys.
 Parameter getParameterByName(Environment env, String paramName)
          Attempts to find a parameter with a given name that might be used by this task in the content of the given environment.
abstract  PlotContext getPlotContext(Environment env)
          Concrete subclasses must implement this method to provide the PlotType and other information from the environment that may not be available at construction time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.starlink.task.Task
getParameters, getPurpose
 

Field Detail

LAYER_PREFIX

public static final String LAYER_PREFIX
See Also:
Constant Field Values

EXAMPLE_LAYER_SUFFIX

public static final String EXAMPLE_LAYER_SUFFIX
See Also:
Constant Field Values
Constructor Detail

AbstractPlot2Task

protected AbstractPlot2Task(boolean allowAnimate)
Constructor with explicit animation capability.

Parameters:
allowAnimate - true iff animation options should be provided

AbstractPlot2Task

protected AbstractPlot2Task()
Constructor with default animation capability.

Method Detail

getPlotContext

public abstract PlotContext getPlotContext(Environment env)
                                    throws TaskException
Concrete subclasses must implement this method to provide the PlotType and other information from the environment that may not be available at construction time.

Parameters:
env - execution environment
Returns:
context
Throws:
TaskException

createConfigParameter

protected abstract <T> ConfigParameter createConfigParameter(Environment env,
                                                             ConfigKey<T> key,
                                                             String[] suffixes)
                                                  throws TaskException
Returns a config parameter for a given config key that may be sensitive to the content of the execution environment. This is here to provide a hook for subclasses to set up defaults for some config parameters on the basis of what layers are present.

Parameters:
env - execution environment
key - config key for which a parameter is required
suffixes - ordered list of the plot layer suffixes in use for the plot being performed
Returns:
parameter to get the value of key
Throws:
TaskException

getBasicParameters

public final Parameter[] getBasicParameters()
Returns the list of parameters supplied by the AbstractPlot2Task implementation. Subclasses should include these alongside any they want to add for presentation to the user.

Returns:
basic parameter list

createExecutable

public Executable createExecutable(Environment env)
                            throws TaskException
Description copied from interface: Task
Creates an executable object which will do the work of this task in the given Environment. This method should do all of the parameter processing and prepare an object which just executes. The idea is that any communication with the user related to the supplied parameter values can be done before the task starts to execute in earnest. Consequently, the returned Executable object ought not to make any reference to env, though this is not absolutely prohibited.

Specified by:
createExecutable in interface Task
Parameters:
env - the environment in which the task will operate
Throws:
TaskException - if no executable can be created; this should usually be a UsageException or some subclass

createPlotIcon

public Icon createPlotIcon(Environment env)
                    throws TaskException,
                           IOException,
                           InterruptedException
Returns an Icon that paints the plot described by a value-bearing execution environment. This utility method is not used for executing this class.

Parameters:
env - execution environment
Returns:
plot icon
Throws:
TaskException
IOException
InterruptedException

createPlotComponent

public PlotDisplay createPlotComponent(Environment env,
                                       boolean caching)
                                throws TaskException,
                                       IOException,
                                       InterruptedException
Returns a graphical component that displays an interactive view of the plot described by a value-bearing execution environment. This utility method is not used for executing the task defined by this class.

Parameters:
env - execution environment
caching - whether data and plot should be cached or re-read at every repaint
Returns:
active plot view component
Throws:
TaskException
IOException
InterruptedException

getContextParameters

public Parameter[] getContextParameters(Environment env)
                                 throws TaskException
Description copied from interface: DynamicTask
Returns the parameters for this task in the context of a given execution environment. If the environment is empty, this should give the same result as Task.getParameters(), but found settings of parameters in the presented environment may lead to parameters being added to or removed from the list.

This ought not to result in additional prompts to the user.

Specified by:
getContextParameters in interface DynamicTask
Parameters:
env - execution environment
Returns:
list of known parameters
Throws:
TaskException

getParameterByName

public Parameter getParameterByName(Environment env,
                                    String paramName)
                             throws TaskException
Description copied from interface: DynamicTask
Attempts to find a parameter with a given name that might be used by this task in the content of the given environment.

This ought not to result in additional prompts to the user.

Specified by:
getParameterByName in interface DynamicTask
Parameters:
env - execution environment
paramName - requested parameter name
Returns:
parameter with the given name, or null
Throws:
TaskException

createTableParameter

public static InputTableParameter createTableParameter(String suffix)
Returns a parameter for acquiring a data table.

Parameters:
suffix - layer-specific suffix
Returns:
table parameter

createFilterParameter

public static FilterParameter createFilterParameter(String suffix,
                                                    InputTableParameter tableParam)
Returns a parameter for acquiring a filter applied to the table input for a given layer.

Parameters:
suffix - layer-specific suffix
tableParam - input table parameter associated with the layer
Returns:
filter parameter

createLabelParameter

public static Parameter<String> createLabelParameter(String suffix)
Returns a parameter to get a textual label corresponding to the layer identified by a given layer suffix. This label is displayed in the legend.

Parameters:
suffix - layer suffix
Returns:
parameter to get legend label for layer

createLayerTypeParameter

public static LayerTypeParameter createLayerTypeParameter(String suffix,
                                                          PlotContext context)
Returns a parameter for acquiring a plotter.

Parameters:
suffix - parameter name suffix
context - plot context
Returns:
plotter parameter

createDataParameter

public static StringParameter createDataParameter(Input input,
                                                  String suffix,
                                                  boolean fullDetail)
Returns a parameter for acquiring a column of data.

Parameters:
input - specifies input value required from user
suffix - layer-specific suffix
fullDetail - if true, extra detail is appended to the description
Returns:
data parameter

createPlotIcon

public static <P,A> Icon createPlotIcon(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 insets,
                                        boolean forceBitmap)
Creates an icon which will paint the content of a plot. This icon is expected to be painted once and then discarded, so it's not cached.

Parameters:
layers - layers constituting plot content
surfFact - surface factory
profile - surface profile
aspect - surface aspect
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
shadeFact - gets shader axis from range, 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 - horizontal size of icon in pixels
ypix - vertical size of icon in pixels
insets - may supply the inset space to be used for axis decoration etc; if null, this will be worked out automatically
forceBitmap - true to force bitmap output of vector graphics, false to use default behaviour
Returns:
icon icon for plotting

getKeyParams

public static List<Parameter> getKeyParams(ConfigKey[] keys)
Returns a list of non-suffixed parameters based on a list of ConfigKeys.

Parameters:
keys - config keys
Returns:
parameters for acquiring config key values


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