logger dash panel enhanced with bar tracking

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@441 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
kascade 2007-01-19 00:41:43 +00:00
parent 0b5f881f50
commit 19e5eb4227
2 changed files with 28 additions and 16 deletions

View File

@ -23,6 +23,8 @@ package enginuity.logger.ui.handler.dash;
import java.awt.*;
import static java.awt.BorderLayout.*;
import static java.awt.Color.BLACK;
import static java.awt.Color.WHITE;
import static java.awt.Font.BOLD;
import static java.awt.Font.PLAIN;
import javax.swing.*;
@ -32,10 +34,13 @@ import enginuity.logger.definition.EcuData;
import static enginuity.util.ParamChecker.checkNotNull;
public final class PlainGauge extends Gauge {
private static final Color RED = new Color(190, 30, 30);
private static final Color DARK_GREY = new Color(40, 40, 40);
private static final Color LIGHT_GREY = new Color(56, 56, 56);
private static final String BLANK = "";
private final String zeroText;
private final EcuData ecuData;
private final JLabel currentLabel = new JLabel(BLANK, JLabel.CENTER);
private final JLabel liveValueLabel = new JLabel(BLANK, JLabel.CENTER);
private final JLabel maxLabel = new JLabel(BLANK, JLabel.CENTER);
private final JLabel minLabel = new JLabel(BLANK, JLabel.CENTER);
private final JLabel title = new JLabel(BLANK, JLabel.CENTER);
@ -59,7 +64,7 @@ public final class PlainGauge extends Gauge {
}
public void resetValue() {
currentLabel.setText(zeroText);
liveValueLabel.setText(zeroText);
max = Double.MIN_VALUE;
maxLabel.setText(zeroText);
min = Double.MAX_VALUE;
@ -73,26 +78,29 @@ public final class PlainGauge extends Gauge {
refreshTitle();
resetValue();
setPreferredSize(new Dimension(60, 40));
setBackground(Color.GREEN);
setBackground(LIGHT_GREY);
setLayout(new BorderLayout(3, 3));
// title
title.setFont(getFont().deriveFont(BOLD, 12F));
title.setForeground(WHITE);
add(title, NORTH);
// data panel
JPanel data = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 3));
data.setBackground(Color.YELLOW);
data.setBackground(BLACK);
data.setBorder(new BevelBorder(LOWERED));
currentLabel.setFont(getFont().deriveFont(PLAIN, 40F));
JPanel currentPanel = new JPanel(new BorderLayout());
currentPanel.setPreferredSize(new Dimension(140, 80));
currentPanel.add(currentLabel, CENTER);
data.add(currentPanel);
liveValueLabel.setFont(getFont().deriveFont(PLAIN, 40F));
liveValueLabel.setForeground(WHITE);
JPanel liveValuePanel = new JPanel(new BorderLayout());
liveValuePanel.setBackground(LIGHT_GREY);
liveValuePanel.setPreferredSize(new Dimension(140, 80));
liveValuePanel.add(liveValueLabel, CENTER);
data.add(liveValuePanel);
// max/min panel
JPanel maxMinPanel = new JPanel(new BorderLayout(2, 2));
maxMinPanel.setBackground(Color.YELLOW);
maxMinPanel.setBackground(BLACK);
JPanel maxPanel = buildMaxMinPanel("max", maxLabel);
JPanel minPanel = buildMaxMinPanel("min", minLabel);
maxMinPanel.add(maxPanel, NORTH);
@ -103,19 +111,23 @@ public final class PlainGauge extends Gauge {
progressBar.setStringPainted(false);
progressBar.setIndeterminate(false);
progressBar.setPreferredSize(new Dimension(20, 82));
progressBar.setBackground(WHITE);
progressBar.setForeground(RED);
data.add(progressBar);
add(data, CENTER);
}
private JPanel buildMaxMinPanel(String title, JLabel label) {
label.setFont(getFont().deriveFont(PLAIN, 12F));
label.setForeground(WHITE);
JPanel panel = new JPanel(new BorderLayout(1, 1));
panel.setPreferredSize(new Dimension(60, 38));
panel.setBackground(Color.CYAN);
panel.setBackground(LIGHT_GREY);
JLabel titleLabel = new JLabel(title, JLabel.CENTER);
titleLabel.setFont(getFont().deriveFont(BOLD, 12F));
titleLabel.setForeground(WHITE);
JPanel dataPanel = new JPanel(new BorderLayout());
dataPanel.setBackground(Color.PINK);
dataPanel.setBackground(DARK_GREY);
dataPanel.add(label, CENTER);
panel.add(titleLabel, NORTH);
panel.add(dataPanel, CENTER);
@ -135,7 +147,7 @@ public final class PlainGauge extends Gauge {
minLabel.setText(text);
progressBar.setMinimum(scaledValue);
}
currentLabel.setText(text);
liveValueLabel.setText(text);
progressBar.setValue(scaledValue);
}

View File

@ -21,8 +21,7 @@
package enginuity.swing;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.*;
import static javax.swing.UIManager.getSystemLookAndFeelClassName;
import static javax.swing.UIManager.setLookAndFeel;
@ -43,6 +42,7 @@ public final class LookAndFeelManager {
System.setProperty("apple.awt.rendering", "true");
System.setProperty("apple.awt.window.position.forceSafeCreation", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Enginuity");
System.setProperty("apple.awt.brushMetalLook", "true");
// setRestrictedPlatformLookAndFeel("Windows", "5.1");
}