View Javadoc

1   /* ============================================================
2    * JRobin : Pure java implementation of RRDTool's functionality
3    * ============================================================
4    *
5    * Project Info:  http://www.jrobin.org
6    * Project Lead:  Sasa Markovic (saxon@jrobin.org)
7    *
8    * Developers:    Sasa Markovic (saxon@jrobin.org)
9    *
10   *
11   * (C) Copyright 2003-2005, by Sasa Markovic.
12   *
13   * This library is free software; you can redistribute it and/or modify it under the terms
14   * of the GNU Lesser General Public License as published by the Free Software Foundation;
15   * either version 2.1 of the License, or (at your option) any later version.
16   *
17   * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18   * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19   * See the GNU Lesser General Public License for more details.
20   *
21   * You should have received a copy of the GNU Lesser General Public License along with this
22   * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23   * Boston, MA 02111-1307, USA.
24   */
25  package org.jrobin.graph;
26  
27  import java.awt.*;
28  import java.util.Calendar;
29  import java.util.Locale;
30  
31  /**
32   * Class to represent various constants used for graphing. No methods are specified.
33   */
34  public interface RrdGraphConstants {
35  	/**
36  	 * Default graph starting time
37  	 */
38  	String DEFAULT_START = "end-1d";
39  	/**
40  	 * Default graph ending time
41  	 */
42  	String DEFAULT_END = "now";
43  
44  	/**
45  	 * Constant to represent second
46  	 */
47  	int SECOND = Calendar.SECOND;
48  	/**
49  	 * Constant to represent minute
50  	 */
51  	int MINUTE = Calendar.MINUTE;
52  	/**
53  	 * Constant to represent hour
54  	 */
55  	int HOUR = Calendar.HOUR_OF_DAY;
56  	/**
57  	 * Constant to represent day
58  	 */
59  	int DAY = Calendar.DAY_OF_MONTH;
60  	/**
61  	 * Constant to represent week
62  	 */
63  	int WEEK = Calendar.WEEK_OF_YEAR;
64  	/**
65  	 * Constant to represent month
66  	 */
67  	int MONTH = Calendar.MONTH;
68  	/**
69  	 * Constant to represent year
70  	 */
71  	int YEAR = Calendar.YEAR;
72  
73  	/**
74  	 * Constant to represent Monday
75  	 */
76  	int MONDAY = Calendar.MONDAY;
77  	/**
78  	 * Constant to represent Tuesday
79  	 */
80  	int TUESDAY = Calendar.TUESDAY;
81  	/**
82  	 * Constant to represent Wednesday
83  	 */
84  	int WEDNESDAY = Calendar.WEDNESDAY;
85  	/**
86  	 * Constant to represent Thursday
87  	 */
88  	int THURSDAY = Calendar.THURSDAY;
89  	/**
90  	 * Constant to represent Friday
91  	 */
92  	int FRIDAY = Calendar.FRIDAY;
93  	/**
94  	 * Constant to represent Saturday
95  	 */
96  	int SATURDAY = Calendar.SATURDAY;
97  	/**
98  	 * Constant to represent Sunday
99  	 */
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 }