logger overlay updated

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@430 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
kascade 2007-01-14 14:06:27 +00:00
parent 423c7e6713
commit 843851bd91
11 changed files with 168 additions and 86 deletions

View File

@ -82,7 +82,6 @@ public class EcuLoggerMenuBar extends JMenuBar implements ActionListener {
add(settingsMenu);
settingsMenu.setMnemonic('E');
logFileLocation.setMnemonic('F');
settingsMenu.add(new JSeparator());
settingsMenu.add(logFileLocation);
logFileLocation.addActionListener(this);

View File

@ -26,14 +26,14 @@ import enginuity.logger.ui.handler.DataUpdateHandler;
import enginuity.maps.Table;
import java.util.ArrayList;
import java.util.Collections;
import static java.util.Collections.synchronizedMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public final class TableUpdateHandler implements DataUpdateHandler {
private static final TableUpdateHandler INSTANCE = new TableUpdateHandler();
private final Map<String, List<Table>> tableMap = Collections.synchronizedMap(new HashMap<String, List<Table>>());
private final Map<String, List<Table>> tableMap = synchronizedMap(new HashMap<String, List<Table>>());
private TableUpdateHandler() {
}

View File

@ -24,6 +24,8 @@ package enginuity.maps;
import enginuity.util.JEPUtil;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.MouseEvent;
@ -49,6 +51,9 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
private double compareValue = 0;
private int compareType = Table.COMPARE_OFF;
private int compareDisplay = Table.COMPARE_ABSOLUTE;
private Border defaultBorder = new LineBorder(Color.BLACK, 1);
private Font defaultFont = new Font("Arial", Font.BOLD, 12);
private Border liveDataTraceBorder = new BevelBorder(BevelBorder.RAISED);
public DataCell() {
}
@ -57,8 +62,8 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
this.scale = scale;
this.setHorizontalAlignment(CENTER);
this.setVerticalAlignment(CENTER);
this.setFont(new Font("Arial", Font.BOLD, 12));
this.setBorder(new LineBorder(Color.BLACK, 1));
this.setFont(defaultFont);
this.setBorder(defaultBorder);
this.setOpaque(true);
this.setVisible(true);
this.addMouseListener(this);
@ -238,7 +243,7 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
if (binValue != getOriginalValue()) {
this.setBorder(new LineBorder(Color.RED, 3));
} else {
this.setBorder(new LineBorder(Color.BLACK, 1));
this.setBorder(defaultBorder);
}
}
@ -332,4 +337,14 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
public double getValue() {
return calcDisplayValue(binValue, table.getScale().getExpression());
}
public void setLiveDataTrace(boolean trace) {
if (trace) {
setBorder(liveDataTraceBorder);
setForeground(Color.RED);
} else {
setBorder(defaultBorder);
setForeground(Color.BLACK);
}
}
}

View File

