From 1105a52a0a68840de6ba9b4a286c801878e21965 Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 3 Jan 2016 15:16:19 -0500 Subject: [PATCH] change "goal" to "sub title." resolves #8 the sub title can still be used to put a goal if the end user really wants it. but it won't do the fancy automatic segment time text if the user had goal showing enabled but no text set. --- .../java/org/fenix/llanfair/Language.java | 5 +- .../java/org/fenix/llanfair/Llanfair.java | 2 +- src/main/java/org/fenix/llanfair/Run.java | 36 ++++---- .../org/fenix/llanfair/config/Settings.java | 4 +- .../org/fenix/llanfair/dialog/EditRun.java | 12 +-- .../fenix/llanfair/dialog/TabComponents.java | 4 +- .../java/org/fenix/llanfair/gui/RunPane.java | 91 +++++-------------- src/main/resources/language.properties | 5 +- 8 files changed, 58 insertions(+), 101 deletions(-) diff --git a/src/main/java/org/fenix/llanfair/Language.java b/src/main/java/org/fenix/llanfair/Language.java index 669d013..303d163 100644 --- a/src/main/java/org/fenix/llanfair/Language.java +++ b/src/main/java/org/fenix/llanfair/Language.java @@ -53,7 +53,7 @@ public enum Language { GLOBAL_HOTKEYS_STARTUP_ERROR, // Settings > Header - setting_header_goal, + setting_header_subTitle, setting_header_title, setting_header_showAttempts, setting_header_titleFont, @@ -146,7 +146,7 @@ public enum Language { FOOTER, MISC, USE_MAIN_FONT, - LB_GOAL, + LB_SUBTITLE, ICON, COLORS, @@ -231,7 +231,6 @@ public enum Language { DISABLED, EDITING, ERROR, - GOAL, IMAGE, INPUTS, MAX_ORDINATE, diff --git a/src/main/java/org/fenix/llanfair/Llanfair.java b/src/main/java/org/fenix/llanfair/Llanfair.java index 78a0433..aea8e1c 100644 --- a/src/main/java/org/fenix/llanfair/Llanfair.java +++ b/src/main/java/org/fenix/llanfair/Llanfair.java @@ -326,7 +326,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener, || Settings.footerUseSplitData.equals(property) || Settings.coreIconSize.equals(property) || Settings.accuracy.equals(property) - || Settings.headerShowGoal.equals(property) + || Settings.headerShowSubtitle.equals(property) || Settings.headerShowTitle.equals(property) || Settings.historyDeltas.equals(property) || Settings.historySegmentFont.equals(property) diff --git a/src/main/java/org/fenix/llanfair/Run.java b/src/main/java/org/fenix/llanfair/Run.java index 4e61bc2..42bed93 100644 --- a/src/main/java/org/fenix/llanfair/Run.java +++ b/src/main/java/org/fenix/llanfair/Run.java @@ -79,6 +79,8 @@ public class Run implements TableModel, Serializable { */ public static final String NAME_PROPERTY = "run.name"; + public static final String SUBTITLE_PROPERTY = "run.subTitle"; + /** * Identifier for the bean property state of the run. */ @@ -89,8 +91,6 @@ public class Run implements TableModel, Serializable { */ public static final String CURRENT_SEGMENT_PROPERTY = "run.currentSegment"; - public static final String GOAL_PROPERTY = "run.goal"; - public static final String COUNTER_VALUE_PROPERTY = "run.counters.value"; public static final String COUNTER_ADD_PROPERTY = "run.counters.add"; @@ -114,6 +114,11 @@ public class Run implements TableModel, Serializable { */ private String name; + /*** + * The subtitle of the run. + */ + private String subTitle; + /** * Current state of the run. Transient as a deserialized run will always * start in {@link State#READY}. @@ -166,8 +171,6 @@ public class Run implements TableModel, Serializable { */ private long delayedStart; - private String goal; - private boolean segmented; private List counters; @@ -191,8 +194,8 @@ public class Run implements TableModel, Serializable { throw new NullPointerException("null run name"); } this.name = name; + this.subTitle = ""; segments = new ArrayList(); - goal = ""; segmented = false; counters = new ArrayList(); initializeTransients(); @@ -217,8 +220,8 @@ public class Run implements TableModel, Serializable { return name; } - public String getGoal() { - return goal; + public String getSubTitle() { + return subTitle; } public long getDelayedStart() { @@ -604,17 +607,14 @@ public class Run implements TableModel, Serializable { pcSupport.firePropertyChange(NAME_PROPERTY, old, name); } - public void setSegmented(boolean segmented) { - this.segmented = segmented; + public void setSubTitle(String subTitle) { + String old = this.subTitle; + this.subTitle = subTitle; + pcSupport.firePropertyChange(SUBTITLE_PROPERTY, old, subTitle); } - public void setGoal(String goal) { - if (goal == null) { - throw new NullPointerException("null goal string"); - } - String old = this.goal; - this.goal = goal; - pcSupport.firePropertyChange(GOAL_PROPERTY, old, goal); + public void setSegmented(boolean segmented) { + this.segmented = segmented; } public void setDelayedStart(long delayedStart) { @@ -1121,8 +1121,8 @@ public class Run implements TableModel, Serializable { current = -1; startTime = 0L; - if (goal == null) { - goal = ""; + if (subTitle == null) { + subTitle = ""; } if (counters == null) { counters = new ArrayList(); diff --git a/src/main/java/org/fenix/llanfair/config/Settings.java b/src/main/java/org/fenix/llanfair/config/Settings.java index 6476344..0fbe2d1 100644 --- a/src/main/java/org/fenix/llanfair/config/Settings.java +++ b/src/main/java/org/fenix/llanfair/config/Settings.java @@ -64,7 +64,7 @@ public class Settings { /* HEADER properties */ - public static final Property headerShowGoal = new Property<>( "header.goal" ); + public static final Property headerShowSubtitle = new Property<>( "header.subTitle" ); public static final Property headerShowTitle = new Property<>( "header.title" ); public static final Property headerShowAttempts = new Property<>( "header.showAttempts" ); public static final Property headerTitleFont = new Property<>(" header.titleFont" ); @@ -227,7 +227,7 @@ public class Settings { global.put( hotkeyPause.key, -1 ); global.put( hotkeyLock.key, -1 ); - global.put( headerShowGoal.key, true ); + global.put( headerShowSubtitle.key, true ); global.put( headerShowTitle.key, true ); global.put( headerShowAttempts.key, true ); global.put( headerTitleFont.key, Font.decode( "Arial-14" ) ); diff --git a/src/main/java/org/fenix/llanfair/dialog/EditRun.java b/src/main/java/org/fenix/llanfair/dialog/EditRun.java index 1543e7e..6123bb7 100644 --- a/src/main/java/org/fenix/llanfair/dialog/EditRun.java +++ b/src/main/java/org/fenix/llanfair/dialog/EditRun.java @@ -56,6 +56,8 @@ implements ActionListener, ListSelectionListener { */ private JLabel runTitleLabel; + private JTextField runSubTitle; + /** * Table d’édition des segments de la course. */ @@ -103,8 +105,6 @@ implements ActionListener, ListSelectionListener { */ private JButton moveDown; - private JTextField runGoal; - private JTextField runDelayedStart; // ----------------------------------------------------------- CONSTRUCTEURS @@ -128,7 +128,7 @@ implements ActionListener, ListSelectionListener { runTitle = new JTextField(run.getName(), 61); runTitleLabel = new JLabel(Language.RUN_TITLE.get()); - runGoal = new JTextField(run.getGoal(), 48); + runSubTitle = new JTextField(run.getSubTitle(), 61); runDelayedStart = new JTextField(delayedStartString, 5); segments = new JTable(run) { @Override protected JTableHeader createDefaultTableHeader() { @@ -173,8 +173,8 @@ implements ActionListener, ListSelectionListener { setLayout(new GridBagLayout()); add(runTitleLabel, GBC.grid(0, 0).insets(4, 4, 0, 4).anchor(GBC.LE)); add(runTitle, GBC.grid(1, 0, 3, 1).insets(4, 0, 0, 4).anchor(GBC.LS)); - add(new JLabel("" + Language.LB_GOAL), GBC.grid(0, 1).insets(4, 4, 0, 4).anchor(GBC.LE)); - add(runGoal, GBC.grid(1, 1).insets(4, 0, 0, 4).anchor(GBC.LS)); + add(new JLabel("" + Language.LB_SUBTITLE), GBC.grid(0, 1).insets(4, 4, 0, 4).anchor(GBC.LE)); + add(runSubTitle, GBC.grid(1, 1).insets(4, 0, 0, 4).anchor(GBC.LS)); add(new JLabel("" + Language.ED_DELAYED_START), GBC.grid(0, 2).insets(4, 4, 0, 4).anchor(GBC.LE)); add(runDelayedStart, GBC.grid(1, 2).insets(4, 0, 0, 4).anchor(GBC.LS)); add(segmented, GBC.grid(2, 2, 2, 1).insets(4, 0, 0, 4).anchor(GBC.LS)); @@ -295,7 +295,7 @@ implements ActionListener, ListSelectionListener { } else if (source.equals(save)) { run.setName(runTitle.getText()); - run.setGoal(runGoal.getText()); + run.setSubTitle(runSubTitle.getText()); run.setSegmented(segmented.isSelected()); long delayedStart = parseDelayedStartTime(runDelayedStart.getText()); diff --git a/src/main/java/org/fenix/llanfair/dialog/TabComponents.java b/src/main/java/org/fenix/llanfair/dialog/TabComponents.java index 92c4030..f590b62 100644 --- a/src/main/java/org/fenix/llanfair/dialog/TabComponents.java +++ b/src/main/java/org/fenix/llanfair/dialog/TabComponents.java @@ -38,7 +38,7 @@ public class TabComponents extends SettingsTab SCB_SETTINGS.add(Settings.graphDisplay); SCB_SETTINGS.add(Settings.coreShowSegmentTimer); SCB_SETTINGS.add(Settings.coreShowIcons); - SCB_SETTINGS.add(Settings.headerShowGoal); + SCB_SETTINGS.add(Settings.headerShowSubtitle); SCB_SETTINGS.add(Settings.headerShowAttempts); } @@ -332,7 +332,7 @@ public class TabComponents extends SettingsTab ); } JPanel miscPanel = new JPanel(new GridBagLayout()); { - miscPanel.add(checkBoxes.get(Settings.headerShowGoal.getKey()), GBC.grid(0, 0).anchor(GBC.LS)); + miscPanel.add(checkBoxes.get(Settings.headerShowSubtitle.getKey()), GBC.grid(0, 0).anchor(GBC.LS)); miscPanel.add(checkBoxes.get(Settings.headerShowTitle.getKey()), GBC.grid(0, 1).anchor(GBC.LS)); miscPanel.add(checkBoxes.get(Settings.graphDisplay.getKey()), GBC.grid(0, 2).anchor(GBC.LS)); miscPanel.add(checkBoxes.get(Settings.headerShowAttempts.getKey()), GBC.grid(0, 3).anchor(GBC.LS)); diff --git a/src/main/java/org/fenix/llanfair/gui/RunPane.java b/src/main/java/org/fenix/llanfair/gui/RunPane.java index 0fdb525..4b55647 100644 --- a/src/main/java/org/fenix/llanfair/gui/RunPane.java +++ b/src/main/java/org/fenix/llanfair/gui/RunPane.java @@ -45,7 +45,7 @@ public class RunPane extends JPanel { /** * Update identifier for time variables. */ - private static final int GOAL = 0x01; + private static final int SUBTITLE = 0x01; /** * Update identifier for separator variables. @@ -96,20 +96,9 @@ public class RunPane extends JPanel { private JLabel title; /** - * Label displaying the current goal of run. By default it’s the time of - * the run we’re comparing against, but it can be a customized string. + * Label displaying the sub title of the current run. */ - private JLabel goal; - - /** - * Label describing the goal value being displayed. - */ - private JLabel goalText; - - /** - * Panel containing both goal value and text. - */ - private JPanel goalPane; + private JLabel subTitle; /** * Label displaying the number of attempts the user has made of this run. @@ -157,8 +146,7 @@ public class RunPane extends JPanel { throw new NullPointerException("null run"); } title = new JLabel(); - goal = new JLabel(); - goalText = new JLabel(); + subTitle = new JLabel(); attemptCounter = new JLabel(); core = new Core(run); graph = new Graph(run); @@ -225,9 +213,8 @@ public class RunPane extends JPanel { String property = event.getPropertyName(); if (Run.STATE_PROPERTY.equals(property)) { - if (run.getState() == State.READY - || run.getState() == State.NULL) { - updateValues(GOAL | SEPARATOR); + if (run.getState() == State.READY || run.getState() == State.NULL) { + updateValues(ATTEMPTS | SEPARATOR); } } else if (Run.NAME_PROPERTY.equals(property)) { updateValues(TITLE); @@ -239,28 +226,24 @@ public class RunPane extends JPanel { updateColors(SEPARATOR); } else if (Settings.historyRowCount.equals(property)) { updateValues(SEPARATOR); - } else if (Settings.colorTime.equals(property)) { - updateColors(GOAL); } else if (Settings.colorTitle.equals(property)) { updateColors(TITLE); - } else if (Settings.compareMethod.equals(property)) { - updateValues(GOAL); } else if (Settings.graphDisplay.equals(property)) { updateVisibility(GRAPH); } else if (Settings.footerDisplay.equals(property)) { updateVisibility(FOOTER); } else if (Settings.headerShowTitle.equals(property)) { - updateVisibility(TITLE | GOAL); + updateVisibility(TITLE); updateValues(SEPARATOR); - } else if (Settings.headerShowGoal.equals(property)) { - updateVisibility(TITLE | GOAL); + } else if (Settings.headerShowSubtitle.equals(property)) { + updateVisibility(SUBTITLE); updateValues(SEPARATOR); } else if (Settings.headerShowAttempts.equals(property)) { updateVisibility(ATTEMPTS); updateValues(SEPARATOR); } else if (Settings.accuracy.equals(property) - || Run.GOAL_PROPERTY.equals(property)) { - updateValues(GOAL); + || Run.SUBTITLE_PROPERTY.equals(property)) { + updateValues(TITLE); } else if (Run.ATTEMPT_COUNTER_PROPERTY.equals(property) || Run.COMPLETED_ATTEMPT_COUNTER_PROPERTY.equals(property)) { updateValues(ATTEMPTS); @@ -284,7 +267,7 @@ public class RunPane extends JPanel { if (event.getType() == TableModelEvent.INSERT || event.getType() == TableModelEvent.DELETE || event.getType() == TableModelEvent.UPDATE) { - updateValues(GOAL); + updateValues(TITLE); } } @@ -306,12 +289,8 @@ public class RunPane extends JPanel { * Places the sub-components within this component. */ private void placeComponents() { - add(title,GBC.grid(0, 0).insets(3, 0, 1, 0)); - goalPane = new JPanel(new GridBagLayout()); { - goalPane.add(goalText, GBC.grid(0, 1)); - goalPane.add(goal, GBC.grid(1, 1).insets(0, 3, 0, 0)); - goalPane.setOpaque(false); - } + add(title, GBC.grid(0, 0).insets(3, 0, 1, 0)); + add(subTitle, GBC.grid(0, 1).insets(3, 0, 0, 0)); add(attemptCounter, GBC.grid(0, 2).insets(1, 0, 1, 3).anchor(GBC.LE)); add(createSeparator(), GBC.grid(0, 3).insets(3, 0).fill(GBC.H)); add(history, GBC.grid(0, 4).fill(GBC.H).insets(0, 5)); @@ -328,19 +307,9 @@ public class RunPane extends JPanel { * @param identifier - one of the constant update identifier. */ private void updateValues(int identifier) { - if ((identifier & GOAL) == GOAL) { - if (run.getGoal() == null || run.getGoal().equals("")) { - Time time = run.getTime(Segment.SET); - goal.setText("" + (time == null ? "???" : time)); - } else { - goal.setText(run.getGoal()); - } - } - if ((identifier & TEXT) == TEXT) { - goalText.setText("" + Language.GOAL); - } if ((identifier & TITLE) == TITLE) { title.setText("" + run.getName()); + subTitle.setText(run.getSubTitle()); } if ((identifier & ATTEMPTS) == ATTEMPTS) { int attempts = run.getNumberOfAttempts(); @@ -353,12 +322,12 @@ public class RunPane extends JPanel { attemptCounter.setText(String.format("%d / %d", completedAttempts, attempts)); } if ((identifier & SEPARATOR) == SEPARATOR) { - boolean hdTitle = Settings.headerShowGoal.get(); - boolean hdGoal = Settings.headerShowTitle.get(); + boolean hdTitle = Settings.headerShowSubtitle.get(); + boolean hdSubtitle = Settings.headerShowTitle.get(); boolean hdAttempts = Settings.headerShowAttempts.get(); boolean hsRows = history.getRowCount() > 0; - separators.get(0).setVisible(hdTitle || hdGoal || hdAttempts); + separators.get(0).setVisible(hdTitle || hdSubtitle || hdAttempts); separators.get(1).setVisible(hsRows); } } @@ -370,14 +339,9 @@ public class RunPane extends JPanel { * @param identifier - one of the constant update identifier. */ private void updateColors(int identifier) { - if ((identifier & GOAL) == GOAL) { - goal.setForeground(Settings.colorTime.get()); - } - if ((identifier & TEXT) == TEXT) { - goalText.setForeground(Settings.colorForeground.get()); - } if ((identifier & TITLE) == TITLE) { title.setForeground(Settings.colorTitle.get()); + subTitle.setForeground(Settings.colorForeground.get()); } if ((identifier & BACKGROUND) == BACKGROUND) { setBackground(Settings.colorBackground.get()); @@ -402,12 +366,7 @@ public class RunPane extends JPanel { private void updateFonts(int identifier) { if ((identifier & TITLE) == TITLE) { title.setFont(Settings.headerTitleFont.get()); - } - if ((identifier & GOAL) == GOAL) { - goal.setFont(Settings.coreFont.get()); - } - if ((identifier & TEXT) == TEXT) { - goalText.setFont(Settings.coreFont.get()); + subTitle.setFont(Settings.headerTitleFont.get()); } if ((identifier & ATTEMPTS) == ATTEMPTS) { attemptCounter.setFont(Settings.coreFont.get()); @@ -441,15 +400,15 @@ public class RunPane extends JPanel { remove(footer); } } - if ((identifier & GOAL) == GOAL) { - if (Settings.headerShowGoal.get()) { + if ((identifier & SUBTITLE) == SUBTITLE) { + if (Settings.headerShowSubtitle.get()) { if (Settings.headerShowTitle.get()) { - add(goalPane, GBC.grid(0, 1)); + add(subTitle, GBC.grid(0, 1)); } else { - add(goalPane, GBC.grid(0, 1).insets(3, 0, 0, 0)); + add(subTitle, GBC.grid(0, 1).insets(3, 0, 0, 0)); } } else { - remove(goalPane); + remove(subTitle); } } if ((identifier & TITLE) == TITLE) { diff --git a/src/main/resources/language.properties b/src/main/resources/language.properties index d8564b5..8b59cff 100644 --- a/src/main/resources/language.properties +++ b/src/main/resources/language.properties @@ -34,7 +34,7 @@ setting_hotkey_lock = Lock / Unlock GLOBAL_HOTKEYS_STARTUP_ERROR =
Key event hook registration failed.

Llanfair requires global access to key events which (depending on your OS) might require some extra security or accessibility permissions. Click the "OK" button to close Llanfair. You will need to grant the required permissions before you will be able to use Llanfair.

Your OS might have just now popped up some sort of notification which will allow you to quickly grant Llanfair the required permissions.
# Settings > Header -setting_header_goal = Display Goal +setting_header_subTitle = Display Sub Title setting_header_title = Display Run Title setting_header_showAttempts = Display Attempt Counter setting_header_titleFont = Main Title @@ -127,7 +127,7 @@ TIMER = Timer FOOTER = Footer MISC = Miscellaneous USE_MAIN_FONT = Use Main Timer's font -LB_GOAL = Goal +LB_SUBTITLE = Sub Title ICON = Icon COLORS = Colors @@ -205,7 +205,6 @@ COMPONENTS = Components DISABLED = EDITING = Editing Run ERROR = Error -GOAL = Goal: IMAGE = Image INPUTS = Hotkeys MAX_ORDINATE = Max Ord.: