mirror of https://github.com/rusefi/RomRaider.git
logger dash panel enhanced with max/min tracking
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@439 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
af35b7c210
commit
ca8ade4152
|
@ -21,6 +21,31 @@
|
|||
|
||||
package enginuity.logger;
|
||||
|
||||
import java.awt.*;
|
||||
import static java.awt.BorderLayout.*;
|
||||
import static java.awt.Color.BLACK;
|
||||
import static java.awt.Color.RED;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import static java.util.Collections.sort;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.swing.*;
|
||||
import static javax.swing.JLabel.RIGHT;
|
||||
import static javax.swing.JScrollPane.*;
|
||||
import static javax.swing.JSplitPane.HORIZONTAL_SPLIT;
|
||||
import static javax.swing.JSplitPane.VERTICAL_SPLIT;
|
||||
import static javax.swing.JTabbedPane.BOTTOM;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import static javax.swing.border.BevelBorder.LOWERED;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableModel;
|
||||
import enginuity.Settings;
|
||||
import enginuity.io.port.SerialPortRefresher;
|
||||
import enginuity.logger.comms.controller.LoggerController;
|
||||
|
@ -28,24 +53,9 @@ import enginuity.logger.comms.controller.LoggerControllerImpl;
|
|||
import enginuity.logger.comms.query.EcuInit;
|
||||
import enginuity.logger.comms.query.EcuInitCallback;
|
||||
import enginuity.logger.comms.query.LoggerCallback;
|
||||
import enginuity.logger.definition.EcuData;
|
||||
import enginuity.logger.definition.EcuDataLoader;
|
||||
import enginuity.logger.definition.EcuDataLoaderImpl;
|
||||
import enginuity.logger.definition.EcuParameter;
|
||||
import enginuity.logger.definition.EcuSwitch;
|
||||
import enginuity.logger.profile.UserProfile;
|
||||
import enginuity.logger.profile.UserProfileImpl;
|
||||
import enginuity.logger.profile.UserProfileItem;
|
||||
import enginuity.logger.profile.UserProfileItemImpl;
|
||||
import enginuity.logger.profile.UserProfileLoader;
|
||||
import enginuity.logger.profile.UserProfileLoaderImpl;
|
||||
import enginuity.logger.ui.DataRegistrationBroker;
|
||||
import enginuity.logger.ui.DataRegistrationBrokerImpl;
|
||||
import enginuity.logger.ui.EcuDataComparator;
|
||||
import enginuity.logger.ui.EcuLoggerMenuBar;
|
||||
import enginuity.logger.ui.MessageListener;
|
||||
import enginuity.logger.ui.SerialPortComboBox;
|
||||
import enginuity.logger.ui.StatusIndicator;
|
||||
import enginuity.logger.definition.*;
|
||||
import enginuity.logger.profile.*;
|
||||
import enginuity.logger.ui.*;
|
||||
import enginuity.logger.ui.handler.DataUpdateHandler;
|
||||
import enginuity.logger.ui.handler.DataUpdateHandlerManager;
|
||||
import enginuity.logger.ui.handler.DataUpdateHandlerManagerImpl;
|
||||
|
@ -64,38 +74,6 @@ import static enginuity.util.ParamChecker.checkNotNull;
|
|||
import static enginuity.util.ParamChecker.isNullOrEmpty;
|
||||
import static enginuity.util.ThreadUtil.sleep;
|
||||
|
||||
import javax.swing.*;
|
||||
import static javax.swing.JLabel.RIGHT;
|
||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
|
||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||
import static javax.swing.JSplitPane.HORIZONTAL_SPLIT;
|
||||
import static javax.swing.JSplitPane.VERTICAL_SPLIT;
|
||||
import static javax.swing.JTabbedPane.BOTTOM;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import static javax.swing.border.BevelBorder.LOWERED;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableModel;
|
||||
import java.awt.*;
|
||||
import static java.awt.BorderLayout.CENTER;
|
||||
import static java.awt.BorderLayout.EAST;
|
||||
import static java.awt.BorderLayout.NORTH;
|
||||
import static java.awt.BorderLayout.SOUTH;
|
||||
import static java.awt.BorderLayout.WEST;
|
||||
import static java.awt.Color.BLACK;
|
||||
import static java.awt.Color.RED;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import static java.util.Collections.sort;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
TODO: add better debug logging, preferably to a file and switchable (on/off)
|
||||
TODO: Clean up this class!
|
||||
|
@ -188,7 +166,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
|||
liveDataUpdateHandler = new LiveDataUpdateHandler(dataTableModel);
|
||||
graphPanel = new JPanel(new SpringLayout());
|
||||
graphUpdateHandler = new GraphUpdateHandler(graphPanel);
|
||||
dashboardPanel = new JPanel(new GridLayout(3, 3, 4, 4));
|
||||
dashboardPanel = new JPanel(new GridLayout(4, 3, 4, 4));
|
||||
dashboardUpdateHandler = new DashboardUpdateHandler(dashboardPanel);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,30 +21,30 @@
|
|||
|
||||
package enginuity.logger.ui.handler.dash;
|
||||
|
||||
import enginuity.logger.definition.EcuData;
|
||||
import static enginuity.util.ParamChecker.checkNotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import static java.awt.BorderLayout.*;
|
||||
import static java.awt.Font.PLAIN;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import static javax.swing.border.BevelBorder.LOWERED;
|
||||
import java.awt.*;
|
||||
import static java.awt.BorderLayout.CENTER;
|
||||
import static java.awt.BorderLayout.NORTH;
|
||||
import static java.awt.Color.GREEN;
|
||||
import static java.awt.Font.PLAIN;
|
||||
import enginuity.logger.definition.EcuData;
|
||||
import static enginuity.util.ParamChecker.checkNotNull;
|
||||
|
||||
public final class PlainGauge extends Gauge {
|
||||
private static final double ZERO = 0.0;
|
||||
private static final String BLANK = "";
|
||||
private final String zeroText;
|
||||
private final EcuData ecuData;
|
||||
private final JLabel data = new JLabel(BLANK, JLabel.CENTER);
|
||||
private final JLabel currentLabel = 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);
|
||||
private double max = Double.MIN_VALUE;
|
||||
private double min = Double.MAX_VALUE;
|
||||
|
||||
public PlainGauge(EcuData ecuData) {
|
||||
checkNotNull(ecuData, "ecuData");
|
||||
this.ecuData = ecuData;
|
||||
initTitleLayout();
|
||||
initDataLayout();
|
||||
zeroText = format(0.0);
|
||||
initGaugeLayout();
|
||||
}
|
||||
|
||||
|
@ -57,28 +57,74 @@ public final class PlainGauge extends Gauge {
|
|||
}
|
||||
|
||||
public void resetValue() {
|
||||
refreshValue(ZERO);
|
||||
}
|
||||
|
||||
private void initTitleLayout() {
|
||||
}
|
||||
|
||||
private void initDataLayout() {
|
||||
data.setBorder(new BevelBorder(LOWERED));
|
||||
data.setFont(data.getFont().deriveFont(PLAIN, 50F));
|
||||
currentLabel.setText(zeroText);
|
||||
max = Double.MIN_VALUE;
|
||||
maxLabel.setText(zeroText);
|
||||
min = Double.MAX_VALUE;
|
||||
minLabel.setText(zeroText);
|
||||
}
|
||||
|
||||
private void initGaugeLayout() {
|
||||
refreshValue(ZERO);
|
||||
refreshTitle();
|
||||
setLayout(new BorderLayout());
|
||||
setBackground(GREEN);
|
||||
add(data, CENTER);
|
||||
resetValue();
|
||||
setPreferredSize(new Dimension(60, 40));
|
||||
setBackground(Color.GREEN);
|
||||
setLayout(new BorderLayout(3, 3));
|
||||
|
||||
// title
|
||||
add(title, NORTH);
|
||||
|
||||
// data panel
|
||||
JPanel data = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 3));
|
||||
data.setBackground(Color.YELLOW);
|
||||
data.setBorder(new BevelBorder(LOWERED));
|
||||
currentLabel.setFont(data.getFont().deriveFont(PLAIN, 40F));
|
||||
JPanel currentPanel = new JPanel(new BorderLayout());
|
||||
currentPanel.setPreferredSize(new Dimension(140, 80));
|
||||
currentPanel.add(currentLabel, CENTER);
|
||||
data.add(currentPanel);
|
||||
|
||||
// max/min panel
|
||||
JPanel maxMinPanel = new JPanel(new BorderLayout(2, 2));
|
||||
maxMinPanel.setBackground(Color.YELLOW);
|
||||
JPanel maxPanel = buildMaxMinPanel("max", maxLabel, data.getFont());
|
||||
JPanel minPanel = buildMaxMinPanel("min", minLabel, data.getFont());
|
||||
maxMinPanel.add(maxPanel, NORTH);
|
||||
maxMinPanel.add(minPanel, SOUTH);
|
||||
data.add(maxMinPanel);
|
||||
add(data, CENTER);
|
||||
}
|
||||
|
||||
private JPanel buildMaxMinPanel(String title, JLabel label, Font font) {
|
||||
label.setFont(font.deriveFont(PLAIN, 12F));
|
||||
JPanel panel = new JPanel(new BorderLayout(1, 1));
|
||||
panel.setPreferredSize(new Dimension(60, 38));
|
||||
panel.setBackground(Color.CYAN);
|
||||
JLabel titleLabel = new JLabel(title, JLabel.CENTER);
|
||||
titleLabel.setFont(font.deriveFont(Font.BOLD, 12F));
|
||||
JPanel dataPanel = new JPanel(new BorderLayout());
|
||||
dataPanel.setBackground(Color.PINK);
|
||||
dataPanel.add(label, CENTER);
|
||||
panel.add(titleLabel, NORTH);
|
||||
panel.add(dataPanel, CENTER);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void refreshValue(double value) {
|
||||
data.setText(ecuData.getSelectedConvertor().format(value));
|
||||
String text = format(value);
|
||||
if (value > max) {
|
||||
max = value;
|
||||
maxLabel.setText(text);
|
||||
}
|
||||
if (value < min) {
|
||||
min = value;
|
||||
minLabel.setText(text);
|
||||
}
|
||||
currentLabel.setText(text);
|
||||
}
|
||||
|
||||
private String format(double value) {
|
||||
return ecuData.getSelectedConvertor().format(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue