KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jcckit > data > DataPlot


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.data;
20
21 import jcckit.util.ConfigParameters;
22
23 import java.util.StringTokenizer JavaDoc;
24
25 /**
26  * A plot is a {@link DataContainer} of {@link DataCurve DataCurves}.
27  *
28  * @author Franz-Josef Elmer
29  */

30 public class DataPlot extends DataContainer {
31   /** Config parameter key. */
32   public static final String JavaDoc CURVES_KEY = "curves",
33                              DATA_KEY = "data";
34
35   /** Creates an empty instance. */
36   public DataPlot() {}
37
38   /**
39    * Creates an instance from the specified config parameters.
40    * <table border=1 cellpadding=5>
41    * <tr><th>Key &amp; Default Value</th><th>Type</th><th>Mandatory</th>
42    * <th>Description</th></tr>
43    * <tr><td><tt>curves</tt></td><td><tt>String[]</tt></td><td>yes</td>
44    * <td>List of keys denoting data curves. Each key refers to
45    * config parameters used in the
46    * <a HREF="DataCurve.html#DataCurve(jcckit.util.ConfigParameters)">
47    * constructor</a> of {@link DataCurve}.</td></tr>
48    * </table>
49    */

50   public DataPlot(ConfigParameters config) {
51     StringTokenizer JavaDoc tokenizer = new StringTokenizer JavaDoc(config.get(CURVES_KEY));
52     while (tokenizer.hasMoreTokens()) {
53       addElement(new DataCurve(config.getNode(tokenizer.nextToken())));
54     }
55   }
56
57   /**
58    * Convenient method to create a <tt>DataPlot</tt> based on the specified
59    * config parameters. It is a short-cut of
60    * <tt>new DataPlot(config.getNode("data"))</tt>.
61    */

62   public static DataPlot create(ConfigParameters config) {
63     return new DataPlot(config.getNode(DATA_KEY));
64   }
65
66   /**
67    * Returns <tt>true</tt> if <tt>element</tt> is an instance of
68    * {@link DataCurve}.
69    */

70   protected boolean isValid(DataElement element) {
71     return element instanceof DataCurve;
72   }
73 }
74
75
Popular Tags