1 18 package org.apache.batik.dom.events; 19 20 import org.w3c.dom.events.Event ; 21 import org.w3c.dom.events.EventTarget ; 22 23 30 public abstract class AbstractEvent implements Event { 31 34 protected String type; 35 36 39 protected boolean isBubbling; 40 41 44 protected boolean cancelable; 45 46 49 protected EventTarget currentTarget; 50 51 54 protected EventTarget target; 55 56 59 protected short eventPhase; 60 61 64 protected long timeStamp = System.currentTimeMillis(); 65 66 69 protected boolean stopPropagation = false; 70 71 74 protected boolean preventDefault = false; 75 76 80 public String getType() { 81 return type; 82 } 83 84 89 public EventTarget getCurrentTarget() { 90 return currentTarget; 91 } 92 93 98 public EventTarget getTarget() { 99 return target; 100 } 101 102 106 public short getEventPhase() { 107 return eventPhase; 108 } 109 110 115 public boolean getBubbles() { 116 return isBubbling; 117 } 118 119 125 public boolean getCancelable() { 126 return cancelable; 127 } 128 129 137 public long getTimeStamp() { 138 return timeStamp; 139 } 140 141 150 public void stopPropagation() { 151 this.stopPropagation = true; 152 } 153 154 167 public void preventDefault() { 168 this.preventDefault = true; 169 } 170 171 190 public void initEvent(String eventTypeArg, 191 boolean canBubbleArg, 192 boolean cancelableArg) { 193 this.type = eventTypeArg; 194 this.isBubbling = canBubbleArg; 195 this.cancelable = cancelableArg; 196 } 197 198 boolean getPreventDefault() { 199 return preventDefault; 200 } 201 202 boolean getStopPropagation() { 203 return stopPropagation; 204 } 205 206 void setEventPhase(short eventPhase) { 207 this.eventPhase = eventPhase; 208 } 209 210 void stopPropagation(boolean state) { 211 this.stopPropagation = state; 212 } 213 214 void preventDefault(boolean state) { 215 this.preventDefault = state; 216 } 217 218 void setCurrentTarget(EventTarget currentTarget) { 219 this.currentTarget = currentTarget; 220 } 221 222 void setTarget(EventTarget target) { 223 this.target = target; 224 } 225 226 public static boolean getEventPreventDefault(Event evt) { 227 AbstractEvent ae = (AbstractEvent)evt; 228 return ae.getPreventDefault(); 229 } 230 } 231 | Popular Tags |