@ -89,7 +89,8 @@ public abstract class Table extends JPanel implements Serializable {
protected int cellHeight = 18;
protected int cellWidth = 42;
protected int minHeight = 100;
protected int minWidth = 425;
protected int minWidthNoOverlay = 465;
protected int minWidthOverlay = 640;
protected Rom container;
protected int highlightX;
protected int highlightY;
@ -651,6 +652,7 @@ public abstract class Table extends JPanel implements Serializable {
if (height < minHeight) {
height = minHeight;
}
int minWidth = isLiveDataSupported() ? minWidthOverlay : minWidthNoOverlay;
if (width < minWidth) {
width = minWidth;
}
@ -670,8 +672,8 @@ public abstract class Table extends JPanel implements Serializable {
}
} else if (userLevel > settings.getUserLevel()) {
JOptionPane.showMessageDialog(this, "This table can only be modified by users with a userlevel of \n" +
userLevel + " or greater. Click View->User Level to change your userlevel.",
"Table cannot be modified",
userLevel + " or greater. Click View->User Level to change your userlevel.",
"Table cannot be modified",
JOptionPane.INFORMATION_MESSAGE);
}
}
@ -685,8 +687,8 @@ public abstract class Table extends JPanel implements Serializable {
}
} else if (userLevel > settings.getUserLevel()) {
JOptionPane.showMessageDialog(this, "This table can only be modified by users with a userlevel of \n" +
userLevel + " or greater. Click View->User Level to change your userlevel.",
"Table cannot be modified",
userLevel + " or greater. Click View->User Level to change your userlevel.",
"Table cannot be modified",
JOptionPane.INFORMATION_MESSAGE);
}
colorize();
@ -701,8 +703,8 @@ public abstract class Table extends JPanel implements Serializable {
}
} else if (userLevel > settings.getUserLevel()) {
JOptionPane.showMessageDialog(this, "This table can only be modified by users with a userlevel of \n" +
userLevel + " or greater. Click View->User Level to change your userlevel.",
"Table cannot be modified",
userLevel + " or greater. Click View->User Level to change your userlevel.",
"Table cannot be modified",
JOptionPane.INFORMATION_MESSAGE);
}
colorize();
@ -1160,6 +1162,9 @@ public abstract class Table extends JPanel implements Serializable {
public void setOverlayLog(boolean overlayLog) {
this.overlayLog = overlayLog;
if (overlayLog) {
clearLiveDataTrace();
}
}
public void setLiveValue(double liveValue) {
@ -1170,9 +1175,14 @@ public abstract class Table extends JPanel implements Serializable {
return liveValue;
}
public abstract boolean isLiveDataSupported();
protected void highlightLiveData() {
}
public void clearLiveDataTrace() {
}
public double getMin() {
if (getScale().getMin() == 0 && getScale().getMax() == 0) {
double low = Double.MAX_VALUE;

View File

@ -178,4 +178,8 @@ public class Table1D extends Table {
parent.highlightLiveData();
}
}
public boolean isLiveDataSupported() {
return false;
}
}

View File

@ -24,6 +24,7 @@ package enginuity.maps;
import enginuity.Settings;
import enginuity.swing.TableFrame;
import enginuity.util.AxisRange;
import static enginuity.util.ParamChecker.isNullOrEmpty;
import static enginuity.util.TableAxisUtil.getLiveDataRangeForAxis;
import javax.swing.*;
@ -73,6 +74,7 @@ public class Table2D extends Table {
if (height < minHeight) {
height = minHeight;
}
int minWidth = isLiveDataSupported() ? minWidthOverlay : minWidthNoOverlay;
if (width < minWidth) {
width = minWidth;
}
@ -290,7 +292,11 @@ public class Table2D extends Table {
axis.setScaleByName(getScale().getName());
}
public void highlightLiveData() {
public boolean isLiveDataSupported() {
return !isNullOrEmpty(axis.getLogParam());
}
protected void highlightLiveData() {
if (overlayLog && frame.isVisible()) {
AxisRange range = getLiveDataRangeForAxis(axis);
clearSelection();
@ -308,8 +314,15 @@ public class Table2D extends Table {
} else {
highlight(x, y);
}
data[i].setLiveDataTrace(true);
}
stopHighlight();
}
}
public void clearLiveDataTrace() {
for (DataCell cell : data) {
cell.setLiveDataTrace(false);
}
}
}

View File

@ -26,6 +26,7 @@ import enginuity.swing.TableFrame;
import enginuity.swing.VTextIcon;
import enginuity.util.AxisRange;
import static enginuity.util.ColorScaler.getScaledColor;
import static enginuity.util.ParamChecker.isNullOrEmpty;
import static enginuity.util.TableAxisUtil.getLiveDataRangeForAxis;
import enginuity.xml.RomAttributeParser;
@ -338,6 +339,7 @@ public class Table3D extends Table {
if (height < minHeight) {
height = minHeight;
}
int minWidth = isLiveDataSupported() ? minWidthOverlay : minWidthNoOverlay;
if (width < minWidth) {
width = minWidth;
}
@ -875,7 +877,11 @@ public class Table3D extends Table {
}
}
public void highlightLiveData() {
public boolean isLiveDataSupported() {
return !isNullOrEmpty(xAxis.getLogParam()) && !isNullOrEmpty(yAxis.getLogParam());
}
protected void highlightLiveData() {
if (overlayLog && frame.isVisible()) {
AxisRange rangeX = getLiveDataRangeForAxis(xAxis);
AxisRange rangeY = getLiveDataRangeForAxis(yAxis);
@ -889,12 +895,21 @@ public class Table3D extends Table {
} else {
highlight(x, y);
}
data[x][y].setLiveDataTrace(true);
}
}
stopHighlight();
}
}
public void clearLiveDataTrace() {
for (int x = 0; x < getSizeX(); x++) {
for (int y = 0; y < getSizeY(); y++) {
data[x][y].setLiveDataTrace(false);
}
}
}
public void setScaleIndex(int scaleIndex) {
super.setScaleIndex(scaleIndex);
xAxis.setScaleByName(getScale().getName());

View File

@ -128,10 +128,10 @@ public class TableSwitch extends Table {
if (height < minHeight) {
height = minHeight;
}
int minWidth = isLiveDataSupported() ? minWidthOverlay : minWidthNoOverlay;
if (width < minWidth) {
width = minWidth;
}
return new Dimension(width, height);
}
@ -152,4 +152,8 @@ public class TableSwitch extends Table {
public void setAxisColor(Color color) {
}
public boolean isLiveDataSupported() {
return false;
}
}

View File

@ -40,9 +40,9 @@ public class TableFrame extends JInternalFrame implements InternalFrameListener
setFrameIcon(null);
setBorder(BorderFactory.createBevelBorder(0));
setVisible(false);
setJMenuBar(new TableMenuBar(table));
toolBar = new TableToolBar(table, this);
add(toolBar, BorderLayout.NORTH);
setJMenuBar(new TableMenuBar(table));
setDefaultCloseOperation(HIDE_ON_CLOSE);
table.setFrame(this);
addInternalFrameListener(this);

View File

@ -32,7 +32,7 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
private Table table;
private JMenu fileMenu = new JMenu("Table");
private JMenuItem graph = new JMenuItem("View Graph");
private JRadioButtonMenuItem overlay = new JRadioButtonMenuItem("Overlay Log");
//private JRadioButtonMenuItem overlay = new JRadioButtonMenuItem("Overlay Log");
private JMenu compareMenu = new JMenu("Compare");
private JRadioButtonMenuItem compareOriginal = new JRadioButtonMenuItem("Show Changes");
@ -57,11 +57,9 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
private ButtonGroup compareDisplayGroup = new ButtonGroup();
public TableMenuBar(Table table) {
super();
this.table = table;
this.add(fileMenu);
fileMenu.add(graph);
fileMenu.add(overlay);
fileMenu.add(compareMenu);
compareMenu.add(compareOriginal);
compareMenu.add(compareMap);
@ -121,7 +119,6 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
tableProperties.addActionListener(this);
graph.addActionListener(this);
overlay.addActionListener(this);
undoSel.addActionListener(this);
undoAll.addActionListener(this);
revert.addActionListener(this);
@ -130,7 +127,6 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
fileMenu.setMnemonic('F');
fileMenu.setMnemonic('T');
graph.setMnemonic('G');
overlay.setMnemonic('L');
undoSel.setMnemonic('U');
undoAll.setMnemonic('A');
revert.setMnemonic('R');
@ -173,7 +169,7 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
} else if (e.getSource() == compareMap) {
JTableChooser chooser = new JTableChooser();
if (chooser.showChooser(table.getRom().getContainer().getImages(), table.getRom().getContainer(), table) == true) {
if (chooser.showChooser(table.getRom().getContainer().getImages(), table.getRom().getContainer(), table)) {
table.pasteCompare();
table.compare(Table.COMPARE_TABLE);
}
@ -184,9 +180,6 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
} else if (e.getSource() == comparePercent) {
table.setCompareDisplay(Table.COMPARE_PERCENT);
} else if (e.getSource() == overlay) {
table.setOverlayLog(overlay.isSelected());
}
}
}

View File

@ -34,6 +34,7 @@ import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
@ -44,7 +45,7 @@ import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.Vector;
public class TableToolBar extends JToolBar implements MouseListener, ItemListener, GraphDataListener {
public class TableToolBar extends JToolBar implements MouseListener, ItemListener, ActionListener, GraphDataListener {
private JButton incrementFine = new JButton(new ImageIcon("./graphics/icon-incfine.png"));
private JButton decrementFine = new JButton(new ImageIcon("./graphics/icon-decfine.png"));
@ -61,6 +62,9 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
private JComboBox scaleSelection = new JComboBox();
private JCheckBox overlayLog = new JCheckBox("Overlay Log");
private JButton clearOverlay = new JButton("Clear Overlay");
private Table table;
private TableFrame frame;
@ -68,56 +72,68 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
this.table = table;
this.setFrame(frame);
this.setFloatable(false);
this.add(incrementFine);
this.add(decrementFine);
this.add(incrementByFine);
this.add(new JLabel(" "));
this.add(incrementCoarse);
this.add(decrementCoarse);
this.setLayout(new FlowLayout(FlowLayout.LEFT));
this.add(new JLabel(" "));
this.add(incrementByCoarse);
this.add(new JLabel(" "));
this.add(setValueText);
this.add(new JLabel(" "));
this.add(setValue);
this.add(multiply);
this.add(new JLabel(" "));
JPanel finePanel = new JPanel();
finePanel.add(incrementFine);
finePanel.add(decrementFine);
finePanel.add(incrementByFine);
this.add(finePanel);
JPanel coarsePanel = new JPanel();
coarsePanel.add(incrementCoarse);
coarsePanel.add(decrementCoarse);
coarsePanel.add(incrementByCoarse);
this.add(coarsePanel);
JPanel setValuePanel = new JPanel();
setValuePanel.add(setValueText);
setValuePanel.add(setValue);
setValuePanel.add(multiply);
this.add(setValuePanel);
//Only add the 3d button if table includes 3d data
if (table.getType() == Table.TABLE_3D) {
this.add(enable3d);
}
this.add(new JLabel(" "));
//this.add(scaleSelection);
incrementFine.setMaximumSize(new Dimension(33, 33));
if (table.isLiveDataSupported()) {
JPanel liveDataPanel = new JPanel();
liveDataPanel.add(overlayLog);
liveDataPanel.add(clearOverlay);
this.add(liveDataPanel);
}
incrementFine.setPreferredSize(new Dimension(33, 33));
incrementFine.setBorder(new LineBorder(new Color(150, 150, 150), 1));
decrementFine.setMaximumSize(new Dimension(33, 33));
decrementFine.setPreferredSize(new Dimension(33, 33));
decrementFine.setBorder(new LineBorder(new Color(150, 150, 150), 1));
incrementCoarse.setMaximumSize(new Dimension(33, 33));
incrementCoarse.setPreferredSize(new Dimension(33, 33));
incrementCoarse.setBorder(new LineBorder(new Color(150, 150, 150), 1));
decrementCoarse.setMaximumSize(new Dimension(33, 33));
decrementCoarse.setPreferredSize(new Dimension(33, 33));
decrementCoarse.setBorder(new LineBorder(new Color(150, 150, 150), 1));
enable3d.setMaximumSize(new Dimension(33, 33));
enable3d.setPreferredSize(new Dimension(33, 33));
enable3d.setBorder(new LineBorder(new Color(150, 150, 150), 1));
setValue.setMaximumSize(new Dimension(33, 23));
setValue.setPreferredSize(new Dimension(33, 23));
setValue.setBorder(new LineBorder(new Color(150, 150, 150), 1));
multiply.setMaximumSize(new Dimension(33, 23));
multiply.setPreferredSize(new Dimension(33, 23));
multiply.setBorder(new LineBorder(new Color(150, 150, 150), 1));
scaleSelection.setMaximumSize(new Dimension(80, 23));
scaleSelection.setPreferredSize(new Dimension(80, 23));
scaleSelection.setFont(new Font("Tahoma", Font.PLAIN, 11));
clearOverlay.setPreferredSize(new Dimension(75, 23));
clearOverlay.setBorder(new LineBorder(new Color(150, 150, 150), 1));
incrementByFine.setAlignmentX(JTextArea.CENTER_ALIGNMENT);
incrementByFine.setAlignmentY(JTextArea.CENTER_ALIGNMENT);
incrementByFine.setMaximumSize(new Dimension(45, 23));
incrementByFine.setPreferredSize(new Dimension(45, 23));
incrementByCoarse.setAlignmentX(JTextArea.CENTER_ALIGNMENT);
incrementByCoarse.setAlignmentY(JTextArea.CENTER_ALIGNMENT);
incrementByCoarse.setMaximumSize(new Dimension(45, 23));
incrementByCoarse.setPreferredSize(new Dimension(45, 23));
setValueText.setAlignmentX(JTextArea.CENTER_ALIGNMENT);
setValueText.setAlignmentY(JTextArea.CENTER_ALIGNMENT);
setValueText.setMaximumSize(new Dimension(45, 23));
setValueText.setPreferredSize(new Dimension(45, 23));
incrementFine.setToolTipText("Increment Value (Fine)");
decrementFine.setToolTipText("Decrement Value (Fine)");
@ -129,6 +145,8 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
incrementByFine.setToolTipText("Fine Value Adjustment");
incrementByCoarse.setToolTipText("Coarse Value Adjustment");
multiply.setToolTipText("Multiply Value");
overlayLog.setToolTipText("Enable Overlay Of Real Time Log Data");
clearOverlay.setToolTipText("Clear Log Data Overlay Highlights");
incrementFine.addMouseListener(this);
decrementFine.addMouseListener(this);
@ -138,6 +156,8 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
setValue.addMouseListener(this);
multiply.addMouseListener(this);
scaleSelection.addItemListener(this);
overlayLog.addItemListener(this);
clearOverlay.addActionListener(this);
try {
incrementByFine.setValue(Math.abs(table.getScale().getFineIncrement()));
@ -323,7 +343,6 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
System.out.println("Scale: " + maxV + "," + minV);
//***********
//Render 3d
Graph3dFrameManager.openGraph3dFrame(graphValues, minV, maxV, xValues, yValues, xLabel, yLabel, zLabel, table.getName());
GraphData.addGraphDataListener(this);
@ -380,9 +399,19 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
}
public void itemStateChanged(ItemEvent e) {
// scale changed
if (e.getSource() == scaleSelection) {
// scale changed
table.setScaleIndex(scaleSelection.getSelectedIndex());
} else if (e.getSource() == overlayLog) {
// enable/disable log overlay and live data display
table.setOverlayLog(overlayLog.isSelected());
}
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == clearOverlay) {
// clear log overlay
table.clearLiveDataTrace();
}
}