// Copyright 2012 Georg-August-Universität Göttingen, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package de.ugoe.cs.autoquest.keyboardmaps; /** *

* This class is used to define key strokes. *

* * @version 1.0 * @author Patrick Harms */ public class KeyStroke { /** *

* Name of the key stroke. *

*/ private String keyStrokeName; /** *

* {@link VirtualKey} associated with the key stroke. *

*/ private VirtualKey virtualKey; /** *

* Defines whether numlock is pressed during the stroke. *

*/ private boolean numlock; /** *

* Defines whether localstate is pressed during the stroke. *

*/ private boolean localstate; /** *

* Defines whether shift is pressed during the stroke. *

*/ private boolean shift; /** *

* Defines whether altgr is pressed during the stroke. *

*/ private boolean altgr; /** *

* Defines whether inhibit is pressed during the stroke. *

*/ private boolean inhibit; /** *

* Defines the character in which the key stroke results. *

*/ private char character; /** *

* Constructor. Creates a new key stroke *

* * @param keyStrokeName * name of the key stroke * @param virtualKey * virtual key associated with the key stroke * @param numlock * defines whether numlock is pressed during the key stroke * @param localstate * defines whether localstate is pressed during the key stroke * @param shift * defines whether shift is pressed during the key stroke * @param altgr * defines whether altgr is pressed during the key stroke * @param inhibit * defines whether inhibit is pressed during the key stroke * @param character * defines that character in which the key stroke results */ public KeyStroke(String keyStrokeName, VirtualKey virtualKey, boolean numlock, boolean localstate, boolean shift, boolean altgr, boolean inhibit, char character) { this.keyStrokeName = keyStrokeName; this.virtualKey = virtualKey; this.numlock = numlock; this.localstate = localstate; this.shift = shift; this.altgr = altgr; this.inhibit = inhibit; this.character = character; } /** *

* Returns the name of the key stroke. *

* * @return the name */ public String getKeyStrokeName() { return keyStrokeName; } /** *

* Returns the virtual key associated with the key stroke. *

* * @return the virtual key */ public VirtualKey getVirtualKey() { return virtualKey; } /** *

* Returns the character in which the key stroke results. *

* * @return the character */ public char getCharacter() { return character; } /** *

* Returns whether inhibit is pressed. *

* * @return true if pressed; false otherwise */ public boolean getInhibit() { return inhibit; } /** *

* Returns whether altgr is pressed. *

* * @return true if pressed; false otherwise */ public boolean getAltgr() { return altgr; } /** *

* Returns whether shift is pressed. *

* * @return true if pressed; false otherwise */ public boolean getShift() { return shift; } /** *

* Returns whether localstate is pressed. *

* * @return true if pressed; false otherwise */ public boolean getLocalstate() { return localstate; } /** *

* Returns whether numlock is pressed. *

* * @return true if pressed; false otherwise */ public boolean getNumlock() { return numlock; } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer toString = new StringBuffer(); toString.append("KeyStroke("); toString.append(keyStrokeName); toString.append(", "); toString.append(virtualKey); if (character != Character.UNASSIGNED) { toString.append(", \'"); toString.append(character); toString.append("\'"); } if (shift) { toString.append(", shift"); } if (altgr) { toString.append(", altgr"); } if (numlock) { toString.append(", numlock"); } if (localstate) { toString.append(", localstate"); } if (inhibit) { toString.append(", inhibit"); } toString.append(")"); return toString.toString(); } }