diff --git a/src/main/java/com/romraider/Settings.java b/src/main/java/com/romraider/Settings.java index 0345c515..40c0a33c 100644 --- a/src/main/java/com/romraider/Settings.java +++ b/src/main/java/com/romraider/Settings.java @@ -96,8 +96,9 @@ public class Settings implements Serializable { public static final int TABLE_Y_AXIS = 5; public static final int TABLE_SWITCH = 6; - public static final int COMPARE_TYPE_ORIGINAL = 0; - public static final int COMPARE_TYPE_BIN = 1; + public static final int DATA_TYPE_ORIGINAL = 0; + public static final int DATA_TYPE_BIN = 1; + public static final int DATA_TYPE_DISPLAYED = 2; public static final int COMPARE_DISPLAY_OFF = 0; public static final int COMPARE_DISPLAY_PERCENT = 1; @@ -115,6 +116,14 @@ public class Settings implements Serializable { public static final int LINEAR = 1; public static final int INVERSE = 2; + /* Compare Image Settings */ + public static Color TABLE_EQUAL_COLOR = new Color(52,114,53); + public static Color TABLE_DIFFERENT_COLOR = new Color(193, 27, 23); + public static Color TABLE_MISSING_COLOR = new Color(251,185,23); + + /* MDI Desktop Settings*/ + public static int FRAME_OFFSET = 20; + private static final String ISO15765 = "ISO15765"; private static final String ISO9141 = "ISO9141"; private static final String SYSTEM_NUMFORMAT = "system"; diff --git a/src/main/java/com/romraider/editor/ecu/ECUEditor.java b/src/main/java/com/romraider/editor/ecu/ECUEditor.java index d73f9637..4226c561 100644 --- a/src/main/java/com/romraider/editor/ecu/ECUEditor.java +++ b/src/main/java/com/romraider/editor/ecu/ECUEditor.java @@ -95,7 +95,6 @@ public class ECUEditor extends AbstractFrame { private final String titleText = PRODUCT_NAME + " v" + VERSION + " | ECU Editor"; - private static final String NEW_LINE = System.getProperty("line.separator"); private final SettingsManager settingsManager = new SettingsManagerImpl(); private final RomTreeRootNode imageRoot = new RomTreeRootNode("Open Images"); private final RomTree imageList = new RomTree(imageRoot); @@ -209,7 +208,7 @@ public class ECUEditor extends AbstractFrame { StringBuffer sb = new StringBuffer(); while (br.ready()) { - sb.append(br.readLine()).append(NEW_LINE); + sb.append(br.readLine()).append(Settings.NEW_LINE); } releaseNotes.setText(sb.toString()); releaseNotes.setCaretPosition(0); @@ -344,7 +343,7 @@ public class ECUEditor extends AbstractFrame { public void closeImage() { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); closeImageWorker = new CloseImageWorker(); - closeImageWorker.addPropertyChangeListener(this); + closeImageWorker.addPropertyChangeListener(getStatusPanel()); closeImageWorker.execute(); } @@ -408,7 +407,7 @@ public class ECUEditor extends AbstractFrame { public void setUserLevel(int userLevel) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setUserLevelWorker = new SetUserLevelWorker(userLevel); - setUserLevelWorker.addPropertyChangeListener(this); + setUserLevelWorker.addPropertyChangeListener(getStatusPanel()); setUserLevelWorker.execute(); } @@ -424,13 +423,27 @@ public class ECUEditor extends AbstractFrame { @Override public void propertyChange(PropertyChangeEvent evt) { imageList.updateUI(); - imageList.repaint(); + imageList.invalidate(); + rightPanel.updateUI(); + rightPanel.invalidate(); + } + + public void refreshUI() + { + getToolBar().updateButtons(); + getEditorMenuBar().updateMenu(); + refreshTableMenus(); + + imageList.updateUI(); + imageList.invalidate(); + rightPanel.updateUI(); + rightPanel.invalidate(); } public void openImage(File inputFile) throws Exception { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); openImageWorker = new OpenImageWorker(inputFile); - openImageWorker.addPropertyChangeListener(statusPanel); + openImageWorker.addPropertyChangeListener(getStatusPanel()); openImageWorker.execute(); } @@ -462,7 +475,7 @@ public class ECUEditor extends AbstractFrame { public void launchLogger() { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); launchLoggerWorker = new LaunchLoggerWorker(); - launchLoggerWorker.addPropertyChangeListener(this); + launchLoggerWorker.addPropertyChangeListener(getStatusPanel()); launchLoggerWorker.execute(); } @@ -509,13 +522,22 @@ class LaunchLoggerWorker extends SwingWorker { return null; } + public void propertyChange(PropertyChangeEvent evnt) + { + SwingWorker source = (SwingWorker) evnt.getSource(); + if (null != source && "state".equals( evnt.getPropertyName() ) + && (source.isDone() || source.isCancelled() ) ) + { + source.removePropertyChangeListener(editor.getStatusPanel()); + } + } + @Override public void done() { editor.getStatusPanel().setStatus("Ready..."); setProgress(0); - editor.getToolBar().updateButtons(); - editor.getEditorMenuBar().updateMenu(); editor.setCursor(null); + editor.refreshUI(); } } @@ -537,13 +559,22 @@ class SetUserLevelWorker extends SwingWorker { return null; } + public void propertyChange(PropertyChangeEvent evnt) + { + SwingWorker source = (SwingWorker) evnt.getSource(); + if (null != source && "state".equals( evnt.getPropertyName() ) + && (source.isDone() || source.isCancelled() ) ) + { + source.removePropertyChangeListener(editor.getStatusPanel()); + } + } + @Override public void done() { editor.getStatusPanel().setStatus("Ready..."); setProgress(0); - editor.getToolBar().updateButtons(); - editor.getEditorMenuBar().updateMenu(); editor.setCursor(null); + editor.refreshUI(); } } @@ -563,17 +594,21 @@ class CloseImageWorker extends SwingWorker { RomTreeNode romTreeNode = (RomTreeNode) imageRoot.getChildAt(i); Rom rom = romTreeNode.getRom(); if (rom == editor.getLastSelectedRom()) { - Vector romTables = rom.getTables(); - for (Table t : romTables) { + for (Table t : rom.getTables()) { editor.getRightPanel().remove(t.getFrame()); TableUpdateHandler.getInstance().deregisterTable(t); } + // Cleanup Rom Data + rom.clearData(); + Vector path = new Vector(); path.add(new TreePath(romTreeNode.getPath())); imageRoot.remove(i); imageList.removeDescendantToggledPaths(path.elements()); + path.clear(); + break; } } @@ -584,7 +619,6 @@ class CloseImageWorker extends SwingWorker { // no other images open editor.setLastSelectedRom(null); } - editor.getRightPanel().repaint(); return null; } @@ -592,10 +626,9 @@ class CloseImageWorker extends SwingWorker { public void done() { editor.getStatusPanel().setStatus("Ready..."); setProgress(0); - editor.getToolBar().updateButtons(); - editor.getEditorMenuBar().updateMenu(); - editor.refreshTableMenus(); editor.setCursor(null); + editor.refreshUI(); + System.gc(); } } @@ -617,23 +650,21 @@ class OpenImageWorker extends SwingWorker { setProgress(0); byte[] input = editor.readFile(inputFile); - DOMRomUnmarshaller domUms = new DOMRomUnmarshaller(); DOMParser parser = new DOMParser(); editor.getStatusPanel().setStatus("Finding ECU definition..."); setProgress(10); - Rom rom; - // parse ecu definition files until result found for (int i = 0; i < settings.getEcuDefinitionFiles().size(); i++) { - InputSource src = new InputSource(new FileInputStream(settings.getEcuDefinitionFiles().get(i))); + FileInputStream fileStream = new FileInputStream(settings.getEcuDefinitionFiles().get(i)); + InputSource src = new InputSource(fileStream); parser.parse(src); Document doc = parser.getDocument(); try { - rom = domUms.unmarshallXMLDefinition(doc.getDocumentElement(), input, editor.getStatusPanel()); + Rom rom = new DOMRomUnmarshaller().unmarshallXMLDefinition(doc.getDocumentElement(), input, editor.getStatusPanel()); editor.getStatusPanel().setStatus("Populating tables..."); setProgress(50); @@ -648,11 +679,20 @@ class OpenImageWorker extends SwingWorker { editor.getStatusPanel().setStatus("Done loading image..."); setProgress(100); + parser.reset(); + try{ + fileStream.close(); + } catch(IOException ioex) { + ;// Do nothing + } return null; } catch (RomNotFoundException ex) { // rom was not found in current file, skip to next } + parser = null; + doc.removeChild(doc.getDocumentElement()); + doc = null; } // if code executes to this point, no ROM was found, report to user @@ -674,13 +714,22 @@ class OpenImageWorker extends SwingWorker { return null; } + public void propertyChange(PropertyChangeEvent evnt) + { + SwingWorker source = (SwingWorker) evnt.getSource(); + if (null != source && "state".equals( evnt.getPropertyName() ) + && (source.isDone() || source.isCancelled() ) ) + { + source.removePropertyChangeListener(editor.getStatusPanel()); + } + } + @Override public void done() { editor.getStatusPanel().setStatus("Ready..."); setProgress(0); - editor.getToolBar().updateButtons(); - editor.getEditorMenuBar().updateMenu(); - editor.refreshTableMenus(); editor.setCursor(null); + editor.refreshUI(); + System.gc(); } } diff --git a/src/main/java/com/romraider/logger/ecu/ui/tab/injector/InjectorControlPanel.java b/src/main/java/com/romraider/logger/ecu/ui/tab/injector/InjectorControlPanel.java index 4a7879fe..e1ea96e7 100644 --- a/src/main/java/com/romraider/logger/ecu/ui/tab/injector/InjectorControlPanel.java +++ b/src/main/java/com/romraider/logger/ecu/ui/tab/injector/InjectorControlPanel.java @@ -19,18 +19,7 @@ package com.romraider.logger.ecu.ui.tab.injector; -import com.romraider.editor.ecu.ECUEditor; -import com.romraider.logger.ecu.definition.EcuParameter; -import com.romraider.logger.ecu.definition.EcuSwitch; -import com.romraider.logger.ecu.definition.ExternalData; -import com.romraider.logger.ecu.definition.LoggerData; -import com.romraider.logger.ecu.ui.DataRegistrationBroker; -import com.romraider.logger.ecu.ui.tab.LoggerChartPanel; import static com.romraider.logger.ecu.ui.tab.TableFinder.findTableStartsWith; -import com.romraider.maps.DataCell; -import com.romraider.maps.Rom; -import com.romraider.maps.Table; -import com.romraider.maps.Table2D; import static com.romraider.util.ParamChecker.checkNotNull; import static java.awt.GridBagConstraints.CENTER; import static java.awt.GridBagConstraints.HORIZONTAL; @@ -41,14 +30,7 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE; import static javax.swing.JOptionPane.YES_NO_OPTION; import static javax.swing.JOptionPane.showConfirmDialog; import static javax.swing.JOptionPane.showMessageDialog; -import org.apache.log4j.Logger; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.JToggleButton; -import javax.swing.border.TitledBorder; + import java.awt.Component; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -58,6 +40,29 @@ import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.JToggleButton; +import javax.swing.border.TitledBorder; + +import org.apache.log4j.Logger; + +import com.romraider.Settings; +import com.romraider.editor.ecu.ECUEditor; +import com.romraider.logger.ecu.definition.EcuParameter; +import com.romraider.logger.ecu.definition.EcuSwitch; +import com.romraider.logger.ecu.definition.ExternalData; +import com.romraider.logger.ecu.definition.LoggerData; +import com.romraider.logger.ecu.ui.DataRegistrationBroker; +import com.romraider.logger.ecu.ui.tab.LoggerChartPanel; +import com.romraider.maps.DataCell; +import com.romraider.maps.Rom; +import com.romraider.maps.Table; +import com.romraider.maps.Table2D; + public final class InjectorControlPanel extends JPanel { /** * @@ -294,6 +299,7 @@ public final class InjectorControlPanel extends JPanel { private JToggleButton buildRecordDataButton() { recordDataButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent actionEvent) { if (recordDataButton.isSelected()) { registerData(COOLANT_TEMP, ENGINE_SPEED, INTAKE_AIR_TEMP, MASS_AIR_FLOW, MASS_AIR_FLOW_V, AFR, CL_OL_16, CL_OL_32, TIP_IN_THROTTLE_16, TIP_IN_THROTTLE_32, PULSE_WIDTH_16, PULSE_WIDTH_32, ENGINE_LOAD_16, ENGINE_LOAD_32); @@ -365,6 +371,7 @@ public final class InjectorControlPanel extends JPanel { private JButton buildResetButton() { JButton resetButton = new JButton("Reset Data"); resetButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent actionEvent) { chartPanel.clear(); parent.repaint(); @@ -376,6 +383,7 @@ public final class InjectorControlPanel extends JPanel { private JButton buildInterpolateButton() { JButton interpolateButton = new JButton("Interpolate"); interpolateButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent actionEvent) { chartPanel.interpolate(1); double[] coefficients = chartPanel.getPolynomialCoefficients(); @@ -393,6 +401,7 @@ public final class InjectorControlPanel extends JPanel { private JButton buildUpdateInjectorScalerButton() { final JButton updateButton = new JButton("Update Scaling"); updateButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent actionEvent) { try { if (showUpdateTableConfirmation("Injector Flow Scaling") == OK_OPTION) { @@ -424,6 +433,7 @@ public final class InjectorControlPanel extends JPanel { private JButton buildUpdateInjectorLatencyButton() { final JButton updateButton = new JButton("Update Latency"); updateButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent actionEvent) { try { if (showUpdateTableConfirmation("Injector Latency") == OK_OPTION) { @@ -432,7 +442,7 @@ public final class InjectorControlPanel extends JPanel { DataCell[] cells = table.getData(); if (isNumber(latencyOffset)) { for (DataCell cell : cells) { - double newLatency = cell.getValue() + parseDouble(latencyOffset); + double newLatency = cell.getValue(Settings.DATA_TYPE_BIN) + parseDouble(latencyOffset); cell.setRealValue("" + newLatency); } table.colorize(); diff --git a/src/main/java/com/romraider/logger/ecu/ui/tab/maf/MafControlPanel.java b/src/main/java/com/romraider/logger/ecu/ui/tab/maf/MafControlPanel.java index 4b1d084c..8760c5a0 100644 --- a/src/main/java/com/romraider/logger/ecu/ui/tab/maf/MafControlPanel.java +++ b/src/main/java/com/romraider/logger/ecu/ui/tab/maf/MafControlPanel.java @@ -19,18 +19,7 @@ package com.romraider.logger.ecu.ui.tab.maf; -import com.romraider.editor.ecu.ECUEditor; -import com.romraider.logger.ecu.definition.EcuParameter; -import com.romraider.logger.ecu.definition.EcuSwitch; -import com.romraider.logger.ecu.definition.ExternalData; -import com.romraider.logger.ecu.definition.LoggerData; -import com.romraider.logger.ecu.ui.DataRegistrationBroker; -import com.romraider.logger.ecu.ui.tab.LoggerChartPanel; import static com.romraider.logger.ecu.ui.tab.TableFinder.findTableStartsWith; -import com.romraider.maps.DataCell; -import com.romraider.maps.Rom; -import com.romraider.maps.Table; -import com.romraider.maps.Table2D; import static com.romraider.util.ParamChecker.checkNotNull; import static java.awt.GridBagConstraints.CENTER; import static java.awt.GridBagConstraints.HORIZONTAL; @@ -41,8 +30,15 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE; import static javax.swing.JOptionPane.YES_NO_OPTION; import static javax.swing.JOptionPane.showConfirmDialog; import static javax.swing.JOptionPane.showMessageDialog; -import org.apache.log4j.Logger; -import org.jfree.ui.KeyedComboBoxModel; + +import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; @@ -51,13 +47,22 @@ import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.JToggleButton; import javax.swing.border.TitledBorder; -import java.awt.Component; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; + +import org.apache.log4j.Logger; +import org.jfree.ui.KeyedComboBoxModel; + +import com.romraider.Settings; +import com.romraider.editor.ecu.ECUEditor; +import com.romraider.logger.ecu.definition.EcuParameter; +import com.romraider.logger.ecu.definition.EcuSwitch; +import com.romraider.logger.ecu.definition.ExternalData; +import com.romraider.logger.ecu.definition.LoggerData; +import com.romraider.logger.ecu.ui.DataRegistrationBroker; +import com.romraider.logger.ecu.ui.tab.LoggerChartPanel; +import com.romraider.maps.DataCell; +import com.romraider.maps.Rom; +import com.romraider.maps.Table; +import com.romraider.maps.Table2D; public final class MafControlPanel extends JPanel { private static final long serialVersionUID = 5787020251107365950L; @@ -180,11 +185,11 @@ public final class MafControlPanel extends JPanel { GridBagLayout gridBagLayout = new GridBagLayout(); panel.setLayout(gridBagLayout); -// add(panel, gridBagLayout, buildAfrSourcePanel(), 0, 0, 1, HORIZONTAL); -// add(panel, gridBagLayout, buildFilterPanel(), 0, 1, 1, HORIZONTAL); -// add(panel, gridBagLayout, buildInterpolatePanel(), 0, 2, 1, HORIZONTAL); -// add(panel, gridBagLayout, buildUpdateMafPanel(), 0, 3, 1, HORIZONTAL); -// add(panel, gridBagLayout, buildResetPanel(), 0, 4, 1, HORIZONTAL); + // add(panel, gridBagLayout, buildAfrSourcePanel(), 0, 0, 1, HORIZONTAL); + // add(panel, gridBagLayout, buildFilterPanel(), 0, 1, 1, HORIZONTAL); + // add(panel, gridBagLayout, buildInterpolatePanel(), 0, 2, 1, HORIZONTAL); + // add(panel, gridBagLayout, buildUpdateMafPanel(), 0, 3, 1, HORIZONTAL); + // add(panel, gridBagLayout, buildResetPanel(), 0, 4, 1, HORIZONTAL); add(panel, gridBagLayout, buildFilterPanel(), 0, 0, 1, HORIZONTAL); add(panel, gridBagLayout, buildInterpolatePanel(), 0, 1, 1, HORIZONTAL); @@ -267,15 +272,16 @@ public final class MafControlPanel extends JPanel { private JToggleButton buildRecordDataButton() { recordDataButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent actionEvent) { if (recordDataButton.isSelected()) { -// afrSourceList.setEnabled(false); -// registerAfr(); + // afrSourceList.setEnabled(false); + // registerAfr(); registerData(COOLANT_TEMP, AF_CORRECTION_1, AF_LEARNING_1, ENGINE_SPEED, INTAKE_AIR_TEMP, MASS_AIR_FLOW, MASS_AIR_FLOW_V, CL_OL_16, CL_OL_32, TIP_IN_THROTTLE_16, TIP_IN_THROTTLE_32); } else { -// deregisterAfr(); + // deregisterAfr(); deregisterData(COOLANT_TEMP, AF_CORRECTION_1, AF_LEARNING_1, ENGINE_SPEED, INTAKE_AIR_TEMP, MASS_AIR_FLOW, MASS_AIR_FLOW_V, CL_OL_16, CL_OL_32, TIP_IN_THROTTLE_16, TIP_IN_THROTTLE_32); -// afrSourceList.setEnabled(true); + // afrSourceList.setEnabled(true); } } }); @@ -367,6 +373,7 @@ public final class MafControlPanel extends JPanel { private JButton buildResetButton() { JButton resetButton = new JButton("Reset Data"); resetButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent actionEvent) { chartPanel.clear(); parent.repaint(); @@ -378,6 +385,7 @@ public final class MafControlPanel extends JPanel { private JButton buildInterpolateButton(final JComboBox orderComboBox) { JButton interpolateButton = new JButton("Interpolate"); interpolateButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent actionEvent) { chartPanel.interpolate((Integer) orderComboBox.getSelectedItem()); parent.repaint(); @@ -395,6 +403,7 @@ public final class MafControlPanel extends JPanel { private JButton buildUpdateMafButton() { final JButton updateMafButton = new JButton("Update MAF"); updateMafButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent actionEvent) { try { if (showUpdateMafConfirmation() == OK_OPTION) { @@ -405,14 +414,14 @@ public final class MafControlPanel extends JPanel { double[] x = new double[axisCells.length]; for (int i = 0; i < axisCells.length; i++) { DataCell cell = axisCells[i]; - x[i] = cell.getValue(); + x[i] = cell.getValue(Settings.DATA_TYPE_BIN); } double[] percentChange = chartPanel.calculate(x); DataCell[] dataCells = table.getData(); for (int i = 0; i < dataCells.length; i++) { - if (inRange(axisCells[i].getValue(), mafvMin, mafvMax)) { + if (inRange(axisCells[i].getValue(Settings.DATA_TYPE_BIN), mafvMin, mafvMax)) { DataCell cell = dataCells[i]; - double value = cell.getValue(); + double value = cell.getValue(Settings.DATA_TYPE_BIN); cell.setRealValue("" + (value * (1.0 + percentChange[i] / 100.0))); } } @@ -485,7 +494,7 @@ public final class MafControlPanel extends JPanel { public void setEcuParams(List params) { this.params = new ArrayList(params); -// updateAfrSourceList(); + // updateAfrSourceList(); } public void setEcuSwitches(List switches) { @@ -494,6 +503,6 @@ public final class MafControlPanel extends JPanel { public void setExternalDatas(List externals) { this.externals = new ArrayList(externals); -// updateAfrSourceList(); + // updateAfrSourceList(); } } diff --git a/src/main/java/com/romraider/maps/DataCell.java b/src/main/java/com/romraider/maps/DataCell.java index 2e7df041..ccfe54b2 100644 --- a/src/main/java/com/romraider/maps/DataCell.java +++ b/src/main/java/com/romraider/maps/DataCell.java @@ -83,7 +83,7 @@ public class DataCell extends JLabel implements MouseListener, Serializable { DecimalFormat formatter = new DecimalFormat(scale.getFormat()); if (getCompareDisplay() == Settings.COMPARE_DISPLAY_OFF) { - displayValue = getRealValue(); + displayValue = getRealValue(Settings.DATA_TYPE_BIN); } else if (getCompareDisplay() == Settings.COMPARE_DISPLAY_ABSOLUTE) { displayValue = formatter.format( @@ -300,12 +300,22 @@ public class DataCell extends JLabel implements MouseListener, Serializable { this.setOriginalValue(binValue); } - public double getValue() { - return calcDisplayValue(binValue, table.getScale().getExpression()); + public double getValue(int valType) { + double cellVal; + switch(valType) { + case Settings.DATA_TYPE_ORIGINAL: + cellVal = getOriginalValue(); + break; + default: + cellVal = getBinValue(); + break; + } + + return calcDisplayValue(cellVal, table.getScale().getExpression()); } - public String getRealValue() { - return new DecimalFormat(scale.getFormat()).format(getValue()); + public String getRealValue(int valType) { + return new DecimalFormat(scale.getFormat()).format(getValue(valType)); } public void setRealValue(String input) { diff --git a/src/main/java/com/romraider/maps/Rom.java b/src/main/java/com/romraider/maps/Rom.java index c736fb0e..40805a6b 100644 --- a/src/main/java/com/romraider/maps/Rom.java +++ b/src/main/java/com/romraider/maps/Rom.java @@ -252,6 +252,11 @@ public class Rom implements Serializable { return binData; } + public void clearData() { + tables.clear(); + binData = null; + } + public int getRealFileSize() { return binData.length; } diff --git a/src/main/java/com/romraider/maps/Table.java b/src/main/java/com/romraider/maps/Table.java index 2322e490..497b7778 100644 --- a/src/main/java/com/romraider/maps/Table.java +++ b/src/main/java/com/romraider/maps/Table.java @@ -102,7 +102,7 @@ public abstract class Table extends JPanel implements Serializable { protected int userLevel = 0; protected boolean locked = false; - protected int compareType = Settings.COMPARE_TYPE_ORIGINAL; + protected int compareType = Settings.DATA_TYPE_ORIGINAL; protected int compareDisplay = Settings.COMPARE_DISPLAY_OFF; protected Table compareTable = null; protected List
comparedToTables = new ArrayList
(); @@ -605,6 +605,42 @@ public abstract class Table extends JPanel implements Serializable { return name; } + @Override + public boolean equals(Object other) { + if(null == other) { + return false; + } + + if(other == this) { + return true; + } + + if(!(other instanceof Table)) { + return false; + } + + Table otherTable = (Table)other; + + if(this.data.length != otherTable.data.length) + { + return false; + } + + if(this.data.equals(otherTable.data)) + { + return true; + } + + // Compare Bin Values + for(int i=0 ; i < this.data.length ; i++) { + if(this.data[i].getBinValue() != otherTable.data[i].getBinValue()) { + return false; + } + } + + return true; + } + public boolean isStatic() { return isStatic; } @@ -636,7 +672,7 @@ public abstract class Table extends JPanel implements Serializable { low = getScale().getMin(); } else { for (int i = 0; i < getDataSize(); i++) { - double value = data[i].getValue(); + double value = data[i].getValue(Settings.DATA_TYPE_BIN); if (value > high) { high = value; } @@ -647,7 +683,7 @@ public abstract class Table extends JPanel implements Serializable { } for (int i = 0; i < getDataSize(); i++) { - double value = data[i].getValue(); + double value = data[i].getValue(Settings.DATA_TYPE_BIN); if (value > high || value < low) { // value exceeds limit data[i].setColor(getSettings().getWarningColor()); @@ -973,11 +1009,10 @@ public abstract class Table extends JPanel implements Serializable { copySelectionWorker.execute(); } - public StringBuffer getTableAsString() { - //make a string of the selection + public StringBuffer getTableAsString(int valType) { StringBuffer output = new StringBuffer(Settings.BLANK); for (int i = 0; i < data.length; i++) { - output.append(data[i].getText()); + output.append(data[i].getRealValue(valType)); if (i < data.length - 1) { output.append(Settings.TAB); } @@ -1142,7 +1177,7 @@ public abstract class Table extends JPanel implements Serializable { int i = 0; for(DataCell cell : data) { - if(compareType == Settings.COMPARE_TYPE_BIN) { + if(compareType == Settings.DATA_TYPE_BIN) { cell.setCompareValue(compareData[i].getBinValue()); } else { cell.setCompareValue(compareData[i].getOriginalValue()); @@ -1268,7 +1303,7 @@ public abstract class Table extends JPanel implements Serializable { if (getScale().getMin() == 0 && getScale().getMax() == 0) { double low = Double.MAX_VALUE; for (int i = 0; i < getDataSize(); i++) { - double value = data[i].getValue(); + double value = data[i].getValue(Settings.DATA_TYPE_BIN); if (value < low) { low = value; } @@ -1283,7 +1318,7 @@ public abstract class Table extends JPanel implements Serializable { if (getScale().getMin() == 0 && getScale().getMax() == 0) { double high = Double.MIN_VALUE; for (int i = 0; i < getDataSize(); i++) { - double value = data[i].getValue(); + double value = data[i].getValue(Settings.DATA_TYPE_BIN); if (value > high) { high = value; } @@ -1407,14 +1442,8 @@ class CopyTableWorker extends SwingWorker { @Override protected Void doInBackground() throws Exception { String tableHeader = table.getSettings().getTableHeader(); - StringBuffer output = new StringBuffer(tableHeader); - for (int i = 0; i < table.getDataSize(); i++) { - output.append(table.getData()[i].getText()); - if (i < table.getDataSize() - 1) { - output.append(Settings.TAB); - } - } + output.append(table.getTableAsString(Settings.DATA_TYPE_DISPLAYED)); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(String.valueOf(output)), null); return null; } diff --git a/src/main/java/com/romraider/maps/Table1D.java b/src/main/java/com/romraider/maps/Table1D.java index 7f6c40e9..f0d77673 100644 --- a/src/main/java/com/romraider/maps/Table1D.java +++ b/src/main/java/com/romraider/maps/Table1D.java @@ -153,18 +153,6 @@ public class Table1D extends Table { super.startHighlight(x, y); } - @Override - public StringBuffer getTableAsString() { - StringBuffer output = new StringBuffer(""); - for (int i = 0; i < getDataSize(); i++) { - output.append(data[i].getText()); - if (i < getDataSize() - 1) { - output.append(Settings.TAB); - } - } - return output; - } - @Override public String getCellAsString(int index) { return data[index].getText(); diff --git a/src/main/java/com/romraider/maps/Table2D.java b/src/main/java/com/romraider/maps/Table2D.java index d97e3d61..4f5eb4cd 100644 --- a/src/main/java/com/romraider/maps/Table2D.java +++ b/src/main/java/com/romraider/maps/Table2D.java @@ -96,6 +96,24 @@ public class Table2D extends Table { axis.colorize(); } + @Override + public StringBuffer getTableAsString(int valType) { + StringBuffer output = new StringBuffer(Settings.BLANK); + if(axis.isStatic){ + for (int i = 0; i < axis.data.length; i++) { + output.append(axis.data[i].getText()); + if (i < axis.data.length - 1) { + output.append(Settings.TAB); + } + } + } else { + output.append(axis.getTableAsString(valType)); + } + output.append(Settings.NEW_LINE); + output.append(super.getTableAsString(valType)); + return output; + } + @Override public void setFrame(TableFrame frame) { this.frame = frame; @@ -370,7 +388,7 @@ public class Table2D extends Table { } DataCell cell = data[i]; cell.setLiveDataTrace(true); - cell.setDisplayValue(cell.getRealValue() + (isNullOrEmpty(liveValue) ? "" : (':' + liveValue))); + cell.setDisplayValue(cell.getRealValue(Settings.DATA_TYPE_BIN) + (isNullOrEmpty(liveValue) ? "" : (':' + liveValue))); } stopHighlight(); getToolbar().setLiveDataValue(liveValue); @@ -435,6 +453,46 @@ public class Table2D extends Table { axis.addComparedToTable(table2D.axis); } } + + @Override + public boolean equals(Object other) { + if(null == other) { + return false; + } + + if(other == this) { + return true; + } + + if(!(other instanceof Table2D)) { + return false; + } + + Table2D otherTable = (Table2D)other; + + if(!this.axis.equals(otherTable.axis)) { + return false; + } + + if(this.data.length != otherTable.data.length) + { + return false; + } + + if(this.data.equals(otherTable.data)) + { + return true; + } + + // Compare Bin Values + for(int i = 0 ; i < this.data.length ; i++) { + if(this.data[i].getBinValue() != otherTable.data[i].getBinValue()) { + return false; + } + } + + return true; + } } class CopySelection2DWorker extends SwingWorker { @@ -474,11 +532,9 @@ class CopyTable2DWorker extends SwingWorker { @Override protected Void doInBackground() throws Exception { String tableHeader = table.getSettings().getTable2DHeader(); - - // create string StringBuffer output = new StringBuffer(tableHeader); - output.append(table.getAxis().getTableAsString()).append(Settings.NEW_LINE); - output.append(table.getTableAsString()); + output.append(table.getTableAsString(Settings.DATA_TYPE_DISPLAYED)); + //copy to clipboard Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(output.toString()), null); return null; diff --git a/src/main/java/com/romraider/maps/Table3D.java b/src/main/java/com/romraider/maps/Table3D.java index a1c9e227..853ba0fd 100644 --- a/src/main/java/com/romraider/maps/Table3D.java +++ b/src/main/java/com/romraider/maps/Table3D.java @@ -227,23 +227,43 @@ public class Table3D extends Table { } @Override - public StringBuffer getTableAsString() { - // Make a string of the table + public StringBuffer getTableAsString(int valType) { StringBuffer output = new StringBuffer(Settings.BLANK); - output.append(xAxis.getTableAsString()).append(Settings.NEW_LINE); + + if(xAxis.isStatic) { + for (int i = 0; i < xAxis.data.length; i++) { + output.append(xAxis.data[i].getText()); + if (i < xAxis.data.length - 1) { + output.append(Settings.TAB); + } + } + } else { + output.append(xAxis.getTableAsString(valType)); + } + + output.append(Settings.NEW_LINE); for (int y = 0; y < getSizeY(); y++) { - output.append(yAxis.getCellAsString(y)).append(Settings.TAB); + if(xAxis.isStatic) { + output.append(yAxis.data[y].getText()); + } else { + output.append(yAxis.data[y].getRealValue(valType)); + } + + output.append(Settings.TAB); + for (int x = 0; x < getSizeX(); x++) { - output.append(data[x][y].getText()); + output.append(data[x][y].getRealValue(valType)); if (x < getSizeX() - 1) { output.append(Settings.TAB); } } + if (y < getSizeY() - 1) { output.append(Settings.NEW_LINE); } } + return output; } @@ -264,7 +284,7 @@ public class Table3D extends Table { // min/max not set in scale for (DataCell[] column : data) { for (DataCell cell : column) { - double value = cell.getValue(); + double value = cell.getValue(Settings.DATA_TYPE_BIN); if (value > high) { high = value; } @@ -277,7 +297,7 @@ public class Table3D extends Table { for (DataCell[] column : data) { for (DataCell cell : column) { - double value = cell.getValue(); + double value = cell.getValue(Settings.DATA_TYPE_BIN); if (value > high || value < low) { // value exceeds limit @@ -388,7 +408,7 @@ public class Table3D extends Table { for (DataCell[] column : data) { y = 0; for(DataCell cell : column) { - if(compareType == Settings.COMPARE_TYPE_BIN) { + if(compareType == Settings.DATA_TYPE_BIN) { cell.setCompareValue(compareTable3D.data[x][y].getBinValue()); } else { cell.setCompareValue(compareTable3D.data[x][y].getOriginalValue()); @@ -908,7 +928,7 @@ public class Table3D extends Table { } DataCell cell = data[x][y]; cell.setLiveDataTrace(true); - cell.setDisplayValue(cell.getRealValue() + (isNullOrEmpty(liveValue) ? "" : (':' + liveValue))); + cell.setDisplayValue(cell.getRealValue(Settings.DATA_TYPE_BIN) + (isNullOrEmpty(liveValue) ? "" : (':' + liveValue))); } } stopHighlight(); @@ -944,7 +964,7 @@ public class Table3D extends Table { for (DataCell[] column : data) { for (DataCell cell : column) { - double value = cell.getValue(); + double value = cell.getValue(Settings.DATA_TYPE_BIN); if (value < low) { low = value; } @@ -964,7 +984,7 @@ public class Table3D extends Table { for (DataCell[] column : data) { for (DataCell cell : column) { - double value = cell.getValue(); + double value = cell.getValue(Settings.DATA_TYPE_BIN); if (value > high) { high = value; } @@ -1055,6 +1075,52 @@ public class Table3D extends Table { yAxis.addComparedToTable(table3D.yAxis); } } + + @Override + public boolean equals(Object other) { + if(null == other) { + return false; + } + + if(other == this) { + return true; + } + + if(!(other instanceof Table3D)) { + return false; + } + + Table3D otherTable = (Table3D)other; + + if(! this.xAxis.equals(otherTable.xAxis)) { + return false; + } + + if(! this.yAxis.equals(otherTable.yAxis)) { + return false; + } + + if(this.data.length != otherTable.data.length || this.data[0].length != otherTable.data[0].length) + { + return false; + } + + if(this.data.equals(otherTable.data)) + { + return true; + } + + // Compare Bin Values + for(int i = 0 ; i < this.data.length ; i++) { + for(int j = 0; j < this.data[i].length ; j++) { + if(this.data[i][j].getBinValue() != otherTable.data[i][j].getBinValue()) { + return false; + } + } + } + + return true; + } } class CopySelection3DWorker extends SwingWorker { @@ -1146,22 +1212,8 @@ class CopyTable3DWorker extends SwingWorker { @Override protected Void doInBackground() throws Exception { String tableHeader = table.getSettings().getTable3DHeader(); - StringBuffer output = new StringBuffer(tableHeader); - output.append(table.getXAxis().getTableAsString()).append(Settings.NEW_LINE); - - for (int y = 0; y < table.getSizeY(); y++) { - output.append(table.getYAxis().getCellAsString(y)).append(Settings.TAB); - for (int x = 0; x < table.getSizeX(); x++) { - output.append(table.get3dData()[x][y].getText()); - if (x < table.getSizeX() - 1) { - output.append(Settings.TAB); - } - } - if (y < table.getSizeY() - 1) { - output.append(Settings.NEW_LINE); - } - } + output.append(table.getTableAsString(Settings.DATA_TYPE_DISPLAYED)); //copy to clipboard Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(String.valueOf(output)), null); return null; diff --git a/src/main/java/com/romraider/swing/CompareImagesForm.java b/src/main/java/com/romraider/swing/CompareImagesForm.java index 18f996f6..c16c6ce4 100644 --- a/src/main/java/com/romraider/swing/CompareImagesForm.java +++ b/src/main/java/com/romraider/swing/CompareImagesForm.java @@ -40,6 +40,7 @@ import javax.swing.ListSelectionModel; import javax.swing.border.EmptyBorder; import javax.swing.border.EtchedBorder; +import com.romraider.Settings; import com.romraider.maps.Rom; import com.romraider.maps.Table; @@ -56,9 +57,6 @@ public class CompareImagesForm extends JFrame implements ActionListener { private final ChangeListCellRenderer changeRenderer = new ChangeListCellRenderer(); private final JScrollPane scrollPaneResults; private final JLabel lblImageResultString; - public static Color equal = new Color(52,114,53); - public static Color different = new Color(193, 27, 23); - public static Color missing = new Color(251,185,23); public CompareImagesForm(Vector roms, Image parentImage) { this.setIconImage(parentImage); @@ -82,22 +80,14 @@ public class CompareImagesForm extends JFrame implements ActionListener { panelImageSelector.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); panelImageSelector.setLayout(null); - JLabel lblImageLeft = new JLabel("Image (Left):"); - lblImageLeft.setBounds(10, 10, 70, 14); - panelImageSelector.add(lblImageLeft); - this.comboBoxImageLeft = new JComboBox(); - this.comboBoxImageLeft.setBounds(89, 7, 475, 20); + this.comboBoxImageLeft.setBounds(10, 7, 554, 20); this.comboBoxImageLeft.setToolTipText("Select an image to compare."); this.comboBoxImageLeft.setRenderer( new ComboBoxRenderer() ); panelImageSelector.add(this.comboBoxImageLeft); - JLabel lblImageRight = new JLabel("Image (Right):"); - lblImageRight.setBounds(10, 35, 70, 14); - panelImageSelector.add(lblImageRight); - this.comboBoxImageRight = new JComboBox(); - this.comboBoxImageRight.setBounds(89, 32, 475, 20); + this.comboBoxImageRight.setBounds(10, 32, 554, 20); this.comboBoxImageRight.setToolTipText("Select an image to compare."); this.comboBoxImageRight.setRenderer( new ComboBoxRenderer() ); panelImageSelector.add(this.comboBoxImageRight); @@ -144,75 +134,63 @@ public class CompareImagesForm extends JFrame implements ActionListener { { listModelChanges.clear(); - Vector
leftTables = left.getTables(); - Vector
rightTables = right.getTables(); - int equal = 0; int different = 0; int missing = 0; - String leftTableName; - String rightTableName; - String leftTableAsString; - String rightTableAsString; - Boolean found = false; - - // Compare the tables. - for(int x=0;x 0 && different == 0 && missing == 0) { lblImageResultString.setText("Images are equal."); - lblImageResultString.setForeground(CompareImagesForm.equal); + lblImageResultString.setForeground(Settings.TABLE_EQUAL_COLOR); } else if(different > 0) { lblImageResultString.setText("Images are NOT equal. Equal Tables: "+equal+", Changed Tables: "+different+", Missing Tables: "+missing); - lblImageResultString.setForeground(CompareImagesForm.different); + lblImageResultString.setForeground(Settings.TABLE_DIFFERENT_COLOR); } else { lblImageResultString.setText("Images are NOT equal. Equal Tables: "+equal+", Changed Tables: "+different+", Missing Tables: "+missing); - lblImageResultString.setForeground(CompareImagesForm.missing); + lblImageResultString.setForeground(Settings.TABLE_MISSING_COLOR); } // Check if the list has items. @@ -320,15 +298,15 @@ public class CompareImagesForm extends JFrame implements ActionListener { switch(item.getType()) { case 1: // equal - default green - setForeground(CompareImagesForm.equal); + setForeground(Settings.TABLE_EQUAL_COLOR); break; case 2: // different - default red - setForeground(CompareImagesForm.different); + setForeground(Settings.TABLE_DIFFERENT_COLOR); break; case 3: // missing - default yellow - setForeground(CompareImagesForm.missing); + setForeground(Settings.TABLE_MISSING_COLOR); break; default: setForeground(paramList.getForeground()); diff --git a/src/main/java/com/romraider/swing/ECUEditorMenuBar.java b/src/main/java/com/romraider/swing/ECUEditorMenuBar.java index 392dc957..60a315dd 100644 --- a/src/main/java/com/romraider/swing/ECUEditorMenuBar.java +++ b/src/main/java/com/romraider/swing/ECUEditorMenuBar.java @@ -38,7 +38,6 @@ import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.FileWriter; -import java.util.Vector; import javax.swing.ButtonGroup; import javax.swing.JFileChooser; @@ -245,6 +244,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { refreshImage.setText("Refresh " + file); closeImage.setText("Close " + file); romProperties.setText(file + "Properties"); + invalidate(); } @Override @@ -281,10 +281,10 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE); } } else if (e.getSource() == closeImage) { - this.closeImage(); + parent.closeImage(); } else if (e.getSource() == closeAll) { - this.closeAllImages(); + parent.closeAllImages(); } else if (e.getSource() == exit) { parent.handleExit(); @@ -384,14 +384,6 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { } } - public void closeImage() { - getEditor().closeImage(); - } - - public void closeAllImages() { - getEditor().closeAllImages(); - } - public void saveImage(Rom input) throws Exception { ECUEditor parent = getEditor(); if (parent.getLastSelectedRom() != null) { @@ -429,6 +421,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { fc.setCurrentDirectory(lastRepositoryDir); fc.setDialogTitle("Select Repository Directory"); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + // disable the "All files" option fc.setAcceptAllFileFilterUsed(false); String separator = System.getProperty("file.separator"); @@ -445,27 +438,32 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { } } if(save) { - Vector
romTables = image.getTables(); - for(int i=0;i 0) { p = array[0].getLocation(); - p.x = p.x + FRAME_OFFSET; - p.y = p.y + FRAME_OFFSET; + p.x = p.x + Settings.FRAME_OFFSET; + p.y = p.y + Settings.FRAME_OFFSET; } else { p = new Point(0, 0); } @@ -119,13 +119,13 @@ public class MDIDesktopPane extends JDesktopPane { JInternalFrame allFrames[] = getAllFrames(); manager.setNormalSize(); - int frameHeight = (getBounds().height - 5) - allFrames.length * FRAME_OFFSET; - int frameWidth = (getBounds().width - 5) - allFrames.length * FRAME_OFFSET; + int frameHeight = (getBounds().height - 5) - allFrames.length * Settings.FRAME_OFFSET; + int frameWidth = (getBounds().width - 5) - allFrames.length * Settings.FRAME_OFFSET; for (int i = allFrames.length - 1; i >= 0; i--) { allFrames[i].setSize(frameWidth, frameHeight); allFrames[i].setLocation(x, y); - x = x + FRAME_OFFSET; - y = y + FRAME_OFFSET; + x = x + Settings.FRAME_OFFSET; + y = y + Settings.FRAME_OFFSET; } } diff --git a/src/main/java/com/romraider/swing/TableMenuBar.java b/src/main/java/com/romraider/swing/TableMenuBar.java index 0a798efa..40bbdbc6 100644 --- a/src/main/java/com/romraider/swing/TableMenuBar.java +++ b/src/main/java/com/romraider/swing/TableMenuBar.java @@ -85,6 +85,7 @@ public class TableMenuBar extends JMenuBar implements ActionListener { public void refreshTableMenuBar() { refreshSimilarOpenTables(); initCompareGroup(); + invalidate(); } private void initFileMenu() { @@ -292,7 +293,7 @@ public class TableMenuBar extends JMenuBar implements ActionListener { compareByDisplay(Settings.COMPARE_DISPLAY_PERCENT); } else if (e.getSource() == compareOriginal) { - table.setCompareType(Settings.COMPARE_TYPE_ORIGINAL); + table.setCompareType(Settings.DATA_TYPE_ORIGINAL); compareToOriginal.setSelected(true); compareByTable(table); @@ -308,10 +309,10 @@ public class TableMenuBar extends JMenuBar implements ActionListener { compareByTable(selectedTable); } else if (e.getSource() == compareToOriginal) { - compareByType(Settings.COMPARE_TYPE_ORIGINAL); + compareByType(Settings.DATA_TYPE_ORIGINAL); } else if (e.getSource() == compareToBin) { - compareByType(Settings.COMPARE_TYPE_BIN); + compareByType(Settings.DATA_TYPE_BIN); } } diff --git a/src/main/java/com/romraider/swing/TableToolBar.java b/src/main/java/com/romraider/swing/TableToolBar.java index b41e4250..e118debd 100644 --- a/src/main/java/com/romraider/swing/TableToolBar.java +++ b/src/main/java/com/romraider/swing/TableToolBar.java @@ -413,7 +413,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene float[] rowValues = new float[valueCount]; for (int i = 0; i < valueCount; i++) { DataCell theCell = tableData[i][j]; - rowValues[i] = (float) theCell.getValue(); + rowValues[i] = (float) theCell.getValue(Settings.DATA_TYPE_BIN); //float theValue = (float)theCell.getValue(); //BigDecimal finalRoundedValue = new BigDecimal(theValue).setScale(2,BigDecimal.ROUND_HALF_UP); //rowValues[i] = finalRoundedValue.floatValue(); @@ -430,7 +430,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene double[] xValues = new double[length]; for (int i = 0; i < length; i++) { - xValues[i] = dataCells[i].getValue(); + xValues[i] = dataCells[i].getValue(Settings.DATA_TYPE_BIN); //double theValue = dataCells[i].getValue(); //BigDecimal finalRoundedValue = new BigDecimal(theValue).setScale(2,BigDecimal.ROUND_HALF_UP); //xValues[i] = finalRoundedValue.doubleValue(); @@ -442,7 +442,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene double[] yValues = new double[length]; for (int i = 0; i < length; i++) { - double theValue = dataCells[i].getValue(); + double theValue = dataCells[i].getValue(Settings.DATA_TYPE_BIN); BigDecimal finalRoundedValue = new BigDecimal(theValue).setScale(2, BigDecimal.ROUND_HALF_UP); yValues[i] = finalRoundedValue.doubleValue(); } diff --git a/src/main/java/com/romraider/util/TableAxisUtil.java b/src/main/java/com/romraider/util/TableAxisUtil.java index 980d81b3..a154aa5d 100644 --- a/src/main/java/com/romraider/util/TableAxisUtil.java +++ b/src/main/java/com/romraider/util/TableAxisUtil.java @@ -19,6 +19,7 @@ package com.romraider.util; +import com.romraider.Settings; import com.romraider.maps.DataCell; import com.romraider.maps.Table1D; @@ -34,7 +35,7 @@ public final class TableAxisUtil { DataCell[] data = axis.getData(); for (int i = 0; i < data.length; i++) { DataCell cell = data[i]; - double axisValue = cell.getValue(); + double axisValue = cell.getValue(Settings.DATA_TYPE_BIN); if (liveAxisValue == axisValue) { startIdx = i; endIdx = i;