diff --git a/topcat/src/main/uk/ac/starlink/topcat/plot2/BasicCoordLayerControl.java b/topcat/src/main/uk/ac/starlink/topcat/plot2/BasicCoordLayerControl.java index c196c18b78..90823918a2 100644 --- a/topcat/src/main/uk/ac/starlink/topcat/plot2/BasicCoordLayerControl.java +++ b/topcat/src/main/uk/ac/starlink/topcat/plot2/BasicCoordLayerControl.java @@ -6,14 +6,13 @@ import java.awt.event.ItemListener; import java.util.Map; import javax.swing.Box; +import javax.swing.ComboBoxModel; import javax.swing.JComboBox; import javax.swing.JComponent; -import javax.swing.ComboBoxModel; import uk.ac.starlink.topcat.LineBox; import uk.ac.starlink.topcat.RowSubset; import uk.ac.starlink.topcat.TablesListComboBox; import uk.ac.starlink.topcat.TopcatModel; -import uk.ac.starlink.ttools.plot.Style; import uk.ac.starlink.ttools.plot2.DataGeom; import uk.ac.starlink.ttools.plot2.LegendEntry; import uk.ac.starlink.ttools.plot2.PlotLayer; @@ -38,6 +37,7 @@ public class BasicCoordLayerControl extends ConfigControl private final JComboBox subsetSelector_; private final ComboBoxModel dummyComboBoxModel_; private final ReportLogger reportLogger_; + private final ConfigStyler styler_; private TopcatModel tcModel_; /** @@ -53,6 +53,7 @@ public BasicCoordLayerControl( Plotter plotter, plotter_ = plotter; coordPanel_ = coordPanel; reportLogger_ = new ReportLogger( this ); + styler_ = new ConfigStyler( coordPanel_.getComponent() ); /* Create data selection components. */ tableSelector_ = new TablesListComboBox(); @@ -106,7 +107,8 @@ public PlotLayer[] getPlotLayers() { DataGeom geom = coordPanel_.getDataGeom(); DataSpec dataSpec = new GuiDataSpec( tcModel_, subset, coordContents ); ConfigMap config = getConfig(); - PlotLayer layer = createLayer( plotter_, geom, dataSpec, config ); + PlotLayer layer = + styler_.createLayer( plotter_, geom, dataSpec, config ); return layer == null ? new PlotLayer[ 0 ] : new PlotLayer[] { layer }; } @@ -163,19 +165,4 @@ protected void tableChanged( TopcatModel tcModel ) { } subsetSelector_.setModel( subselModel ); } - - /** - * Creates a new layer from a plotter. - * - * @param plotter plotter - * @param geom data geom - * @param dataSpec data spec - * @param config style configuration - */ - private static - PlotLayer createLayer( Plotter plotter, DataGeom geom, - DataSpec dataSpec, ConfigMap config ) { - S style = plotter.createStyle( config ); - return plotter.createLayer( geom, dataSpec, style ); - } } diff --git a/topcat/src/main/uk/ac/starlink/topcat/plot2/ConfigStyler.java b/topcat/src/main/uk/ac/starlink/topcat/plot2/ConfigStyler.java new file mode 100644 index 0000000000..2ab4067115 --- /dev/null +++ b/topcat/src/main/uk/ac/starlink/topcat/plot2/ConfigStyler.java @@ -0,0 +1,78 @@ +package uk.ac.starlink.topcat.plot2; + +import java.awt.Component; +import javax.swing.JOptionPane; +import uk.ac.starlink.ttools.plot.Style; +import uk.ac.starlink.ttools.plot2.DataGeom; +import uk.ac.starlink.ttools.plot2.PlotLayer; +import uk.ac.starlink.ttools.plot2.Plotter; +import uk.ac.starlink.ttools.plot2.config.ConfigException; +import uk.ac.starlink.ttools.plot2.config.ConfigMap; +import uk.ac.starlink.ttools.plot2.data.DataSpec; + +/** + * Manages creation of PlotLayers from Plotters by turning ConfigMaps into + * appropriate Style instances. + * This would be just a case of calling the relevant Plotter method, + * except that method can throw a ConfigException, and we have to manage + * behaviour in the case that that happens. + * + * This is currently done by popping up a dialogue window the first time the + * error occurs. + * + * @author Mark Taylor + * @since 25 Feb 2015 + */ +public class ConfigStyler { + + private final Component parent_; + private boolean lastFailed_; + + /** + * Constructor. + * + * @param parent parent component for dialogue windows + */ + public ConfigStyler( Component parent ) { + parent_ = parent; + } + + /** + * Creates a new layer from a plotter. + * + * @param plotter plotter + * @param geom data geom + * @param dataSpec data spec + * @param config style configuration + * @return layer, or null in case of failure + */ + public PlotLayer createLayer( Plotter plotter, + DataGeom geom, + DataSpec dataSpec, + ConfigMap config ) { + S style; + try { + style = plotter.createStyle( config ); + lastFailed_ = false; + } + catch ( ConfigException e ) { + if ( ! lastFailed_ ) { + String name = e.getConfigKey().getMeta().getLongName(); + String[] msg = new String[] { name + ": ", e.getMessage() }; + JOptionPane.showMessageDialog( parent_, msg, name + " Error", + JOptionPane.ERROR_MESSAGE ); + lastFailed_ = true; + } + return null; + } + try { + S dupStyle = plotter.createStyle( config ); + assert style.equals( dupStyle ); + assert style.hashCode() == dupStyle.hashCode(); + } + catch ( ConfigException e ) { + assert false : "Shouldn't happen"; + } + return plotter.createLayer( geom, dataSpec, style ); + } +} diff --git a/topcat/src/main/uk/ac/starlink/topcat/plot2/FormControl.java b/topcat/src/main/uk/ac/starlink/topcat/plot2/FormControl.java index d9813cd8d4..bc74d1a43a 100644 --- a/topcat/src/main/uk/ac/starlink/topcat/plot2/FormControl.java +++ b/topcat/src/main/uk/ac/starlink/topcat/plot2/FormControl.java @@ -38,6 +38,7 @@ public abstract class FormControl implements Control { private SubsetConfigManager subManager_; private FormStylePanel stylePanel_; private JComponent panel_; + private ConfigStyler styler_; private ReportPanel reportPanel_; /** @@ -88,6 +89,20 @@ public JComponent getPanel() { return panel_; } + /** + * Returns this component's ConfigStyler. + * + * @return config styler + */ + private synchronized ConfigStyler getStyler() { + + /* Constructed lazily because it needs the component. */ + if ( styler_ == null ) { + styler_ = new ConfigStyler( getPanel() ); + } + return styler_; + } + /** * Returns the data and metadata for the additional coordinates * entered by the user in this control. @@ -185,33 +200,13 @@ public FormStylePanel getStylePanel() { * set up for the given subset * @param subset row subset in the current table for which the * layer is to be plotted - * @return new plot layer + * @return new plot layer, may be null in case of incorrect GUI config */ public PlotLayer createLayer( DataGeom geom, DataSpec dataSpec, RowSubset subset ) { - return createLayer( getPlotter(), geom, dataSpec, subset ); - } - - /** - * Creates a plot layer. - * - * @param geom data position geometry - * @param dataSpec data specification, which must contain any data - * required by this control's extra coords and be - * set up for the given subset - * @param subset row subset in the current table for which the - * layer is to be plotted - * @param new plot layer - */ - private - PlotLayer createLayer( Plotter plotter, DataGeom geom, - DataSpec dataSpec, RowSubset subset ) { ConfigMap config = stylePanel_.getConfig( subset ); config.putAll( getExtraConfig() ); - S style = plotter.createStyle( config ); - assert style.equals( plotter.createStyle( config ) ); - assert style.hashCode() == plotter.createStyle( config ).hashCode(); - return plotter.createLayer( geom, dataSpec, style ); + return getStyler().createLayer( getPlotter(), geom, dataSpec, config ); } /** diff --git a/topcat/src/main/uk/ac/starlink/topcat/plot2/FormLayerControl.java b/topcat/src/main/uk/ac/starlink/topcat/plot2/FormLayerControl.java index 4112fce19f..942a70aa55 100644 --- a/topcat/src/main/uk/ac/starlink/topcat/plot2/FormLayerControl.java +++ b/topcat/src/main/uk/ac/starlink/topcat/plot2/FormLayerControl.java @@ -193,7 +193,10 @@ public PlotLayer[] getPlotLayers() { PlotUtil.arrayConcat( posContents, extraContents ); DataSpec dspec = new GuiDataSpec( tcModel_, subset, contents ); - layerList.add( fc.createLayer( geom, dspec, subset ) ); + PlotLayer layer = fc.createLayer( geom, dspec, subset ); + if ( layer != null ) { + layerList.add( layer ); + } } } } @@ -244,10 +247,12 @@ public void submitReports( Map reports ) { DataSpec dspec = new GuiDataSpec( tcModel_, rset, contents ); PlotLayer layer = fc.createLayer( geom, dspec, rset ); - ReportMap report = - reports.get( LayerId.createLayerId( layer ) ); - if ( report != null ) { - sreports.put( rset, report ); + if ( layer != null ) { + ReportMap report = + reports.get( LayerId.createLayerId( layer ) ); + if ( report != null ) { + sreports.put( rset, report ); + } } } } diff --git a/topcat/src/main/uk/ac/starlink/topcat/plot2/FormStylePanel.java b/topcat/src/main/uk/ac/starlink/topcat/plot2/FormStylePanel.java index 10227c9813..c4b46e3708 100644 --- a/topcat/src/main/uk/ac/starlink/topcat/plot2/FormStylePanel.java +++ b/topcat/src/main/uk/ac/starlink/topcat/plot2/FormStylePanel.java @@ -22,8 +22,10 @@ import javax.swing.border.BevelBorder; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; +import uk.ac.starlink.ttools.plot.Style; import uk.ac.starlink.ttools.plot2.PlotUtil; import uk.ac.starlink.ttools.plot2.Plotter; +import uk.ac.starlink.ttools.plot2.config.ConfigException; import uk.ac.starlink.ttools.plot2.config.ConfigKey; import uk.ac.starlink.ttools.plot2.config.ConfigMap; import uk.ac.starlink.topcat.ActionForwarder; @@ -300,14 +302,21 @@ private void setSubsetSpecifierActive( boolean isActive ) { * the state of its configuration. */ private void updateLegendIcon() { - final Icon icon; + Style style; if ( subsetSelector_.getSelectedItem() instanceof RowSubset ) { ConfigMap config = subsetSpecifier_.getSpecifiedValue(); - icon = plotterFact_.getItem().createStyle( config ).getLegendIcon(); + try { + style = plotterFact_.getItem().createStyle( config ); + } + catch ( ConfigException e ) { + style = null; + } } else { - icon = IconUtils.emptyIcon( 24, 24 ); + style = null; } + Icon icon = style == null ? IconUtils.emptyIcon( 24, 24 ) + : style.getLegendIcon(); iconLabel_.setIcon( icon ); } diff --git a/topcat/src/main/uk/ac/starlink/topcat/plot2/PlotPositionSpecifier.java b/topcat/src/main/uk/ac/starlink/topcat/plot2/PlotPositionSpecifier.java index be1d1e899b..a1fa920125 100644 --- a/topcat/src/main/uk/ac/starlink/topcat/plot2/PlotPositionSpecifier.java +++ b/topcat/src/main/uk/ac/starlink/topcat/plot2/PlotPositionSpecifier.java @@ -112,7 +112,7 @@ private static ConfigKey createIntegerKey( ConfigMeta meta ) { public String valueToString( Integer value ) { return value == null ? "" : value.toString(); } - public Integer stringToValue( String txt ) { + public Integer stringToValue( String txt ) throws ConfigException { if ( txt == null || txt.trim().length() == 0 ) { return null; } diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/SurfaceFactory.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/SurfaceFactory.java index 3a64730090..345780ee22 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/SurfaceFactory.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/SurfaceFactory.java @@ -54,7 +54,7 @@ public interface SurfaceFactory { * @param config map of profile configuration items * @return factory-specific plot surface profile */ - P createProfile( ConfigMap config ) throws ConfigException; + P createProfile( ConfigMap config ); /** * Returns the configuration keys that may be used to configure aspect @@ -109,8 +109,7 @@ public interface SurfaceFactory { * @param ranges range data filled in from layers, or null * @return new aspect */ - A createAspect( P profile, ConfigMap aspectConfig, Range[] ranges ) - throws ConfigException; + A createAspect( P profile, ConfigMap aspectConfig, Range[] ranges ); /** * Returns the configuration keys that may be used to configure diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/BooleanConfigKey.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/BooleanConfigKey.java index bb3fb87fc1..7a63f4b489 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/BooleanConfigKey.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/BooleanConfigKey.java @@ -45,7 +45,7 @@ public BooleanConfigKey( ConfigMeta meta ) { this( meta, false ); } - public Boolean stringToValue( String txt ) { + public Boolean stringToValue( String txt ) throws ConfigException { txt = txt.toLowerCase(); if ( TRUE_STRINGS.contains( txt ) ) { return Boolean.TRUE; diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/ChoiceConfigKey.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/ChoiceConfigKey.java index 192852beb8..06a0769c22 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/ChoiceConfigKey.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/ChoiceConfigKey.java @@ -90,7 +90,7 @@ public Map getOptionMap() { */ public abstract String stringifyValue( T value ); - public T stringToValue( String sval ) { + public T stringToValue( String sval ) throws ConfigException { if ( sval == null || sval.length() == 0 ) { if ( nullPermitted_ ) { return null; diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/ConfigException.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/ConfigException.java index 7a9ee8d82c..d20e9d27e9 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/ConfigException.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/ConfigException.java @@ -3,15 +3,10 @@ /** * Exception thrown when a configuration input value is not suitable. * - *

This exception is currently unchecked because it will not - * often be thrown and to avoid clutter in the code. - * However, it should be checked for (explicitly caught) in some places, - * in particular where controlled values are input from text fields. - * * @author Mark Taylor * @since 26 Feb 2013 */ -public class ConfigException extends RuntimeException { +public class ConfigException extends Exception { private final ConfigKey key_; diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/DoubleConfigKey.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/DoubleConfigKey.java index 57d44e34f8..caabf873ad 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/DoubleConfigKey.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/DoubleConfigKey.java @@ -35,7 +35,7 @@ public String valueToString( Double value ) { : value.toString(); } - public Double stringToValue( String txt ) { + public Double stringToValue( String txt ) throws ConfigException { if ( txt == null || txt.trim().length() == 0 ) { return new Double( Double.NaN ); } diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/OptionConfigKey.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/OptionConfigKey.java index 29212de7af..f017315aa8 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/OptionConfigKey.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/OptionConfigKey.java @@ -81,7 +81,7 @@ public String valueToString( T value ) { * This means that if valueToString is overridden it * is usually not necessary to override this method. */ - public T stringToValue( String txt ) { + public T stringToValue( String txt ) throws ConfigException { if ( txt == null || txt.trim().length() == 0 ) { return null; } diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/SkySysConfigKey.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/SkySysConfigKey.java index d9c18a667f..96d2e8933d 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/SkySysConfigKey.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/SkySysConfigKey.java @@ -24,7 +24,7 @@ public String valueToString( SkySys sys ) { return sys == null ? "generic" : super.valueToString( sys ); } - public SkySys stringToValue( String str ) { + public SkySys stringToValue( String str ) throws ConfigException { return "generic".equals( str ) ? null : super.stringToValue( str ); } diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/SubrangeConfigKey.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/SubrangeConfigKey.java index 15cbd59e41..acdec81aa2 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/SubrangeConfigKey.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/SubrangeConfigKey.java @@ -53,7 +53,7 @@ public String valueToString( Subrange value ) { return format( value.getLow(), 3 ) + "," + format( value.getHigh(), 3 ); } - public Subrange stringToValue( String txt ) { + public Subrange stringToValue( String txt ) throws ConfigException { String[] limits = txt.split( "," ); if ( limits.length == 2 ) { String slo = limits[ 0 ].trim(); diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/TimeConfigKey.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/TimeConfigKey.java index dab7ef49be..1e7f36d0f9 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/TimeConfigKey.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/TimeConfigKey.java @@ -59,7 +59,7 @@ public String valueToString( Double value ) { : formatTime( stime ); } - public Double stringToValue( String txt ) { + public Double stringToValue( String txt ) throws ConfigException { if ( txt == null || txt.trim().length() == 0 ) { return new Double( Double.NaN ); } diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/CubeSurfaceFactory.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/CubeSurfaceFactory.java index 72b68158de..1469eccb61 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/CubeSurfaceFactory.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/CubeSurfaceFactory.java @@ -312,7 +312,7 @@ public ConfigKey[] getProfileKeys() { return list.toArray( new ConfigKey[ 0 ] ); } - public Profile createProfile( ConfigMap config ) throws ConfigException { + public Profile createProfile( ConfigMap config ) { boolean xlog = isIso_ ? false : config.get( XLOG_KEY ); boolean ylog = isIso_ ? false : config.get( YLOG_KEY ); boolean zlog = isIso_ ? false : config.get( ZLOG_KEY ); diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/PlaneSurfaceFactory.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/PlaneSurfaceFactory.java index a796529e46..947c6c519e 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/PlaneSurfaceFactory.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/PlaneSurfaceFactory.java @@ -179,7 +179,7 @@ public ConfigKey[] getProfileKeys() { return list.toArray( new ConfigKey[ 0 ] ); } - public Profile createProfile( ConfigMap config ) throws ConfigException { + public Profile createProfile( ConfigMap config ) { boolean xlog = config.get( XLOG_KEY ); boolean ylog = config.get( YLOG_KEY ); boolean xflip = config.get( XFLIP_KEY ); diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/SkySurfaceFactory.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/SkySurfaceFactory.java index 85b1cb0aa1..9e8b07bfa5 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/SkySurfaceFactory.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/geom/SkySurfaceFactory.java @@ -198,7 +198,7 @@ public ConfigKey[] getProfileKeys() { return list.toArray( new ConfigKey[ 0 ] ); } - public Profile createProfile( ConfigMap config ) throws ConfigException { + public Profile createProfile( ConfigMap config ) { Projection proj = config.get( PROJECTION_KEY ); boolean reflect = config.get( REFLECT_KEY ); SkySys viewSystem = config.get( VIEWSYS_KEY ); diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/BinSizer.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/BinSizer.java index 4699a167a0..485e98e17a 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/BinSizer.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/BinSizer.java @@ -195,7 +195,7 @@ private static class BinSizerConfigKey extends ConfigKey { dfltNbin_ = dfltNbin; } - public BinSizer stringToValue( String txt ) { + public BinSizer stringToValue( String txt ) throws ConfigException { double dval; try { dval = Double.valueOf( txt.trim() ); diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/FunctionPlotter.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/FunctionPlotter.java index 908c80bcd8..0763a34405 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/FunctionPlotter.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/FunctionPlotter.java @@ -160,7 +160,8 @@ public ConfigKey[] getFunctionStyleKeys() { }; } - public FunctionStyle createStyle( ConfigMap config ) { + public FunctionStyle createStyle( ConfigMap config ) + throws ConfigException { String xname = config.get( XNAME_KEY ); String fexpr = config.get( FEXPR_KEY ); if ( xname == null || xname.trim().length() == 0 || diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/LabelPlotter.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/LabelPlotter.java index 5c302a9d05..43627dad42 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/LabelPlotter.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/LabelPlotter.java @@ -142,7 +142,7 @@ public ConfigKey[] getStyleKeys() { return list.toArray( new ConfigKey[ 0 ] ); } - public LabelStyle createStyle( ConfigMap config ) { + public LabelStyle createStyle( ConfigMap config ) throws ConfigException { int iclimit = config.get( CROWDLIMIT_KEY ); if ( iclimit < 1 || iclimit > MAX_CROWDLIMIT ) { throw new ConfigException( CROWDLIMIT_KEY, diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/ShapePlotter.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/ShapePlotter.java index a591cf4a57..43d9752187 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/ShapePlotter.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/ShapePlotter.java @@ -67,7 +67,7 @@ public ConfigKey[] getStyleKeys() { mode_.getConfigKeys() ); } - public ShapeStyle createStyle( ConfigMap config ) throws ConfigException { + public ShapeStyle createStyle( ConfigMap config ) { ShapeStyle style = new ShapeStyle( form_.createOutliner( config ), mode_.createStamper( config ) ); assert style.equals( new ShapeStyle( form_.createOutliner( config ), diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/task/AbstractPlot2Task.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/task/AbstractPlot2Task.java index 05b9838512..7615ed4766 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/task/AbstractPlot2Task.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/task/AbstractPlot2Task.java @@ -44,6 +44,7 @@ import uk.ac.starlink.task.StringParameter; import uk.ac.starlink.task.Task; import uk.ac.starlink.task.TaskException; +import uk.ac.starlink.task.UsageException; import uk.ac.starlink.ttools.func.Strings; import uk.ac.starlink.ttools.plot.GraphicExporter; import uk.ac.starlink.ttools.plot.Range; @@ -65,6 +66,7 @@ import uk.ac.starlink.ttools.plot2.SubCloud; import uk.ac.starlink.ttools.plot2.Surface; import uk.ac.starlink.ttools.plot2.SurfaceFactory; +import uk.ac.starlink.ttools.plot2.config.ConfigException; import uk.ac.starlink.ttools.plot2.config.ConfigKey; import uk.ac.starlink.ttools.plot2.config.ConfigMap; import uk.ac.starlink.ttools.plot2.config.KeySet; @@ -1529,7 +1531,14 @@ PlotLayer createPlotLayer( Environment env, String suffix, /* Work out the requested style. */ @SuppressWarnings("unchecked") Plotter splotter = (Plotter) plotter; - S style = splotter.createStyle( config ); + S style; + try { + style = splotter.createStyle( config ); + } + catch ( ConfigException e ) { + throw new UsageException( e.getConfigKey().getMeta().getShortName() + + ": " + e.getMessage(), e ); + } /* Return a layer based on these. */ return splotter.createLayer( geom, dataSpec, style );