01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.script.rhino.svg12;
20:
21: import org.apache.batik.dom.svg12.SVGGlobal;
22: import org.apache.batik.script.rhino.WindowWrapper;
23:
24: import org.mozilla.javascript.Context;
25: import org.mozilla.javascript.Function;
26: import org.mozilla.javascript.NativeJavaObject;
27: import org.mozilla.javascript.Scriptable;
28: import org.mozilla.javascript.ScriptableObject;
29:
30: import org.w3c.dom.events.EventTarget;
31:
32: /**
33: * Wrapper class for the SVGGlobal object.
34: *
35: * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
36: * @version $Id: GlobalWrapper.java 475477 2006-11-15 22:44:28Z cam $
37: */
38: public class GlobalWrapper extends WindowWrapper {
39:
40: /**
41: * Creates a new GlobalWrapper.
42: */
43: public GlobalWrapper(Context context) {
44: super (context);
45: String[] names = { "startMouseCapture", "stopMouseCapture" };
46: this .defineFunctionProperties(names, GlobalWrapper.class,
47: ScriptableObject.DONTENUM);
48: }
49:
50: public String getClassName() {
51: return "SVGGlobal";
52: }
53:
54: public String toString() {
55: return "[object SVGGlobal]";
56: }
57:
58: /**
59: * Wraps the 'startMouseCapture' method of the SVGGlobal interface.
60: */
61: public static void startMouseCapture(Context cx,
62: Scriptable this Obj, Object[] args, Function funObj) {
63: int len = args.length;
64: GlobalWrapper gw = (GlobalWrapper) this Obj;
65: SVGGlobal global = (SVGGlobal) gw.window;
66: if (len >= 3) {
67: EventTarget et = null;
68: if (args[0] instanceof NativeJavaObject) {
69: Object o = ((NativeJavaObject) args[0]).unwrap();
70: if (o instanceof EventTarget) {
71: et = (EventTarget) o;
72: }
73: }
74: if (et == null) {
75: throw Context
76: .reportRuntimeError("First argument to startMouseCapture must be an EventTarget");
77: }
78: boolean sendAll = Context.toBoolean(args[1]);
79: boolean autoRelease = Context.toBoolean(args[2]);
80: global.startMouseCapture(et, sendAll, autoRelease);
81: }
82: }
83:
84: /**
85: * Wraps the 'stopMouseCapture' method of the SVGGlobal interface.
86: */
87: public static void stopMouseCapture(Context cx, Scriptable this Obj,
88: Object[] args, Function funObj) {
89: GlobalWrapper gw = (GlobalWrapper) this Obj;
90: SVGGlobal global = (SVGGlobal) gw.window;
91: global.stopMouseCapture();
92: }
93: }
|