Refactoring: TableType enum & reducing code complexity

This commit is contained in:
rusefi 2018-12-22 23:10:14 -05:00
parent 40af0dd981
commit 94ce1e8a9c
12 changed files with 143 additions and 119 deletions

View File

@ -93,13 +93,6 @@ public class Settings implements Serializable {
public static final int ENDIAN_LITTLE = 1;
public static final int ENDIAN_BIG = 2;
public static final int TABLE_1D = 1;
public static final int TABLE_2D = 2;
public static final int TABLE_3D = 3;
public static final int TABLE_X_AXIS = 4;
public static final int TABLE_Y_AXIS = 5;
public static final int TABLE_SWITCH = 6;
public enum DataType {
ORIGINAL,
BIN

View File

@ -67,7 +67,6 @@ public abstract class Table extends JPanel implements Serializable {
protected static int memModelEndian;
protected String name;
protected int type;
protected String category = "Other";
protected String description = Settings.BLANK;
protected Vector<Scale> scales = new Vector<Scale>();
@ -123,7 +122,7 @@ public abstract class Table extends JPanel implements Serializable {
private Table compareTable = null;
public Table() {
protected Table() {
scales.clear();
this.setLayout(borderLayout);
@ -548,18 +547,12 @@ public abstract class Table extends JPanel implements Serializable {
calcCellRanges();
}
public int getType() {
return type;
}
public abstract TableType getType();
public DataCell getDataCell(int location) {
return data[location];
}
public void setType(int type) {
this.type = type;
}
@Override
public String getName() {
if(null == name || name.isEmpty()) {
@ -1256,7 +1249,7 @@ public abstract class Table extends JPanel implements Serializable {
}
public void validateScaling() {
if (type != Settings.TABLE_SWITCH) {
if (getType() != TableType.SWITCH) {
// make sure a scale is present
if (scales.isEmpty()) {
@ -1521,6 +1514,38 @@ public abstract class Table extends JPanel implements Serializable {
public int getMemModelEndian() {
return memModelEndian;
}
public enum TableType {
TABLE_1D(1),
TABLE_2D(2),
TABLE_3D(3),
X_AXIS(4),
Y_AXIS(5),
SWITCH(6);
private final int marshallingCode;
TableType(int marshallingCode) {
this.marshallingCode = marshallingCode;
}
public int getDimension() {
switch (this) {
case TABLE_1D:
return 1;
case TABLE_2D:
return 2;
case TABLE_3D:
return 3;
default:
return -1;
}
}
public String getMarshallingString() {
return String.valueOf(marshallingCode);
}
}
}
class CopySelectionWorker extends SwingWorker<Void, Void> {

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2017 RomRaider.com
* Copyright (C) 2006-2018 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,8 +28,15 @@ import com.romraider.util.NumberUtil;
public class Table1D extends Table {
private static final long serialVersionUID = -8747180767803835631L;
private Table axisParent = null;
private final TableType type;
public Table1D() {
public Table1D(TableType type) {
this.type = type;
}
@Override
public TableType getType() {
return type;
}
public void setAxisParent(Table axisParent) {
@ -81,50 +88,50 @@ public class Table1D extends Table {
@Override
public void cursorUp() {
if (type == Settings.TABLE_Y_AXIS) {
if (type == Table.TableType.Y_AXIS) {
if (highlightY > 0 && data[highlightY].isSelected()) {
selectCellAt(highlightY - 1);
}
} else if (type == Settings.TABLE_X_AXIS) {
} else if (type == Table.TableType.X_AXIS) {
// Y axis is on top.. nothing happens
} else if (type == Settings.TABLE_1D) {
} else if (type == Table.TableType.TABLE_1D) {
// no where to move up to
}
}
@Override
public void cursorDown() {
if (type == Settings.TABLE_Y_AXIS) {
if (getAxisParent().getType() == Settings.TABLE_3D) {
if (type == Table.TableType.Y_AXIS) {
if (getAxisParent().getType() == Table.TableType.TABLE_3D) {
if (highlightY < getDataSize() - 1 && data[highlightY].isSelected()) {
selectCellAt(highlightY + 1);
}
} else if (getAxisParent().getType() == Settings.TABLE_2D) {
} else if (getAxisParent().getType() == Table.TableType.TABLE_2D) {
if (data[highlightY].isSelected()) {
getAxisParent().selectCellAt(highlightY);
}
}
} else if (type == Settings.TABLE_X_AXIS && data[highlightY].isSelected()) {
} else if (type == Table.TableType.X_AXIS && data[highlightY].isSelected()) {
((Table3D) getAxisParent()).selectCellAt(highlightY, this);
} else if (type == Settings.TABLE_1D) {
} else if (type == Table.TableType.TABLE_1D) {
// no where to move down to
}
}
@Override
public void cursorLeft() {
if (type == Settings.TABLE_Y_AXIS) {
if (type == Table.TableType.Y_AXIS) {
// X axis is on left.. nothing happens
if (getAxisParent().getType() == Settings.TABLE_2D) {
if (getAxisParent().getType() == Table.TableType.TABLE_2D) {
if (data[highlightY].isSelected()) {
selectCellAt(highlightY - 1);
}
}
} else if (type == Settings.TABLE_X_AXIS && data[highlightY].isSelected()) {
} else if (type == Table.TableType.X_AXIS && data[highlightY].isSelected()) {
if (highlightY > 0) {
selectCellAt(highlightY - 1);
}
} else if (type == Settings.TABLE_1D && data[highlightY].isSelected()) {
} else if (type == Table.TableType.TABLE_1D && data[highlightY].isSelected()) {
if (highlightY > 0) {
selectCellAt(highlightY - 1);
}
@ -133,17 +140,17 @@ public class Table1D extends Table {
@Override
public void cursorRight() {
if (type == Settings.TABLE_Y_AXIS && data[highlightY].isSelected()) {
if (getAxisParent().getType() == Settings.TABLE_3D) {
if (type == Table.TableType.Y_AXIS && data[highlightY].isSelected()) {
if (getAxisParent().getType() == Table.TableType.TABLE_3D) {
((Table3D) getAxisParent()).selectCellAt(highlightY, this);
} else if (getAxisParent().getType() == Settings.TABLE_2D) {
} else if (getAxisParent().getType() == Table.TableType.TABLE_2D) {
selectCellAt(highlightY + 1);
}
} else if (type == Settings.TABLE_X_AXIS && data[highlightY].isSelected()) {
} else if (type == Table.TableType.X_AXIS && data[highlightY].isSelected()) {
if (highlightY < getDataSize() - 1) {
selectCellAt(highlightY + 1);
}
} else if (type == Settings.TABLE_1D && data[highlightY].isSelected()) {
} else if (type == Table.TableType.TABLE_1D && data[highlightY].isSelected()) {
if (highlightY < getDataSize() - 1) {
selectCellAt(highlightY + 1);
}
@ -152,50 +159,50 @@ public class Table1D extends Table {
@Override
public void shiftCursorUp() {
if (type == Settings.TABLE_Y_AXIS) {
if (type == Table.TableType.Y_AXIS) {
if (highlightY > 0 && data[highlightY].isSelected()) {
selectCellAtWithoutClear(highlightY - 1);
}
} else if (type == Settings.TABLE_X_AXIS) {
} else if (type == Table.TableType.X_AXIS) {
// Y axis is on top.. nothing happens
} else if (type == Settings.TABLE_1D) {
} else if (type == Table.TableType.TABLE_1D) {
// no where to move up to
}
}
@Override
public void shiftCursorDown() {
if (type == Settings.TABLE_Y_AXIS) {
if (getAxisParent().getType() == Settings.TABLE_3D) {
if (type == Table.TableType.Y_AXIS) {
if (getAxisParent().getType() == Table.TableType.TABLE_3D) {
if (highlightY < getDataSize() - 1 && data[highlightY].isSelected()) {
selectCellAtWithoutClear(highlightY + 1);
}
} else if (getAxisParent().getType() == Settings.TABLE_2D) {
} else if (getAxisParent().getType() == Table.TableType.TABLE_2D) {
if (data[highlightY].isSelected()) {
getAxisParent().selectCellAtWithoutClear(highlightY);
}
}
} else if (type == Settings.TABLE_X_AXIS && data[highlightY].isSelected()) {
} else if (type == Table.TableType.X_AXIS && data[highlightY].isSelected()) {
((Table3D) getAxisParent()).selectCellAt(highlightY, this);
} else if (type == Settings.TABLE_1D) {
} else if (type == Table.TableType.TABLE_1D) {
// no where to move down to
}
}
@Override
public void shiftCursorLeft() {
if (type == Settings.TABLE_Y_AXIS) {
if (type == Table.TableType.Y_AXIS) {
// X axis is on left.. nothing happens
if (getAxisParent().getType() == Settings.TABLE_2D) {
if (getAxisParent().getType() == Table.TableType.TABLE_2D) {
if (data[highlightY].isSelected()) {
selectCellAtWithoutClear(highlightY - 1);
}
}
} else if (type == Settings.TABLE_X_AXIS && data[highlightY].isSelected()) {
} else if (type == Table.TableType.X_AXIS && data[highlightY].isSelected()) {
if (highlightY > 0) {
selectCellAtWithoutClear(highlightY - 1);
}
} else if (type == Settings.TABLE_1D && data[highlightY].isSelected()) {
} else if (type == Table.TableType.TABLE_1D && data[highlightY].isSelected()) {
if (highlightY > 0) {
selectCellAtWithoutClear(highlightY - 1);
}
@ -204,17 +211,17 @@ public class Table1D extends Table {
@Override
public void shiftCursorRight() {
if (type == Settings.TABLE_Y_AXIS && data[highlightY].isSelected()) {
if (getAxisParent().getType() == Settings.TABLE_3D) {
if (type == Table.TableType.Y_AXIS && data[highlightY].isSelected()) {
if (getAxisParent().getType() == Table.TableType.TABLE_3D) {
((Table3D) getAxisParent()).selectCellAt(highlightY, this);
} else if (getAxisParent().getType() == Settings.TABLE_2D) {
} else if (getAxisParent().getType() == Table.TableType.TABLE_2D) {
selectCellAtWithoutClear(highlightY + 1);
}
} else if (type == Settings.TABLE_X_AXIS && data[highlightY].isSelected()) {
} else if (type == Table.TableType.X_AXIS && data[highlightY].isSelected()) {
if (highlightY < getDataSize() - 1) {
selectCellAtWithoutClear(highlightY + 1);
}
} else if (type == Settings.TABLE_1D && data[highlightY].isSelected()) {
} else if (type == Table.TableType.TABLE_1D && data[highlightY].isSelected()) {
if (highlightY < getDataSize() - 1) {
selectCellAtWithoutClear(highlightY + 1);
}
@ -234,9 +241,9 @@ public class Table1D extends Table {
if(axisParent instanceof Table3D) {
Table3D table3D = (Table3D) axisParent;
if(getType() == Settings.TABLE_X_AXIS) {
if(getType() == Table.TableType.X_AXIS) {
table3D.getYAxis().clearSelectedData();
} else if (getType() == Settings.TABLE_Y_AXIS) {
} else if (getType() == Table.TableType.Y_AXIS) {
table3D.getXAxis().clearSelectedData();
}
} else if (axisParent instanceof Table2D) {
@ -308,8 +315,8 @@ public class Table1D extends Table {
}
public boolean isAxis() {
return getType() == Settings.TABLE_X_AXIS ||
getType() == Settings.TABLE_Y_AXIS || isStaticDataTable();
return getType() == Table.TableType.X_AXIS ||
getType() == Table.TableType.Y_AXIS || isStaticDataTable();
}
@Override

View File

@ -44,7 +44,7 @@ import com.romraider.util.SettingsManager;
public class Table2D extends Table {
private static final long serialVersionUID = -7684570967109324784L;
private Table1D axis = new Table1D();
private Table1D axis = new Table1D(Table.TableType.Y_AXIS);
private JLabel axisLabel;
private CopyTable2DWorker copyTable2DWorker;
@ -54,6 +54,11 @@ public class Table2D extends Table {
verticalOverhead += 18;
}
@Override
public TableType getType() {
return TableType.TABLE_2D;
}
public Table1D getAxis() {
return axis;
}

View File

@ -52,8 +52,8 @@ import com.romraider.xml.RomAttributeParser;
public class Table3D extends Table {
private static final long serialVersionUID = 3103448753263606599L;
private Table1D xAxis = new Table1D();
private Table1D yAxis = new Table1D();
private Table1D xAxis = new Table1D(TableType.X_AXIS);
private Table1D yAxis = new Table1D(TableType.Y_AXIS);
private JLabel xAxisLabel;
private JLabel yAxisLabel;
@ -70,6 +70,11 @@ public class Table3D extends Table {
horizontalOverhead += 10;
}
@Override
public TableType getType() {
return Table.TableType.TABLE_3D;
}
public Table1D getXAxis() {
return xAxis;
}
@ -612,7 +617,7 @@ public class Table3D extends Table {
}
public void selectCellAt(int y, Table1D axisType) {
if (axisType.getType() == Settings.TABLE_Y_AXIS) {
if (axisType.getType() == Table.TableType.Y_AXIS) {
selectCellAt(0, y);
} else { // y axis
selectCellAt(y, 0);

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2014 RomRaider.com
* Copyright (C) 2006-2018 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -44,8 +44,6 @@ import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import com.romraider.Settings;
public class TableSwitch extends Table {
private static final long serialVersionUID = -4887718305447362308L;
@ -56,7 +54,6 @@ public class TableSwitch extends Table {
public TableSwitch() {
super();
storageType = 1;
type = Settings.TABLE_SWITCH;
locked = true;
removeAll();
setLayout(new BorderLayout());
@ -165,8 +162,8 @@ public class TableSwitch extends Table {
}
@Override
public int getType() {
return Settings.TABLE_SWITCH;
public TableType getType() {
return Table.TableType.SWITCH;
}
@Override

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
* Copyright (C) 2006-2018 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -35,7 +35,6 @@ import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;
import com.romraider.Settings;
import com.romraider.maps.Rom;
import com.romraider.maps.Table;
@ -108,13 +107,13 @@ public class RomCellRenderer implements TreeCellRenderer {
renderer.setBackground(Color.WHITE);
// display icon
if (table.getType() == Settings.TABLE_1D) {
if (table.getType() == Table.TableType.TABLE_1D) {
tableName = new JLabel(table.getName() + " ", new ImageIcon(getClass().getResource("/graphics/1d.gif")), JLabel.LEFT);
} else if (table.getType() == Settings.TABLE_2D) {
} else if (table.getType() == Table.TableType.TABLE_2D) {
tableName = new JLabel(table.getName() + " ", new ImageIcon(getClass().getResource("/graphics/2d.gif")), JLabel.LEFT);
} else if (table.getType() == Settings.TABLE_3D) {
} else if (table.getType() == Table.TableType.TABLE_3D) {
tableName = new JLabel(table.getName() + " ", new ImageIcon(getClass().getResource("/graphics/3d.gif")), JLabel.LEFT);
} else if (table.getType() == Settings.TABLE_SWITCH) {
} else if (table.getType() == Table.TableType.SWITCH) {
tableName = new JLabel(table.getName() + " ", new ImageIcon(getClass().getResource("/graphics/switch.gif")), JLabel.LEFT);
}

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
* Copyright (C) 2006-2018 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,7 +26,7 @@ import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;
import com.romraider.Settings;
import com.romraider.maps.Table;
import com.romraider.maps.Table3D;
public class TableMenuBar extends JMenuBar {
@ -216,7 +216,7 @@ public class TableMenuBar extends JMenuBar {
private void applyTableTypeRules(TableFrame frame) {
// Hide items that don't work with a DTC tables.
if(frame.getTable().getType() == Settings.TABLE_SWITCH) {
if(frame.getTable().getType() == Table.TableType.SWITCH) {
editMenu.setEnabled(false);
getCompareOriginal().setEnabled(false);
getComparePercent().setEnabled(false);

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2017 RomRaider.com
* Copyright (C) 2006-2018 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -45,7 +45,7 @@ public class TablePropertyPanel extends javax.swing.JPanel {
category.setText(table.getCategory());
int dim;
if (Settings.TABLE_SWITCH == table.getType()) {
if (Table.TableType.SWITCH == table.getType()) {
dim = 1;
storageSize.setText("switch");
scrollPane.setViewportView(populateScalesTable(
@ -71,7 +71,7 @@ public class TablePropertyPanel extends javax.swing.JPanel {
}
storageSize.setText(dataType + (table.getStorageType() * 8));
}
dim = table.getType();
dim = table.getType().getDimension();
scrollPane.setViewportView(populateScalesTable(table.getScales()));
}

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2017 RomRaider.com
* Copyright (C) 2006-2018 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -329,7 +329,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
updateToolbarIncrementDecrementValues();
this.overlayLog.setSelected(selectedTable.getOverlayLog());
this.enable3d.setEnabled(selectedTable.getType() == Settings.TABLE_3D);
this.enable3d.setEnabled(selectedTable.getType() == Table.TableType.TABLE_3D);
setScales(selectedTable.getScales());
@ -406,7 +406,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
refreshCompare.setEnabled(enabled);
//Only enable the 3d button if table includes 3d data
if (null != currentTable && currentTable.getType() == Settings.TABLE_3D && enabled) {
if (null != currentTable && currentTable.getType() == Table.TableType.TABLE_3D && enabled) {
enable3d.setEnabled(true);
}
else{
@ -577,7 +577,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
Vector<float[]> graphValues = new Vector<float[]>();
graphValues.clear();
if (currentTable.getType() == Settings.TABLE_3D) {
if (currentTable.getType() == Table.TableType.TABLE_3D) {
Table3D table3d = (Table3D) currentTable;
DataCell[][] tableData = table3d.get3dData();
valueCount = tableData.length;
@ -758,7 +758,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
return;
}
if(curTable.getType() == Settings.TABLE_3D) {
if(curTable.getType() == Table.TableType.TABLE_3D) {
Table3D table3d = (Table3D) curTable;
table3d.selectCellAt(x, table3d.getSizeY() - z - 1);
@ -774,7 +774,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
return;
}
if(curTable.getType() == Settings.TABLE_3D) {
if(curTable.getType() == Table.TableType.TABLE_3D) {
if (value) {
Table3D table3d = (Table3D) curTable;
table3d.selectCellAtWithoutClear(x, table3d.getSizeY() - z - 1);

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2017 RomRaider.com
* Copyright (C) 2006-2018 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -37,7 +37,6 @@ import org.apache.log4j.Logger;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.maps.DataCell;
import com.romraider.maps.Rom;
@ -373,10 +372,7 @@ public final class DOMRomUnmarshaller {
}
}
try {
if (table.getType() < 1) {
}
} catch (NullPointerException ex) { // if type is null or less than 0,
if (table == null) {
// create new instance (otherwise it
// is inherited)
final String tn = unmarshallAttribute(tableNode, "name", "unknown");
@ -397,20 +393,19 @@ public final class DOMRomUnmarshaller {
} else if (unmarshallAttribute(tableNode, "type", "unknown")
.equalsIgnoreCase("1D")) {
table = new Table1D();
table = new Table1D(Table.TableType.TABLE_1D);
} else if (unmarshallAttribute(tableNode, "type", "unknown")
.equalsIgnoreCase("X Axis")
|| unmarshallAttribute(tableNode, "type", "unknown")
.equalsIgnoreCase("Y Axis")) {
table = new Table1D();
.equalsIgnoreCase("Static X Axis")) {
table = new Table1D(Table.TableType.X_AXIS);
} else if (unmarshallAttribute(tableNode, "type", "unknown")
.equalsIgnoreCase("Static Y Axis")
.equalsIgnoreCase("Y Axis")
|| unmarshallAttribute(tableNode, "type", "unknown")
.equalsIgnoreCase("Static X Axis")) {
table = new Table1D();
.equalsIgnoreCase("Static Y Axis")) {
table = new Table1D(Table.TableType.Y_AXIS);
} else if (unmarshallAttribute(tableNode, "type", "unknown")
.equalsIgnoreCase("Switch")) {
table = new TableSwitch();
@ -428,10 +423,7 @@ public final class DOMRomUnmarshaller {
// unmarshall table attributes
final String tn = unmarshallAttribute(tableNode, "name", table.getName());
final int type = RomAttributeParser.parseTableType(unmarshallAttribute(
tableNode, "type", String.valueOf(table.getType())));
table.setName(tn);
table.setType(type);
if (unmarshallAttribute(tableNode, "beforeram", "false")
.equalsIgnoreCase("true")) {
table.setBeforeRam(true);
@ -479,7 +471,7 @@ public final class DOMRomUnmarshaller {
table.setLogParam(unmarshallAttribute(tableNode, "logparam",
table.getLogParam()));
if (table.getType() == Settings.TABLE_3D) {
if (table.getType() == Table.TableType.TABLE_3D) {
((Table3D) table).setSwapXY(unmarshallAttribute(tableNode,
"swapxy", ((Table3D) table).getSwapXY()));
((Table3D) table).setFlipX(unmarshallAttribute(tableNode, "flipx",
@ -501,15 +493,15 @@ public final class DOMRomUnmarshaller {
if (n.getNodeType() == ELEMENT_NODE) {
if (n.getNodeName().equalsIgnoreCase("table")) {
if (table.getType() == Settings.TABLE_2D) { // if table is 2D,
if (table.getType() == Table.TableType.TABLE_2D) { // if table is 2D,
// parse axis
if (RomAttributeParser
.parseTableType(unmarshallAttribute(n, "type",
"unknown")) == Settings.TABLE_Y_AXIS
"unknown")) == Table.TableType.Y_AXIS
|| RomAttributeParser
.parseTableType(unmarshallAttribute(n,
"type", "unknown")) == Settings.TABLE_X_AXIS) {
"type", "unknown")) == Table.TableType.X_AXIS) {
Table1D tempTable = (Table1D) unmarshallTable(n,
((Table2D) table).getAxis(), rom);
@ -521,13 +513,13 @@ public final class DOMRomUnmarshaller {
((Table2D) table).setAxis(tempTable);
}
} else if (table.getType() == Settings.TABLE_3D) { // if table
} else if (table.getType() == Table.TableType.TABLE_3D) { // if table
// is 3D,
// populate
// xAxis
if (RomAttributeParser
.parseTableType(unmarshallAttribute(n, "type",
"unknown")) == Settings.TABLE_X_AXIS) {
"unknown")) == Table.TableType.X_AXIS) {
Table1D tempTable = (Table1D) unmarshallTable(n,
((Table3D) table).getXAxis(), rom);
@ -542,7 +534,7 @@ public final class DOMRomUnmarshaller {
} else if (RomAttributeParser
.parseTableType(unmarshallAttribute(n, "type",
"unknown")) == Settings.TABLE_Y_AXIS) {
"unknown")) == Table.TableType.Y_AXIS) {
Table1D tempTable = (Table1D) unmarshallTable(n,
((Table3D) table).getYAxis(), rom);

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2017 RomRaider.com
* Copyright (C) 2006-2018 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import com.romraider.Settings;
import com.romraider.maps.Table;
public final class RomAttributeParser {
@ -96,21 +97,21 @@ public final class RomAttributeParser {
}
}
public static int parseTableType(String input) {
if (input.equalsIgnoreCase("3D") || input.equalsIgnoreCase(String.valueOf(Settings.TABLE_3D))) {
return Settings.TABLE_3D;
public static Table.TableType parseTableType(String input) {
if (input.equalsIgnoreCase("3D") || input.equalsIgnoreCase(Table.TableType.TABLE_3D.getMarshallingString())) {
return Table.TableType.TABLE_3D;
}
else if (input.equalsIgnoreCase("2D") || input.equalsIgnoreCase(String.valueOf(Settings.TABLE_2D))) {
return Settings.TABLE_2D;
else if (input.equalsIgnoreCase("2D") || input.equalsIgnoreCase(Table.TableType.TABLE_2D.getMarshallingString())) {
return Table.TableType.TABLE_2D;
}
else if (input.equalsIgnoreCase("X Axis") || input.equalsIgnoreCase("Static X Axis") || input.equalsIgnoreCase(String.valueOf(Settings.TABLE_X_AXIS))) {
return Settings.TABLE_X_AXIS;
else if (input.equalsIgnoreCase("X Axis") || input.equalsIgnoreCase("Static X Axis") || input.equalsIgnoreCase(Table.TableType.X_AXIS.getMarshallingString())) {
return Table.TableType.X_AXIS;
}
else if (input.equalsIgnoreCase("Y Axis") || input.equalsIgnoreCase("Static Y Axis") || input.equalsIgnoreCase(String.valueOf(Settings.TABLE_Y_AXIS))) {
return Settings.TABLE_Y_AXIS;
else if (input.equalsIgnoreCase("Y Axis") || input.equalsIgnoreCase("Static Y Axis") || input.equalsIgnoreCase(Table.TableType.Y_AXIS.getMarshallingString())) {
return Table.TableType.Y_AXIS;
}
else {
return Settings.TABLE_1D;
return Table.TableType.TABLE_1D;
}
}