Debian Codegraph @

documentation-sources/content/xdocs/demo.xml

raw
1 <?xml version="1.0"?>
2
3 <!--
4
5 Licensed to the Apache Software Foundation (ASF) under one or more
6 contributor license agreements. See the NOTICE file distributed with
7 this work for additional information regarding copyright ownership.
8 The ASF licenses this file to You under the Apache License, Version 2.0
9 (the "License"); you may not use this file except in compliance with
10 the License. You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19
20 -->
21
22 <!-- ========================================================================= -->
23 <!-- author [email protected] -->
24 <!-- version $Id$ -->
25 <!-- ========================================================================= -->
26
27 <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
28 <document>
29 <header>
30 <title>Batik Demo</title>
31 </header>
32
33 <body>
34 <p>
35 This page demonstrates the use of Batik’s
36 <a href="site:swing">JSVGCanvas</a> swing component in a Java applet.
37 </p>
38
39 <table id="layout">
40 <tr>
41 <td>
42 <applet id="chart" codebase="demo/" code="AppletDemo.class"
43 width="400" height="300" mayscript="mayscript"
44 archive="batik-awt-util.jar,
45 batik-bridge.jar,
46 batik-css.jar,
47 batik-dom.jar,
48 batik-ext.jar,
49 batik-gvt.jar,
50 batik-parser.jar,
51 batik-svg-dom.jar,
52 batik-script.jar,
53 batik-swing.jar,
54 batik-util.jar,
55 batik-xml.jar,
56 xml-apis-dom3.jar">
57 [Your browser doesn’t seem to support Java applets, which is required
58 for this demo.]
59 </applet>
60 </td>
61 <td>
62 <table id="data">
63 <tr>
64 <th>Expense</th><th>Amount</th>
65 </tr>
66 <tr>
67 <td>Shoe</td>
68 <td><input id="ShoeBar" type="text" value="10"/></td>
69 </tr>
70 <tr>
71 <td>Car</td>
72 <td><input id="CarBar" type="text" value="20"/></td>
73 </tr>
74 <tr>
75 <td>Travel</td>
76 <td><input id="TravelBar" type="text" value="10"/></td>
77 </tr>
78 <tr>
79 <td>Computer</td>
80 <td><input id="ComputerBar" type="text" value="60"/></td>
81 </tr>
82 </table>
83 <p>
84 <button onclick="update()">Update chart</button>
85 </p>
86 </td>
87 </tr>
88 </table>
89
90 <script><![CDATA[
91 var chart;
92
93 function get(id) {
94 var e = document.getElementById(id);
95 // This loop just gets around the problem of IE returning the 'a'
96 // element looked up by name, rather than the desired element by id.
97 while (e.nodeType != 1 || e.getAttribute("id") != id) {
98 e = e.nextSibling;
99 }
100 return e;
101 }
102
103 function update() {
104 chart = get("chart");
105 updateBar("ShoeBar");
106 updateBar("CarBar");
107 updateBar("TravelBar");
108 updateBar("ComputerBar");
109 }
110
111 function updateBar(name) {
112 var input = get(name);
113 var value = Number(input.value);
114 if (!isNaN(value) && value >= 0) {
115 chart.updateBar(name, value);
116 }
117 }
118 ]]></script>
119
120 <p>
121 The applet (<a href="demo/AppletDemo.java">view source</a>) displays
122 the
123 <a href="http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk/samples/barChart.svg">barChart.svg</a>
124 sample from the Batik distribution using a <code>JSVGCanvas</code>.
125 Script in the web page then interacts with the applet, by calling the
126 <code>updateBar</code> method of the applet object when the
127 <b>Update chart</b> button is pressed. This method modifies the
128 SVG document being displayed to update the heights of the bars.
129 </p>
130 </body>
131 </document>