KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > svg > SVGZoomAndPanSupport


1 /*
2
3    Copyright 2000-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.dom.svg;
19
20 import org.apache.batik.dom.AbstractNode;
21 import org.apache.batik.util.SVGConstants;
22 import org.w3c.dom.DOMException JavaDoc;
23 import org.w3c.dom.Element JavaDoc;
24 import org.w3c.dom.svg.SVGZoomAndPan;
25
26 /**
27  * This class provides support for SVGZoomAndPan features.
28  *
29  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
30  * @version $Id: SVGZoomAndPanSupport.java,v 1.6 2004/08/18 07:13:19 vhardy Exp $
31  */

32 public class SVGZoomAndPanSupport implements SVGConstants {
33
34     /**
35      * This class does not need to be instantiated.
36      */

37     protected SVGZoomAndPanSupport() {
38     }
39     
40     /**
41      * Sets the zoomAndPan attribute value.
42      */

43     public static void setZoomAndPan(Element JavaDoc elt, short val)
44     throws DOMException JavaDoc {
45     switch (val) {
46     case SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE:
47         elt.setAttributeNS(null, SVG_ZOOM_AND_PAN_ATTRIBUTE,
48                                SVG_DISABLE_VALUE);
49         break;
50     case SVGZoomAndPan.SVG_ZOOMANDPAN_MAGNIFY:
51         elt.setAttributeNS(null, SVG_ZOOM_AND_PAN_ATTRIBUTE,
52                                SVG_MAGNIFY_VALUE);
53         break;
54     default:
55         throw ((AbstractNode)elt).createDOMException
56         (DOMException.INVALID_MODIFICATION_ERR,
57          "zoom.and.pane",
58          new Object JavaDoc[] { new Integer JavaDoc(val) });
59     }
60     }
61
62     /**
63      * Returns the ZoomAndPan attribute value.
64      */

65     public static short getZoomAndPan(Element JavaDoc elt) {
66     String JavaDoc s = elt.getAttributeNS(null, SVG_ZOOM_AND_PAN_ATTRIBUTE);
67     if (s.equals(SVG_MAGNIFY_VALUE)) {
68         return SVGZoomAndPan.SVG_ZOOMANDPAN_MAGNIFY;
69     }
70     return SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
71     }
72 }
73
Popular Tags