Editor Updates:

- Added log param to table properties.
 - Updated live data overlay functionality.
This commit is contained in:
Scotthew 2014-01-04 22:29:53 -08:00
parent bce412bf9c
commit 3def3b1663
8 changed files with 238 additions and 167 deletions

View File

@ -143,6 +143,12 @@ public class Settings implements Serializable {
public static String METRIC_SCALE = "Metric";
public static String STANDARD_SCALE = "Standard";
/* DataCell Colors */
public static final Color scaleTextColor = new Color(0, 0, 0);
public static final Color highlightTextColor = new Color(255, 255, 255);
public static final Color selectTextColor = new Color(0, 0, 0);
public static final Color liveDataTraceTextColor = new Color(105, 105, 105);
private static final String ISO15765 = "ISO15765";
private static final String ISO9141 = "ISO9141";
private static final String SYSTEM_NUMFORMAT = "system";
@ -175,6 +181,7 @@ public class Settings implements Serializable {
private Color selectColor = new Color(204, 204, 204);
private Color highlightColor = new Color(27, 161, 226);
private Color liveValueColor = new Color (255, 255, 0);
private Color decreaseBorder = new Color(0, 0, 255);
private Color increaseBorder = new Color(255, 0, 0);
@ -363,6 +370,14 @@ public class Settings implements Serializable {
this.highlightColor = highlightColor;
}
public Color getliveValueColor() {
return this.liveValueColor;
}
public void setLiveValueColor(Color liveValueColor) {
this.liveValueColor = liveValueColor;
}
public Color getSelectColor() {
return selectColor;
}

View File

@ -50,11 +50,6 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
private final Table table;
private final Color scaleTextColor = new Color(0, 0, 0);
private final Color highlightTextColor = new Color(255, 255, 255);
private final Color selectTextColor = new Color(0, 0, 0);
private final Color liveDataTraceTextColor = new Color(229, 20, 0);
private Boolean selected = false;
private Boolean highlighted = false;
private Boolean traced = false;
@ -65,7 +60,7 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
private double binValue = 0.0;
private double originalValue = 0.0;
private double compareToValue = 0.0;
private String liveValue = "";
private String liveValue = Settings.BLANK;
private final Color defaultBorderColor = new Color(0, 0, 0);
private final Color increaseBorderColor = getSettings().getIncreaseBorder();
@ -217,13 +212,21 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
Color textColor;
if(traced) {
textColor = liveDataTraceTextColor;
if(!getLiveValue().isEmpty()) {
if(table instanceof Table1D) {
textColor = Settings.scaleTextColor;
} else {
textColor = Settings.liveDataTraceTextColor;
}
} else {
textColor = Settings.scaleTextColor;
}
} else if (highlighted) {
textColor = highlightTextColor;
textColor = Settings.highlightTextColor;
} else if (selected) {
textColor = selectTextColor;
textColor = Settings.selectTextColor;
} else {
textColor = scaleTextColor;
textColor = Settings.scaleTextColor;
}
return textColor;
@ -231,20 +234,24 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
private Border getCellBorder() {
Border border;
double checkValue;
if(null == table.getCompareTable()) {
checkValue= originalValue;
if(traced) {
border = createLineBorder(getSettings().getliveValueColor(), 2);
} else {
checkValue = compareToValue;
}
double checkValue;
if (checkValue < binValue) {
border = createLineBorder(increaseBorderColor, 2);
} else if (checkValue > binValue) {
border = createLineBorder(decreaseBorderColor, 2);
} else {
border = createLineBorder(defaultBorderColor, 1);
if(null == table.getCompareTable()) {
checkValue= originalValue;
} else {
checkValue = compareToValue;
}
if (checkValue < binValue) {
border = createLineBorder(increaseBorderColor, 2);
} else if (checkValue > binValue) {
border = createLineBorder(decreaseBorderColor, 2);
} else {
border = createLineBorder(defaultBorderColor, 1);
}
}
return border;
@ -271,7 +278,9 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
}
if(traced) {
displayString = displayString + (isNullOrEmpty(liveValue) ? "" : (':' + liveValue));
if(!(table instanceof Table1D)) {
displayString = displayString + (isNullOrEmpty(liveValue) ? Settings.BLANK : (':' + liveValue));
}
}
return displayString;
}
@ -284,6 +293,10 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
return Double.toString(getRealValue());
}
private String getLiveValue() {
return this.liveValue;
}
public void setBinValue(double newBinValue) {
if(binValue == newBinValue) {
return;
@ -463,14 +476,6 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
}
}
public double getLiveDataTraceValue() {
try {
return Double.parseDouble(liveValue);
} catch (NumberFormatException e) {
return 0.0;
}
}
private Settings getSettings() {
return SettingsManager.getSettings();
}

View File

@ -111,6 +111,8 @@ public abstract class Table extends JPanel implements Serializable {
protected int compareValueType = Settings.DATA_TYPE_BIN;
protected boolean staticDataTable = false;
protected String liveAxisValue = Settings.BLANK;
protected int liveDataIndex = 0;
private Table compareTable = null;
@ -1217,14 +1219,75 @@ public abstract class Table extends JPanel implements Serializable {
return this.overlayLog;
}
public double getLiveAxisValue() {
try {
return Double.parseDouble(liveAxisValue);
} catch (NumberFormatException e) {
return 0.0;
}
}
public abstract boolean isLiveDataSupported();
public abstract boolean isButtonSelected();
public void highlightLiveData(String liveValue) {
public void highlightLiveData(String liveVal) {
if (getOverlayLog()) {
double liveValue = 0.0;
try{
liveValue = Double.parseDouble(liveVal);
} catch(NumberFormatException nex) {
return;
}
int startIdx = data.length;
for (int i = 0; i < data.length; i++) {
double currentValue = data[i].getRealValue();
if (liveValue == currentValue) {
startIdx = i;
break;
} else if (liveValue < currentValue){
startIdx = i-1;
break;
}
}
setLiveDataIndex(startIdx);
DataCell cell = data[getLiveDataIndex()];
cell.setLiveDataTrace(true);
cell.setLiveDataTraceValue(liveVal);
getToolbar().setLiveDataValue(liveVal);
}
}
public void updateLiveDataHighlight() {
if (getOverlayLog()) {
data[getLiveDataIndex()].setLiveDataTrace(true);
}
}
public int getLiveDataIndex() {
return liveDataIndex;
}
public void setLiveDataIndex(int index) {
if (index < 0) {
index = 0;
}
if (index >= data.length) {
index = data.length - 1;
}
this.liveDataIndex = index;
}
public void clearLiveDataTrace() {
for (DataCell cell : data) {
cell.setLiveDataTrace(false);
}
}
public String getLogParamString() {
return getName()+ ":" + getLogParam();
}
public Table getCompareTable() {

View File

@ -182,6 +182,37 @@ public class Table1D extends Table {
return data[index].getText();
}
@Override
public void highlightLiveData(String liveVal) {
if (getOverlayLog()) {
double liveValue = 0.0;
try{
liveValue = Double.parseDouble(liveVal);
} catch(NumberFormatException nex) {
return;
}
int startIdx = data.length;
for (int i = 0; i < data.length; i++) {
double currentValue = data[i].getRealValue();
if (liveValue == currentValue) {
startIdx = i;
break;
} else if (liveValue < currentValue){
startIdx = i-1;
break;
}
}
setLiveDataIndex(startIdx);
DataCell cell = data[getLiveDataIndex()];
cell.setLiveDataTrace(true);
cell.setLiveDataTraceValue(liveVal);
getToolbar().setLiveDataValue(liveVal);
}
getAxisParent().updateLiveDataHighlight();
}
@Override
public boolean isLiveDataSupported() {
return false;

View File

@ -20,7 +20,6 @@
package com.romraider.maps;
import static com.romraider.util.ParamChecker.isNullOrEmpty;
import static com.romraider.util.TableAxisUtil.getLiveDataRangeForAxis;
import java.awt.BorderLayout;
import java.awt.Cursor;
@ -41,7 +40,6 @@ import javax.swing.SwingWorker;
import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.util.AxisRange;
import com.romraider.util.SettingsManager;
public class Table2D extends Table {
@ -316,37 +314,32 @@ public class Table2D extends Table {
}
@Override
public void highlightLiveData(String liveValue) {
if (overlayLog) {
AxisRange range = getLiveDataRangeForAxis(axis);
clearSelection();
boolean first = true;
for (int i = range.getStartIndex(); i <= range.getEndIndex(); i++) {
int x = 0;
int y = i;
if (axis.getType() == Settings.TABLE_X_AXIS) {
x = i;
y = 0;
}
if (first) {
startHighlight(x, y);
first = false;
} else {
highlight(x, y);
}
DataCell cell = data[i];
cell.setLiveDataTrace(true);
cell.setLiveDataTraceValue(liveValue);
}
stopHighlight();
getToolbar().setLiveDataValue(liveValue);
public void clearLiveDataTrace() {
super.clearLiveDataTrace();
axis.clearLiveDataTrace();
}
@Override
public void updateLiveDataHighlight() {
if (getOverlayLog()) {
data[axis.getLiveDataIndex()].setLiveDataTrace(true);
}
}
@Override
public void clearLiveDataTrace() {
for (DataCell cell : data) {
cell.setLiveDataTrace(false);
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);
if (overlayLog) {
axis.clearLiveDataTrace();
}
}

View File

@ -20,7 +20,6 @@
package com.romraider.maps;
import static com.romraider.util.ParamChecker.isNullOrEmpty;
import static com.romraider.util.TableAxisUtil.getLiveDataRangeForAxis;
import java.awt.BorderLayout;
import java.awt.Color;
@ -46,7 +45,6 @@ import javax.swing.SwingWorker;
import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.logger.ecu.ui.swing.vertical.VerticalLabelUI;
import com.romraider.util.AxisRange;
import com.romraider.util.SettingsManager;
import com.romraider.xml.RomAttributeParser;
@ -794,30 +792,27 @@ public class Table3D extends Table {
@Override
public void highlightLiveData(String liveValue) {
if (overlayLog) {
AxisRange rangeX = getLiveDataRangeForAxis(xAxis);
AxisRange rangeY = getLiveDataRangeForAxis(yAxis);
clearSelection();
boolean first = true;
for (int x = rangeX.getStartIndex(); x <= rangeX.getEndIndex(); x++) {
for (int y = rangeY.getStartIndex(); y <= rangeY.getEndIndex(); y++) {
if (first) {
startHighlight(x, y);
first = false;
} else {
highlight(x, y);
}
DataCell cell = data[x][y];
cell.setLiveDataTrace(true);
cell.setLiveDataTraceValue(liveValue);
}
}
stopHighlight();
int x = xAxis.getLiveDataIndex();
int y = yAxis.getLiveDataIndex();
DataCell cell = data[x][y];
cell.setLiveDataTrace(true);
cell.setLiveDataTraceValue(liveValue);
getToolbar().setLiveDataValue(liveValue);
}
}
public void updateLiveDataHighlight() {
if (overlayLog) {
int x = xAxis.getLiveDataIndex();
int y = yAxis.getLiveDataIndex();
data[x][y].setLiveDataTrace(true);
}
}
@Override
public void clearLiveDataTrace() {
xAxis.clearLiveDataTrace();
yAxis.clearLiveDataTrace();
for (int x = 0; x < getSizeX(); x++) {
for (int y = 0; y < getSizeY(); y++) {
data[x][y].setLiveDataTrace(false);
@ -860,6 +855,26 @@ public class Table3D extends Table {
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);
xAxis.setOverlayLog(overlayLog);
yAxis.setOverlayLog(overlayLog);
if (overlayLog) {
xAxis.clearLiveDataTrace();
yAxis.clearLiveDataTrace();
}
}
@Override
public boolean equals(Object other) {
try {

View File

@ -21,6 +21,7 @@ package com.romraider.swing;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.LayoutStyle.ComponentPlacement;
@ -87,6 +88,7 @@ public class TablePropertyPanel extends javax.swing.JPanel {
userLevel.setText("Debug");
}
lblTableLogID.setText(table.getLogParamString());
}
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
@ -228,28 +230,33 @@ public class TablePropertyPanel extends javax.swing.JPanel {
userLevel.setText("Beginner");
lblLogId = new JLabel("Log Param:");
lblTableLogID = new JLabel();
GroupLayout layout = new GroupLayout(this);
layout.setHorizontalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
.addComponent(jPanel3, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(lblCategory)
.addComponent(lblTable))
.addComponent(lblTable)
.addComponent(lblLogId))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createParallelGroup(Alignment.TRAILING)
.addComponent(tableName, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
.addComponent(category, GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
.addComponent(lblTableLogID, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addComponent(category)
.addGap(110)
.addComponent(jLabel5)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(userLevel))
.addComponent(tableName, GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)))
.addComponent(jPanel2, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(userLevel, GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE))
.addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
.addComponent(jPanel2, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
.addComponent(jPanel3, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
@ -262,16 +269,22 @@ public class TablePropertyPanel extends javax.swing.JPanel {
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblCategory)
.addComponent(category)
.addComponent(jLabel5)
.addComponent(userLevel))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jPanel2, GroupLayout.PREFERRED_SIZE, 89, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jPanel3, GroupLayout.PREFERRED_SIZE, 136, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addComponent(category))
.addGap(4)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblLogId)
.addComponent(lblTableLogID))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(userLevel))
.addGap(5)
.addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jPanel2, GroupLayout.PREFERRED_SIZE, 89, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jPanel3, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE)
.addGap(23))
);
this.setLayout(layout);
}// </editor-fold>//GEN-END:initComponents
@ -294,4 +307,6 @@ public class TablePropertyPanel extends javax.swing.JPanel {
private javax.swing.JLabel userLevel;
private JTextPane textPaneScales;
private JScrollPane scrollPane;
private JLabel lblLogId;
private JLabel lblTableLogID;
}

View File

@ -1,66 +0,0 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.util;
import com.romraider.maps.DataCell;
import com.romraider.maps.Table1D;
public final class TableAxisUtil {
private TableAxisUtil() {
}
public static AxisRange getLiveDataRangeForAxis(Table1D axis) {
int startIdx = 0;
int endIdx = 0;
DataCell[] data = axis.getData();
for (int i = 0; i < data.length; i++) {
DataCell cell = data[i];
double axisValue = cell.getRealValue();
double liveValue = cell.getLiveDataTraceValue();
if (liveValue == axisValue) {
startIdx = i;
endIdx = i;
break;
} else if (liveValue < axisValue) {
startIdx = i - 1;
endIdx = i;
break;
} else {
startIdx = i;
endIdx = i + 1;
}
}
if (startIdx < 0) {
startIdx = 0;
}
if (startIdx >= data.length) {
startIdx = data.length - 1;
}
if (endIdx < 0) {
endIdx = 0;
}
if (endIdx >= data.length) {
endIdx = data.length - 1;
}
return new AxisRange(startIdx, endIdx);
}
}