KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jcckit > plot > AxisParameters


1 /*
2  * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved
3  *
4  * This library is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation; either version 2.1 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details
13  * (http://www.gnu.org/copyleft/lesser.html).
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package jcckit.plot;
20
21 import java.util.Properties JavaDoc;
22
23 import jcckit.graphic.BasicGraphicAttributes;
24 import jcckit.graphic.GraphPoint;
25 import jcckit.graphic.LineAttributes;
26 import jcckit.graphic.ShapeAttributes;
27 import jcckit.graphic.TextAttributes;
28 import jcckit.util.ConfigData;
29 import jcckit.util.ConfigParameters;
30 import jcckit.util.ConfigParametersBasedConfigData;
31 import jcckit.util.Factory;
32 import jcckit.util.Format;
33 import jcckit.util.PropertiesBasedConfigData;
34 import jcckit.util.TicLabelFormat;
35 import jcckit.util.Util;
36
37 /**
38  * Helper class with various parameters defining an axis.
39  * This helper class is used by {@link CartesianCoordinateSystem}
40  * to set up a coordinate systems.
41  * <p>
42  * This class holds more than a dozen parameters. There are two factory
43  * methods creating instances for x- and y-axis based on
44  * {@link ConfigParameters}. They differ in their default parameters for
45  * those axes.
46  * <p>
47  * Note, that there is a direct access of these parameters without getters
48  * and setters but only for classes in the package <tt>jcckit.plot</tt>.
49  *
50  * @author Franz-Josef Elmer
51  */

