1
/* $Revision: 7636 $ $Author: egonw $ $Date: 2007-01-04 18:46:10 +0100 (Thu, 04 Jan 2007) $
3
* Copyright (C) 2001-2007 Stephan Michels <stephan@vern.chem.tu-berlin.de>
5
* Contact: cdk-devel@lists.sourceforge.net
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public License
9
* as published by the Free Software Foundation; either version 2.1
10
* of the License, or (at your option) any later version.
11
* All we ask is that proper credit is given for our work, which includes
12
* - but is not limited to - adding the above copyright notice to the beginning
13
* of your source code files, and to any copyright notice that you may distribute
14
* with programs based on this work.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26
package org.openscience.cdk.renderer;
28
import java.awt.Color;
30
import org.openscience.cdk.math.IFunction;
33
* This class handles a set of function for the GraphRenderer
35
* @author Stephan Michels <stephan@vern.chem.tu-berlin.de>
36
* @cdk.created 2001-07-02
38
public class GraphRendererModel
40
private double xmin = -1d;
41
private double xmax = +1d;
42
private double ymin = -1d;
43
private double ymax = +1d;
45
private String title = "Main title"; // Main title
46
private String xtitle = "X title"; // Title of the x axis
47
private String ytitle = "Y title"; // Title of the y axis
49
private java.util.Vector functions = new java.util.Vector();
50
private java.util.Vector colors = new java.util.Vector();
52
/** Paints the function normal */
53
public final static int NORMAL = 0;
54
/** Paints the area below the function */
55
public final static int BELOWAREA = 1;
56
/** Paints the area over the function */
57
public final static int OVERAREA = 2;
59
private int displaymode = NORMAL;
62
* Sets the function area, which will painted
64
public void setX(double xmin, double xmax)
74
* Sets the function area, which will painted
76
public void setY(double ymin, double ymax)
86
* Gets the function area, which will painted
88
public double getXMin()
94
* Sets the function area, which will painted
96
public double getXMax()
102
* Sets the function area, which will painted
104
public double getYMin()
110
* Sets the function area, which will painted
112
public double getYMax()
120
public void setTitle(String string)
129
public String getTitle()
135
* Set the title of the x axis
137
public void setXTitle(String string)
144
* Get the title of the x axis
146
public String getXTitle()
152
* Set the title of the y axis
154
public void setYTitle(String string)
161
* Get the title of the y axis
163
public String getYTitle()
169
* Set the display mode
171
public void setDisplayMode(int mode)
173
if ((NORMAL<=mode) && (mode<=OVERAREA))
178
* Get the display mode
180
public int getDisplayMode()
186
* Add a function to the set of functions
188
public void addFunction(IFunction function)
190
if ((function!=null) && (!functions.contains(function)))
192
functions.add(function);
193
colors.add(Color.black);
198
* Add a function to the set of functions
200
public void addFunction(IFunction function, Color color)
202
if ((function!=null) && (!functions.contains(function)))
204
functions.add(function);
208
colors.setElementAt(color, functions.indexOf(function));
212
* Get the count of functions in this set
214
public int getFunctionsSize()
216
return functions.size();
220
* Get a function from this set
222
public IFunction getFunction(int index)
224
return (IFunction) functions.elementAt(index);
228
* Get a color from a function in this set
230
public Color getFunctionColor(int index)
232
return (Color) colors.elementAt(index);