Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/kmcaster.git

Use empty string to denote regular key release

Author DaveJarvis <email>
Date 2020-07-25 15:32:48 GMT-0700
Commit bcb671a11de87027bde0196b6b4902b6bb6cdefb
Parent 1e9c5f4
src/main/com/whitemagicsoftware/kmcaster/EventHandler.java
import static com.whitemagicsoftware.kmcaster.HardwareState.SWITCH_PRESSED;
import static com.whitemagicsoftware.kmcaster.HardwareState.SWITCH_RELEASED;
-import static java.awt.Font.BOLD;
+import static com.whitemagicsoftware.kmcaster.ui.Constants.*;
import static javax.swing.SwingConstants.CENTER;
import static javax.swing.SwingConstants.TOP;
/**
* Responsible for controlling the application state between the events
* and the view.
*/
public class EventHandler implements PropertyChangeListener {
- /**
- * DejaVu Sans is the only free, open, sans serif font that supports
- * all the Unicode blocks used by the application. The font size is
- * arbitrary, the font will be scaled dynamically to the window size.
- */
- private static final Font LABEL_FONT = new Font( "DejaVu Sans", BOLD, 32 );
-
- /**
- * Matches the shift-key arrow font colour when pressed.
- */
- private static final Color COLOUR_KEY_DN = new Color( 0x21, 0x21, 0x21 );
-
- /**
- * Matches the shift-key arrow font colour when released.
- */
- private static final Color COLOUR_KEY_UP = new Color( 0xE5, 0xE5, 0xE5 );
/**
src/main/com/whitemagicsoftware/kmcaster/HardwareState.java
/**
- * Convenience constant.
+ * Convenience constant used to determine pressed or released state.
*/
public final static String BOOLEAN_FALSE = FALSE.toString();
*/
public static HardwareState valueFrom( final String state ) {
- return BOOLEAN_FALSE.equals( state ) ? SWITCH_RELEASED : SWITCH_PRESSED;
+ return (BOOLEAN_FALSE.equals( state ) || state.isEmpty())
+ ? SWITCH_RELEASED
+ : SWITCH_PRESSED;
}
}
src/main/com/whitemagicsoftware/kmcaster/KmCaster.java
import javax.swing.*;
-import java.awt.*;
-import java.awt.geom.RoundRectangle2D;
import java.beans.PropertyChangeListener;
src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardListener.java
import java.util.Stack;
-import static com.whitemagicsoftware.kmcaster.HardwareState.BOOLEAN_FALSE;
import static com.whitemagicsoftware.kmcaster.HardwareSwitch.*;
import static java.util.Map.entry;
() -> {
final var timer = delayedAction( mDelayRegular, ( action ) ->
- updateRegular( getDisplayText( e ), BOOLEAN_FALSE )
+ updateRegular( getDisplayText( e ), "" )
);
src/main/com/whitemagicsoftware/kmcaster/ui/Constants.java
import java.awt.*;
+import static java.awt.Font.BOLD;
+
/**
* Responsible for containing shared constants required by the GUI.
*/
public final static int DELAY_KEY_MODIFIER = 150;
+
+ /**
+ * DejaVu Sans is the only free, open, sans serif font that supports
+ * all the Unicode blocks used by the application. The font size is
+ * arbitrary, the font will be scaled dynamically to the window size.
+ */
+ public static final Font LABEL_FONT = new Font( "DejaVu Sans", BOLD, 32 );
+
+ /**
+ * Matches the shift-key arrow font colour when pressed.
+ */
+ public static final Color COLOUR_KEY_DN = new Color( 0x21, 0x21, 0x21 );
+
+ /**
+ * Matches the shift-key arrow font colour when released.
+ */
+ public static final Color COLOUR_KEY_UP = new Color( 0xE5, 0xE5, 0xE5 );
/**
Delta 25 lines added, 23 lines removed, 2-line increase