Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/kmcaster.git
.idea/workspace.xml
<component name="ChangeListManager">
<list default="true" id="be1819c5-28d3-4984-9634-0b266734e13c" name="Default Changelist" comment="">
- <change afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/Key.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardListener.java" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/Modifier.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardModifier.java" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardModifier.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardModifier.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardListener.java
// If it's not a modifier key, broadcast the regular value.
if( isRegular ) {
- tryFire( KEY_REGULAR.toString(), mRegularHeld, regularHeld );
+ tryFire( KEY_REGULAR, mRegularHeld, regularHeld );
mRegularHeld = regularHeld;
}
for( final var modifier : mModifiers ) {
final boolean down = modifier.matches( e );
- tryFire( modifier.toString(), modifier.isHeld(), down );
+ tryFire( modifier.getKey(), modifier.isHeld(), down );
modifier.setHeld( down );
}
}
/**
* Called to fire the property change with the two given values differ.
*
- * @param name The name of the property that has changed.
- * @param o Old property value.
- * @param n New property value.
+ * @param key The name of the property that has changed.
+ * @param o Old property value.
+ * @param n New property value.
*/
- private void tryFire( final String name, final String o, final String n ) {
+ private void tryFire( final Key key, final String o, final String n ) {
if( !o.equals( n ) ) {
- mDispatcher.firePropertyChange( name, o, n );
+ mDispatcher.firePropertyChange( key.toString(), o, n );
}
}
/**
- * Delegates to {@link #tryFire(String, String, String)} with {@link Boolean}
+ * Delegates to {@link #tryFire(Key, String, String)} with {@link Boolean}
* values as strings.
*
- * @param name The name of the property that has changed.
- * @param o Old property value.
- * @param n New property value.
+ * @param key The name of the property that has changed.
+ * @param o Old property value.
+ * @param n New property value.
*/
- private void tryFire( final String name, final boolean o, final boolean n ) {
- tryFire( name, Boolean.toString( o ), Boolean.toString( n ) );
+ private void tryFire( final Key key, final boolean o, final boolean n ) {
+ tryFire( key, Boolean.toString( o ), Boolean.toString( n ) );
}
src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardModifier.java
public boolean isKeyName( final String key ) {
- return mKey.isName( key );
+ return getKey().isName( key );
}
public boolean isHeld() {
return mHeld;
}
public void setHeld( final boolean held ) {
mHeld = held;
+ }
+
+ public Key getKey() {
+ return mKey;
}
public String toString() {
- return mKey.toString();
+ return getKey().toString();
}
}

Eliminate a little duplication

Author DaveJarvis <email>
Date 2020-07-16 20:18:03 GMT-0700
Commit 7c9d188f06694e22f88e3f7dc3784b54fd9dd21f
Parent 7d04ecf
Delta 20 lines added, 17 lines removed, 3-line increase