00001 package edu.stanford.hci.r3.events; 00002 00003 import edu.stanford.hci.r3.pen.PenSample; 00004 import edu.stanford.hci.r3.units.coordinates.PercentageCoordinates; 00005 import edu.stanford.hci.r3.units.coordinates.StreamedPatternCoordinates; 00006 00018 public class PenEvent { 00019 00020 public enum PenEventModifier { 00021 // a pen down event 00022 DOWN, 00023 00024 // a regular sample event 00025 SAMPLE, 00026 00027 // a pen up event 00028 UP 00029 } 00030 00038 private transient boolean consumed = false; 00039 00043 private PenEventModifier eventModifier = PenEventModifier.SAMPLE; 00044 00048 private PercentageCoordinates locationOnRegion; 00049 00053 private int penID; 00054 00058 private String penName = "Digital Pen"; 00059 00063 private PenSample penSample; 00064 00068 private long timestamp; 00069 00076 public PenEvent(int thePenID, String thePenName, long time, PenSample sample) { 00077 penID = thePenID; 00078 timestamp = time; 00079 penSample = sample; 00080 penName = thePenName; 00081 } 00082 00086 public void consume() { 00087 consumed = true; 00088 } 00089 00099 public PenSample getOriginalSample() { 00100 return penSample; 00101 } 00102 00106 public int getPenID() { 00107 return penID; 00108 } 00109 00113 public String getPenName() { 00114 return penName; 00115 } 00116 00124 public PercentageCoordinates getPercentageLocation() { 00125 return locationOnRegion; 00126 } 00127 00135 public StreamedPatternCoordinates getStreamedPatternCoordinate() { 00136 return new StreamedPatternCoordinates(penSample); 00137 } 00138 00142 public long getTimestamp() { 00143 return timestamp; 00144 } 00145 00149 public PenEventModifier getType() { 00150 return eventModifier; 00151 } 00152 00156 public boolean isConsumed() { 00157 return consumed; 00158 } 00159 00163 public boolean isTypePenDown() { 00164 return eventModifier.equals(PenEventModifier.DOWN); 00165 } 00166 00170 public boolean isTypePenUp() { 00171 return eventModifier.equals(PenEventModifier.UP); 00172 } 00173 00179 public void setModifier(PenEventModifier modifier) { 00180 eventModifier = modifier; 00181 } 00182 00188 public void setOriginalSample(PenSample sample) { 00189 penSample = sample; 00190 } 00191 00197 public void setPenName(String name) { 00198 penName = name; 00199 } 00200 00204 public void setPercentageLocation(PercentageCoordinates location) { 00205 locationOnRegion = location; 00206 } 00207 00208 /* 00209 * (non-Javadoc) 00210 * 00211 * @see java.lang.Object#toString() 00212 */ 00213 public String toString() { 00214 return "PenEvent {Pen " + penID + " (" + penName + ") " + penSample + "}"; 00215 } 00216 }