View Javadoc

1   /**********************************************
2    * Copyright (C) 2010 Lukas Laag
3    * This file is part of lib-gwt-svg.
4    * 
5    * libgwtsvg is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU Lesser General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    * 
10   * libgwtsvg is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU Lesser General Public License for more details.
14   * 
15   * You should have received a copy of the GNU Lesser General Public License
16   * along with libgwtsvg.  If not, see http://www.gnu.org/licenses/
17   **********************************************/
18  /*
19   * Copyright (c) 2004 World Wide Web Consortium,
20   *
21   * (Massachusetts Institute of Technology, European Research Consortium for
22   * Informatics and Mathematics, Keio University). All Rights Reserved. This
23   * work is distributed under the W3C(r) Software License [1] in the hope that
24   * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
25   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26   *
27   * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
28   */
29  package org.vectomatic.dom.svg.events;
30  
31  import org.vectomatic.dom.svg.OMSVGPoint;
32  import org.vectomatic.dom.svg.OMSVGRect;
33  import org.vectomatic.dom.svg.impl.NativeSVGZoomEvent;
34  
35  import com.google.gwt.event.dom.client.DomEvent;
36  
37  /**
38   * The zoom event occurs when the user initiates an action which causes 
39   * the current view of the SVG document fragment to be rescaled. 
40   * Event handlers are only recognized on <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
41   * title='svg element specification'>svg</a> elements.
42   */
43  public class SVGZoomEvent extends DomEvent<SVGZoomHandler> {
44  	private static final Type<SVGZoomHandler> TYPE = new Type<SVGZoomHandler>(
45  			"SVGZoom", new SVGZoomEvent());
46  
47  	/**
48  	 * Protected constructor, use
49  	 * {@link DomEvent#fireNativeEvent(com.google.gwt.dom.client.NativeEvent, com.google.gwt.event.shared.HasHandlers)}
50  	 * to fire mouse out events.
51  	 */
52  	protected SVGZoomEvent() {
53  	}
54  
55  	/**
56  	 * @return the handler type
57  	 */
58  	public Type<SVGZoomHandler> getAssociatedType() {
59  		return TYPE;
60  	}
61  
62  	/**
63  	 * @return the handler type
64  	 */
65  	public static Type<SVGZoomHandler> getType() {
66  		return TYPE;
67  	}
68  
69  	@Override
70  	protected void dispatch(SVGZoomHandler handler) {
71  		handler.onZoom(this);
72  	}
73  
74  	// Implementation of the svg::SVGZoomEvent W3C IDL interface
75  	/**
76  	 * Returns the specified zoom rectangle in screen units.
77  	 * @return the specified zoom rectangle in screen units.
78  	 */
79  	public final OMSVGRect getZoomRectScreen() {
80  		return ((NativeSVGZoomEvent)getNativeEvent().cast()).getZoomRectScreen();
81  	}
82  
83  	/**
84  	 * Returns the scale factor from previous zoom operations that was in place before the zoom operation occurred. 
85  	 * @return the scale factor from previous zoom operations
86  	 */
87  	public final float getPreviousScale() {
88  		return ((NativeSVGZoomEvent)getNativeEvent().cast()).getPreviousScale();
89  	};
90  
91  	/**
92  	 * Returns the translation values from previous zoom operations that
93  	 * were in place before the zoom operation occurred. The {@link org.vectomatic.dom.svg.OMSVGPoint} 
94  	 * object is read only.
95  	 * @return the translation values from previous zoom operations
96  	 */
97  	public final OMSVGPoint getPreviousTranslate() {
98  		return ((NativeSVGZoomEvent)getNativeEvent().cast()).getPreviousTranslate();
99  	};
100 
101 	/**
102 	 * Returns the scale factor that will be in place after the zoom operation has been processed. 
103 	 * @return the scale factor that will be in place after the zoom operation has been processed
104 	 */
105 	public final float getNewScale() {
106 		return ((NativeSVGZoomEvent)getNativeEvent().cast()).getNewScale();
107 	};
108 
109 	/**
110 	 * Returns the translation values that will be in place after the zoom operation 
111 	 * has been processed. The {@link org.vectomatic.dom.svg.OMSVGPoint} 
112 	 * object is read only.
113 	 * @return the translation values that will be in place after the zoom operation has been processed.
114 	 */
115 	public final OMSVGPoint getNewTranslate() {
116 		return ((NativeSVGZoomEvent)getNativeEvent().cast()).getNewTranslate();
117 	};
118 
119 }