From 42eb6b07bfcc19239ba5055ca31bbf093e858226 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Thu, 30 Apr 2015 18:06:14 -0400 Subject: [PATCH] auto-sync --- .../ui/src/com/rusefi/AverageAnglePanel.java | 2 +- java_console/ui/src/com/rusefi/Launcher.java | 12 ++++---- ...Central.java => SensorSnifferCentral.java} | 2 +- ...ChartPanel.java => SensorSnifferPane.java} | 22 +++++++------- ...{TableEditor.java => TableEditorPane.java} | 4 +-- .../rusefi/test/AnalogChartPanelSandbox.java | 4 +-- .../ui/src/com/rusefi/ui/ChartHelper.java | 4 +-- .../ui/src/com/rusefi/ui/GaugesPanel.java | 9 +++++- .../ui/src/com/rusefi/ui/MessagesPane.java | 18 +++++------- .../ui/src/com/rusefi/ui/MessagesPanel.java | 2 +- .../ui/src/com/rusefi/ui/RpmLabel.java | 6 +++- .../ui/src/com/rusefi/ui/RpmPanel.java | 13 ++++----- .../rusefi/ui/engine/EngineSnifferPanel.java | 29 +++++++++---------- .../src/com/rusefi/ui/engine/ZoomControl.java | 9 +++--- .../ui/src/com/rusefi/ui/util/UiUtils.java | 8 +++++ 15 files changed, 78 insertions(+), 66 deletions(-) rename java_console/ui/src/com/rusefi/{AnalogChartCentral.java => SensorSnifferCentral.java} (95%) rename java_console/ui/src/com/rusefi/{AnalogChartPanel.java => SensorSnifferPane.java} (92%) rename java_console/ui/src/com/rusefi/{TableEditor.java => TableEditorPane.java} (94%) diff --git a/java_console/ui/src/com/rusefi/AverageAnglePanel.java b/java_console/ui/src/com/rusefi/AverageAnglePanel.java index 40a6e5a7fb..6dac84ae68 100644 --- a/java_console/ui/src/com/rusefi/AverageAnglePanel.java +++ b/java_console/ui/src/com/rusefi/AverageAnglePanel.java @@ -35,7 +35,7 @@ public class AverageAnglePanel { } }, BorderLayout.CENTER); - AnalogChartCentral.addListener(new AnalogChartCentral.AnalogChartListener() { + SensorSnifferCentral.addListener(new SensorSnifferCentral.AnalogChartListener() { @Override public void onAnalogChart(String message) { int rpm = (int) SensorCentral.getInstance().getValue(Sensor.RPM); diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 43f59b6f25..b16c7b30b5 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -42,7 +42,7 @@ public class Launcher { public static int defaultFontSize; private static Frame staticFrame; - TableEditor tableEditor = new TableEditor(); + private final TableEditorPane tableEditor = new TableEditorPane(); FrameHelper frame = new FrameHelper() { @Override @@ -68,25 +68,24 @@ public class Launcher { this.port = port; staticFrame = frame.getFrame(); FileLog.MAIN.start(); + FileLog.MAIN.logLine("Console " + CONSOLE_VERSION); getConfig().getRoot().setProperty(PORT_KEY, port); LinkManager.start(port); - FileLog.MAIN.logLine("Console " + CONSOLE_VERSION); - - EngineSnifferPanel engineSnifferPanel = new EngineSnifferPanel(getConfig().getRoot().getChild("digital_sniffer")); if (LinkManager.isLogViewerMode(port)) tabbedPane.add("Log Viewer", new LogViewer(engineSnifferPanel)); + ConnectionWatchdog.start(); + RpmPanel mainGauges = new RpmPanel(getConfig().getRoot().getChild("main_gauges")); tabbedPane.addTab("Main", mainGauges.createRpmPanel()); tabbedPane.addTab("Gauges", new GaugesPanel().getContent()); tabbedPane.addTab("Engine Sniffer", engineSnifferPanel.getPanel()); - tabbedPane.addTab("Sensor Sniffer", new AnalogChartPanel().getPanel()); + tabbedPane.addTab("Sensor Sniffer", new SensorSnifferPane().getPanel()); - tabbedPane.addTab("Table Editor", tableEditor); // tabbedPane.addTab("LE controls", new FlexibleControls().getPanel()); @@ -98,6 +97,7 @@ public class Launcher { } // tabbedPane.addTab("live map adjustment", new Live3DReport().getControl()); tabbedPane.add("Messages", new MessagesPane(getConfig().getRoot().getChild("messages")).getContent()); + tabbedPane.addTab("Table Editor", tableEditor); // tabbedPane.add("Wizards", new Wizard().createPane()); tabbedPane.add("Settings", new SettingsTab().createPane()); diff --git a/java_console/ui/src/com/rusefi/AnalogChartCentral.java b/java_console/ui/src/com/rusefi/SensorSnifferCentral.java similarity index 95% rename from java_console/ui/src/com/rusefi/AnalogChartCentral.java rename to java_console/ui/src/com/rusefi/SensorSnifferCentral.java index 9ebf80e5f7..90277101fc 100644 --- a/java_console/ui/src/com/rusefi/AnalogChartCentral.java +++ b/java_console/ui/src/com/rusefi/SensorSnifferCentral.java @@ -6,7 +6,7 @@ import com.rusefi.io.LinkManager; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -public class AnalogChartCentral { +public class SensorSnifferCentral { private static List listeners = new CopyOnWriteArrayList<>(); diff --git a/java_console/ui/src/com/rusefi/AnalogChartPanel.java b/java_console/ui/src/com/rusefi/SensorSnifferPane.java similarity index 92% rename from java_console/ui/src/com/rusefi/AnalogChartPanel.java rename to java_console/ui/src/com/rusefi/SensorSnifferPane.java index e15d76561a..ff6c3d370a 100644 --- a/java_console/ui/src/com/rusefi/AnalogChartPanel.java +++ b/java_console/ui/src/com/rusefi/SensorSnifferPane.java @@ -1,6 +1,7 @@ package com.rusefi; import com.rusefi.config.Fields; +import com.rusefi.ui.RpmLabel; import com.rusefi.ui.RpmModel; import com.rusefi.ui.config.EnumConfigField; import com.rusefi.ui.util.UiUtils; @@ -23,7 +24,7 @@ import static com.rusefi.ui.util.LocalizedMessages.RESUME; * Date: 12/21/13 * Andrey Belomutskiy (c) 2012-2013 */ -public class AnalogChartPanel { +public class SensorSnifferPane { private static final String HELP_URL = "http://rusefi.com/wiki/index.php?title=Manual:DevConsole#Analog_Chart"; private final TreeMap values = new TreeMap<>(); @@ -38,9 +39,8 @@ public class AnalogChartPanel { private boolean paused = false; - public AnalogChartPanel() { - - AnalogChartCentral.addListener(new AnalogChartCentral.AnalogChartListener() { + public SensorSnifferPane() { + SensorSnifferCentral.addListener(new SensorSnifferCentral.AnalogChartListener() { @Override public void onAnalogChart(final String message) { // this callback is invoked from the connectivity thread, need to handle in AWT for thread-safety @@ -57,7 +57,7 @@ public class AnalogChartPanel { } }); - final JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0)); + final JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); JButton clearButton = new JButton(CLEAR.getMessage()); clearButton.setMnemonic('c'); @@ -70,10 +70,9 @@ public class AnalogChartPanel { }); upperPanel.add(clearButton); - JButton imageButton = new JButton(EngineSnifferPanel.SAVE_IMAGE); - imageButton.setMnemonic('s'); - upperPanel.add(imageButton); - imageButton.addActionListener(new ActionListener() { + JButton saveImageButton = UiUtils.createSaveImageButton(); + upperPanel.add(saveImageButton); + saveImageButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int rpm = RpmModel.getInstance().getValue(); @@ -86,6 +85,7 @@ public class AnalogChartPanel { final JButton pauseButton = new JButton(PAUSE.getMessage()); upperPanel.add(pauseButton); + upperPanel.add(new RpmLabel(2).getContent()); upperPanel.add(new URLLabel(EngineSnifferPanel.HELP_TEXT, HELP_URL)); pauseButton.addActionListener(new @@ -98,13 +98,13 @@ public class AnalogChartPanel { } ); - upperPanel.setBorder(BorderFactory.createLineBorder(Color.white)); +// upperPanel.setBorder(BorderFactory.createLineBorder(Color.orange)); content.add(upperPanel, BorderLayout.NORTH); content.add(canvas, BorderLayout.CENTER); final JPanel lowerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0)); - lowerPanel.setBorder(BorderFactory.createLineBorder(Color.white)); + lowerPanel.setBorder(BorderFactory.createLineBorder(Color.cyan)); content.add(lowerPanel, BorderLayout.SOUTH); lowerPanel.add(new EnumConfigField(Fields.SENSOR_SNIFFER_MODE, "Mode", "Off", "Trigger", "MAP").getContent()); diff --git a/java_console/ui/src/com/rusefi/TableEditor.java b/java_console/ui/src/com/rusefi/TableEditorPane.java similarity index 94% rename from java_console/ui/src/com/rusefi/TableEditor.java rename to java_console/ui/src/com/rusefi/TableEditorPane.java index 419da37d0e..16ddd51e12 100644 --- a/java_console/ui/src/com/rusefi/TableEditor.java +++ b/java_console/ui/src/com/rusefi/TableEditorPane.java @@ -11,9 +11,9 @@ import java.awt.*; import static com.romraider.editor.ecu.ECUEditorManager.getECUEditor; -public class TableEditor extends JPanel { +public class TableEditorPane extends JPanel { - public TableEditor() { + public TableEditorPane() { super(new BorderLayout()); add(new JLabel("Loading tables"), BorderLayout.CENTER); } diff --git a/java_console/ui/src/com/rusefi/test/AnalogChartPanelSandbox.java b/java_console/ui/src/com/rusefi/test/AnalogChartPanelSandbox.java index e8a18e868d..ce5bd022dd 100644 --- a/java_console/ui/src/com/rusefi/test/AnalogChartPanelSandbox.java +++ b/java_console/ui/src/com/rusefi/test/AnalogChartPanelSandbox.java @@ -1,6 +1,6 @@ package com.rusefi.test; -import com.rusefi.AnalogChartPanel; +import com.rusefi.SensorSnifferPane; import com.rusefi.ui.util.FrameHelper; /** @@ -10,6 +10,6 @@ import com.rusefi.ui.util.FrameHelper; public class AnalogChartPanelSandbox extends FrameHelper { public static void main(String[] args) { - new EcuStimulatorSandbox().showFrame(new AnalogChartPanel().getPanel()); + new EcuStimulatorSandbox().showFrame(new SensorSnifferPane().getPanel()); } } \ No newline at end of file diff --git a/java_console/ui/src/com/rusefi/ui/ChartHelper.java b/java_console/ui/src/com/rusefi/ui/ChartHelper.java index b2e963532b..16458c5de6 100644 --- a/java_console/ui/src/com/rusefi/ui/ChartHelper.java +++ b/java_console/ui/src/com/rusefi/ui/ChartHelper.java @@ -3,7 +3,6 @@ package com.rusefi.ui; import com.rusefi.FileLog; import com.rusefi.models.Range; import com.rusefi.models.XYData; -import com.rusefi.ui.engine.EngineSnifferPanel; import com.rusefi.ui.util.UiUtils; import com.rusefi.ui.util.JTextFieldWithWidth; import net.ericaro.surfaceplotter.DefaultSurfaceModel; @@ -37,8 +36,7 @@ public class ChartHelper { jsp.getSurface().setYLabel("MAF voltage"); result.add(BorderLayout.CENTER, jsp); - JButton saveImageButton = new JButton(EngineSnifferPanel.SAVE_IMAGE); - saveImageButton.setMnemonic('s'); + JButton saveImageButton = UiUtils.createSaveImageButton(); saveImageButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { diff --git a/java_console/ui/src/com/rusefi/ui/GaugesPanel.java b/java_console/ui/src/com/rusefi/ui/GaugesPanel.java index 432ba454d0..7271d9145b 100644 --- a/java_console/ui/src/com/rusefi/ui/GaugesPanel.java +++ b/java_console/ui/src/com/rusefi/ui/GaugesPanel.java @@ -2,6 +2,7 @@ package com.rusefi.ui; import com.rusefi.core.Sensor; import com.rusefi.ui.util.FrameHelper; +import com.rusefi.ui.util.UiUtils; import com.rusefi.ui.widgets.RpmCommand; import com.rusefi.ui.widgets.SensorGauge; @@ -23,6 +24,12 @@ public class GaugesPanel { public GaugesPanel() { // Radial radial2 = createRadial("title"); + + JButton saveImageButton = UiUtils.createSaveImageButton(); + + JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); + upperPanel.add(saveImageButton); + JPanel box2 = new JPanel(new GridLayout(3, 5)); box2.add(createControls()); @@ -68,8 +75,8 @@ public class GaugesPanel { box2.add(SensorGauge.createGauge(Sensor.TIMING)); - //add(rpmGauge); + content.add(upperPanel, BorderLayout.NORTH); content.add(box2, BorderLayout.CENTER); content.add(new WarningPanel().getPanel(), BorderLayout.SOUTH); // add(new JLabel("fd"), BorderLayout.EAST); diff --git a/java_console/ui/src/com/rusefi/ui/MessagesPane.java b/java_console/ui/src/com/rusefi/ui/MessagesPane.java index a5aa96242f..842d38086a 100644 --- a/java_console/ui/src/com/rusefi/ui/MessagesPane.java +++ b/java_console/ui/src/com/rusefi/ui/MessagesPane.java @@ -25,20 +25,19 @@ public class MessagesPane { private final JButton fontButton = new JButton("Font"); public MessagesPane(final Node config) { - JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0)); + JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); - final MessagesPanel messagesPanel = new MessagesPanel(config, true); - messagesPanel.loadFont(config); - content.setBorder(BorderFactory.createLineBorder(Color.red)); + final MessagesPanel upperPanel = new MessagesPanel(config, true); + upperPanel.loadFont(config); JPanel middlePanel = new JPanel(new BorderLayout()); - middlePanel.add(messagesPanel.getMessagesScroll(), BorderLayout.CENTER); + middlePanel.add(upperPanel.getMessagesScroll(), BorderLayout.CENTER); middlePanel.add(new RecentCommands().getContent(), BorderLayout.EAST); content.add(middlePanel, BorderLayout.CENTER); - messagesPanel.getButtonPanel().add(new RpmLabel().getContent()); - topPanel.add(messagesPanel.getButtonPanel()); + upperPanel.getButtonPanel().add(new RpmLabel(2).getContent()); + topPanel.add(upperPanel.getButtonPanel()); topPanel.add(fontButton); topPanel.add(new URLLabel(EngineSnifferPanel.HELP_TEXT, HELP_URL)); content.add(topPanel, BorderLayout.NORTH); @@ -51,14 +50,13 @@ public class MessagesPane { content.add(statsPanel, BorderLayout.SOUTH); - fontButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFontChooser fc = new JFontChooser(Launcher.getFrame()); fc.setLocationRelativeTo(fontButton); - if (fc.showDialog(messagesPanel.getFont()) == JFontChooser.OK_OPTION) { - messagesPanel.setFont(fc.getFont(), config); + if (fc.showDialog(upperPanel.getFont()) == JFontChooser.OK_OPTION) { + upperPanel.setFont(fc.getFont(), config); } } }); diff --git a/java_console/ui/src/com/rusefi/ui/MessagesPanel.java b/java_console/ui/src/com/rusefi/ui/MessagesPanel.java index 351b5da5a2..cf61d2e569 100644 --- a/java_console/ui/src/com/rusefi/ui/MessagesPanel.java +++ b/java_console/ui/src/com/rusefi/ui/MessagesPanel.java @@ -51,7 +51,7 @@ public class MessagesPanel { public MessagesPanel(Node config, boolean listenToCommands) { JPanel middlePanel = new JPanel(new BorderLayout()); middlePanel.add(messagesScroll, BorderLayout.CENTER); - buttonPanel.setBorder(BorderFactory.createLineBorder(Color.red)); +// buttonPanel.setBorder(BorderFactory.createLineBorder(Color.cyan)); StyledDocument d = (StyledDocument) messages.getDocument(); bold = d.addStyle("StyleName", null); diff --git a/java_console/ui/src/com/rusefi/ui/RpmLabel.java b/java_console/ui/src/com/rusefi/ui/RpmLabel.java index 06ce3fc396..942fbbadf1 100644 --- a/java_console/ui/src/com/rusefi/ui/RpmLabel.java +++ b/java_console/ui/src/com/rusefi/ui/RpmLabel.java @@ -17,7 +17,10 @@ public class RpmLabel { private final JLabel rpmCaption = new JLabel("RPM:"); public RpmLabel() { - rpmCaption.setBorder(BorderFactory.createLineBorder(Color.white)); + this(1); + } + + public RpmLabel(int size) { rpmValue.setForeground(Color.red); content.setBorder(BorderFactory.createLineBorder(Color.white)); @@ -45,6 +48,7 @@ public class RpmLabel { } } }); + setSize(size); } public JPanel getContent() { diff --git a/java_console/ui/src/com/rusefi/ui/RpmPanel.java b/java_console/ui/src/com/rusefi/ui/RpmPanel.java index ccc39eda50..148d844a31 100644 --- a/java_console/ui/src/com/rusefi/ui/RpmPanel.java +++ b/java_console/ui/src/com/rusefi/ui/RpmPanel.java @@ -15,7 +15,7 @@ import java.awt.*; */ public class RpmPanel { private final Node config; - private RpmLabel rpmLabel = new RpmLabel(); + private RpmLabel rpmLabel = new RpmLabel(15); // that's for CKP signal emulation public final WaveInfoPanel wave0 = new WaveInfoPanel(0); public final WaveInfoPanel wave1 = new WaveInfoPanel(1); @@ -23,11 +23,10 @@ public class RpmPanel { public RpmPanel(Node config) { this.config = config; - rpmLabel.setSize(15); } public JComponent createRpmPanel() { - JPanel controls = createControls(); +// JPanel leftSideControls = createControls(); JPanel gauges = new JPanel(new GridLayout(2, 3)); gauges.setBorder(BorderFactory.createLineBorder(Color.black)); @@ -39,29 +38,26 @@ public class RpmPanel { gauges.add(SensorGauge.createGauge(Sensor.MAF)); gauges.add(SensorGauge.createGauge(Sensor.TPS)); - ConnectionWatchdog.start(); - JPanel smallMessagePanel = new JPanel(new BorderLayout()); MessagesPanel mp = new MessagesPanel(config, false); smallMessagePanel.add(BorderLayout.NORTH, mp.getButtonPanel()); smallMessagePanel.add(BorderLayout.CENTER, mp.getMessagesScroll()); JPanel msgPanel = new JPanel(new BorderLayout()); - msgPanel.add(new AnyCommand(config, false).getContent(), BorderLayout.NORTH); msgPanel.add(smallMessagePanel, BorderLayout.CENTER); JComponent rpmPanel = new JPanel(new BorderLayout()); rpmPanel.setBorder(BorderFactory.createLineBorder(Color.white)); rpmPanel.add(rpmLabel.getContent(), BorderLayout.NORTH); - rpmPanel.add(controls, BorderLayout.WEST); +// rpmPanel.add(leftSideControls, BorderLayout.WEST); rpmPanel.add(gauges, BorderLayout.CENTER); rpmPanel.add(msgPanel, BorderLayout.EAST); rpmPanel.add(new WarningPanel().getPanel(), BorderLayout.SOUTH); return rpmPanel; } - +/* private JPanel createControls() { JPanel controls = new JPanel(new MigLayout()); controls.setBorder(BorderFactory.createLineBorder(Color.red)); @@ -85,5 +81,6 @@ public class RpmPanel { return controls; } +*/ } diff --git a/java_console/ui/src/com/rusefi/ui/engine/EngineSnifferPanel.java b/java_console/ui/src/com/rusefi/ui/engine/EngineSnifferPanel.java index a27ed889f2..ecf3db2773 100644 --- a/java_console/ui/src/com/rusefi/ui/engine/EngineSnifferPanel.java +++ b/java_console/ui/src/com/rusefi/ui/engine/EngineSnifferPanel.java @@ -43,7 +43,6 @@ public class EngineSnifferPanel { public static final Comparator INSTANCE = new NameUtil.ImageOrderComparator(); private static final String HELP_URL = "http://rusefi.com/wiki/index.php?title=Manual:DevConsole#Digital_Chart"; public static final String HELP_TEXT = "Click here for online help"; - public static final String SAVE_IMAGE = "save image"; private final JPanel chartPanel = new JPanel(new BorderLayout()); private final JPanel panel = new JPanel(new BorderLayout()); @@ -64,12 +63,12 @@ public class EngineSnifferPanel { } }; - JScrollPane pane = new JScrollPane(imagePanel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + private final JScrollPane pane = new JScrollPane(imagePanel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); private final ZoomControl zoomControl = new ZoomControl(); private final EngineSnifferStatusPanel statusPanel = new EngineSnifferStatusPanel(zoomControl.getZoomProvider()); private final UpDownImage crank = createImage(NameUtil.CRANK1); - private ChartScrollControl scrollControl; + private final ChartScrollControl scrollControl; private boolean isPaused; @@ -101,8 +100,7 @@ public class EngineSnifferPanel { } }); - JButton saveImageButton = new JButton(SAVE_IMAGE); - saveImageButton.setMnemonic('s'); + JButton saveImageButton = UiUtils.createSaveImageButton(); saveImageButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -120,16 +118,16 @@ public class EngineSnifferPanel { } }); - JPanel topButtons = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); - topButtons.add(clearButton); - topButtons.add(saveImageButton); - topButtons.add(pauseButton); - topButtons.add(new RpmLabel().setSize(2).getContent()); + JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); + upperPanel.add(clearButton); + upperPanel.add(saveImageButton); + upperPanel.add(pauseButton); + upperPanel.add(new RpmLabel(2).getContent()); JComponent command = new AnyCommand(config, "chartsize " + EFI_DEFAULT_CHART_SIZE, true).getContent(); - topButtons.add(command); + upperPanel.add(command); - topButtons.add(zoomControl); + upperPanel.add(zoomControl); scrollControl = ChartRepository.getInstance().createControls(new ChartRepository.ChartRepositoryListener() { @Override @@ -137,9 +135,10 @@ public class EngineSnifferPanel { displayChart(chart); } }); - topButtons.add(scrollControl.getContent()); + if (LinkManager.isLogViewer()) + upperPanel.add(scrollControl.getContent()); - topButtons.add(new URLLabel(HELP_TEXT, HELP_URL)); + upperPanel.add(new URLLabel(HELP_TEXT, HELP_URL)); JPanel lowerButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0)); lowerButtons.add(new BitConfigField(Fields.isDigitalChartEnabled, "Collect Engine Data").getContent()); @@ -149,7 +148,7 @@ public class EngineSnifferPanel { bottomPanel.add(lowerButtons, BorderLayout.NORTH); bottomPanel.add(statusPanel.infoPanel, BorderLayout.SOUTH); - chartPanel.add(topButtons, BorderLayout.NORTH); + chartPanel.add(upperPanel, BorderLayout.NORTH); chartPanel.add(pane, BorderLayout.CENTER); chartPanel.add(bottomPanel, BorderLayout.SOUTH); diff --git a/java_console/ui/src/com/rusefi/ui/engine/ZoomControl.java b/java_console/ui/src/com/rusefi/ui/engine/ZoomControl.java index 5a9d6f1632..5f18440130 100644 --- a/java_console/ui/src/com/rusefi/ui/engine/ZoomControl.java +++ b/java_console/ui/src/com/rusefi/ui/engine/ZoomControl.java @@ -14,9 +14,10 @@ import java.awt.event.KeyEvent; * (c) Andrey Belomutskiy */ class ZoomControl extends JPanel { - private final JLabel currentValue = new JLabel(); +// private final JLabel currentValue = new JLabel(); private double value; public ZoomControlListener listener = null; + private final JButton resetZoom = new JButton("*"); ZoomProvider zoomProvider = new ZoomProvider() { @Override @@ -41,7 +42,7 @@ class ZoomControl extends JPanel { // } // }; - add(currentValue); +// add(currentValue); JButton plus = new JButton("+"); plus.setMnemonic('z'); @@ -54,7 +55,6 @@ class ZoomControl extends JPanel { plus.setToolTipText("Zoom in"); add(plus); - JButton resetZoom = new JButton("*"); resetZoom.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -107,7 +107,8 @@ class ZoomControl extends JPanel { private void setValue(double value) { this.value = value; - currentValue.setText(String.format(" %.4fms", value)); + //currentValue.setText(String.format(" %.4fms", value)); + resetZoom.setEnabled(Math.abs(1 - value) > 0.01); if (listener != null) listener.onZoomChange(); } diff --git a/java_console/ui/src/com/rusefi/ui/util/UiUtils.java b/java_console/ui/src/com/rusefi/ui/util/UiUtils.java index 4635f607bd..bc600eed3a 100644 --- a/java_console/ui/src/com/rusefi/ui/util/UiUtils.java +++ b/java_console/ui/src/com/rusefi/ui/util/UiUtils.java @@ -17,6 +17,8 @@ import static com.rusefi.ui.util.LocalizedMessages.RESUME; * (c) Andrey Belomutskiy */ public class UiUtils { + private static final String SAVE_IMAGE = "save image"; + public static void saveImageWithPrompt(String fileName, Component parent, Component component) { JFileChooser fc = new JFileChooser(); FileFilter filter = new FileNameExtensionFilter("PNG files", "png"); @@ -95,4 +97,10 @@ public class UiUtils { result.add(component); return result; } + + public static JButton createSaveImageButton() { + JButton imageButton = new JButton(SAVE_IMAGE); + imageButton.setMnemonic('s'); + return imageButton; + } }