52 public class AxisParameters {
53   /** Configuration parameter key. */
54   public static final String JavaDoc LOG_SCALE_KEY = "logScale",
55                              MINIMUM_KEY = "minimum",
56                              MAXIMUM_KEY = "maximum",
57                              AXIS_LENGTH_KEY = "axisLength",
58                              AXIS_ATTRIBUTES_KEY = "axisAttributes",
59                              AXIS_LABEL_KEY = "axisLabel",
60                              AXIS_LABEL_POSITION_KEY = "axisLabelPosition",
61                              AXIS_LABEL_ATTRIBUTES_KEY = "axisLabelAttributes",
62                              AUTOMATIC_TIC_CALCULATION_KEY
63                                   = "automaticTicCalculation",
64                              MINIMUM_TIC_KEY = "minimumTic",
65                              MAXIMUM_TIC_KEY = "maximumTic",
66                              NUMBER_OF_TICS_KEY = "numberOfTics",
67                              TIC_LENGTH_KEY = "ticLength",
68                              TIC_ATTRIBUTES_KEY = "ticAttributes",
69                              TIC_LABEL_FORMAT_KEY = "ticLabelFormat",
70                              TIC_LABEL_POSITION_KEY = "ticLabelPosition",
71                              TIC_LABEL_ATTRIBUTES_KEY = "ticLabelAttributes",
72                              GRID_KEY = "grid",
73                              GRID_ATTRIBUTES_KEY = "gridAttributes";
74
75   private static final double LN10 = Math.log(10);
76
77   /** If <tt>true</tt> the scale is logarithmic otherwise linear. */
78   boolean logScale;
79   /** Minimum data value represented by the axis. */
80   double minimum;
81   /** Maximum data value represented by the axis. */
82   double maximum;
83   /** Length of the axis in device-independent graphical units. */
84   double axisLength;
85   /**
86    * Line attributes of the axis.
87    * Can be <tt>null</tt> which means default attributes.
88    */

89   LineAttributes axisAttributes;
90
91   boolean automaticTicCalculation;
92   double minimumTic;
93   double maximumTic;
94   int numberOfTics;
95   /**
96    * Length of the tics in device-independent graphical units.
97    * If 0 no tics and tics label will be drawn.
98    */

99   double ticLength;
100   /**
101    * Attributes of the tics.
102    * Can be <tt>null</tt> which means default attributes.
103    */

104   LineAttributes ticAttributes;
105   /** Tic label formatter. */
106   TicLabelFormat ticLabelFormat;
107   /** Position of the tic label relative to the tic. */
108   GraphPoint ticLabelPosition;
109   /** Text attributes of the tic labels. */
110   TextAttributes ticLabelAttributes;
111
112   /** If <tt>true</tt> grid lines are drawn. */
113   boolean grid;
114   /**
115    * Attributes of the grid lines.
116    * Can be <tt>null</tt> which means default attributes.
117    */

118   LineAttributes gridAttributes;
119
120   /** Axis label. */
121   String JavaDoc axisLabel;
122   /** Position of the axis label relative to the center of the axis. */
123   GraphPoint axisLabelPosition;
124   /** Text attributes of the axis label. */
125   TextAttributes axisLabelAttributes;
126
127   /**
128    * Calculate the tics based on <tt>minimumTic</tt>, <tt>maximumTic</tt>,
129    * and <tt>numberOfTics</tt>. If <tt>automaticTicCalculation == true</tt>
130    * appropriated values for these fields are calculated.
131    */

132   double[] calculateTics() {
133     if (automaticTicCalculation) {
134       calculateTicsParameters();
135     }
136     double[] result = new double[numberOfTics];
137     if (numberOfTics > 0) {
138       double b = Util.log(minimumTic, logScale);
139       double a = Util.log(maximumTic, logScale);
140       a = numberOfTics > 1 ? (a - b) / (numberOfTics - 1) : 0;
141       for (int i = 0; i < result.length; i++) {
142         result[i] = Util.exp(a * i + b, logScale);
143       }
144       result[0] = adjust(minimum, result[0]);
145       result[numberOfTics - 1] = adjust(maximum, result[numberOfTics - 1]);
146     }
147     return result;
148   }
149
150   private void calculateTicsParameters() {
151     double min = Math.min(minimum, maximum);
152     double max = Math.max(minimum, maximum);
153     if (logScale) {
154       int minExponent = (int) (199.9999 + Math.log(min) / LN10) - 199;
155       int maxExponent = (int) (200.0001 + Math.log(max) / LN10) - 200;
156       minimumTic = Math.exp(LN10 * minExponent);
157       maximumTic = Math.exp(LN10 * maxExponent);
158       numberOfTics = maxExponent - minExponent + 1;
159     } else {
160       int baseExponent = (int) (199.69 + Math.log(max - min) / LN10) - 200;
161       double base = 0.2 * Math.exp(LN10 * baseExponent);
162       do
163       {
164         base *= 5;
165         int minInt = (int) (999999.999999 + min / base) - 999999;
166         int maxInt = (int) (1000000.000001 + max / base) - 1000000;
167         minimumTic = minInt * base;
168         maximumTic = maxInt * base;
169         numberOfTics = maxInt - minInt + 1;
170       } while (numberOfTics > 11);
171     }
172   }
173
174   /**
175    * Returns <tt>adjustingValue</tt> if <tt>value</tt> is very close
176    * to <tt>adjustingValue</tt>. Otherwise <tt>value</tt> is returned.
177    */

178   private static double adjust(double adjustingValue, double value) {
179     return value != 0 && Math.abs(adjustingValue / value - 1) < 1e-11
180                                               ? adjustingValue : value;
181   }
182
183   /**
184    * Returns a <tt>Properties</tt> object with those default parameters
185    * which are common for x- and y-axis.
186    */

187   private static Properties JavaDoc createDefaultAxisProperties() {
188     Properties JavaDoc p = new Properties JavaDoc();
189     p.put(LOG_SCALE_KEY, "false");
190     p.put(MINIMUM_KEY, "0");
191     p.put(MAXIMUM_KEY, "1");
192     p.put(AXIS_LENGTH_KEY, "0.8");
193     p.put(AXIS_ATTRIBUTES_KEY + '/' + Factory.CLASS_NAME_KEY,
194           ShapeAttributes.class.getName());
195     p.put(AXIS_LABEL_KEY, "x");
196     p.put(AXIS_LABEL_POSITION_KEY, "0 -0.05");
197     p.put(AXIS_LABEL_ATTRIBUTES_KEY + '/' + Factory.CLASS_NAME_KEY,
198           BasicGraphicAttributes.class.getName());
199     p.put(AXIS_LABEL_ATTRIBUTES_KEY + '/'
200           + BasicGraphicAttributes.HORIZONTAL_ANCHOR_KEY, "center");
201     p.put(AUTOMATIC_TIC_CALCULATION_KEY, "true");
202     p.put(TIC_LENGTH_KEY, "0.01");
203     p.put(TIC_ATTRIBUTES_KEY + '/' + Factory.CLASS_NAME_KEY,
204           ShapeAttributes.class.getName());
205     p.put(TIC_LABEL_POSITION_KEY, "0 -0.01");
206     p.put(TIC_LABEL_FORMAT_KEY, "%1.1f");
207     p.put(TIC_LABEL_ATTRIBUTES_KEY + '/' + Factory.CLASS_NAME_KEY,
208           BasicGraphicAttributes.class.getName());
209     p.put(TIC_LABEL_ATTRIBUTES_KEY + '/'
210           + BasicGraphicAttributes.HORIZONTAL_ANCHOR_KEY, "center");
211     p.put(TIC_LABEL_ATTRIBUTES_KEY + '/'
212           + BasicGraphicAttributes.VERTICAL_ANCHOR_KEY, "top");
213     p.put(GRID_KEY, "false");
214     p.put(GRID_ATTRIBUTES_KEY + '/' + Factory.CLASS_NAME_KEY,
215           ShapeAttributes.class.getName());
216     return p;
217   }
218
219   /**
220    * Returns a <tt>Properties</tt> object of the default parameters for
221    * an x-axis.
222    */

223   private static Properties JavaDoc createDefaultXAxisProperties() {
224     Properties JavaDoc p = createDefaultAxisProperties();
225     p.put(AXIS_LABEL_KEY, "x");
226     p.put(AXIS_LABEL_POSITION_KEY, "0 -0.05");
227     p.put(AXIS_LABEL_ATTRIBUTES_KEY + '/'
228           + BasicGraphicAttributes.VERTICAL_ANCHOR_KEY, "top");
229     p.put(TIC_LABEL_POSITION_KEY, "0 -0.01");
230     p.put(TIC_LABEL_ATTRIBUTES_KEY + '/'
231           + BasicGraphicAttributes.HORIZONTAL_ANCHOR_KEY, "center");
232     p.put(TIC_LABEL_ATTRIBUTES_KEY + '/'
233           + BasicGraphicAttributes.VERTICAL_ANCHOR_KEY, "top");
234     return p;
235   }
236
237   /**
238    * Creates an x axis based on the specified configuration parameters.
239    * All numbers (lengths, fontsizes, linethicknesses, etc.) are in
240    * device-independent units.
241    * <table border=1 cellpadding=5>
242    * <tr><th>Key &amp; Default Value</th><th>Type</th><th>Mandatory</th>
243    * <th>Description</th></tr>
244    * <tr><td><tt>automaticTicCalculation = true</tt></td>
245    * <td><tt>boolean</tt></td><td>no</td>
246    * <td>Has to be <tt>true</tt> if the tics should be calculated
247    * automatically.</td></tr>
248    * <tr><td><tt>axisAttributes = </tt>default values of
249    * {@link ShapeAttributes}</td>
250    * <td><tt>ConfigParameters</tt></td><td>no</td>
251    * <td>Attributes of the axis box.</td></tr>
252    * <tr><td><tt>axisLabel = x</tt></td>
253    * <td><tt>String</tt></td><td>no</td>
254    * <td>Axis label.</td></tr>
255    * <tr><td><tt>axisLabelAttributes = </tt>default values of
256    * {@link BasicGraphicAttributes} with a text anchor CENTER
257    * TOP.</td>
258    * <td><tt>ConfigParameters</tt></td><td>no</td>
259    * <td>Text attributes of axis label.</td></tr>
260    * <tr><td><tt>axisLabelPosition = 0 -0.05</tt></td>
261    * <td><tt>double[]</tt></td><td>no</td>
262    * <td>Position of the anchor of the axis
263    * label relative to the center of the x-axis line.</td></tr>
264    * <tr><td><tt>axisLength = 0.8</tt></td>
265    * <td><tt>double</tt></td><td>no</td>
266    * <td>Length of the x-axis.</td></tr>
267    * <tr><td><tt>grid = false</tt></td>
268    * <td><tt>boolean</tt></td><td>no</td>
269    * <td>If <tt>true</tt> grid lines will be drawn through the axis
270    * tics.</td></tr>
271    * <tr><td><tt>gridAttributes = </tt>default values of
272    * {@link ShapeAttributes}</td>
273    * <td><tt>ConfigParameters</tt></td><td>no</td>
274    * <td>Attributes of the grid lines.</td></tr>
275    * <tr><td><tt>logScale = false</tt></td>
276    * <td><tt>boolean</tt></td><td>no</td>
277    * <td>If <tt>true</tt> the axis will be logarithmic. Otherwise
278    * the axis is linear.</td></tr>
279    * <tr><td><tt>maximum = 1</tt></td>
280    * <td><tt>double</tt></td><td>no</td>
281    * <td>The corresponding data value of one end of the axis.</td></tr>
282    * <tr><td><tt>maximumTic = </tt>result from automatic calculation</td>
283    * <td><tt>double</tt></td><td>no</td>
284    * <td>The corresponding data value of the tic nearest the maximum end
285    * of the axis.</td></tr>
286    * <tr><td><tt>minimum = 0</tt></td>
287    * <td><tt>double</tt></td><td>no</td>
288    * <td>The corresponding data value of one end of the axis.</td></tr>
289    * <tr><td><tt>minimumTic = </tt>result from automatic calculation</td>
290    * <td><tt>double</tt></td><td>no</td>
291    * <td>The corresponding data value of the tic nearest the minimum end
292    * of the axis.</td></tr>
293    * <tr><td><tt>numberOfTics = </tt>result from automatic calculation</td>
294    * <td><tt>int</tt></td><td>no</td>
295    * <td>Number of tics. The tics between the minimum and maximum tic
296    * are spaced equidistantly.</td></tr>
297    * <tr><td><tt>ticAttributes = </tt>default values of
298    * {@link ShapeAttributes}</td>
299    * <td><tt>ConfigParameters</tt></td><td>no</td>
300    * <td>Attributes of the tics.</td></tr>
301    * <tr><td><tt>ticLabelAttributes = </tt>default values of
302    * {@link BasicGraphicAttributes} with a text anchor CENTER
303    * TOP.</td>
304    * <td><tt>ConfigParameters</tt></td><td>no</td>
305    * <td>Text attributes of tic labels.</td></tr>
306    * <tr><td><tt>ticLabelFormat = %1.1f</tt></td>
307    * <td><tt>String</tt> or <tt>ConfigParameters</tt></td><td>no</td>
308    * <td>Defines rendering of the tic label. By default a
309    * <tt>printf</tt>-like format string is given (see {@link Format}).
310    * Note, that an empty string means that tic labels are dropped.
311    * <p>
312    * For non-numerical rendering an implementation of a
313    * {@link TicLabelFormat} can be specified (e.g.
314    * {@link TicLabelMap}). Note, that a configuration sub tree with
315    * a <tt>className</tt> key-value pair overwrites any string
316    * definition.</td></tr>
317    * <tr><td><tt>ticLabelPosition = 0 -0.01</tt></td>
318    * <td><tt>double[]</tt></td><td>no</td>
319    * <td>Position of the anchor of the tic label relative to the
320    * tic position on the axis.</td></tr>
321    * <tr><td><tt>ticLength = 0.01</tt></td>
322    * <td><tt>double</tt></td><td>no</td>
323    * <td>Length of the tics. Negative/positive values mean tics
324    * inside/outside the box.</td></tr>
325    * </table>
326    */

327   public static AxisParameters createXAxis(ConfigParameters config) {
328     return createAxis(config, createDefaultXAxisProperties());
329   }
330
331   /**
332    * Returns a <tt>Properties</tt> object of the default parameters for
333    * an x-axis.
334    */

335   private static Properties JavaDoc createDefaultYAxisProperties() {
336     Properties JavaDoc p = createDefaultAxisProperties();
337     p.put(AXIS_LENGTH_KEY, "0.45");
338     p.put(AXIS_LABEL_KEY, "y");
339     p.put(AXIS_LABEL_POSITION_KEY, "-0.1 0");
340     p.put(AXIS_LABEL_ATTRIBUTES_KEY + '/'
341           + BasicGraphicAttributes.VERTICAL_ANCHOR_KEY, "bottom");
342     p.put(AXIS_LABEL_ATTRIBUTES_KEY + '/'
343           + BasicGraphicAttributes.ORIENTATION_ANGLE_KEY, "90");
344     p.put(TIC_LABEL_POSITION_KEY, "-0.01 0");
345     p.put(TIC_LABEL_ATTRIBUTES_KEY + '/'
346           + BasicGraphicAttributes.HORIZONTAL_ANCHOR_KEY, "right");
347     p.put(TIC_LABEL_ATTRIBUTES_KEY + '/'
348           + BasicGraphicAttributes.VERTICAL_ANCHOR_KEY, "center");
349     return p;
350   }
351
352   /**
353    * Creates an y axis based on the specified configuration parameters.
354    * All numbers (lengths, fontsizes, linethicknesses, etc.) are in
355    * device-independent units.
356    * <table border=1 cellpadding=5>
357    * <tr><th>Key &amp; Default Value</th><th>Type</th><th>Mandatory</th>
358    * <th>Description</th></tr>
359    * <tr><td><tt>automaticTicCalculation = true</tt></td>
360    * <td><tt>boolean</tt></td><td>no</td>
361    * <td>Has to be <tt>true</tt> if the tics should be calculated
362    * automatically.</td></tr>
363    * <tr><td><tt>axisAttributes = </tt>default values of
364    * {@link ShapeAttributes}</td>
365    * <td><tt>ConfigParameters</tt></td><td>no</td>
366    * <td>Attributes of the axis box.</td></tr>
367    * <tr><td><tt>axisLabel = y</tt></td>
368    * <td><tt>String</tt></td><td>no</td>
369    * <td>Axis label.</td></tr>
370    * <tr><td><tt>axisLabelAttributes = </tt>default values of
371    * {@link BasicGraphicAttributes} with a text anchor CENTER
372    * BOTTOM and the text rotated by 90 degree.</td>
373    * <td><tt>ConfigParameters</tt></td><td>no</td>
374    * <td>Text attributes of axis label.</td></tr>
375    * <tr><td><tt>axisLabelPosition = -0.1 0</tt></td>
376    * <td><tt>double[]</tt></td><td>no</td>
377    * <td>Position of the anchor of the axis
378    * label relative to the center of the y-axis line.</td></tr>
379    * <tr><td><tt>axisLength = 0.45</tt></td>
380    * <td><tt>double</tt></td><td>no</td>
381    * <td>Length of the y-axis.</td></tr>
382    * <tr><td><tt>grid = false</tt></td>
383    * <td><tt>boolean</tt></td><td>no</td>
384    * <td>If <tt>true</tt> grid lines will be drawn through the axis
385    * tics.</td></tr>
386    * <tr><td><tt>gridAttributes = </tt>default values of
387    * {@link ShapeAttributes}</td>
388    * <td><tt>ConfigParameters</tt></td><td>no</td>
389    * <td>Attributes of the grid lines.</td></tr>
390    * <tr><td><tt>logScale = false</tt></td>
391    * <td><tt>boolean</tt></td><td>no</td>
392    * <td>If <tt>true</tt> the axis will be logarithmic. Otherwise
393    * the axis is linear.</td></tr>
394    * <tr><td><tt>maximum = 1</tt></td>
395    * <td><tt>double</tt></td><td>no</td>
396    * <td>The corresponding data value of one end of the axis.</td></tr>
397    * <tr><td><tt>maximumTic = </tt>result from automatic calculation</td>
398    * <td><tt>double</tt></td><td>no</td>
399    * <td>The corresponding data value of the tic nearest the maximum end
400    * of the axis.</td></tr>
401    * <tr><td><tt>minimum = 0</tt></td>
402    * <td><tt>double</tt></td><td>no</td>
403    * <td>The corresponding data value of one end of the axis.</td></tr>
404    * <tr><td><tt>minimumTic = </tt>result from automatic calculation</td>
405    * <td><tt>double</tt></td><td>no</td>
406    * <td>The corresponding data value of the tic nearest the minimum end
407    * of the axis.</td></tr>
408    * <tr><td><tt>numberOfTics = </tt>result from automatic calculation</td>
409    * <td><tt>int</tt></td><td>no</td>
410    * <td>Number of tics. The tics between the minimum and maximum tic
411    * are spaced equidistantly.</td></tr>
412    * <tr><td><tt>ticAttributes = </tt>default values of
413    * {@link ShapeAttributes}</td>
414    * <td><tt>ConfigParameters</tt></td><td>no</td>
415    * <td>Attributes of the tics.</td></tr>
416    * <tr><td><tt>ticLabelAttributes = </tt>default values of
417    * {@link BasicGraphicAttributes} with a text anchor RIGHT CENTER.
418    * </td>
419    * <td><tt>ConfigParameters</tt></td><td>no</td>
420    * <td>Text attributes of tic labels.</td></tr>
421    * <tr><td><tt>ticLabelFormat = %1.1f</tt></td>
422    * <td><tt>String</tt></td><td>no</td>
423    * <td>Defines rendering of the tic label. By default a
424    * <tt>printf</tt>-like format string is given (see {@link Format}).
425    * Note, that an empty string means that tic labels are dropped.
426    * <p>
427    * For non-numerical rendering an implementation of a
428    * {@link TicLabelFormat} can be specified (e.g.
429    * {@link TicLabelMap}). Note, that a configuration sub tree with
430    * a <tt>className</tt> key-value pair overwrites any string
431    * definition.</td></tr>
432    * <tr><td><tt>ticLabelPosition = -0.01 0</tt></td>
433    * <td><tt>double[]</tt></td><td>no</td>
434    * <td>Position of the anchor of the tic label relative to the
435    * tic position on the axis.</td></tr>
436    * <tr><td><tt>ticLength = 0.01</tt></td>
437    * <td><tt>double</tt></td><td>no</td>
438    * <td>Length of the tics. Negative/positive values mean tics
439    * inside/outside the box.</td></tr>
440    * </table>
441    */

442   public static AxisParameters createYAxis(ConfigParameters config) {
443     return createAxis(config, createDefaultYAxisProperties());
444   }
445
446   private static AxisParameters createAxis(ConfigParameters config,
447                                            Properties JavaDoc p) {
448     ConfigData cd = new PropertiesBasedConfigData(p);
449     ConfigParameters c = new ConfigParameters(cd);
450     cd = new ConfigParametersBasedConfigData(config, c);
451     c = new ConfigParameters(cd);
452
453     AxisParameters a = new AxisParameters();
454     a.logScale = c.getBoolean(LOG_SCALE_KEY);
455     a.minimum = c.getDouble(MINIMUM_KEY);
456     a.maximum = c.getDouble(MAXIMUM_KEY);
457     a.axisLength = c.getDouble(AXIS_LENGTH_KEY);
458     a.axisAttributes
459         = (LineAttributes) Factory.create(c.getNode(AXIS_ATTRIBUTES_KEY));
460     a.axisLabel = c.get(AXIS_LABEL_KEY);
461     a.axisLabelPosition
462         = new GraphPoint(c.getDoubleArray(AXIS_LABEL_POSITION_KEY));
463     a.axisLabelAttributes = (TextAttributes) Factory.create(
464                                 c.getNode(AXIS_LABEL_ATTRIBUTES_KEY));
465     a.ticLength = c.getDouble(TIC_LENGTH_KEY);
466     a.automaticTicCalculation
467         = c.getBoolean(AUTOMATIC_TIC_CALCULATION_KEY);
468     if (!a.automaticTicCalculation) {
469       a.calculateTicsParameters(); // calculate default parameters
470
a.minimumTic = c.getDouble(MINIMUM_TIC_KEY, a.minimumTic);
471       a.maximumTic = c.getDouble(MAXIMUM_TIC_KEY, a.maximumTic);
472       a.numberOfTics = c.getInt(NUMBER_OF_TICS_KEY, a.numberOfTics);
473     }
474     a.ticAttributes
475         = (LineAttributes) Factory.create(c.getNode(TIC_ATTRIBUTES_KEY));
476     a.ticLabelFormat = createTicLabelFormat(c);
477     a.ticLabelPosition
478         = new GraphPoint(c.getDoubleArray(TIC_LABEL_POSITION_KEY));
479     a.ticLabelAttributes = (TextAttributes) Factory.create(
480                                 c.getNode(TIC_LABEL_ATTRIBUTES_KEY));
481     a.grid = c.getBoolean(GRID_KEY);
482     a.gridAttributes
483         = (LineAttributes) Factory.create(c.getNode(GRID_ATTRIBUTES_KEY));
484     return a;
485   }
486
487   private static TicLabelFormat createTicLabelFormat(ConfigParameters c)
488   {
489     TicLabelFormat result = Format.create(c, TIC_LABEL_FORMAT_KEY);
490     ConfigParameters node = c.getNode(TIC_LABEL_FORMAT_KEY);
491     if (node.get(Factory.CLASS_NAME_KEY, null) != null) {
492       result = (TicLabelFormat) Factory.create(node);
493     }
494     return result;
495   }
496 }
497
Popular Tags