Skip to content

Commit

Permalink
ttools: update EnvPlanePlotter example for plot2 task changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbtaylor committed Oct 3, 2014
1 parent 76ef30e commit 6b0c7ba
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions ttools/src/main/uk/ac/starlink/ttools/example/EnvPlanePlotter.java
@@ -1,11 +1,12 @@
package uk.ac.starlink.ttools.example;

import java.awt.Insets;
import java.io.IOException;
import javax.swing.JComponent;
import uk.ac.starlink.table.StarTable;
import uk.ac.starlink.task.Environment;
import uk.ac.starlink.task.TaskException;
import uk.ac.starlink.ttools.plot2.task.GenericPlot2Task;
import uk.ac.starlink.ttools.plot2.task.PlanePlot2Task;
import uk.ac.starlink.ttools.task.MapEnvironment;

/**
Expand All @@ -32,20 +33,20 @@ public JComponent createPlotComponent( StarTable table,
* pairs describing what plot to do on the table. */
Environment env = configurePlotEnvironment( table );

/* Pass the populated environment to the GenericPlot2Task object,
/* Pass the populated environment to the PlanePlot2Task object,
* which can turn it into a JComponent containing the plot. */
boolean caching = ! dataMayChange;
return new GenericPlot2Task().createPlotComponent( env, caching );
return new PlanePlot2Task().createPlotComponent( env, caching );
}

/**
* Constructs and returns an execution environment populated with
* the name/value pairs that will cause GenericPlot2Task to make a plot
* the name/value pairs that will cause PlanePlot2Task to make a plot
* for the supplied table. This method does the work of specifying
* the plot.
*
* @param table input table
* @return GenericPlot2Task execution environment ready to plot
* @return PlanePlot2Task execution environment ready to plot
*/
private Environment configurePlotEnvironment( StarTable table ) {

Expand All @@ -54,16 +55,16 @@ private Environment configurePlotEnvironment( StarTable table ) {

/* Populate the environment with parameter name/value pairs.
* For the available parameters and their values, see the user
* documentation of the corresponding STILTS command-line task.
* At time of writing, this documentation does not exist :-[.
* documentation of the corresponding STILTS command-line task,
* plot2plane.
*
* Some general points:
*
* - In most cases the values are strings.
* - Values can always be set as strings.
*
* - For some parameters non-String objects of a relevant type
* are also allowed. In particular parameters accepting
* tables will take StarTable objects.
* - In most cases, values can alternatively be set as objects of
* the type corresponding to the parameter. These types are
* reported as part of the usage documentation for each parameter.
*
* - Most parameters are optional, and will assume sensible
* defaults if not set. There are several tens of parameters
Expand All @@ -74,17 +75,18 @@ private Environment configurePlotEnvironment( StarTable table ) {

/* Global parameters for the plot. */
env.setValue( "type", "plane" ); // required
env.setValue( "insets", "10,30,30,8" );
env.setValue( "insets", new Insets( 10 , 30, 30, 8 ) );

/* Parameters for the first (in this case, only) layer;
* the parameter names have a trailing (arbitrary) label "_1".
* The values of the x1/y1 parameters, giving the data coordinates,
* The values of the x_1/y_1 parameters, giving the data coordinates,
* are names of the columns in the input table. */
env.setValue( "layer_1", "mark-flat" ); // required
env.setValue( "layer_1", "mark" ); // required
env.setValue( "in_1", table ); // required
env.setValue( "x_1", "x" ); // required
env.setValue( "y_1", "y" ); // required
env.setValue( "shape_1", "open circle" );
env.setValue( "shading_1", "flat" );
env.setValue( "shape_1", "open_circle" );
env.setValue( "size_1", "2" );

/* You could add more layers here. */
Expand Down

0 comments on commit 6b0c7ba

Please sign in to comment.