001 package jigcell.compare.plotter;
002
003 import java.awt.Color;
004 import jigcell.compare.IDataElement;
005 import jigcell.compare.IWriteableDataSource;
006
007 /**
008 * This interface is implemented by classes that wish to provide plotting services to some other program.
009 *
010 * <p>
011 * This code is licensed under the DARPA BioCOMP Open Source License. See LICENSE for more details.
012 * </p>
013 *
014 * @author Nicholas Allen
015 */
016
017 public interface IPlotter extends IWriteableDataSource {
018
019 /**
020 * The types of series combine options.
021 */
022
023 final class Combine {
024
025 /**
026 * Combine across series option. In this mode, the data is expected to contain all of the x values in the first series, all of the y1
027 * values in the second series, all of the y2 values in the third series, and so on.
028 */
029
030 public final static Combine ACROSS = new Combine ("across");
031
032 /**
033 * No series combining option. In this mode, the data is expected to contain a list of series. A series has an x and y coordinate for
034 * each point.
035 */
036
037 public final static Combine NONE = new Combine ("none");
038
039 /**
040 * Name of this option
041 */
042
043 private final String name;
044
045 public String toString () {
046 return name;
047 }
048
049 /**
050 * Creates a new combine option.
051 *
052 * @param name Display name
053 */
054
055 private Combine (String name) {
056 this.name = name;
057 }
058 }
059
060 /**
061 * Series combining key
062 */
063
064 String OPTION_COMBINE = "IPlotter.combine";
065
066 /**
067 * View range key
068 */
069
070 String OPTION_VIEWRANGE = "IPlotter.viewRange";
071
072 /**
073 * View title key
074 */
075
076 String OPTION_VIEWTITLE = "IPlotter.viewTitle";
077
078 /**
079 * A data series from the data aggregate.
080 *
081 * @param pos Position
082 */
083
084 IDataElement getSeries (long pos);
085
086 /**
087 * The color of a series.
088 *
089 * @param pos Position
090 */
091
092 Color getSeriesColor (long pos);
093
094 /**
095 * The series combine option.
096 */
097
098 Combine getSeriesCombine ();
099
100 /**
101 * The name of a series.
102 *
103 * @param pos Position
104 */
105
106 String getSeriesName (long pos);
107
108 /**
109 * The view range option. The range is either null (fit to data) or in the form ((xmin, ymin), (xmax, ymax)).
110 */
111
112 IDataElement getViewRange ();
113
114 /**
115 * Whether the data aggregate is immutable.
116 */
117
118 boolean isImmutable ();
119
120 /**
121 * Produces a plot from the underlying data.
122 */
123
124 void plot () throws PlotException;
125
126 /**
127 * Sets the data aggregate.
128 *
129 * @param data Data
130 */
131
132 void setData (IDataElement data);
133
134 /**
135 * Sets one of the data series in the aggregate. If the aggregate is immutable, an exception is thrown.
136 *
137 * @param series Data series
138 * @param pos Position
139 */
140
141 void setSeries (long pos, IDataElement series);
142
143 /**
144 * Sets the color of a series.
145 *
146 * @param pos Position
147 * @param color Series color
148 */
149
150 void setSeriesColor (long pos, Color color);
151
152 /**
153 * Sets the series combine option.
154 *
155 * @param option Series combine option
156 */
157
158 void setSeriesCombine (Combine option);
159
160 /**
161 * Sets the name of a series.
162 *
163 * @param pos Position
164 * @param name Series name
165 */
166
167 void setSeriesName (long pos, String name);
168
169 /**
170 * Sets the title of the plot window.
171 *
172 * @param title Window title
173 */
174
175 void setTitle (String title);
176
177 /**
178 * Sets the view range option. The range must be either null (fit to data) or in the form ((xmin, ymin), (xmax, ymax)).
179 *
180 * @param range View range
181 */
182
183 void setViewRange (IDataElement range);
184 }