1 /**********************************************
2 * Copyright (C) 2010 Lukas Laag
3 * This file is part of svgreal.
4 *
5 * svgreal is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU 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 * svgreal 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 General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with svgreal. If not, see http://www.gnu.org/licenses/
17 **********************************************/
18 package org.vectomatic.svg.edit.client.event;
19
20 import com.google.gwt.event.shared.GwtEvent;
21
22 /**
23 * Event emitted when a rotation occurs
24 * @author laaglu
25 */
26 public class RotationEvent extends GwtEvent<RotationHandler> {
27 /**
28 * Handler type.
29 */
30 private static Type<RotationHandler> TYPE;
31
32 private final float angleDeg;
33
34 public RotationEvent(float angleDeg) {
35 this.angleDeg = angleDeg;
36 }
37
38 @Override
39 public com.google.gwt.event.shared.GwtEvent.Type<RotationHandler> getAssociatedType() {
40 if (TYPE == null) {
41 TYPE = new Type<RotationHandler>();
42 }
43 return TYPE;
44 }
45
46 /**
47 * Ensures the existence of the handler hook and then returns it.
48 *
49 * @return returns a handler hook
50 */
51 public static Type<RotationHandler> getType() {
52 if (TYPE == null) {
53 TYPE = new Type<RotationHandler>();
54 }
55 return TYPE;
56 }
57
58 @Override
59 protected void dispatch(RotationHandler handler) {
60 handler.onRotate(this);
61 }
62
63 public float getAngle() {
64 return angleDeg;
65 }
66
67 }