File: demo.xml

package info (click to toggle)
batik 1.19-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 28,976 kB
  • sloc: java: 192,236; xml: 19,457; javascript: 1,276; sh: 85; makefile: 5
file content (131 lines) | stat: -rw-r--r-- 4,534 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0"?>

<!--

   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

-->

<!-- ========================================================================= -->
<!-- author vincent.hardy@eng.sun.com                                          -->
<!-- version $Id$ -->
<!-- ========================================================================= -->

<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
<document>
  <header>
    <title>Batik Demo</title>
  </header>

  <body>
    <p>
      This page demonstrates the use of Batik’s
      <a href="site:swing">JSVGCanvas</a> swing component in a Java applet.
    </p>

    <table id="layout">
      <tr>
        <td>
          <applet id="chart" codebase="demo/" code="AppletDemo.class"
                  width="400" height="300" mayscript="mayscript"
                  archive="batik-awt-util.jar,
                           batik-bridge.jar,
                           batik-css.jar,
                           batik-dom.jar,
                           batik-ext.jar,
                           batik-gvt.jar,
                           batik-parser.jar,
                           batik-svg-dom.jar,
                           batik-script.jar,
                           batik-swing.jar,
                           batik-util.jar,
                           batik-xml.jar,
                           xml-apis-dom3.jar">
            [Your browser doesn’t seem to support Java applets, which is required
            for this demo.]
          </applet>
        </td>
        <td>
          <table id="data">
            <tr>
              <th>Expense</th><th>Amount</th>
            </tr>
            <tr>
              <td>Shoe</td>
              <td><input id="ShoeBar" type="text" value="10"/></td>
            </tr>
            <tr>
              <td>Car</td>
              <td><input id="CarBar" type="text" value="20"/></td>
            </tr>
            <tr>
              <td>Travel</td>
              <td><input id="TravelBar" type="text" value="10"/></td>
            </tr>
            <tr>
              <td>Computer</td>
              <td><input id="ComputerBar" type="text" value="60"/></td>
            </tr>
          </table>
          <p>
            <button onclick="update()">Update chart</button>
          </p>
        </td>
      </tr>
    </table>

    <script><![CDATA[
      var chart;

      function get(id) {
        var e = document.getElementById(id);
        // This loop just gets around the problem of IE returning the 'a'
        // element looked up by name, rather than the desired element by id.
        while (e.nodeType != 1 || e.getAttribute("id") != id) {
          e = e.nextSibling;
        }
        return e;
      }

      function update() {
        chart = get("chart");
        updateBar("ShoeBar");
        updateBar("CarBar");
        updateBar("TravelBar");
        updateBar("ComputerBar");
      }

      function updateBar(name) {
        var input = get(name);
        var value = Number(input.value);
        if (!isNaN(value) && value >= 0) {
          chart.updateBar(name, value);
        }
      }
    ]]></script>

    <p>
      The applet (<a href="demo/AppletDemo.java">view source</a>) displays
      the
      <a href="http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk/samples/barChart.svg">barChart.svg</a>
      sample from the Batik distribution using a <code>JSVGCanvas</code>.
      Script in the web page then interacts with the applet, by calling the
      <code>updateBar</code> method of the applet object when the
      <b>Update chart</b> button is pressed.  This method modifies the
      SVG document being displayed to update the heights of the bars.
    </p>
  </body>
</document>