Debian Codegraph @

samples/sparklines/README.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <!--
3
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5
6 Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.
7
8 The contents of this file are subject to the terms of either the GNU
9 General Public License Version 2 only ("GPL") or the Common Development
10 and Distribution License("CDDL") (collectively, the "License"). You
11 may not use this file except in compliance with the License. You can
12 obtain a copy of the License at
13 http://glassfish.java.net/public/CDDL+GPL_1_1.html
14 or packager/legal/LICENSE.txt. See the License for the specific
15 language governing permissions and limitations under the License.
16
17 When distributing the software, include this License Header Notice in each
18 file and include the License file at packager/legal/LICENSE.txt.
19
20 GPL Classpath Exception:
21 Oracle designates this particular file as subject to the "Classpath"
22 exception as provided by Oracle in the GPL Version 2 section of the License
23 file that accompanied this code.
24
25 Modifications:
26 If applicable, add the following below the License Header, with the fields
27 enclosed by brackets [] replaced by your own identifying information:
28 "Portions Copyright [year] [name of copyright owner]"
29
30 Contributor(s):
31 If you wish your version of this file to be governed by only the CDDL or
32 only the GPL Version 2, indicate your decision by adding "[Contributor]
33 elects to include this software in this distribution under the [CDDL or GPL
34 Version 2] license." If you don't indicate a single choice of license, a
35 recipient has the option to distribute your version of this file under
36 either the CDDL, the GPL Version 2 or to extend the choice of license to
37 its licensees as provided above. However, if you add GPL Version 2 code
38 and therefore, elected the GPL Version 2 license, then the option applies
39 only if the new code is made subject to such option by the copyright
40 holder.
41
42 -->
43 <HTML>
44 <HEAD>
45 <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
46 <TITLE>Sparklines Example</TITLE>
47 <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.0 Beta (Unix)">
48 <META NAME="CREATED" CONTENT="0;0">
49 <META NAME="CHANGED" CONTENT="20080919;16520600">
50 <META NAME="Info 1" CONTENT="">
51 <META NAME="Info 2" CONTENT="">
52 <META NAME="Info 3" CONTENT="">
53 <META NAME="Info 4" CONTENT="">
54 </HEAD>
55 <BODY LANG="en" DIR="LTR">
56 <H1>Sparklines Example</H1>
57 <P>This example is inspired by Joe Gregorio's <A HREF="http://bitworking.org/projects/sparklines/">Sparkline</A>
58 Generator Web Application. For more about the concept of sparklines
59 read <A HREF="http://en.wikipedia.org/wiki/Sparkline">here</A>.</P>
60 <H2>Contents</H2>
61 <P>The example consists of one web resource implemented by the
62 following:
63 </P>
64 <DL>
65 <DT><CODE>com.sun.jersey.samples.sparklines.SparklinesResource</CODE>
66 </DT><DD STYLE="margin-bottom: 0.2in">
67 This Java class returns the a PNG image of a sparkline calculated
68 for a given set of query parameters.
69 </DD></DL>
70 <P>
71 The example makes use of classes to parse query parameters, a message
72 body writer to write an image in the PNG format, and makes use of
73 entity tags and performs precondition checking to support not
74 modified responses.</P>
75 <P>The mapping of the URI path space is presented in the following
76 table:</P>
77 <TABLE WIDTH=542 BORDER=1 CELLPADDING=2 CELLSPACING=4>
78 <COL WIDTH=84>
79 <COL WIDTH=143>
80 <COL WIDTH=80>
81 <COL WIDTH=198>
82 <TR>
83 <TH WIDTH=84>
84 <P>URI path</P>
85 </TH>
86 <TH WIDTH=143>
87 <P>Resource class</P>
88 </TH>
89 <TH WIDTH=80>
90 <P>HTTP methods</P>
91 </TH>
92 <TH WIDTH=198>
93 <P>Description</P>
94 </TH>
95 </TR>
96 <TR>
97 <TD WIDTH=84>
98 <P>discrete</P>
99 </TD>
100 <TD WIDTH=143>
101 <P>SparklinesResource</P>
102 </TD>
103 <TD WIDTH=80>
104 <P>GET</P>
105 </TD>
106 <TD WIDTH=198>
107 <P>Plot a sparkline as discrete vertical bars, one per data value.</P>
108 </TD>
109 </TR>
110 <TR>
111 <TD WIDTH=84>
112 <P>smooth</P>
113 </TD>
114 <TD WIDTH=143>
115 <P>SparklinesResource</P>
116 </TD>
117 <TD WIDTH=80>
118 <P>GET</P>
119 </TD>
120 <TD WIDTH=198>
121 <P>Plot a sparkline as continuous line.</P>
122 </TD>
123 </TR>
124 </TABLE>
125 <P><BR><BR>
126 </P>
127 <P>For either URI path the following query parameters can be
128 declared:</P>
129 <TABLE WIDTH=419 BORDER=1 CELLPADDING=2 CELLSPACING=4>
130 <COL WIDTH=126>
131 <COL WIDTH=103>
132 <COL WIDTH=160>
133 <TR>
134 <TH WIDTH=126>
135 <P>Query parameter</P>
136 </TH>
137 <TH WIDTH=103>
138 <P>Default Value</P>
139 </TH>
140 <TH WIDTH=160>
141 <P>Description</P>
142 </TH>
143 </TR>
144 <TR>
145 <TD WIDTH=126>
146 <P>d</P>
147 </TD>
148 <TD WIDTH=103>
149 <P><BR>
150 </P>
151 </TD>
152 <TD WIDTH=160>
153 <P>A comma separated list of integer values that represents the
154 input data to plot as a sparkline.</P>
155 </TD>
156 </TR>
157 <TR>
158 <TD WIDTH=126>
159 <P>limits</P>
160 </TD>
161 <TD WIDTH=103>
162 <P>0,100</P>
163 </TD>
164 <TD WIDTH=160>
165 <P>The valid range of the input data in “d”.</P>
166 </TD>
167 </TR>
168 </TABLE>
169 <P><BR><BR>
170 </P>
171 <P>The “smooth” URI path can have following query parameters:</P>
172 <TABLE WIDTH=419 BORDER=1 CELLPADDING=2 CELLSPACING=4>
173 <COL WIDTH=126>
174 <COL WIDTH=103>
175 <COL WIDTH=160>
176 <TR>
177 <TH WIDTH=126>
178 <P>Query parameter</P>
179 </TH>
180 <TH WIDTH=103>
181 <P>Default Value</P>
182 </TH>
183 <TH WIDTH=160>
184 <P>Description</P>
185 </TH>
186 </TR>
187 <TR>
188 <TD WIDTH=126>
189 <P>min-m</P>
190 </TD>
191 <TD WIDTH=103>
192 <P>true</P>
193 </TD>
194 <TD WIDTH=160>
195 <P>If true then a marker is placed at the smallest value in the
196 input data.</P>
197 </TD>
198 </TR>
199 <TR>
200 <TD WIDTH=126>
201 <P>max-m
202 </P>
203 </TD>
204 <TD WIDTH=103>
205 <P>true</P>
206 </TD>
207 <TD WIDTH=160>
208 <P>If true then a marker is placed at the largest value in the
209 input data.</P>
210 </TD>
211 </TR>
212 <TR>
213 <TD WIDTH=126>
214 <P>last-m</P>
215 </TD>
216 <TD WIDTH=103>
217 <P>true</P>
218 </TD>
219 <TD WIDTH=160>
220 <P>If true then a marker is placed at the last value in the input
221 data.</P>
222 </TD>
223 </TR>
224 <TR>
225 <TD WIDTH=126>
226 <P>min-color</P>
227 </TD>
228 <TD WIDTH=103>
229 <P>blue</P>
230 </TD>
231 <TD WIDTH=160>
232 <P>The colour of the marker placed at the smallest value in the
233 input data</P>
234 </TD>
235 </TR>
236 <TR>
237 <TD WIDTH=126>
238 <P>max-color</P>
239 </TD>
240 <TD WIDTH=103>
241 <P>green</P>
242 </TD>
243 <TD WIDTH=160>
244 <P>The colour of the marker placed at the largest value in the
245 input data.</P>
246 </TD>
247 </TR>
248 <TR>
249 <TD WIDTH=126>
250 <P>last-color</P>
251 </TD>
252 <TD WIDTH=103>
253 <P>red</P>
254 </TD>
255 <TD WIDTH=160>
256 <P>The colour of the marker placed at the last value in the input
257 data.</P>
258 </TD>
259 </TR>
260 <TR>
261 <TD WIDTH=126>
262 <P>step</P>
263 </TD>
264 <TD WIDTH=103>
265 <P>2</P>
266 </TD>
267 <TD WIDTH=160>
268 <P>The horizontal distance, in pixels, between each plot of a data
269 value.</P>
270 </TD>
271 </TR>
272 </TABLE>
273 <P><BR><BR>
274 </P>
275 <P>The “discrete” URI path can have following query parameters:</P>
276 <TABLE WIDTH=419 BORDER=1 CELLPADDING=2 CELLSPACING=4>
277 <COL WIDTH=126>
278 <COL WIDTH=103>
279 <COL WIDTH=160>
280 <TR>
281 <TH WIDTH=126>
282 <P>Query parameter</P>
283 </TH>
284 <TH WIDTH=103>
285 <P>Default Value</P>
286 </TH>
287 <TH WIDTH=160>
288 <P>Description</P>
289 </TH>
290 </TR>
291 <TR>
292 <TD WIDTH=126>
293 <P>width</P>
294 </TD>
295 <TD WIDTH=103>
296 <P>2</P>
297 </TD>
298 <TD WIDTH=160>
299 <P>The width, in pixels, of each plot of a virtual bar for each
300 data value.</P>
301 </TD>
302 </TR>
303 <TR>
304 <TD WIDTH=126>
305 <P>upper
306 </P>
307 </TD>
308 <TD WIDTH=103>
309 <P>50</P>
310 </TD>
311 <TD WIDTH=160>
312 <P>Data values &gt;= upper will be coloured in “upper-color”
313 otherwse data values will be colured in “lower-color”</P>
314 </TD>
315 </TR>
316 <TR>
317 <TD WIDTH=126>
318 <P>upper-color</P>
319 </TD>
320 <TD WIDTH=103>
321 <P>red</P>
322 </TD>
323 <TD WIDTH=160>
324 <P>The colour for data values &gt;= “upper”</P>
325 </TD>
326 </TR>
327 <TR>
328 <TD WIDTH=126>
329 <P>lower-color</P>
330 </TD>
331 <TD WIDTH=103>
332 <P>gray</P>
333 </TD>
334 <TD WIDTH=160>
335 <P>The colour for data values &lt; upper</P>
336 </TD>
337 </TR>
338 </TABLE>
339 <P><BR><BR>
340 </P>
341 <H2>Running the Example</H2>
342 <P>Run the example as follows:</P>
343 <P>run
344 </P>
345 <BLOCKQUOTE><CODE>mvn compile exec:java</CODE></BLOCKQUOTE>
346 <P>From a web browser, visit:</P>
347 <BLOCKQUOTE><CODE><A HREF="http://localhost:9998/sparklines/discrete?d=88,84,82,92,82,86,66,82,44,64,66,88,96,80,24,26,14,0,0,26,8,6,6,24,52,66,36,6,10,14,30">http://localhost:9998/sparklines/discrete?d=88,84,82,92,82,86,66,82,44,64,66,88,96,80,24,26,14,0,0,26,8,6,6,24,52,66,36,6,10,14,30</A></CODE></BLOCKQUOTE>
348 </BODY>
349 </HTML>