add internal support for more font settings
This commit is contained in:
parent
a1fa2e763d
commit
7b580553bd
|
@ -67,6 +67,7 @@ public class Settings {
|
|||
public static final Property<Boolean> headerShowGoal = new Property<>( "header.goal" );
|
||||
public static final Property<Boolean> headerShowTitle = new Property<>( "header.title" );
|
||||
public static final Property<Boolean> headerShowAttempts = new Property<>( "header.showAttempts" );
|
||||
public static final Property<Font> headerTitleFont = new Property<>(" header.titleFont" );
|
||||
|
||||
/* HISTORY properties */
|
||||
|
||||
|
@ -96,6 +97,8 @@ public class Settings {
|
|||
public static final Property<Boolean> coreShowSegmentTimer = new Property<>( "core.segmentTimer" );
|
||||
public static final Property<Font> coreTimerFont = new Property<>( "core.timerFont" );
|
||||
public static final Property<Font> coreSegmentTimerFont = new Property<>( "core.segmentTimerFont" );
|
||||
public static final Property<Font> coreFont = new Property<>( "core.font" );
|
||||
public static final Property<Font> coreOtherTimeFont = new Property<>( "core.otherTimeFont" );
|
||||
|
||||
/* GRAPH properties */
|
||||
|
||||
|
@ -227,6 +230,7 @@ public class Settings {
|
|||
global.put( headerShowGoal.key, true );
|
||||
global.put( headerShowTitle.key, true );
|
||||
global.put( headerShowAttempts.key, true );
|
||||
global.put( headerTitleFont.key, Font.decode( "Arial-14" ) );
|
||||
|
||||
global.put( historyRowCount.key, 8 );
|
||||
global.put( historyTabular.key, true );
|
||||
|
@ -252,6 +256,8 @@ public class Settings {
|
|||
global.put( coreShowSegmentTimer.key, true );
|
||||
global.put( coreTimerFont.key, Font.decode( "Digitalism-32" ) );
|
||||
global.put( coreSegmentTimerFont.key, Font.decode( "Digitalism-18" ) );
|
||||
global.put( coreFont.key, Font.decode( "Arial-12" ) );
|
||||
global.put( coreOtherTimeFont.key, Font.decode( "Arial-11" ) );
|
||||
|
||||
global.put( graphDisplay.key, true );
|
||||
global.put( graphScale.key, 3.0F );
|
||||
|
|
|
@ -182,6 +182,7 @@ class Core extends JPanel implements ActionListener {
|
|||
|
||||
placeComponents();
|
||||
updateColors(ALL);
|
||||
updateFonts(ALL);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------- INTERFACE
|
||||
|
@ -395,7 +396,7 @@ class Core extends JPanel implements ActionListener {
|
|||
revalidate();
|
||||
} else if (Settings.coreTimerFont.equals(property)
|
||||
|| Settings.coreSegmentTimerFont.equals(property)) {
|
||||
updateValues(FONT);
|
||||
updateFonts(TIMER);
|
||||
resize = true;
|
||||
revalidate();
|
||||
} else if (Settings.coreShowSegmentTimer.equals(property)) {
|
||||
|
@ -406,6 +407,14 @@ class Core extends JPanel implements ActionListener {
|
|||
updateVisibility(ICON);
|
||||
resize = true;
|
||||
revalidate();
|
||||
} else if (Settings.coreFont.equals(property)) {
|
||||
updateFonts(NAME);
|
||||
resize = true;
|
||||
revalidate();
|
||||
} else if (Settings.coreOtherTimeFont.equals(property)) {
|
||||
updateFonts(TIME);
|
||||
resize = true;
|
||||
revalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -566,10 +575,6 @@ class Core extends JPanel implements ActionListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((identifier & FONT) == FONT) {
|
||||
splitTimer.setFont(Settings.coreTimerFont.get());
|
||||
segmentTimer.setFont(Settings.coreSegmentTimerFont.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -600,4 +605,27 @@ class Core extends JPanel implements ActionListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the fonts of the group of components specified by the
|
||||
* identifier.
|
||||
* @param identifier - one of the constant update identifier.
|
||||
*/
|
||||
private void updateFonts(int identifier) {
|
||||
if ((identifier & TIME) == TIME) {
|
||||
split.setFont(Settings.coreOtherTimeFont.get());
|
||||
segment.setFont(Settings.coreOtherTimeFont.get());
|
||||
best.setFont(Settings.coreOtherTimeFont.get());
|
||||
}
|
||||
if ((identifier & NAME) == NAME) {
|
||||
name.setFont(Settings.coreFont.get());
|
||||
labelBest.setFont(Settings.coreFont.get());
|
||||
labelSegment.setFont(Settings.coreFont.get());
|
||||
labelSplit.setFont(Settings.coreFont.get());
|
||||
}
|
||||
if ((identifier & TIMER) == TIMER) {
|
||||
splitTimer.setFont(Settings.coreTimerFont.get());
|
||||
segmentTimer.setFont(Settings.coreSegmentTimerFont.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,18 @@
|
|||
package org.fenix.llanfair.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.fenix.llanfair.Language;
|
||||
import org.fenix.llanfair.Run;
|
||||
import org.fenix.llanfair.Segment;
|
||||
import org.fenix.llanfair.config.Settings;
|
||||
import org.fenix.llanfair.Time;
|
||||
import org.fenix.llanfair.Run.State;
|
||||
import org.fenix.llanfair.Segment;
|
||||
import org.fenix.llanfair.Time;
|
||||
import org.fenix.llanfair.config.Settings;
|
||||
import org.fenix.utils.gui.GBC;
|
||||
import org.fenix.utils.locale.LocaleEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
/**
|
||||
* A simple pane displaying the bare minimum of information concerning the
|
||||
* previous segment of a run, namely the cumulative gain/loss on the run
|
||||
|
@ -95,6 +89,7 @@ class Footer extends JPanel {
|
|||
placeComponents();
|
||||
updateValues(TEXT);
|
||||
updateColors(ALL);
|
||||
updateFonts(ALL);
|
||||
updateVisibility(ALL);
|
||||
forceResize();
|
||||
}
|
||||
|
@ -219,6 +214,12 @@ class Footer extends JPanel {
|
|||
updateValues(DELTA);
|
||||
updateVisibility(VERBOSE);
|
||||
forceResize();
|
||||
} else if (Settings.coreFont.equals(property)) {
|
||||
updateFonts(TEXT);
|
||||
forceResize();
|
||||
} else if (Settings.coreOtherTimeFont.equals(property)) {
|
||||
updateFonts(TIME | DELTA);
|
||||
forceResize();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,6 +380,33 @@ class Footer extends JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the fonts of the group of components specified by the
|
||||
* identifier.
|
||||
* @param identifier - one of the constant update identifier.
|
||||
*/
|
||||
private void updateFonts(int identifier) {
|
||||
if ((identifier & TIME) == TIME) {
|
||||
liveL.setFont(Settings.coreOtherTimeFont.get());
|
||||
liveR.setFont(Settings.coreOtherTimeFont.get());
|
||||
time.setFont(Settings.coreOtherTimeFont.get());
|
||||
best.setFont(Settings.coreOtherTimeFont.get());
|
||||
inlineBest.setFont(Settings.coreOtherTimeFont.get());
|
||||
}
|
||||
if ((identifier & DELTA) == DELTA) {
|
||||
delta.setFont(Settings.coreOtherTimeFont.get());
|
||||
deltaBest.setFont(Settings.coreOtherTimeFont.get());
|
||||
inlineDeltaBest.setFont(Settings.coreOtherTimeFont.get());
|
||||
}
|
||||
if ((identifier & TEXT) == TEXT) {
|
||||
labelPrev.setFont(Settings.coreFont.get());
|
||||
labelDelta.setFont(Settings.coreFont.get());
|
||||
labelLive.setFont(Settings.coreFont.get());
|
||||
labelBest.setFont(Settings.coreFont.get());
|
||||
labelDeltaBest.setFont(Settings.coreFont.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the values of the group of components specified by the
|
||||
* identifier.
|
||||
|
|
|
@ -1,28 +1,19 @@
|
|||
package org.fenix.llanfair.gui;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Stroke;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
|
||||
import org.fenix.llanfair.Language;
|
||||
import org.fenix.llanfair.Run;
|
||||
import org.fenix.llanfair.Segment;
|
||||
import org.fenix.llanfair.config.Settings;
|
||||
import org.fenix.llanfair.Time;
|
||||
import org.fenix.llanfair.Run.State;
|
||||
import org.fenix.llanfair.Segment;
|
||||
import org.fenix.llanfair.Time;
|
||||
import org.fenix.llanfair.config.Settings;
|
||||
import org.fenix.utils.gui.GBC;
|
||||
import org.fenix.utils.locale.LocaleEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
/**
|
||||
* Graph panel displaying information concerning a run. It includes an actual
|
||||
* graph where each vertex is a live split time and a scale. The vertices are
|
||||
|
@ -119,6 +110,7 @@ class Graph extends JPanel {
|
|||
|
||||
updateValues(TEXT);
|
||||
updateColors(ALL);
|
||||
updateFonts(ALL);
|
||||
placeComponents();
|
||||
|
||||
Dimension size = new Dimension(PACK_WIDTH, PACK_HEIGHT);
|
||||
|
@ -176,6 +168,8 @@ class Graph extends JPanel {
|
|||
} else if (run.getState() == State.NULL) {
|
||||
updateValues(TIME);
|
||||
}
|
||||
} else if (Settings.coreFont.equals(property)) {
|
||||
updateFonts(ALL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,6 +269,20 @@ class Graph extends JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the fonts of the group of components specified by the
|
||||
* identifier.
|
||||
* @param identifier - one of the constant update identifier.
|
||||
*/
|
||||
private void updateFonts(int identifier) {
|
||||
if ((identifier & TIME) == TIME) {
|
||||
scale.setFont(Settings.coreFont.get());
|
||||
}
|
||||
if ((identifier & TEXT) == TEXT) {
|
||||
scaleText.setFont(Settings.coreFont.get());
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------- INTERNAL TYPE
|
||||
|
||||
/**
|
||||
|
|
|
@ -171,9 +171,8 @@ public class RunPane extends JPanel {
|
|||
|
||||
updateValues(TEXT);
|
||||
updateColors(ALL);
|
||||
updateFonts(ALL);
|
||||
updateVisibility(ALL);
|
||||
|
||||
title.setFont(RUN_TITLE_FONT);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------- INTERFACE
|
||||
|
@ -265,6 +264,10 @@ public class RunPane extends JPanel {
|
|||
} else if (Run.ATTEMPT_COUNTER_PROPERTY.equals(property) ||
|
||||
Run.COMPLETED_ATTEMPT_COUNTER_PROPERTY.equals(property)) {
|
||||
updateValues(ATTEMPTS);
|
||||
} else if (Settings.headerTitleFont.equals(property)) {
|
||||
updateFonts(TITLE);
|
||||
} else if (Settings.coreFont.equals(property)) {
|
||||
updateFonts(ALL & ~TITLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,6 +393,27 @@ public class RunPane extends JPanel {
|
|||
attemptCounter.setForeground(Color.WHITE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the fonts of the group of components specified by the
|
||||
* identifier.
|
||||
*
|
||||
* @param identifier - one of the constant update identifier.
|
||||
*/
|
||||
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());
|
||||
}
|
||||
if ((identifier & ATTEMPTS) == ATTEMPTS) {
|
||||
attemptCounter.setFont(Settings.coreFont.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the visibility of the components specified by the
|
||||
* identifier.
|
||||
|
|
Reference in a new issue