Editor Cleanup:

- Moved static settings to the Settings class.
 - Added better support for cleaning up listeners, and refreshing the UI.
 - Now manually call GC after open and close.
 - Revised the compare image functionality.
 - Revised getTableAsString() functions.  These now can get different values as a string.
 - Revised "save as repository" to properly save table headers.
This commit is contained in:
Scotthew 2013-05-16 14:38:32 -07:00
parent 04ea346a70
commit 90a747bd57
17 changed files with 437 additions and 239 deletions

View File

@ -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";

View File

@ -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<Void, Void> {
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<Void, Void> {
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<Void, Void> {
RomTreeNode romTreeNode = (RomTreeNode) imageRoot.getChildAt(i);
Rom rom = romTreeNode.getRom();
if (rom == editor.getLastSelectedRom()) {
Vector<Table> 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<TreePath> path = new Vector<TreePath>();
path.add(new TreePath(romTreeNode.getPath()));
imageRoot.remove(i);
imageList.removeDescendantToggledPaths(path.elements());
path.clear();
break;
}
}
@ -584,7 +619,6 @@ class CloseImageWorker extends SwingWorker<Void, Void> {
// no other images open
editor.setLastSelectedRom(null);
}
editor.getRightPanel().repaint();
return null;
}
@ -592,10 +626,9 @@ class CloseImageWorker extends SwingWorker<Void, Void> {
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<Void, Void> {
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<Void, Void> {
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<Void, Void> {
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();
}
}

View File

@ -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();

View File

@ -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<EcuParameter> params) {
this.params = new ArrayList<EcuParameter>(params);
// updateAfrSourceList();
// updateAfrSourceList();
}
public void setEcuSwitches(List<EcuSwitch> switches) {
@ -494,6 +503,6 @@ public final class MafControlPanel extends JPanel {
public void setExternalDatas(List<ExternalData> externals) {
this.externals = new ArrayList<ExternalData>(externals);
// updateAfrSourceList();
// updateAfrSourceList();
}
}

View File

@ -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) {

View File

@ -252,6 +252,11 @@ public class Rom implements Serializable {
return binData;
}
public void clearData() {
tables.clear();
binData = null;
}
public int getRealFileSize() {
return binData.length;
}

View File

@ -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<Table> comparedToTables = new ArrayList<Table>();
@ -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<Void, Void> {
@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;
}

View File

@ -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();

View File

@ -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<Void, Void> {
@ -474,11 +532,9 @@ class CopyTable2DWorker extends SwingWorker<Void, Void> {
@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;

View File

@ -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<Void, Void> {
@ -1146,22 +1212,8 @@ class CopyTable3DWorker extends SwingWorker<Void, Void> {
@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;

View File

@ -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<Rom> 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<Table> leftTables = left.getTables();
Vector<Table> 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<leftTables.size();x++) {
found = false;
leftTableName = leftTables.get(x).getName().trim().toLowerCase();
for(int y=0;y<rightTables.size();y++) {
rightTableName = rightTables.get(y).getName().trim().toLowerCase();
if(leftTableName.equals(rightTableName)) {
// Same table. Compare table as string
found = true;
leftTableAsString = leftTables.get(x).getTableAsString().toString().trim().toLowerCase();
rightTableAsString = rightTables.get(y).getTableAsString().toString().trim().toLowerCase();
if(leftTableAsString.equals(rightTableAsString)) {
// Tables are equal
for(Table leftTable : left.getTables())
{
Boolean found = false;
for(Table rightTable : right.getTables())
{
if(leftTable.getName().equalsIgnoreCase(rightTable.getName()))
{
if(leftTable.equals(rightTable)) {
equal++;
listModelChanges.addElement(new ListItem(1, leftTables.get(x).getName()));
} else {
// Tables are different
different++;
listModelChanges.addElement(new ListItem(2, leftTables.get(x).getName()));
listModelChanges.addElement(new ListItem(1, leftTable.getName()));
}
else {
different++;
listModelChanges.addElement(new ListItem(2, leftTable.getName()));
}
found = true;
break;
}
}
if(!found) {
missing++;
listModelChanges.addElement(new ListItem(3, leftTables.get(x).getName()));
listModelChanges.addElement(new ListItem(3, leftTable.getName()));
}
}
// Check if rightTables has tables that do not exist in left table.
for(int x=0;x<rightTables.size();x++) {
found = false;
rightTableName = rightTables.get(x).getName().trim().toLowerCase();
for(int y=0;y<leftTables.size();y++) {
leftTableName = leftTables.get(y).getName().trim().toLowerCase();
if(rightTableName.equals(leftTableName))
for(Table rightTable : right.getTables()) {
Boolean found = false;
for(Table leftTable : left.getTables()) {
if(leftTable.getName().equalsIgnoreCase(rightTable.getName()))
{
found = true;
break;
}
}
if(!found) {
missing++;
listModelChanges.addElement(new ListItem(3, rightTables.get(x).getName()));
listModelChanges.addElement(new ListItem(3, rightTable.getName()));
}
}
// Fill out the result string.
if(equal > 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());

View File

@ -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<Table> romTables = image.getTables();
for(int i=0;i<romTables.size();i++) {
Table curTable = romTables.get(i);
String category = curTable.getCategory();
String tableName = curTable.getName();
for(Table table : image.getTables())
{
String category = table.getCategory();
String tableName = table.getName();
String tableDirString = selectedDir.getAbsolutePath() + separator + category;
File tableDir = new File(tableDirString.replace('/', '-'));
tableDir.mkdirs();
String tableFileString = tableDir.getAbsolutePath() + separator + tableName+".txt";
File tableFile = new File(tableFileString.replace('/', '-'));
if(tableFile.exists())
{
tableFile.delete();
}
tableFile.createNewFile();
StringBuffer tableData = curTable.getTableAsString();
StringBuffer tableData = table.getTableAsString(Settings.DATA_TYPE_BIN);
BufferedWriter out = new BufferedWriter(new FileWriter(tableFile));
try {
out.write(tableData.toString());
} finally {
out.close();
try {
out.close();
} catch(Exception ex) {
;// Do Nothing.
}
}
}
getSettings().setLastRepositoryDir(selectedDir);

View File

@ -80,10 +80,12 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
}
public void updateIcons() {
openImage.setIcon(rescaleImageIcon(new ImageIcon(getClass().getResource("/graphics/icon-open.png")), getSettings().getEditorIconScale()));
saveImage.setIcon(rescaleImageIcon(new ImageIcon(getClass().getResource("/graphics/icon-save.png")), getSettings().getEditorIconScale()));
refreshImage.setIcon(rescaleImageIcon(new ImageIcon(getClass().getResource("/graphics/icon-refresh.png")), getSettings().getEditorIconScale()));
closeImage.setIcon(rescaleImageIcon(new ImageIcon( getClass().getResource("/graphics/icon-close.png")), getSettings().getEditorIconScale()));
int iconScale = getSettings().getEditorIconScale();
openImage.setIcon(rescaleImageIcon(new ImageIcon(getClass().getResource("/graphics/icon-open.png")), iconScale));
saveImage.setIcon(rescaleImageIcon(new ImageIcon(getClass().getResource("/graphics/icon-save.png")), iconScale));
refreshImage.setIcon(rescaleImageIcon(new ImageIcon(getClass().getResource("/graphics/icon-refresh.png")), iconScale));
closeImage.setIcon(rescaleImageIcon(new ImageIcon( getClass().getResource("/graphics/icon-close.png")), iconScale));
invalidate();
}
private ImageIcon rescaleImageIcon(ImageIcon imageIcon, int percentOfOriginal) {
@ -114,6 +116,7 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
refreshImage.setEnabled(true);
closeImage.setEnabled(true);
}
invalidate();
}
@Override
@ -123,23 +126,23 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
((ECUEditorMenuBar) getEditor().getJMenuBar()).openImageDialog();
} catch (Exception ex) {
JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex,
getEditor().getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE);
getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE);
}
} else if (e.getSource() == saveImage) {
try {
((ECUEditorMenuBar) getEditor().getJMenuBar()).saveImage(getEditor().getLastSelectedRom());
} catch (Exception ex) {
JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex,
getEditor().getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE);
getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE);
}
} else if (e.getSource() == closeImage) {
((ECUEditorMenuBar) getEditor().getJMenuBar()).closeImage();
getEditor().closeImage();
} else if (e.getSource() == refreshImage) {
try {
((ECUEditorMenuBar) getEditor().getJMenuBar()).refreshImage();
} catch (Exception ex) {
JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex,
getEditor().getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE);
getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE);
}
}
}

View File

@ -32,6 +32,7 @@ import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.editor.ecu.ECUEditorManager;
@ -43,7 +44,6 @@ import com.romraider.editor.ecu.ECUEditorManager;
public class MDIDesktopPane extends JDesktopPane {
private static final long serialVersionUID = -1839360490978587035L;
private static int FRAME_OFFSET = 20;
private final MDIDesktopManager manager;
public MDIDesktopPane() {
@ -68,8 +68,8 @@ public class MDIDesktopPane extends JDesktopPane {
checkDesktopSize();
if (array.length > 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;
}
}

View File

@ -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);
}
}

View File

@ -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();
}

View File

@ -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;