Continued table rework

This commit is contained in:
Robin K 2021-09-23 19:04:59 +02:00
parent f0e0577e4e
commit 64aff76b23
11 changed files with 382 additions and 1985 deletions

View File

@ -49,7 +49,6 @@ public class DataCell {
private double compareToValue = 0.0;
private String liveValue = Settings.BLANK;
private String staticText = null;
private boolean isSelected = false;
private byte[] input;
//Index within table
@ -335,7 +334,7 @@ public class DataCell {
return JEPUtil.evaluate(table.getCurrentScale().getExpression(), binValue);
}
public void setRealValue(String input) {
public void setRealValue(String input) throws UserLevelException {
// create parser
input = input.replaceAll(DataCellView.REPLACE_TEXT, Settings.BLANK);
try {
@ -377,10 +376,13 @@ public class DataCell {
}
}
public void setBinValue(double newBinValue) {
if(binValue == newBinValue) {
public void setBinValue(double newBinValue) throws UserLevelException {
if(binValue == newBinValue || table.locked) {
return;
}
if (table.userLevel > getSettings().getUserLevel())
throw new UserLevelException(table.userLevel);
double checkedValue = newBinValue;
@ -403,7 +405,7 @@ public class DataCell {
updateView();
}
public void increment(double increment) {
public void increment(double increment) throws UserLevelException {
double oldValue = getRealValue();
if (table.getCurrentScale().getCoarseIncrement() < 0.0) {
@ -434,7 +436,7 @@ public class DataCell {
}
}
public void undo() {
public void undo() throws UserLevelException {
this.setBinValue(originalValue);
}
@ -464,29 +466,18 @@ public class DataCell {
}
}
public void multiply(double factor) {
String newValue = (getRealValue() * factor) + "";
//We need to convert from dot to comma, in the case of EU Format. This is because getRealValue to String has dot notation.
if(NumberUtil.getSeperator() == ',') newValue = newValue.replace('.', ',');
setRealValue(newValue);
}
//Used to be multiply(), this doesn't work as expected on negative values though
public void multiplyRaw(double factor) {
setBinValue(binValue * factor);
}
public void setSelected(boolean selected) {
if(!table.isStaticDataTable() && this.isSelected != selected) {
this.isSelected = selected;
public void multiply(double factor) throws UserLevelException {
if(table.getCurrentScale().getName().equals("Raw Value"))
setBinValue(binValue * factor);
else {
String newValue = (getRealValue() * factor) + "";
//We need to convert from dot to comma, in the case of EU Format. This is because getRealValue to String has dot notation.
if(NumberUtil.getSeperator() == ',') newValue = newValue.replace('.', ',');
setRealValue(newValue);
}
}
public boolean isSelected() {
return isSelected;
}
}
@Override
public boolean equals(Object other) {

View File

@ -58,6 +58,7 @@ public class DataCellView extends JLabel implements MouseListener, Serializable
private int x = 0;
private int y = 0;
private boolean isSelected = false;
private boolean highlighted = false;
private boolean traced = false;
private boolean tracedStale = false;
@ -90,8 +91,14 @@ public class DataCellView extends JLabel implements MouseListener, Serializable
this.setPreferredSize(getSettings().getCellSize());
}
public void setSelected(boolean selected) {
if(!tableView.getTable().isStaticDataTable() && this.isSelected != selected) {
this.isSelected = selected;
}
}
public boolean isSelected() {
return dataCell.isSelected();
return isSelected;
}
public boolean equals (DataCellView v) {
@ -129,7 +136,7 @@ public class DataCellView extends JLabel implements MouseListener, Serializable
if(highlighted) {
backgroundColor = settings.getHighlightColor();
} else if(dataCell.isSelected()) {
} else if(isSelected()) {
backgroundColor = settings.getSelectColor();
} else if(null == tableView.getTable().getCompareTable()) {
backgroundColor = getBinColor();
@ -243,7 +250,7 @@ public class DataCellView extends JLabel implements MouseListener, Serializable
}
} else if (highlighted) {
textColor = Settings.highlightTextColor;
} else if (dataCell.isSelected()) {
} else if (isSelected()) {
textColor = Settings.selectTextColor;
} else {
textColor = Settings.scaleTextColor;
@ -340,8 +347,8 @@ public class DataCellView extends JLabel implements MouseListener, Serializable
if(isHighlighted()) {
setHighlighted(false);
}
if(dataCell.isSelected()) {
dataCell.setSelected(false);
if(isSelected()) {
setSelected(false);
}
}

View File

@ -129,7 +129,10 @@ public class PresetPanel extends JPanel {
if(table.getTable().getDataSize() == button.values.size()) {
for (int i = 0; i < table.getTable().getDataSize(); i++) {
table.data[i].getDataCell().setBinValue(button.values.get(i));
try {
table.data[i].getDataCell().setBinValue(button.values.get(i));
} catch (UserLevelException e) {
}
}
}

View File

@ -216,7 +216,7 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
table.getStorageAddress() + " " + binData.length + " filesize", ex);
// table storage address extends beyond end of file
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table),
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table.getTableView()),
MessageFormat.format(rb.getString("ADDROUTOFBNDS"), table.getName()),
rb.getString("ECUDEFERROR"), JOptionPane.ERROR_MESSAGE);
tableNodes.removeElementAt(i);
@ -227,7 +227,7 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
table.getStorageAddress() + " " + binData.length + " filesize", iex);
// table storage address extends beyond end of file
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table),
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table.getTableView()),
MessageFormat.format(rb.getString("ADDROUTOFBNDS"), table.getName()),
rb.getString("ECUDEFERROR"), JOptionPane.ERROR_MESSAGE);
tableNodes.removeElementAt(i);
@ -242,7 +242,7 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
} catch (NullPointerException ex) {
LOGGER.error("Error Populating Table", ex);
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table),
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table.getTableView()),
MessageFormat.format(rb.getString("TABLELOADERR"), table.getName()),
rb.getString("ECUDEFERROR"), JOptionPane.ERROR_MESSAGE);
tableNodes.removeElementAt(i);
@ -360,7 +360,7 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
Object[] options = {rb.getString("YES"), rb.getString("NO")};
final String message = rb.getString("CHKSUMINVALID");
int answer = showOptionDialog(
SwingUtilities.windowForComponent(checksum.getTable()),
SwingUtilities.windowForComponent(checksum.getTable().getTableView()),
message,
rb.getString("CHECKSUMFIX"),
DEFAULT_OPTION,

View File

@ -37,6 +37,8 @@ public abstract class Table implements Serializable {
protected static final String ST_DELIMITER = "\t\n\r\f";
protected static Settings.Endian memModelEndian;
protected TableView tableView;
protected String name;
protected String category = "Other";
protected String description = Settings.BLANK;
@ -83,7 +85,14 @@ public abstract class Table implements Serializable {
scales.clear();
};
public void setTableView(TableView v) {
this.tableView = v;
}
public TableView getTableView() {
return this.tableView;
}
public DataCell[] getData() {
return data;
}
@ -240,6 +249,10 @@ public abstract class Table implements Serializable {
public String getLogParam() {
return logParam;
}
public String getLogParamString() {
return getName()+ ":" + getLogParam();
}
@Override
public String toString() {
@ -459,64 +472,7 @@ public abstract class Table implements Serializable {
this.minCompare = minCompare;
}
//TODO: Rework
//Cell should check if selected and then increment
public void increment(double increment) throws UserLevelException {
if (!locked && !(userLevel > getSettings().getUserLevel())) {
for (DataCell cell : data) {
if (cell.isSelected()) {
cell.increment(increment);
}
}
} else if (userLevel > getSettings().getUserLevel()) {
throw new UserLevelException(userLevel);
/*
JOptionPane.showMessageDialog(this, MessageFormat.format(
rb.getString("USERLVLTOLOW"), userLevel),
rb.getString("TBLNOTMODIFY"),
JOptionPane.INFORMATION_MESSAGE);*/
}
}
public void multiply(double factor) throws UserLevelException{
if (!locked && !(userLevel > getSettings().getUserLevel())) {
for (DataCell cell : data) {
if (cell.isSelected()) {
//Use raw or real value, depending on view settings
if(getCurrentScale().getName().equals("Raw Value"))
cell.multiplyRaw(factor);
else
cell.multiply(factor);
}
}
} else if (userLevel > getSettings().getUserLevel()) {
throw new UserLevelException(userLevel);
/*
JOptionPane.showMessageDialog(this, MessageFormat.format(
rb.getString("USERLVLTOLOW"), userLevel),
rb.getString("TBLNOTMODIFY"),
JOptionPane.INFORMATION_MESSAGE);*/
}
}
public void setRealValue(String realValue) throws UserLevelException {
if (!locked && userLevel <= getSettings().getUserLevel()) {
for(DataCell cell : data) {
if (cell.isSelected()) {
cell.setRealValue(realValue);
}
}
} else if (userLevel > getSettings().getUserLevel()) {
throw new UserLevelException(userLevel);
/*
JOptionPane.showMessageDialog(this, MessageFormat.format(
rb.getString("USERLVLTOLOW"), userLevel),
rb.getString("TBLNOTMODIFY"),
JOptionPane.INFORMATION_MESSAGE);*/
}
}
public void setRevertPoint() {
@ -525,21 +481,12 @@ public abstract class Table implements Serializable {
}
}
public void undoAll() {
public void undoAll() throws UserLevelException {
for (DataCell cell : data) {
cell.undo();
}
}
public void undoSelected() {
for (DataCell cell : data) {
// reset current value to original value
if (cell.isSelected()) {
cell.undo();
}
}
}
abstract public byte[] saveFile(byte[] binData);
public void setValues(String name, String value) {
@ -589,21 +536,6 @@ public abstract class Table implements Serializable {
return bitMask;
}
public void verticalInterpolate() {
}
public void horizontalInterpolate() {
}
public void interpolate() {
horizontalInterpolate();
}
public double linearInterpolation(double x, double x1, double x2, double y1, double y2) {
return (x1 == x2) ? 0.0 : (y1 + (x - x1) * (y2 - y1) / (x2 - x1));
}
public void validateScaling() {
if (getType() != TableType.SWITCH) {

View File

@ -31,7 +31,7 @@ public class Table1DView extends TableView {
private static final long serialVersionUID = -8747180767803835631L;
private Table1D table;
protected Table1DView(Table1D table) {
super(table);
this.table = table;
@ -47,10 +47,6 @@ public class Table1DView extends TableView {
}
}
@Override
public byte[] saveFile(byte[] binData) {
return binData;
}
@Override
public void populateTable(byte[] input, int romRamOffset) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
@ -88,7 +84,7 @@ public class Table1DView extends TableView {
@Override
public void cursorUp() {
if (table.getType() == Table.TableType.Y_AXIS) {
if (highlightY > 0 && data[highlightY].getDataCell().isSelected()) {
if (highlightY > 0 && data[highlightY].isSelected()) {
selectCellAt(highlightY - 1);
}
} else if (table.getType() == Table.TableType.X_AXIS) {
@ -102,16 +98,16 @@ public class Table1DView extends TableView {
public void cursorDown() {
if (table.getType() == Table.TableType.Y_AXIS) {
if (table.getAxisParent().getType() == Table.TableType.TABLE_3D) {
if (highlightY < table.getDataSize() - 1 && data[highlightY].getDataCell().isSelected()) {
if (highlightY < table.getDataSize() - 1 && data[highlightY].isSelected()) {
selectCellAt(highlightY + 1);
}
} else if (table.getAxisParent().getType() == Table.TableType.TABLE_2D) {
if (data[highlightY].getDataCell().isSelected()) {
if (data[highlightY].isSelected()) {
selectCellAt(highlightY);
}
}
} else if (table.getType() == Table.TableType.X_AXIS && data[highlightY].getDataCell().isSelected()) {
((Table3D) table.getAxisParent()).selectCellAt(highlightY, this);
} else if (table.getType() == Table.TableType.X_AXIS && data[highlightY].isSelected()) {
((Table3D) table.getAxisParent()).getTableView().selectCellAt(highlightY);
} else if (table.getType() == Table.TableType.TABLE_1D) {
// no where to move down to
}
@ -141,7 +137,7 @@ public class Table1DView extends TableView {
public void cursorRight() {
if (table.getType() == Table.TableType.Y_AXIS && data[highlightY].isSelected()) {
if (table.getAxisParent().getType() == Table.TableType.TABLE_3D) {
((Table3D) table.getAxisParent()).selectCellAt(highlightY, this);
((Table3D) table.getAxisParent()).getTableView().selectCellAt(highlightY);
} else if (table.getAxisParent().getType() == Table.TableType.TABLE_2D) {
selectCellAt(highlightY + 1);
}
@ -178,11 +174,11 @@ public class Table1DView extends TableView {
}
} else if (table.getAxisParent().getType() == Table.TableType.TABLE_2D) {
if (data[highlightY].isSelected()) {
table.getAxisParent().selectCellAtWithoutClear(highlightY);
table.getAxisParent().getTableView().selectCellAtWithoutClear(highlightY);
}
}
} else if (table.getType() == Table.TableType.X_AXIS && data[highlightY].isSelected()) {
((Table3D) table.getAxisParent()).selectCellAt(highlightY, this);
((Table3D) table.getAxisParent()).getTableView().selectCellAt(highlightY);
} else if (table.getType() == Table.TableType.TABLE_1D) {
// no where to move down to
}
@ -212,7 +208,7 @@ public class Table1DView extends TableView {
public void shiftCursorRight() {
if (table.getType() == Table.TableType.Y_AXIS && data[highlightY].isSelected()) {
if (table.getAxisParent().getType() == Table.TableType.TABLE_3D) {
((Table3D) table.getAxisParent()).selectCellAt(highlightY, this);
((Table3D) table.getAxisParent()).getTableView().selectCellAt(highlightY);
} else if (table.getAxisParent().getType() == Table.TableType.TABLE_2D) {
selectCellAtWithoutClear(highlightY + 1);
}
@ -229,11 +225,11 @@ public class Table1DView extends TableView {
@Override
public void clearSelection() {
// Call to the axis parent. The axis parent should then call to clear this data.
// Call to the axis parent. The axis parent should then call to clear this data.
Table p = table.getAxisParent();
if(p != null)
p.clearSelection();
p.getTableView().clearSelection();
}
@Override
@ -241,17 +237,17 @@ public class Table1DView extends TableView {
Table axisParent = table.getAxisParent();
if(axisParent != null)
axisParent.clearSelectedData();
axisParent.getTableView().clearSelection();
if(axisParent instanceof Table3D) {
Table3D table3D = (Table3D) axisParent;
if(table.getType() == Table.TableType.X_AXIS) {
table3D.getYAxis().clearSelectedData();
table3D.getYAxis().getTableView().clearSelection();
} else if (table.getType() == Table.TableType.Y_AXIS) {
table3D.getXAxis().clearSelectedData();
table3D.getXAxis().getTableView().clearSelection();
}
} else if (axisParent instanceof Table2D) {
((Table2D) axisParent).getAxis().clearSelectedData();
((Table2D) axisParent).getAxis().getTableView().clearSelection();
}
@ -305,7 +301,8 @@ public class Table1DView extends TableView {
cell.getDataCell().setLiveDataTraceValue(liveVal);
getToolbar().setLiveDataValue(liveVal);
}
table.getAxisParent().updateLiveDataHighlight();
table.getAxisParent().getTableView().updateLiveDataHighlight();
}
public boolean isAxis() {
@ -360,7 +357,7 @@ public class Table1DView extends TableView {
@Override
public void updateTableLabel() {
this.table.getAxisParent().updateTableLabel();
this.table.getAxisParent().getTableView().updateTableLabel();
}
@Override

View File

@ -46,14 +46,10 @@ import com.romraider.util.SettingsManager;
public class Table2D extends Table {
private static final long serialVersionUID = -7684570967109324784L;
private Table1D axis = new Table1D(Table.TableType.Y_AXIS);
private JLabel axisLabel;
private CopyTable2DWorker copyTable2DWorker;
private CopySelection2DWorker copySelection2DWorker;
public Table2D() {
verticalOverhead += 18;
}
@Override
public TableType getType() {
@ -64,13 +60,6 @@ public class Table2D extends Table {
return axis;
}
public JLabel getAxisLabel() {
return axisLabel;
}
public void setAxisLabel(JLabel label) {
axisLabel = label;
}
public void setAxis(Table1D axis) {
this.axis = axis;
@ -80,8 +69,8 @@ public class Table2D extends Table {
@Override
public String toString() {
return super.toString() + " (2D)";// + axis;
}
}
@Override
public void populateCompareValues(Table otherTable) {
if(null == otherTable || !(otherTable instanceof Table2D)) {
@ -105,93 +94,15 @@ public class Table2D extends Table {
}
@Override
public StringBuffer getTableAsString() {
StringBuffer output = new StringBuffer(Settings.BLANK);
output.append(axis.getTableAsString());
output.append(Settings.NEW_LINE);
output.append(super.getTableAsString());
return output;
}
@Override
public Dimension getFrameSize() {
int height = verticalOverhead + cellHeight * 2;
int width = horizontalOverhead + data.length * cellWidth;
if (height < minHeight) {
height = minHeight;
}
int minWidth = isLiveDataSupported() ? minWidthOverlay : minWidthNoOverlay;
if (width < minWidth) {
width = minWidth;
}
return new Dimension(width, height);
}
@Override
public void populateTable(byte[] input, int romRamOffset) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
this.input = input;
centerLayout.setRows(2);
centerLayout.setColumns(this.getDataSize());
public void populateTable(byte[] input, int romRamOffset) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
try {
axis.populateTable(input, romRamOffset);
super.populateTable(input, romRamOffset);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new ArrayIndexOutOfBoundsException();
}
// add to table
for (int i = 0; i < this.getDataSize(); i++) {
centerPanel.add(axis.getDataCell(i));
}
if (flip) {
for (int i = this.getDataSize() - 1; i >= 0; i--) {
centerPanel.add(this.getDataCell(i));
}
} else {
for (int i = 0; i < this.getDataSize(); i++) {
centerPanel.add(this.getDataCell(i));
}
}
if(null == axis.getName() || axis.getName().isEmpty() || Settings.BLANK == axis.getName()) {
;// Do not add label.
} else if(null == axis.getCurrentScale() || "0x" == axis.getCurrentScale().getUnit()) {
// static or no scale exists.
axisLabel = new JLabel(axis.getName(), JLabel.CENTER);
add(axisLabel, BorderLayout.NORTH);
} else {
axisLabel = new JLabel(axis.getName() + " (" + axis.getCurrentScale().getUnit() + ")", JLabel.CENTER);
add(axisLabel, BorderLayout.NORTH);
}
tableLabel = new JLabel(getCurrentScale().getUnit(), JLabel.CENTER);
add(tableLabel, BorderLayout.SOUTH);
axisLabel.setBorder(new EmptyBorder(2, 4, 2, 4));
if(presetPanel != null) presetPanel.populatePanel();
repaint();
}
@Override
public void updateTableLabel() {
if(null == axis.getName() || axis.getName().length() < 1 || Settings.BLANK == axis.getName()) {
;// Do not update label.
} else if(null == axis.getCurrentScale() || "0x" == axis.getCurrentScale().getUnit()) {
// static or no scale exists.
axisLabel.setText(axis.getName());
} else {
axisLabel.setText(axis.getName() + " (" + axis.getCurrentScale().getUnit() + ")");
}
tableLabel.setText(getCurrentScale().getUnit());
}
@Override
public void clearSelection() {
axis.clearSelectedData();
clearSelectedData();
}
@Override
public void setRevertPoint() {
@ -200,7 +111,7 @@ public class Table2D extends Table {
}
@Override
public void undoAll() {
public void undoAll() throws UserLevelException {
super.undoAll();
axis.undoAll();
}
@ -216,190 +127,13 @@ public class Table2D extends Table {
}
@Override
public void addKeyListener(KeyListener listener) {
super.addKeyListener(listener);
axis.addKeyListener(listener);
public String getLogParamString() {
StringBuilder sb = new StringBuilder();
sb.append(axis.getLogParamString()+ ", ");
sb.append(getName()+ ":" + getLogParam());
return sb.toString();
}
@Override
public void cursorUp() {
if (data[highlightY].isSelected()) {
axis.selectCellAt(highlightY);
}
}
@Override
public void drawTable() {
super.drawTable();
axis.drawTable();
}
@Override
public void cursorDown() {
axis.cursorDown();
}
@Override
public void cursorLeft() {
if (highlightY > 0 && data[highlightY].isSelected()) {
selectCellAt(highlightY - 1);
} else {
axis.cursorLeft();
}
}
@Override
public void cursorRight() {
if (highlightY < data.length - 1 && data[highlightY].isSelected()) {
selectCellAt(highlightY + 1);
} else {
axis.cursorRight();
}
}
@Override
public void shiftCursorUp() {
if (data[highlightY].isSelected()) {
data[highlightY].setSelected(false);
}
axis.selectCellAt(highlightY);
}
@Override
public void shiftCursorDown() {
axis.cursorDown();
}
@Override
public void shiftCursorLeft() {
if (highlightY > 0 && data[highlightY].isSelected()) {
selectCellAtWithoutClear(highlightY - 1);
} else {
axis.shiftCursorLeft();
}
}
@Override
public void shiftCursorRight() {
if (highlightY < data.length - 1 && data[highlightY].isSelected()) {
selectCellAtWithoutClear(highlightY + 1);
} else {
axis.shiftCursorRight();
}
}
@Override
public void startHighlight(int x, int y) {
axis.clearSelectedData();
super.startHighlight(x, y);
}
@Override
public void copySelection() {
Window ancestorWindow = SwingUtilities.getWindowAncestor(this);
if(null != ancestorWindow) {
ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
ECUEditorManager.getECUEditor().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
super.copySelection();
copySelection2DWorker = new CopySelection2DWorker(this);
copySelection2DWorker.execute();
}
@Override
public void copyTable() {
Window ancestorWindow = SwingUtilities.getWindowAncestor(this);
if(null != ancestorWindow) {
ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
ECUEditorManager.getECUEditor().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
copyTable2DWorker = new CopyTable2DWorker(this);
copyTable2DWorker.execute();
}
@Override
public void paste() {
StringTokenizer st = new StringTokenizer(Settings.BLANK);
String input = Settings.BLANK;
try {
input = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor);
st = new StringTokenizer(input, ST_DELIMITER);
} catch (UnsupportedFlavorException ex) { /* wrong paste type -- do nothing */
} catch (IOException ex) {
}
String pasteType = st.nextToken();
if (pasteType.equalsIgnoreCase("[Table2D]")) { // Paste table
String currentToken = st.nextToken(Settings.NEW_LINE);
if (currentToken.endsWith("\t")) {
currentToken = st.nextToken(Settings.NEW_LINE);
}
String axisValues = "[Table1D]" + Settings.NEW_LINE + currentToken;
String dataValues = "[Table1D]" + Settings.NEW_LINE + st.nextToken(Settings.NEW_LINE);
// put axis in clipboard and paste
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(axisValues), null);
axis.paste();
// put datavalues in clipboard and paste
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(dataValues), null);
super.paste();
// reset clipboard
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(input), null);
} else if (pasteType.equalsIgnoreCase("[Selection1D]")) { // paste selection
if (data[highlightY].isSelected()) {
super.paste();
} else {
axis.paste();
}
}
}
@Override
public void interpolate() {
super.interpolate();
this.getAxis().interpolate();
}
@Override
public void verticalInterpolate() {
super.verticalInterpolate();
this.getAxis().verticalInterpolate();
}
@Override
public void horizontalInterpolate() {
int[] coords = { getDataSize(), 0};
DataCellView[] tableData = getData();
DataCellView[] axisData = getAxis().getData();
for (int i = 0; i < getDataSize(); ++i) {
if (tableData[i].isSelected()) {
if (i < coords[0])
coords[0] = i;
if (i > coords[1])
coords[1] = i;
}
}
if (coords[1] - coords[0] > 1) {
double x, x1, x2, y1, y2;
x1 = axisData[coords[0]].getDataCell().getBinValue();
y1 = tableData[coords[0]].getDataCell().getBinValue();
x2 = axisData[coords[1]].getDataCell().getBinValue();
y2 = tableData[coords[1]].getDataCell().getBinValue();
for (int i = coords[0] + 1; i < coords[1]; ++i) {
x = axisData[i].getDataCell().getBinValue();
data[i].getDataCell().setBinValue(linearInterpolation(x, x1, x2, y1, y2));
}
}
// Interpolate x axis in case the x axis in selected.
this.getAxis().horizontalInterpolate();
}
@Override
public boolean isLiveDataSupported() {
return !isNullOrEmpty(axis.getLogParam());
@ -409,42 +143,7 @@ public class Table2D extends Table {
public boolean isButtonSelected() {
return true;
}
@Override
public void clearLiveDataTrace() {
super.clearLiveDataTrace();
axis.clearLiveDataTrace();
}
@Override
public void updateLiveDataHighlight() {
if (getOverlayLog()) {
data[axis.getPreviousLiveDataIndex()].setPreviousLiveDataTrace(true);
data[axis.getLiveDataIndex()].setPreviousLiveDataTrace(false);
data[axis.getLiveDataIndex()].setLiveDataTrace(true);
}
}
@Override
public String getLogParamString() {
StringBuilder sb = new StringBuilder();
sb.append(axis.getLogParamString()+ ", ");
sb.append(getName()+ ":" + getLogParam());
return sb.toString();
}
@Override
public void setOverlayLog(boolean overlayLog) {
super.setOverlayLog(overlayLog);
axis.setOverlayLog(overlayLog);
}
@Override
public void setCompareDisplay(Settings.CompareDisplay compareDisplay) {
super.setCompareDisplay(compareDisplay);
axis.setCompareDisplay(compareDisplay);
}
@Override
public void setCompareValueType(Settings.DataType compareValueType) {
super.setCompareValueType(compareValueType);
@ -464,8 +163,6 @@ public class Table2D extends Table {
}
}
this.curScale = curScale;
updateTableLabel();
drawTable();
}
@Override
@ -518,70 +215,5 @@ public class Table2D extends Table {
// TODO: Log Exception.
return false;
}
}
@Override
public void repaint() {
super.repaint();
if(null != axis) {
axis.repaint();
}
}
}
class CopySelection2DWorker extends SwingWorker<Void, Void> {
Table2D table;
Table extendedTable;
public CopySelection2DWorker(Table2D table)
{
this.table = table;
}
@Override
protected Void doInBackground() throws Exception {
table.getAxis().copySelection();
return null;
}
@Override
public void done() {
Window ancestorWindow = SwingUtilities.getWindowAncestor(table);
if(null != ancestorWindow) {
ancestorWindow.setCursor(null);
}
table.setCursor(null);
ECUEditorManager.getECUEditor().setCursor(null);
}
}
class CopyTable2DWorker extends SwingWorker<Void, Void> {
Table2D table;
public CopyTable2DWorker(Table2D table)
{
this.table = table;
}
@Override
protected Void doInBackground() throws Exception {
String tableHeader = table.getSettings().getTable2DHeader();
StringBuffer output = new StringBuffer(tableHeader);
output.append(table.getTableAsString());
//copy to clipboard
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(output.toString()), null);
return null;
}
@Override
public void done() {
Window ancestorWindow = SwingUtilities.getWindowAncestor(table);
if(null != ancestorWindow) {
ancestorWindow.setCursor(null);
}
table.setCursor(null);
ECUEditorManager.getECUEditor().setCursor(null);
}
}
}

View File

@ -18,9 +18,6 @@
*/
package com.romraider.maps;
import static com.romraider.util.ParamChecker.isNullOrEmpty;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
@ -33,7 +30,7 @@ import java.awt.event.KeyListener;
import java.io.IOException;
import java.util.StringTokenizer;
import javax.naming.NameNotFoundException;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
@ -41,27 +38,24 @@ import javax.swing.border.EmptyBorder;
import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.util.SettingsManager;
public class Table2D extends Table {
private static final long serialVersionUID = -7684570967109324784L;
private Table1D axis = new Table1D(Table.TableType.Y_AXIS);
public class Table2DView extends TableView {
private static final long serialVersionUID = -7684570967109324784L;
private JLabel axisLabel;
private Table1DView axis;
private CopyTable2DWorker copyTable2DWorker;
private CopySelection2DWorker copySelection2DWorker;
public Table2D() {
protected Table2DView(Table2D table) {
super(table);
axis = new Table1DView(table.getAxis());
verticalOverhead += 18;
}
@Override
public TableType getType() {
return TableType.TABLE_2D;
}
public Table1D getAxis() {
return axis;
}
public Table1DView getAxis() {
return axis;
}
public JLabel getAxisLabel() {
@ -72,38 +66,11 @@ public class Table2D extends Table {
axisLabel = label;
}
public void setAxis(Table1D axis) {
this.axis = axis;
axis.setAxisParent(this);
}
@Override
public String toString() {
return super.toString() + " (2D)";// + axis;
}
@Override
public void populateCompareValues(Table otherTable) {
if(null == otherTable || !(otherTable instanceof Table2D)) {
return;
}
Table2D compareTable2D = (Table2D) otherTable;
if(data.length != compareTable2D.data.length ||
axis.data.length != compareTable2D.axis.data.length) {
return;
}
super.populateCompareValues(otherTable);
axis.populateCompareValues(compareTable2D.getAxis());
}
@Override
public void refreshCompare() {
populateCompareValues(getCompareTable());
axis.refreshCompare();
}
@Override
public StringBuffer getTableAsString() {
StringBuffer output = new StringBuffer(Settings.BLANK);
@ -120,7 +87,7 @@ public class Table2D extends Table {
if (height < minHeight) {
height = minHeight;
}
int minWidth = isLiveDataSupported() ? minWidthOverlay : minWidthNoOverlay;
int minWidth = table.isLiveDataSupported() ? minWidthOverlay : minWidthNoOverlay;
if (width < minWidth) {
width = minWidth;
}
@ -129,43 +96,36 @@ public class Table2D extends Table {
@Override
public void populateTable(byte[] input, int romRamOffset) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
this.input = input;
centerLayout.setRows(2);
centerLayout.setColumns(this.getDataSize());
try {
axis.populateTable(input, romRamOffset);
super.populateTable(input, romRamOffset);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new ArrayIndexOutOfBoundsException();
}
centerLayout.setColumns(table.getDataSize());
// add to table
for (int i = 0; i < this.getDataSize(); i++) {
for (int i = 0; i < axis.getTable().getDataSize(); i++) {
centerPanel.add(axis.getDataCell(i));
}
if (flip) {
for (int i = this.getDataSize() - 1; i >= 0; i--) {
if (table.flip) {
for (int i = table.getDataSize() - 1; i >= 0; i--) {
centerPanel.add(this.getDataCell(i));
}
} else {
for (int i = 0; i < this.getDataSize(); i++) {
for (int i = 0; i < table.getDataSize(); i++) {
centerPanel.add(this.getDataCell(i));
}
}
if(null == axis.getName() || axis.getName().isEmpty() || Settings.BLANK == axis.getName()) {
;// Do not add label.
} else if(null == axis.getCurrentScale() || "0x" == axis.getCurrentScale().getUnit()) {
} else if(null == axis.getTable().getCurrentScale() || "0x" == axis.getTable().getCurrentScale().getUnit()) {
// static or no scale exists.
axisLabel = new JLabel(axis.getName(), JLabel.CENTER);
add(axisLabel, BorderLayout.NORTH);
} else {
axisLabel = new JLabel(axis.getName() + " (" + axis.getCurrentScale().getUnit() + ")", JLabel.CENTER);
axisLabel = new JLabel(axis.getName() + " (" + axis.getTable().getCurrentScale().getUnit() + ")", JLabel.CENTER);
add(axisLabel, BorderLayout.NORTH);
}
tableLabel = new JLabel(getCurrentScale().getUnit(), JLabel.CENTER);
tableLabel = new JLabel(table.getCurrentScale().getUnit(), JLabel.CENTER);
add(tableLabel, BorderLayout.SOUTH);
axisLabel.setBorder(new EmptyBorder(2, 4, 2, 4));
@ -177,44 +137,64 @@ public class Table2D extends Table {
public void updateTableLabel() {
if(null == axis.getName() || axis.getName().length() < 1 || Settings.BLANK == axis.getName()) {
;// Do not update label.
} else if(null == axis.getCurrentScale() || "0x" == axis.getCurrentScale().getUnit()) {
} else if(null == axis.getTable().getCurrentScale() || "0x" == axis.getTable().getCurrentScale().getUnit()) {
// static or no scale exists.
axisLabel.setText(axis.getName());
} else {
axisLabel.setText(axis.getName() + " (" + axis.getCurrentScale().getUnit() + ")");
axisLabel.setText(axis.getName() + " (" + axis.getTable().getCurrentScale().getUnit() + ")");
}
tableLabel.setText(getCurrentScale().getUnit());
tableLabel.setText(table.getCurrentScale().getUnit());
}
@Override
public void clearSelection() {
axis.clearSelectedData();
clearSelectedData();
public void interpolate() throws UserLevelException {
super.interpolate();
this.getAxis().interpolate();
}
@Override
public void setRevertPoint() {
super.setRevertPoint();
axis.setRevertPoint();
public void verticalInterpolate() throws UserLevelException {
super.verticalInterpolate();
this.getAxis().verticalInterpolate();
}
@Override
public void undoAll() {
super.undoAll();
axis.undoAll();
public void horizontalInterpolate() throws UserLevelException {
int[] coords = { table.getDataSize(), 0};
DataCellView[] tableData = getData();
DataCellView[] axisData = getAxis().getData();
for (int i = 0; i < table.getDataSize(); ++i) {
if (tableData[i].isSelected()) {
if (i < coords[0])
coords[0] = i;
if (i > coords[1])
coords[1] = i;
}
}
if (coords[1] - coords[0] > 1) {
double x, x1, x2, y1, y2;
x1 = axisData[coords[0]].getDataCell().getBinValue();
y1 = tableData[coords[0]].getDataCell().getBinValue();
x2 = axisData[coords[1]].getDataCell().getBinValue();
y2 = tableData[coords[1]].getDataCell().getBinValue();
for (int i = coords[0] + 1; i < coords[1]; ++i) {
x = axisData[i].getDataCell().getBinValue();
data[i].getDataCell().setBinValue(linearInterpolation(x, x1, x2, y1, y2));
}
}
// Interpolate x axis in case the x axis in selected.
this.getAxis().horizontalInterpolate();
}
@Override
public byte[] saveFile(byte[] binData) {
/*
binData = super.saveFile(binData);
binData = axis.saveFile(binData);*/
return binData;
public void clearSelection() {
axis.clearSelection();
clearSelection();
}
@Override
public void addKeyListener(KeyListener listener) {
super.addKeyListener(listener);
@ -290,7 +270,7 @@ public class Table2D extends Table {
@Override
public void startHighlight(int x, int y) {
axis.clearSelectedData();
axis.clearSelection();
super.startHighlight(x, y);
}
@ -320,12 +300,12 @@ public class Table2D extends Table {
}
@Override
public void paste() {
public void paste() throws UserLevelException {
StringTokenizer st = new StringTokenizer(Settings.BLANK);
String input = Settings.BLANK;
try {
input = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor);
st = new StringTokenizer(input, ST_DELIMITER);
st = new StringTokenizer(input, table.ST_DELIMITER);
} catch (UnsupportedFlavorException ex) { /* wrong paste type -- do nothing */
} catch (IOException ex) {
}
@ -359,57 +339,6 @@ public class Table2D extends Table {
}
}
@Override
public void interpolate() {
super.interpolate();
this.getAxis().interpolate();
}
@Override
public void verticalInterpolate() {
super.verticalInterpolate();
this.getAxis().verticalInterpolate();
}
@Override
public void horizontalInterpolate() {
int[] coords = { getDataSize(), 0};
DataCellView[] tableData = getData();
DataCellView[] axisData = getAxis().getData();
for (int i = 0; i < getDataSize(); ++i) {
if (tableData[i].isSelected()) {
if (i < coords[0])
coords[0] = i;
if (i > coords[1])
coords[1] = i;
}
}
if (coords[1] - coords[0] > 1) {
double x, x1, x2, y1, y2;
x1 = axisData[coords[0]].getDataCell().getBinValue();
y1 = tableData[coords[0]].getDataCell().getBinValue();
x2 = axisData[coords[1]].getDataCell().getBinValue();
y2 = tableData[coords[1]].getDataCell().getBinValue();
for (int i = coords[0] + 1; i < coords[1]; ++i) {
x = axisData[i].getDataCell().getBinValue();
data[i].getDataCell().setBinValue(linearInterpolation(x, x1, x2, y1, y2));
}
}
// Interpolate x axis in case the x axis in selected.
this.getAxis().horizontalInterpolate();
}
@Override
public boolean isLiveDataSupported() {
return !isNullOrEmpty(axis.getLogParam());
}
@Override
public boolean isButtonSelected() {
return true;
}
@Override
public void clearLiveDataTrace() {
super.clearLiveDataTrace();
@ -425,13 +354,6 @@ public class Table2D extends Table {
}
}
@Override
public String getLogParamString() {
StringBuilder sb = new StringBuilder();
sb.append(axis.getLogParamString()+ ", ");
sb.append(getName()+ ":" + getLogParam());
return sb.toString();
}
@Override
public void setOverlayLog(boolean overlayLog) {
@ -445,79 +367,9 @@ public class Table2D extends Table {
axis.setCompareDisplay(compareDisplay);
}
@Override
public void setCompareValueType(Settings.DataType compareValueType) {
super.setCompareValueType(compareValueType);
axis.setCompareValueType(compareValueType);
}
@Override
public void setCurrentScale(Scale curScale) {
if(SettingsManager.getSettings().isScaleHeadersAndData() && !axis.isStaticDataTable()) {
try {
this.axis.setScaleByName(curScale.getName());
} catch (NameNotFoundException e) {
try {
this.axis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
} catch (NameNotFoundException e1) {
}
}
}
this.curScale = curScale;
updateTableLabel();
drawTable();
}
@Override
public boolean equals(Object other) {
try {
if(null == other) {
return false;
}
if(other == this) {
return true;
}
if(!(other instanceof Table2D)) {
return false;
}
Table2D otherTable = (Table2D)other;
if( (null == this.getName() && null == otherTable.getName())
|| (this.getName().isEmpty() && otherTable.getName().isEmpty()) ) {
;// Skip name compare if name is null or empty.
} else if (!this.getName().equalsIgnoreCase(otherTable.getName())) {
return false;
}
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].equals(otherTable.data[i])) {
return false;
}
}
return true;
} catch(Exception ex) {
// TODO: Log Exception.
return false;
}
return table.equals(other);
}
@Override
@ -526,14 +378,14 @@ public class Table2D extends Table {
if(null != axis) {
axis.repaint();
}
}
}
}
class CopySelection2DWorker extends SwingWorker<Void, Void> {
Table2D table;
Table extendedTable;
Table2DView table;
TableView extendedTable;
public CopySelection2DWorker(Table2D table)
public CopySelection2DWorker(Table2DView table)
{
this.table = table;
}
@ -556,9 +408,9 @@ class CopySelection2DWorker extends SwingWorker<Void, Void> {
}
class CopyTable2DWorker extends SwingWorker<Void, Void> {
Table2D table;
Table2DView table;
public CopyTable2DWorker(Table2D table)
public CopyTable2DWorker(Table2DView table)
{
this.table = table;
}

File diff suppressed because it is too large Load Diff

View File

@ -55,89 +55,30 @@ import com.romraider.util.SettingsManager;
public class Table3DView extends TableView {
private static final long serialVersionUID = 3103448753263606599L;
private static final ResourceBundle rb = new ResourceUtil().getBundle(
Table3D.class.getName());
private Table1D xAxis = new Table1D(TableType.X_AXIS);
private Table1D yAxis = new Table1D(TableType.Y_AXIS);
private static final ResourceBundle rb = new ResourceUtil().getBundle(Table3D.class.getName());
private Table3D table;
private Table1DView xAxis;
private Table1DView yAxis;
private JLabel xAxisLabel;
private JLabel yAxisLabel;
DataCellView[][] data = new DataCellView[1][1];
private boolean swapXY = false;
private boolean flipX = false;
private boolean flipY = false;
CopyTable3DWorker copyTable3DWorker;
CopySelection3DWorker copySelection3DWorker;
public Table3D() {
public Table3DView(Table3D table) {
super(table);
xAxis = new Table1DView(table.getXAxis());
yAxis = new Table1DView(table.getYAxis());
verticalOverhead += 39;
horizontalOverhead += 10;
}
@Override
public TableType getType() {
return Table.TableType.TABLE_3D;
}
public Table1D getXAxis() {
return xAxis;
}
public void setXAxis(Table1D xAxis) {
this.xAxis = xAxis;
xAxis.setAxisParent(this);
}
public Table1D getYAxis() {
return yAxis;
}
public void setYAxis(Table1D yAxis) {
this.yAxis = yAxis;
yAxis.setAxisParent(this);
}
public boolean getSwapXY() {
return swapXY;
}
public void setSwapXY(boolean swapXY) {
this.swapXY = swapXY;
}
public boolean getFlipX() {
return flipX;
}
public void setFlipX(boolean flipX) {
this.flipX = flipX;
}
public boolean getFlipY() {
return flipY;
}
public void setFlipY(boolean flipY) {
this.flipY = flipY;
}
public void setSizeX(int size) {
data = new DataCellView[size][data[0].length];
centerLayout.setColumns(size + 1);
}
public int getSizeX() {
return data.length;
}
public void setSizeY(int size) {
data = new DataCellView[data.length][size];
centerLayout.setRows(size + 1);
}
public int getSizeY() {
return data[0].length;
public Table3D getTable() {
return table;
}
@Override
@ -155,16 +96,12 @@ public class Table3DView extends TableView {
@Override
public void populateTable(byte[] input, int romRamOffset) throws NullPointerException, ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
this.input = input;
// fill first empty cell
centerPanel.add(new JLabel());
if (!beforeRam) {
this.ramOffset = romRamOffset;
}
/*
// temporarily remove lock
boolean tempLock = locked;
locked = false;
boolean tempLock = table.locked;
table.locked = false;
// populate axes
try {
@ -174,14 +111,14 @@ public class Table3DView extends TableView {
throw new ArrayIndexOutOfBoundsException();
}
for (int x = 0; x < xAxis.getDataSize(); x++) {
for (int x = 0; x < xAxis.getTable().getDataSize(); x++) {
centerPanel.add(xAxis.getDataCell(x));
}
int offset = 0;
int iMax = swapXY ? xAxis.getDataSize() : yAxis.getDataSize();
int jMax = swapXY ? yAxis.getDataSize() : xAxis.getDataSize();
int iMax = swapXY ? xAxis.getTable().getDataSize() : yAxis.getTable().getDataSize();
int jMax = swapXY ? yAxis.getTable().getDataSize() : xAxis.getTable().getDataSize();
for (int i = 0; i < iMax; i++) {
for (int j = 0; j < jMax; j++) {
@ -251,67 +188,33 @@ public class Table3DView extends TableView {
if(xAxisLabel!=null)
xAxisLabel.setBorder(new EmptyBorder(2, 4, 2, 4));
if(presetPanel != null) presetPanel.populatePanel();
calcCellRanges();
if(presetPanel != null) presetPanel.populatePanel();*/
}
@Override
public void updateTableLabel() {
if(null == xAxis.getName() || xAxis.getName().length() < 1 || Settings.BLANK == xAxis.getName()) {
;// Do not update label.
} else if(null == xAxis.getCurrentScale() || "0x" == xAxis.getCurrentScale().getUnit()) {
} else if(null == xAxis.getTable().getCurrentScale() || "0x" == xAxis.getTable().getCurrentScale().getUnit()) {
// static or no scale exists.
xAxisLabel.setText(xAxis.getName());
} else {
xAxisLabel.setText(xAxis.getName() + " (" + xAxis.getCurrentScale().getUnit() + ")");
xAxisLabel.setText(xAxis.getName() + " (" + xAxis.getTable().getCurrentScale().getUnit() + ")");
}
if(null == yAxis.getName() || yAxis.getName().length() < 1 || Settings.BLANK == yAxis.getName()) {
;// Do not update label.
} else if(null == yAxis.getCurrentScale() || "0x" == yAxis.getCurrentScale().getUnit()) {
} else if(null == yAxis.getTable().getCurrentScale() || "0x" == yAxis.getTable().getCurrentScale().getUnit()) {
// static or no scale exists.
yAxisLabel.setText(yAxis.getName());
} else {
yAxisLabel.setText(yAxis.getName() + " (" + yAxis.getCurrentScale().getUnit() + ")");
yAxisLabel.setText(yAxis.getName() + " (" + yAxis.getTable().getCurrentScale().getUnit() + ")");
}
tableLabel.setText(getCurrentScale().getUnit());
}
@Override
public void calcCellRanges() {
double binMax = data[0][0].getDataCell().getBinValue();
double binMin = data[0][0].getDataCell().getBinValue();
double compareMax = data[0][0].getDataCell().getCompareValue();
double compareMin = data[0][0].getDataCell().getCompareValue();
for(DataCellView[] column : data) {
for(DataCellView cell : column) {
// Calc bin
if(binMax < cell.getDataCell().getBinValue()) {
binMax = cell.getDataCell().getBinValue();
}
if(binMin > cell.getDataCell().getBinValue()) {
binMin = cell.getDataCell().getBinValue();
}
// Calc compare
double compareValue = cell.getDataCell().getCompareValue();
if(compareMax < compareValue) {
compareMax = compareValue;
}
if(compareMin > compareValue) {
compareMin = compareValue;
}
}
}
setMaxBin(binMax);
setMinBin(binMin);
setMaxCompare(compareMax);
setMinCompare(compareMin);
tableLabel.setText(table.getCurrentScale().getUnit());
}
@Override
public StringBuffer getTableAsString() {
StringBuffer output = new StringBuffer(Settings.BLANK);
@ -319,23 +222,23 @@ public class Table3DView extends TableView {
output.append(xAxis.getTableAsString());
output.append(Settings.NEW_LINE);
for (int y = 0; y < getSizeY(); y++) {
for (int y = 0; y < table.getSizeY(); y++) {
output.append(NumberUtil.stringValue(yAxis.data[y].getDataCell().getRealValue()));
output.append(Settings.TAB);
for (int x = 0; x < getSizeX(); x++) {
for (int x = 0; x < table.getSizeX(); x++) {
if (overlayLog) {
output.append(data[x][y].getCellText());
}
else {
output.append(NumberUtil.stringValue(data[x][y].getDataCell().getRealValue()));
}
if (x < getSizeX() - 1) {
if (x < table.getSizeX() - 1) {
output.append(Settings.TAB);
}
}
if (y < getSizeY() - 1) {
if (y < table.getSizeY() - 1) {
output.append(Settings.NEW_LINE);
}
}
@ -343,46 +246,6 @@ public class Table3DView extends TableView {
return output;
}
@Override
public void populateCompareValues(Table otherTable) {
if(null == otherTable || !(otherTable instanceof Table3D)) {
return;
}
Table3D compareTable3D = (Table3D) otherTable;
if(data.length != compareTable3D.data.length ||
data[0].length != compareTable3D.data[0].length ||
xAxis.getDataSize() != compareTable3D.xAxis.getDataSize() ||
yAxis.getDataSize() != compareTable3D.yAxis.getDataSize()) {
return;
}
clearLiveDataTrace();
int x=0;
for (DataCellView[] column : data) {
int y = 0;
for(DataCellView cell : column) {
cell.getDataCell().setCompareValue(compareTable3D.data[x][y].getDataCell());
y++;
}
x++;
}
xAxis.populateCompareValues(compareTable3D.getXAxis());
yAxis.populateCompareValues(compareTable3D.getYAxis());
calcCellRanges();
drawTable();
}
@Override
public void refreshCompare() {
populateCompareValues(getCompareTable());
xAxis.refreshCompare();
yAxis.refreshCompare();
}
@Override
public Dimension getFrameSize() {
int height = verticalOverhead + cellHeight * data[0].length;
@ -390,7 +253,7 @@ public class Table3DView extends TableView {
if (height < minHeight) {
height = minHeight;
}
int minWidth = isLiveDataSupported() ? minWidthOverlay : minWidthNoOverlay;
int minWidth = table.isLiveDataSupported() ? minWidthOverlay : minWidthNoOverlay;
if (width < minWidth) {
width = minWidth;
}
@ -410,46 +273,34 @@ public class Table3DView extends TableView {
}
@Override
public void increment(double increment) {
if (!locked) {
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
public void increment(double increment) throws UserLevelException {
for (int x = 0; x < table.getSizeX(); x++) {
for (int y = 0; y < table.getSizeY(); y++) {
if (data[x][y].isSelected()) {
data[x][y].getDataCell().increment(increment);
}
}
}
}
}
@Override
public void multiply(double factor) {
if (!locked) {
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
if (data[x][y].isSelected()) {
if(getCurrentScale().getName().equals("Raw Value"))
data[x][y].getDataCell().multiplyRaw(factor);
else
public void multiply(double factor) throws UserLevelException {
for (int x = 0; x < table.getSizeX(); x++) {
for (int y = 0; y < table.getSizeY(); y++) {
if (data[x][y].isSelected()) {
data[x][y].getDataCell().multiply(factor);
}
}
}
}
}
}
@Override
public void clearSelection() {
xAxis.clearSelectedData();
yAxis.clearSelectedData();
clearSelectedData();
}
@Override
public void clearSelectedData() {
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
xAxis.clearSelection();
yAxis.clearSelection();
for (int x = 0; x < table.getSizeX(); x++) {
for (int y = 0; y < table.getSizeY(); y++) {
data[x][y].setSelected(false);
}
}
@ -458,8 +309,8 @@ public class Table3DView extends TableView {
@Override
public void highlight(int xCoord, int yCoord) {
if (highlight) {
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
for (int x = 0; x < table.getSizeX(); x++) {
for (int y = 0; y < table.getSizeY(); y++) {
if (((y >= highlightY && y <= yCoord) ||
(y <= highlightY && y >= yCoord)) &&
((x >= highlightX && x <= xCoord) ||
@ -477,8 +328,8 @@ public class Table3DView extends TableView {
public void stopHighlight() {
highlight = false;
// loop through, selected and un-highlight
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
for (int x = 0; x < table.getSizeX(); x++) {
for (int y = 0; y < table.getSizeY(); y++) {
if (data[x][y].isHighlighted()) {
data[x][y].setSelected(true);
data[x][y].setHighlighted(false);
@ -488,33 +339,10 @@ public class Table3DView extends TableView {
}
@Override
public void setRevertPoint() {
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
data[x][y].getDataCell().setRevertPoint();
}
}
yAxis.setRevertPoint();
xAxis.setRevertPoint();
}
@Override
public void undoAll() {
public void undoSelected() throws UserLevelException {
clearLiveDataTrace();
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
data[x][y].getDataCell().undo();
}
}
yAxis.undoAll();
xAxis.undoAll();
}
@Override
public void undoSelected() {
clearLiveDataTrace();
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
for (int x = 0; x < table.getSizeX(); x++) {
for (int y = 0; y < table.getSizeY(); y++) {
if (data[x][y].isSelected()) {
data[x][y].getDataCell().undo();
}
@ -522,28 +350,16 @@ public class Table3DView extends TableView {
}
}
@Override
public byte[] saveFile(byte[] binData) {
return binData;
}
@Override
public void setRealValue(String realValue) {
if (!locked && !(userLevel > getSettings().getUserLevel()) ) {
for(DataCellView[] column : data) {
for(DataCellView cell : column) {
if(cell.isSelected()) {
cell.getDataCell().setRealValue(realValue);
}
public void setRealValue(String realValue) throws UserLevelException {
for(DataCellView[] column : data) {
for(DataCellView cell : column) {
if(cell.isSelected()) {
cell.getDataCell().setRealValue(realValue);
}
}
} else if (userLevel > getSettings().getUserLevel()) {
JOptionPane.showMessageDialog(this, MessageFormat.format(
rb.getString("USERLVLTOLOW"), userLevel),
rb.getString("TBLNOTMODIFY"),
JOptionPane.INFORMATION_MESSAGE);
}
xAxis.setRealValue(realValue);
yAxis.setRealValue(realValue);
}
@ -552,8 +368,8 @@ public class Table3DView extends TableView {
public void addKeyListener(KeyListener listener) {
xAxis.addKeyListener(listener);
yAxis.addKeyListener(listener);
for (int x = 0; x < this.getSizeX(); x++) {
for (int y = 0; y < this.getSizeY(); y++) {
for (int x = 0; x < table.getSizeX(); x++) {
for (int y = 0; y < table.getSizeY(); y++) {
data[x][y].addKeyListener(listener);
}
}
@ -565,7 +381,7 @@ public class Table3DView extends TableView {
} else { // y axis
selectCellAt(y, 0);
}
ECUEditorManager.getECUEditor().getTableToolBar().updateTableToolBar(this);
ECUEditorManager.getECUEditor().getTableToolBar().updateTableToolBar(table);
}
public void deSelectCellAt(int x, int y) {
@ -602,7 +418,7 @@ public class Table3DView extends TableView {
@Override
public void cursorDown() {
if (highlightY < getSizeY() - 1 && data[highlightX][highlightY].isSelected()) {
if (highlightY < table.getSizeY() - 1 && data[highlightX][highlightY].isSelected()) {
selectCellAt(highlightX, highlightY + 1);
} else {
xAxis.cursorDown();
@ -624,7 +440,7 @@ public class Table3DView extends TableView {
@Override
public void cursorRight() {
if (highlightX < getSizeX() - 1 && data[highlightX][highlightY].isSelected()) {
if (highlightX < table.getSizeX() - 1 && data[highlightX][highlightY].isSelected()) {
selectCellAt(highlightX + 1, highlightY);
} else {
xAxis.cursorRight();
@ -647,7 +463,7 @@ public class Table3DView extends TableView {
@Override
public void shiftCursorDown() {
if (highlightY < getSizeY() - 1 && data[highlightX][highlightY].isSelected()) {
if (highlightY < table.getSizeY() - 1 && data[highlightX][highlightY].isSelected()) {
selectCellAtWithoutClear(highlightX, highlightY + 1);
} else {
xAxis.shiftCursorDown();
@ -669,7 +485,7 @@ public class Table3DView extends TableView {
@Override
public void shiftCursorRight() {
if (highlightX < getSizeX() - 1 && data[highlightX][highlightY].isSelected()) {
if (highlightX < table.getSizeX() - 1 && data[highlightX][highlightY].isSelected()) {
selectCellAtWithoutClear(highlightX + 1, highlightY);
} else {
xAxis.shiftCursorRight();
@ -679,8 +495,8 @@ public class Table3DView extends TableView {
@Override
public void startHighlight(int x, int y) {
xAxis.clearSelectedData();
yAxis.clearSelectedData();
xAxis.clearSelection();
yAxis.clearSelection();
super.startHighlight(x, y);
}
@ -710,12 +526,12 @@ public class Table3DView extends TableView {
}
@Override
public void paste() {
public void paste() throws UserLevelException {
StringTokenizer st = new StringTokenizer(Settings.BLANK);
String input = Settings.BLANK;
try {
input = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor);
st = new StringTokenizer(input, ST_DELIMITER);
st = new StringTokenizer(input, Table.ST_DELIMITER);
} catch (UnsupportedFlavorException ex) { /* wrong paste type -- do nothing */
} catch (IOException ex) {
}
@ -757,11 +573,11 @@ public class Table3DView extends TableView {
}
}
public void pasteValues() {
public void pasteValues() throws UserLevelException {
StringTokenizer st = new StringTokenizer(Settings.BLANK);
try {
String input = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor);
st = new StringTokenizer(input, ST_DELIMITER);
st = new StringTokenizer(input, Table.ST_DELIMITER);
} catch (UnsupportedFlavorException ex) { /* wrong paste type -- do nothing */
} catch (IOException ex) {
}
@ -778,13 +594,13 @@ public class Table3DView extends TableView {
}
// set values
for (int y = startY; st.hasMoreTokens() && y < getSizeY(); y++) {
for (int y = startY; st.hasMoreTokens() && y < table.getSizeY(); y++) {
String checkToken = st.nextToken(Settings.NEW_LINE);
if (y==startY && checkToken.endsWith("\t")) {
checkToken = st.nextToken(Settings.NEW_LINE);
}
StringTokenizer currentLine = new StringTokenizer(checkToken, ST_DELIMITER);
for (int x = startX; currentLine.hasMoreTokens() && x < getSizeX(); x++) {
StringTokenizer currentLine = new StringTokenizer(checkToken, Table.ST_DELIMITER);
for (int x = startX; currentLine.hasMoreTokens() && x < table.getSizeX(); x++) {
String currentToken = currentLine.nextToken();
try {
@ -797,13 +613,13 @@ public class Table3DView extends TableView {
}
@Override
public void verticalInterpolate() {
int[] coords = { getSizeX(), getSizeY(), 0, 0};
public void verticalInterpolate() throws UserLevelException {
int[] coords = { table.getSizeX(), table.getSizeY(), 0, 0};
DataCellView[][] tableData = get3dData();
DataCellView[] axisData = getYAxis().getData();
DataCellView[] axisData = table.getYAxis().getTableView().getData();
int i, j;
for (i = 0; i < getSizeX(); ++i) {
for (j = 0; j < getSizeY(); ++j) {
for (i = 0; i < table.getSizeX(); ++i) {
for (j = 0; j < table.getSizeY(); ++j) {
if (tableData[i][j].isSelected()) {
if (i < coords[0])
coords[0] = i;
@ -830,17 +646,17 @@ public class Table3DView extends TableView {
}
}
// Interpolate y axis in case the y axis in selected.
this.getYAxis().verticalInterpolate();
table.getYAxis().getTableView().verticalInterpolate();
}
@Override
public void horizontalInterpolate() {
int[] coords = { getSizeX(), getSizeY(), 0, 0 };
public void horizontalInterpolate() throws UserLevelException {
int[] coords = { table.getSizeX(), table.getSizeY(), 0, 0 };
DataCellView[][] tableData = get3dData();
DataCellView[] axisData = getXAxis().getData();
DataCellView[] axisData = table.getXAxis().getTableView().getData();
int i, j;
for (i = 0; i < getSizeX(); ++i) {
for (j = 0; j < getSizeY(); ++j) {
for (i = 0; i < table.getSizeX(); ++i) {
for (j = 0; j < table.getSizeY(); ++j) {
if (tableData[i][j].isSelected()) {
if (i < coords[0])
coords[0] = i;
@ -867,25 +683,15 @@ public class Table3DView extends TableView {
}
}
// Interpolate x axis in case the x axis in selected.
this.getXAxis().horizontalInterpolate();
table.getXAxis().getTableView().horizontalInterpolate();
}
@Override
public void interpolate() {
public void interpolate() throws UserLevelException {
verticalInterpolate();
horizontalInterpolate();
}
@Override
public boolean isLiveDataSupported() {
return !isNullOrEmpty(xAxis.getLogParam()) && !isNullOrEmpty(yAxis.getLogParam());
}
@Override
public boolean isButtonSelected() {
return true;
}
@Override
public void highlightLiveData(String liveValue) {
if (getOverlayLog()) {
@ -915,8 +721,8 @@ public class Table3DView extends TableView {
public void clearLiveDataTrace() {
xAxis.clearLiveDataTrace();
yAxis.clearLiveDataTrace();
for (int x = 0; x < getSizeX(); x++) {
for (int y = 0; y < getSizeY(); y++) {
for (int x = 0; x < table.getSizeX(); x++) {
for (int y = 0; y < table.getSizeY(); y++) {
data[x][y].setLiveDataTrace(false);
data[x][y].setPreviousLiveDataTrace(false);
}
@ -934,51 +740,6 @@ public class Table3DView extends TableView {
yAxis.setCompareDisplay(compareDisplay);
}
@Override
public void setCompareValueType(Settings.DataType compareValueType) {
super.setCompareValueType(compareValueType);
xAxis.setCompareValueType(compareValueType);
yAxis.setCompareValueType(compareValueType);
}
@Override
public void setCurrentScale(Scale curScale) {
if(SettingsManager.getSettings().isScaleHeadersAndData()) {
if(!xAxis.isStaticDataTable()) {
try {
this.xAxis.setScaleByName(curScale.getName());
} catch (NameNotFoundException e) {
try {
this.xAxis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
} catch (NameNotFoundException e1) {
}
}
}
if(!yAxis.isStaticDataTable()) {
try {
this.yAxis.setScaleByName(curScale.getName());
} catch (NameNotFoundException e) {
try {
this.yAxis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
} catch (NameNotFoundException e1) {
}
}
}
}
this.curScale = curScale;
updateTableLabel();
drawTable();
}
@Override
public String getLogParamString() {
StringBuilder sb = new StringBuilder();
sb.append(xAxis.getLogParamString()+", ");
sb.append(yAxis.getLogParamString()+", ");
sb.append(getName()+ ":" + getLogParam());
return sb.toString();
}
@Override
public void setOverlayLog(boolean overlayLog) {
super.setOverlayLog(overlayLog);
@ -988,60 +749,7 @@ public class Table3DView extends TableView {
@Override
public boolean equals(Object other) {
try {
if(null == other) {
return false;
}
if(other == this) {
return true;
}
if(!(other instanceof Table3D)) {
return false;
}
Table3D otherTable = (Table3D)other;
if( (null == this.getName() && null == otherTable.getName())
|| (this.getName().isEmpty() && otherTable.getName().isEmpty()) ) {
;// Skip name compare if name is null or empty.
} else if(!this.getName().equalsIgnoreCase(otherTable.getName())) {
return false;
}
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].equals(otherTable.data[i][j]) ) {
return false;
}
}
}
return true;
} catch(Exception ex) {
// TODO: Log Exception.
return false;
}
return table.equals(other);
}
@Override
@ -1059,11 +767,11 @@ public class Table3DView extends TableView {
}
class CopySelection3DWorker extends SwingWorker<Void, Void> {
Table3D table;
Table3DView tableView;
public CopySelection3DWorker(Table3D table)
public CopySelection3DWorker(Table3DView table)
{
this.table = table;
this.tableView = table;
}
@Override
@ -1072,12 +780,12 @@ class CopySelection3DWorker extends SwingWorker<Void, Void> {
// coords[0] = x min, y min, x max, y max
boolean copy = false;
int[] coords = new int[4];
coords[0] = table.getSizeX();
coords[1] = table.getSizeY();
coords[0] = tableView.getTable().getSizeX();
coords[1] = tableView.getTable().getSizeY();
for (int x = 0; x < table.getSizeX(); x++) {
for (int y = 0; y < table.getSizeY(); y++) {
if (table.get3dData()[x][y].isSelected()) {
for (int x = 0; x < tableView.getTable().getSizeX(); x++) {
for (int y = 0; y < tableView.getTable().getSizeY(); y++) {
if (tableView.get3dData()[x][y].isSelected()) {
if (x < coords[0]) {
coords[0] = x;
copy = true;
@ -1102,8 +810,8 @@ class CopySelection3DWorker extends SwingWorker<Void, Void> {
StringBuffer output = new StringBuffer("[Selection3D]" + Settings.NEW_LINE);
for (int y = coords[1]; y <= coords[3]; y++) {
for (int x = coords[0]; x <= coords[2]; x++) {
if (table.get3dData()[x][y].isSelected()) {
output.append(NumberUtil.stringValue(table.get3dData()[x][y].getDataCell().getRealValue()));
if (tableView.get3dData()[x][y].isSelected()) {
output.append(NumberUtil.stringValue(tableView.get3dData()[x][y].getDataCell().getRealValue()));
} else {
output.append("x"); // x represents non-selected cell
}
@ -1118,47 +826,47 @@ class CopySelection3DWorker extends SwingWorker<Void, Void> {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(String.valueOf(output)), null);
}
} else {
table.getXAxis().copySelection();
table.getYAxis().copySelection();
tableView.getTable().getXAxis().getTableView().copySelection();
tableView.getTable().getYAxis().getTableView().copySelection();
}
return null;
}
@Override
public void done() {
Window ancestorWindow = SwingUtilities.getWindowAncestor(table);
Window ancestorWindow = SwingUtilities.getWindowAncestor(tableView);
if(null != ancestorWindow) {
ancestorWindow.setCursor(null);
}
table.setCursor(null);
tableView.setCursor(null);
ECUEditorManager.getECUEditor().setCursor(null);
}
}
class CopyTable3DWorker extends SwingWorker<Void, Void> {
Table3D table;
Table3DView tableView;
public CopyTable3DWorker(Table3D table)
public CopyTable3DWorker(Table3DView v)
{
this.table = table;
this.tableView = v;
}
@Override
protected Void doInBackground() throws Exception {
String tableHeader = table.getSettings().getTable3DHeader();
String tableHeader = TableView.getSettings().getTable3DHeader();
StringBuffer output = new StringBuffer(tableHeader);
output.append(table.getTableAsString());
output.append(tableView.getTableAsString());
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(String.valueOf(output)), null);
return null;
}
@Override
public void done() {
Window ancestorWindow = SwingUtilities.getWindowAncestor(table);
Window ancestorWindow = SwingUtilities.getWindowAncestor(tableView);
if(null != ancestorWindow){
ancestorWindow.setCursor(null);
}
table.setCursor(null);
tableView.setCursor(null);
ECUEditorManager.getECUEditor().setCursor(null);
}
}

View File

@ -65,7 +65,7 @@ public abstract class TableView extends JPanel implements Serializable {
protected Table table;
protected PresetPanel presetPanel;
protected DataCellView[] data;
protected BorderLayout borderLayout = new BorderLayout();
protected GridLayout centerLayout = new GridLayout(1, 1, 0, 0);
protected JPanel centerPanel = new JPanel(centerLayout);
@ -92,6 +92,7 @@ public abstract class TableView extends JPanel implements Serializable {
protected TableView(Table table) {
this.table = table;
table.setTableView(this);
//Populate Views from table here
@ -297,7 +298,11 @@ public abstract class TableView extends JPanel implements Serializable {
@Override
public void actionPerformed(ActionEvent e) {
paste();
try {
paste();
} catch (UserLevelException e1) {
showInvalidUserLevelPopup(e1);
}
}
};
Action interpolate = new AbstractAction() {
@ -305,7 +310,11 @@ public abstract class TableView extends JPanel implements Serializable {
@Override
public void actionPerformed(ActionEvent e) {
table.interpolate();
try {
interpolate();
} catch (UserLevelException e1) {
showInvalidUserLevelPopup(e1);
}
}
};
Action verticalInterpolate = new AbstractAction() {
@ -313,7 +322,11 @@ public abstract class TableView extends JPanel implements Serializable {
@Override
public void actionPerformed(ActionEvent e) {
table.verticalInterpolate();
try {
verticalInterpolate();
} catch (UserLevelException e1) {
showInvalidUserLevelPopup(e1);
}
}
};
Action horizontalInterpolate = new AbstractAction() {
@ -321,7 +334,11 @@ public abstract class TableView extends JPanel implements Serializable {
@Override
public void actionPerformed(ActionEvent e) {
table.horizontalInterpolate();
try {
horizontalInterpolate();
} catch (UserLevelException e1) {
showInvalidUserLevelPopup(e1);
}
}
};
Action multiplyAction = new AbstractAction() {
@ -475,7 +492,7 @@ public abstract class TableView extends JPanel implements Serializable {
public String toString() {
return table.toString();
}
public void drawTable() {
for(DataCellView cell : data) {
@ -485,6 +502,20 @@ public abstract class TableView extends JPanel implements Serializable {
}
}
public void verticalInterpolate() throws UserLevelException{
}
public void horizontalInterpolate() throws UserLevelException {
}
public void interpolate() throws UserLevelException {
horizontalInterpolate();
}
public double linearInterpolation(double x, double x1, double x2, double y1, double y2) {
return (x1 == x2) ? 0.0 : (y1 + (x - x1) * (y2 - y1) / (x2 - x1));
}
public abstract void populateTable(byte[] input, int romRamOffset);
public Dimension getFrameSize() {
@ -502,7 +533,7 @@ public abstract class TableView extends JPanel implements Serializable {
public void clearSelection() {
for (DataCellView cell : data) {
cell.getDataCell().setSelected(false);
cell.setSelected(false);
}
}
@ -531,7 +562,7 @@ public abstract class TableView extends JPanel implements Serializable {
for (DataCellView cell : data) {
if (cell.isHighlighted()) {
cell.setHighlighted(false);
cell.getDataCell().setSelected(true);
cell.setSelected(true);
}
}
}
@ -551,10 +582,47 @@ public abstract class TableView extends JPanel implements Serializable {
public abstract void shiftCursorLeft();
public abstract void shiftCursorRight();
public void undoSelected() throws UserLevelException {
for (DataCellView cell : data) {
// reset current value to original value
if (cell.isSelected()) {
cell.getDataCell().undo();
}
}
}
public static void showInvalidUserLevelPopup(UserLevelException e) {
JOptionPane.showMessageDialog(null, MessageFormat.format(
rb.getString("USERLVLTOLOW"), e.getLevel()),
rb.getString("TBLNOTMODIFY"),
JOptionPane.INFORMATION_MESSAGE);
}
public void increment(double increment) throws UserLevelException {
for (DataCellView cell : data) {
if (cell.isSelected()) {
cell.getDataCell().increment(increment);
}
}
}
abstract public byte[] saveFile(byte[] binData);
public void multiply(double factor) throws UserLevelException{
for (DataCellView cell : data) {
if (cell.isSelected()) {
cell.getDataCell().multiply(factor);
}
}
}
public void setRealValue(String realValue) throws UserLevelException {
for(DataCellView cell : data) {
if (cell.isSelected()) {
cell.getDataCell().setRealValue(realValue);
}
}
}
@Override
public void addKeyListener(KeyListener listener) {
super.addKeyListener(listener);
@ -568,7 +636,7 @@ public abstract class TableView extends JPanel implements Serializable {
public void selectCellAt(int y) {
if(y >= 0 && y < data.length) {
clearSelection();
data[y].getDataCell().setSelected(true);
data[y].setSelected(true);
highlightY = y;
ECUEditorManager.getECUEditor().getTableToolBar().updateTableToolBar(table);
}
@ -576,7 +644,7 @@ public abstract class TableView extends JPanel implements Serializable {
public void selectCellAtWithoutClear(int y) {
if(y >= 0 && y < data.length) {
data[y].getDataCell().setSelected(true);
data[y].setSelected(true);
highlightY = y;
ECUEditorManager.getECUEditor().getTableToolBar().updateTableToolBar(table);
}
@ -630,7 +698,7 @@ public abstract class TableView extends JPanel implements Serializable {
return data[index].getText();
}
public void pasteValues(String[] input) {
public void pasteValues(String[] input) throws UserLevelException {
//set real values
for (int i = 0; i < input.length; i++) {
try {
@ -640,7 +708,7 @@ public abstract class TableView extends JPanel implements Serializable {
}
}
public void paste() {
public void paste() throws UserLevelException {
// TODO: This sounds like desearialize.
if (!table.isStaticDataTable()) {
StringTokenizer st = new StringTokenizer(Settings.BLANK);
@ -665,7 +733,7 @@ public abstract class TableView extends JPanel implements Serializable {
i++;
}
} else if ("[Selection1D]".equalsIgnoreCase(pasteType)) { // copied selection
if (data[highlightY].getDataCell().isSelected()) {
if (data[highlightY].isSelected()) {
int i = 0;
while (st.hasMoreTokens()) {
String currentToken = st.nextToken();
@ -736,7 +804,6 @@ public abstract class TableView extends JPanel implements Serializable {
}
}
public void highlightLiveData(String liveVal) {
if (getOverlayLog()) {
@ -841,7 +908,7 @@ class CopySelectionWorker extends SwingWorker<Void, Void> {
coords[0] = table.getDataSize();
for (int i = 0; i < table.getDataSize(); i++) {
if (table.getData()[i].isSelected()) {
if (tableView.getData()[i].isSelected()) {
if (i < coords[0]) {
coords[0] = i;
copy = true;
@ -854,7 +921,7 @@ class CopySelectionWorker extends SwingWorker<Void, Void> {
}
//make a string of the selection
for (int i = coords[0]; i <= coords[1]; i++) {
if (table.getData()[i].isSelected()) {
if (tableView.getData()[i].isSelected()) {
output = output + NumberUtil.stringValue(table.getData()[i].getRealValue());
} else {
output = output + "x"; // x represents non-selected cell