001 /* ============================================================
002 * JRobin : Pure java implementation of RRDTool's functionality
003 * ============================================================
004 *
005 * Project Info: http://www.jrobin.org
006 * Project Lead: Sasa Markovic (saxon@jrobin.org)
007 *
008 * Developers: Sasa Markovic (saxon@jrobin.org)
009 *
010 *
011 * (C) Copyright 2003-2005, by Sasa Markovic.
012 *
013 * This library is free software; you can redistribute it and/or modify it under the terms
014 * of the GNU Lesser General Public License as published by the Free Software Foundation;
015 * either version 2.1 of the License, or (at your option) any later version.
016 *
017 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
018 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
019 * See the GNU Lesser General Public License for more details.
020 *
021 * You should have received a copy of the GNU Lesser General Public License along with this
022 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
023 * Boston, MA 02111-1307, USA.
024 */
025 package org.jrobin.graph;
026
027 import java.awt.*;
028 import java.util.Calendar;
029 import java.util.Locale;
030
031 /**
032 * Class to represent various constants used for graphing. No methods are specified.
033 */
034 public interface RrdGraphConstants {
035 /**
036 * Default graph starting time
037 */
038 String DEFAULT_START = "end-1d";
039 /**
040 * Default graph ending time
041 */
042 String DEFAULT_END = "now";
043
044 /**
045 * Constant to represent second
046 */
047 int SECOND = Calendar.SECOND;
048 /**
049 * Constant to represent minute
050 */
051 int MINUTE = Calendar.MINUTE;
052 /**
053 * Constant to represent hour
054 */
055 int HOUR = Calendar.HOUR_OF_DAY;
056 /**
057 * Constant to represent day
058 */
059 int DAY = Calendar.DAY_OF_MONTH;
060 /**
061 * Constant to represent week
062 */
063 int WEEK = Calendar.WEEK_OF_YEAR;
064 /**
065 * Constant to represent month
066 */
067 int MONTH = Calendar.MONTH;
068 /**
069 * Constant to represent year
070 */
071 int YEAR = Calendar.YEAR;
072
073 /**
074 * Constant to represent Monday
075 */
076 int MONDAY = Calendar.MONDAY;
077 /**
078 * Constant to represent Tuesday
079 */
080 int TUESDAY = Calendar.TUESDAY;
081 /**
082 * Constant to represent Wednesday
083 */
084 int WEDNESDAY = Calendar.WEDNESDAY;
085 /**
086 * Constant to represent Thursday
087 */
088 int THURSDAY = Calendar.THURSDAY;
089 /**
090 * Constant to represent Friday
091 */
092 int FRIDAY = Calendar.FRIDAY;
093 /**
094 * Constant to represent Saturday
095 */
096 int SATURDAY = Calendar.SATURDAY;
097 /**
098 * Constant to represent Sunday
099 */
100 int SUNDAY = Calendar.SUNDAY;
101
102 /**
103 * Index of the canvas color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)}
104 */
105 int COLOR_CANVAS = 0;
106 /**
107 * Index of the background color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)}
108 */
109 int COLOR_BACK = 1;
110 /**
111 * Index of the top-left graph shade color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)}
112 */
113 int COLOR_SHADEA = 2;
114 /**
115 * Index of the bottom-right graph shade color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)}
116 */
117 int COLOR_SHADEB = 3;
118 /**
119 * Index of the minor grid color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)}
120 */
121 int COLOR_GRID = 4;
122 /**
123 * Index of the major grid color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)}
124 */
125 int COLOR_MGRID = 5;
126 /**
127 * Index of the font color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)}
128 */
129 int COLOR_FONT = 6;
130 /**
131 * Index of the frame color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)}
132 */
133 int COLOR_FRAME = 7;
134 /**
135 * Index of the arrow color. Used in {@link RrdGraphDef#setColor(int, java.awt.Paint)}
136 */
137 int COLOR_ARROW = 8;
138
139 /**
140 * Allowed color names which can be used in {@link RrdGraphDef#setColor(String, java.awt.Paint)} method
141 */
142 String[] COLOR_NAMES = {
143 "canvas", "back", "shadea", "shadeb", "grid", "mgrid", "font", "frame", "arrow"
144 };
145
146 /**
147 * Default first day of the week (obtained from the default locale)
148 */
149 int FIRST_DAY_OF_WEEK = Calendar.getInstance(Locale.getDefault()).getFirstDayOfWeek();
150
151 /**
152 * Default graph canvas color
153 */
154 Color DEFAULT_CANVAS_COLOR = Color.WHITE;
155 /**
156 * Default graph background color
157 */
158 Color DEFAULT_BACK_COLOR = new Color(245, 245, 245);
159 /**
160 * Default top-left graph shade color
161 */
162 Color DEFAULT_SHADEA_COLOR = new Color(200, 200, 200);
163 /**
164 * Default bottom-right graph shade color
165 */
166 Color DEFAULT_SHADEB_COLOR = new Color(150, 150, 150);
167 /**
168 * Default minor grid color
169 */
170 Color DEFAULT_GRID_COLOR = new Color(171, 171, 171, 95);
171 // Color DEFAULT_GRID_COLOR = new Color(140, 140, 140);
172 /**
173 * Default major grid color
174 */
175 Color DEFAULT_MGRID_COLOR = new Color(255, 91, 91, 95);
176 // Color DEFAULT_MGRID_COLOR = new Color(130, 30, 30);
177 /**
178 * Default font color
179 */
180 Color DEFAULT_FONT_COLOR = Color.BLACK;
181 /**
182 * Default frame color
183 */
184 Color DEFAULT_FRAME_COLOR = Color.BLACK;
185 /**
186 * Default arrow color
187 */
188 Color DEFAULT_ARROW_COLOR = Color.RED;
189
190 /**
191 * Constant to represent left alignment marker
192 */
193 String ALIGN_LEFT_MARKER = "\\l";
194 /**
195 * Constant to represent centered alignment marker
196 */
197 String ALIGN_CENTER_MARKER = "\\c";
198 /**
199 * Constant to represent right alignment marker
200 */
201 String ALIGN_RIGHT_MARKER = "\\r";
202 /**
203 * Constant to represent justified alignment marker
204 */
205 String ALIGN_JUSTIFIED_MARKER = "\\j";
206 /**
207 * Constant to represent "glue" marker
208 */
209 String GLUE_MARKER = "\\g";
210 /**
211 * Constant to represent vertical spacing marker
212 */
213 String VERTICAL_SPACING_MARKER = "\\s";
214 /**
215 * Constant to represent no justification markers
216 */
217 String NO_JUSTIFICATION_MARKER = "\\J";
218 /**
219 * Used internally
220 */
221 String[] MARKERS = {
222 ALIGN_LEFT_MARKER, ALIGN_CENTER_MARKER, ALIGN_RIGHT_MARKER,
223 ALIGN_JUSTIFIED_MARKER, GLUE_MARKER, VERTICAL_SPACING_MARKER, NO_JUSTIFICATION_MARKER
224 };
225
226 /**
227 * Constant to represent in-memory image name
228 */
229 String IN_MEMORY_IMAGE = "-";
230
231 /**
232 * Default units length
233 */
234 int DEFAULT_UNITS_LENGTH = 9;
235 /**
236 * Default graph width
237 */
238 int DEFAULT_WIDTH = 400;
239 /**
240 * Default graph height
241 */
242 int DEFAULT_HEIGHT = 100;
243 /**
244 * Default image format
245 */
246 String DEFAULT_IMAGE_FORMAT = "gif";
247 /**
248 * Default image quality, used only for jpeg graphs
249 */
250 float DEFAULT_IMAGE_QUALITY = 0.8F; // only for jpegs, not used for png/gif
251 /**
252 * Default value base
253 */
254 double DEFAULT_BASE = 1000;
255
256 /**
257 * Default font name, determined based on the current operating system
258 */
259 String DEFAULT_FONT_NAME = System.getProperty("os.name").toLowerCase().contains("windows") ?
260 "Lucida Sans Typewriter" : "Monospaced";
261
262 /**
263 * Default graph small font
264 */
265 String DEFAULT_MONOSPACE_FONT_FILE = "DejaVuSansMono.ttf";
266
267 /**
268 * Default graph large font
269 */
270 String DEFAULT_PROPORTIONAL_FONT_FILE = "DejaVuSans-Bold.ttf";
271
272 /**
273 * Used internally
274 */
275 double LEGEND_LEADING = 1.2; // chars
276 /**
277 * Used internally
278 */
279 double LEGEND_LEADING_SMALL = 0.7; // chars
280 /**
281 * Used internally
282 */
283 double LEGEND_BOX_SPACE = 1.2; // chars
284 /**
285 * Used internally
286 */
287 double LEGEND_BOX = 0.9; // chars
288 /**
289 * Used internally
290 */
291 int LEGEND_INTERSPACING = 2; // chars
292 /**
293 * Used internally
294 */
295 int PADDING_LEFT = 10; // pix
296 /**
297 * Used internally
298 */
299 int PADDING_TOP = 12; // pix
300 /**
301 * Used internally
302 */
303 int PADDING_TITLE = 6; // pix
304 /**
305 * Used internally
306 */
307 int PADDING_RIGHT = 16; // pix
308 /**
309 * Used internally
310 */
311 int PADDING_PLOT = 2; //chars
312 /**
313 * Used internally
314 */
315 int PADDING_LEGEND = 2; // chars
316 /**
317 * Used internally
318 */
319 int PADDING_BOTTOM = 6; // pix
320 /**
321 * Used internally
322 */
323 int PADDING_VLABEL = 7; // pix
324
325 /**
326 * Stroke used to draw grid
327 */
328 // solid line
329 Stroke GRID_STROKE = new BasicStroke(1);
330
331 // dotted line
332 // Stroke GRID_STROKE = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, new float[] {1, 1}, 0);
333 /**
334 * Stroke used to draw ticks
335 */
336 Stroke TICK_STROKE = new BasicStroke(1);
337 }