001: /*
002: JOpenChart Java Charting Library and Toolkit
003: Copyright (C) 2001 Sebastian Müller
004: http://jopenchart.sourceforge.net
005:
006: This library is free software; you can redistribute it and/or
007: modify it under the terms of the GNU Lesser General Public
008: License as published by the Free Software Foundation; either
009: version 2.1 of the License, or (at your option) any later version.
010:
011: This library is distributed in the hope that it will be useful,
012: but WITHOUT ANY WARRANTY; without even the implied warranty of
013: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: Lesser General Public License for more details.
015:
016: You should have received a copy of the GNU Lesser General Public
017: License along with this library; if not, write to the Free Software
018: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019:
020: ChartDataModel.java
021: Created on 28. Juni 2001, 18:58
022: */
023:
024: package de.progra.charting.model;
025:
026: import de.progra.charting.event.*;
027:
028: /**
029: * This interface defines the methods to access chart data. It has to deal
030: * with several difficulties. The model is basically
031: * resembling a Swing table model. Furthermore, in the implementation it
032: * needs to be defined whether the datasets are organized in rows or in columns,
033: * whether the x-axis values are numeric etc. In order to layout
034: * certain components, there must be methods to return the maximum and minimum
035: * values.<p>
036: * A DataSet is a series of figures belonging together, whereas a column
037: * is the value printed at the x-axis. They can be rendered using specific
038: * Format classes.
039: * @author mueller
040: * @version 1.0
041: */
042: public interface ChartDataModel {
043:
044: /** Returns the total amount of datasets.
045: * @return the total amount of DataSets
046: */
047: public int getDataSetNumber();
048:
049: /** Returns the Axis binding of a specific DataSet.
050: * @param set the DataSet index
051: * @return an integer constant defining the Axis binding
052: */
053: public int getAxisBinding(int set);
054:
055: /** Sets the Axis binding of a DataSet.
056: * @param set the DataSet index
057: * @param axis the Axis binding constant
058: */
059: public void setAxisBinding(int set, int axis);
060:
061: /** Returns the length of a certain dataset. Note that for proper
062: * rendering all datasets should have an equal length.
063: * @param set the DataSet index
064: * @return the int length of a DataSet
065: */
066: public int getDataSetLength(int set);
067:
068: /** Returns the title of the DataSet used for rendering the Legend.
069: * @param set the DataSet index
070: * @return a String containing the Title.
071: */
072: public String getDataSetName(int set);
073:
074: /** Returns the Value in a specific dataset at a certain index.
075: * @param set the DataSet index
076: * @param index the value index in the DataSet
077: * @return the value Object
078: */
079: public Number getValueAt(int set, int index);
080:
081: /** Sets the value in a specific dataset at the given index.
082: * @param set the DataSet index
083: * @param index the value index in the DataSet
084: * @param value the value to be stored
085: */
086: public void setValueAt(int set, int index, Object value);
087:
088: /** Returns the class of the columns.
089: * @return the class of the column values. In case of numeric
090: * columns this is always Number.class.
091: */
092: public Class getColumnClass();
093:
094: /** Returns a specific column value.
095: * @param col the column index
096: * @return the column value. In case of numeric columns this is
097: * always a Number object.
098: */
099: public Object getColumnValueAt(int col);
100:
101: /** Returns a specific column value.
102: * @param set the data set index
103: * @param col the column index
104: * @return the column value. In case of numeric columns this is
105: * always a Number object.
106: */
107: public Object getColumnValueAt(int set, int col);
108:
109: /** Defines whether the column values are numeric,
110: * that is, they can be casted to <code>Number</code>.
111: * @return <CODE>true</CODE> if the column value can be
112: * safely casted to Number type.
113: */
114: public boolean isColumnNumeric();
115:
116: /** Adds a ChartDataModelListener
117: * @param l the ChartDataModelListener
118: */
119: public void addChartDataModelListener(ChartDataModelListener l);
120:
121: /** Removes a ChartDataModelListener
122: * @param l the ChartDataModelListener
123: */
124: public void removeChartDataModelListener(ChartDataModelListener l);
125:
126: /** Returns a ChartDataModelConstraints object for the given
127: * axis binding.
128: * @param axis the Axis constant
129: * @return a ChartDataModelConstraints object.
130: */
131: public ChartDataModelConstraints getChartDataModelConstraints(
132: int axis);
133:
134: /** Sets the ChartDataModelConstraints object for the given
135: * axis binding.
136: * @param axis the Axis constant
137: * @param constraints the ChartDataModelConstraints object
138: * @return a ChartDataModelConstraints object.
139: */
140: public void setChartDataModelConstraints(int axis,
141: ChartDataModelConstraints constraints);
142:
143: public void setAutoScale(boolean b);
144:
145: public boolean isAutoScale();
146:
147: /** Enables the manual axis scaling. Set the desired
148: * maximum and minimum values using the setMaximum...Value
149: * functions.
150: */
151: public void setManualScale(boolean b);
152:
153: /** Returns true if the manual axis scaling is enabled. This overrides
154: * the enabled automatic axis scaling.
155: */
156: public boolean isManualScale();
157:
158: /** Sets the maximum x-axis value. */
159: public void setMaximumColumnValue(double d);
160:
161: /** Sets the minimum x-axis value. */
162: public void setMinimumColumnValue(double d);
163:
164: /** Sets the maximum y-axis value. */
165: public void setMaximumValue(Number n);
166:
167: /** Sets the minimum y-axis value. */
168: public void setMinimumValue(Number n);
169:
170: public double getManualMaximumColumnValue();
171:
172: public double getManualMinimumColumnValue();
173:
174: public Number getManualMaximumValue();
175:
176: public Number getManualMinimumValue();
177: }
|