diff --git a/src/enginuity/logger/ui/handler/graph/GraphUpdateHandler.java b/src/enginuity/logger/ui/handler/graph/GraphUpdateHandler.java index f6d9fbf7..2c237e95 100644 --- a/src/enginuity/logger/ui/handler/graph/GraphUpdateHandler.java +++ b/src/enginuity/logger/ui/handler/graph/GraphUpdateHandler.java @@ -21,6 +21,13 @@ package enginuity.logger.ui.handler.graph; +import java.awt.*; +import static java.awt.Color.BLACK; +import static java.awt.Color.WHITE; +import static java.util.Collections.synchronizedMap; +import java.util.HashMap; +import java.util.Map; +import javax.swing.*; import enginuity.logger.definition.ConvertorUpdateListener; import enginuity.logger.definition.EcuData; import enginuity.logger.ui.handler.DataUpdateHandler; @@ -29,16 +36,15 @@ import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import static org.jfree.chart.plot.PlotOrientation.VERTICAL; +import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import javax.swing.*; -import static java.util.Collections.synchronizedMap; -import java.util.HashMap; -import java.util.Map; - public final class GraphUpdateHandler implements DataUpdateHandler, ConvertorUpdateListener { + private static final Color RED = new Color(190, 30, 30); + private static final Color DARK_GREY = new Color(56, 56, 56); + private static final Color LIGHT_GREY = new Color(99, 99, 99); private final JPanel graphPanel; private final Map chartMap = synchronizedMap(new HashMap()); private final Map seriesMap = synchronizedMap(new HashMap()); @@ -53,10 +59,7 @@ public final class GraphUpdateHandler implements DataUpdateHandler, ConvertorUpd final XYSeries series = new XYSeries(ecuData.getName()); //TODO: Make chart max item count configurable via settings series.setMaximumItemCount(200); - final XYDataset xyDataset = new XYSeriesCollection(series); - final JFreeChart chart = ChartFactory.createXYLineChart(ecuData.getName(), "Time (sec)", buildRangeAxisTitle(ecuData), xyDataset, - VERTICAL, false, true, false); - ChartPanel chartPanel = new ChartPanel(chart, false, true, true, true, true); + ChartPanel chartPanel = new ChartPanel(createXYLineChart(series, ecuData), false, true, true, true, true); graphPanel.add(chartPanel); seriesMap.put(ecuData, series); chartMap.put(ecuData, chartPanel); @@ -91,6 +94,25 @@ public final class GraphUpdateHandler implements DataUpdateHandler, ConvertorUpd } } + private JFreeChart createXYLineChart(XYSeries series, EcuData ecuData) { + final XYDataset xyDataset = new XYSeriesCollection(series); + final JFreeChart chart = ChartFactory.createXYLineChart(ecuData.getName(), "Time (sec)", buildRangeAxisTitle(ecuData), xyDataset, + VERTICAL, false, true, false); + chart.setBackgroundPaint(BLACK); + chart.getTitle().setPaint(WHITE); + final XYPlot plot = chart.getXYPlot(); + plot.setBackgroundPaint(BLACK); + plot.getRenderer().setPaint(RED); + plot.setDomainGridlinePaint(DARK_GREY); + plot.setRangeGridlinePaint(DARK_GREY); + plot.setOutlinePaint(DARK_GREY); + plot.getDomainAxis().setLabelPaint(WHITE); + plot.getRangeAxis().setLabelPaint(WHITE); + plot.getDomainAxis().setTickLabelPaint(LIGHT_GREY); + plot.getRangeAxis().setTickLabelPaint(LIGHT_GREY); + return chart; + } + private String buildRangeAxisTitle(EcuData ecuData) { return ecuData.getName() + " (" + ecuData.getSelectedConvertor().getUnits() + ")"; } diff --git a/src/enginuity/swing/ECUEditorMenuBar.java b/src/enginuity/swing/ECUEditorMenuBar.java index 32890bd5..2a2e1199 100644 --- a/src/enginuity/swing/ECUEditorMenuBar.java +++ b/src/enginuity/swing/ECUEditorMenuBar.java @@ -21,36 +21,35 @@ package enginuity.swing; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileOutputStream; +import javax.management.modelmbean.XMLParseException; +import javax.swing.*; +import static javax.swing.JFrame.DISPOSE_ON_CLOSE; import com.centerkey.utils.BareBonesBrowserLaunch; import enginuity.ECUEditor; import enginuity.logger.EcuLogger; import enginuity.maps.Rom; -import javax.management.modelmbean.XMLParseException; -import javax.swing.*; -import static javax.swing.JFrame.DISPOSE_ON_CLOSE; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.FileOutputStream; - public class ECUEditorMenuBar extends JMenuBar implements ActionListener { private JMenu fileMenu = new JMenu("File"); - private JMenuItem openImage = new JMenuItem("Open Image"); - private JMenuItem saveImage = new JMenuItem("Save Image"); + private JMenuItem openImage = new JMenuItem("Open Image..."); + private JMenuItem saveImage = new JMenuItem("Save Image..."); private JMenuItem refreshImage = new JMenuItem("Refresh Image"); private JMenuItem closeImage = new JMenuItem("Close Image"); private JMenuItem closeAll = new JMenuItem("Close All Images"); private JMenuItem exit = new JMenuItem("Exit"); private JMenu definitionMenu = new JMenu("ECU Definitions"); - private JMenuItem defManager = new JMenuItem("ECU Definition Manager"); - private JMenuItem editDefinition = new JMenuItem("Edit ECU Definitions"); - private JMenuItem updateDefinition = new JMenuItem("Update ECU Definitions"); + private JMenuItem defManager = new JMenuItem("ECU Definition Manager..."); + private JMenuItem editDefinition = new JMenuItem("Edit ECU Definitions..."); + private JMenuItem updateDefinition = new JMenuItem("Update ECU Definitions..."); private JMenu editMenu = new JMenu("Edit"); - private JMenuItem settings = new JMenuItem("Enginuity Settings"); + private JMenuItem settings = new JMenuItem("Enginuity Settings..."); private JMenu viewMenu = new JMenu("View"); private JMenuItem romProperties = new JMenuItem("ECU Image Properties"); @@ -63,7 +62,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { private JRadioButtonMenuItem level5 = new JRadioButtonMenuItem("5 Debug Mode"); private JMenu loggerMenu = new JMenu("Logger"); - private JMenuItem openLogger = new JMenuItem("Open ECU Logger"); + private JMenuItem openLogger = new JMenuItem("Launch ECU Logger..."); private JMenu helpMenu = new JMenu("Help"); private JMenuItem about = new JMenuItem("About Enginuity"); @@ -189,14 +188,15 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { closeImage.setEnabled(false); closeAll.setEnabled(false); romProperties.setEnabled(false); + saveImage.setText("Save..."); } else { saveImage.setEnabled(true); closeImage.setEnabled(true); closeAll.setEnabled(true); romProperties.setEnabled(true); + saveImage.setText("Save " + file + "..."); } - saveImage.setText("Save " + file); refreshImage.setText("Refresh " + file); closeImage.setText("Close " + file); romProperties.setText(file + "Properties");