mirror of https://github.com/rusefi/RomRaider.git
Getting closer.
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@535 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
6ef7c12a0a
commit
d6c263ea09
|
@ -14,6 +14,7 @@ import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
import enginuity.Settings;
|
import enginuity.Settings;
|
||||||
|
import enginuity.logger.utec.gui.mapTabs.DataManager;
|
||||||
import enginuity.logger.utec.gui.mapTabs.MapJPanel;
|
import enginuity.logger.utec.gui.mapTabs.MapJPanel;
|
||||||
import enginuity.logger.utec.gui.realtimeData.*;
|
import enginuity.logger.utec.gui.realtimeData.*;
|
||||||
import enginuity.logger.utec.gui.bottomControl.*;
|
import enginuity.logger.utec.gui.bottomControl.*;
|
||||||
|
@ -133,6 +134,9 @@ public class JutecGUI extends JFrame implements ActionListener,
|
||||||
fileMenu.add(exitItem);
|
fileMenu.add(exitItem);
|
||||||
menuBar.add(fileMenu);
|
menuBar.add(fileMenu);
|
||||||
|
|
||||||
|
// ****************************************
|
||||||
|
// Add menu item to pull maps from the utec
|
||||||
|
// ****************************************
|
||||||
JMenu getMapsMenu = new JMenu("Load Map");
|
JMenu getMapsMenu = new JMenu("Load Map");
|
||||||
loadMapOne.addActionListener(this);
|
loadMapOne.addActionListener(this);
|
||||||
loadMapTwo.addActionListener(this);
|
loadMapTwo.addActionListener(this);
|
||||||
|
@ -146,9 +150,9 @@ public class JutecGUI extends JFrame implements ActionListener,
|
||||||
getMapsMenu.add(loadMapFive);
|
getMapsMenu.add(loadMapFive);
|
||||||
menuBar.add(getMapsMenu);
|
menuBar.add(getMapsMenu);
|
||||||
|
|
||||||
// ----------------------------------
|
// ***************************************
|
||||||
// Add a menu item for comm port selection
|
// Add a menu item for comm port selection
|
||||||
// ----------------------------------
|
// ***************************************
|
||||||
JMenu portsMenu = new JMenu("Ports");
|
JMenu portsMenu = new JMenu("Ports");
|
||||||
|
|
||||||
// Gather list of ports from interface
|
// Gather list of ports from interface
|
||||||
|
@ -170,6 +174,7 @@ public class JutecGUI extends JFrame implements ActionListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
menuBar.add(portsMenu);
|
menuBar.add(portsMenu);
|
||||||
|
|
||||||
|
|
||||||
// Add menu item to the JFrame
|
// Add menu item to the JFrame
|
||||||
this.setJMenuBar(menuBar);
|
this.setJMenuBar(menuBar);
|
||||||
|
@ -325,6 +330,7 @@ public class JutecGUI extends JFrame implements ActionListener,
|
||||||
// Close out the application
|
// Close out the application
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Only non explicitly defined actions are those generated by ports.
|
// Only non explicitly defined actions are those generated by ports.
|
||||||
// Since an arbitrary machine could have any number of serial ports
|
// Since an arbitrary machine could have any number of serial ports
|
||||||
|
@ -368,9 +374,7 @@ public class JutecGUI extends JFrame implements ActionListener,
|
||||||
public void mapRetrieved(UtecMapData theMap) {
|
public void mapRetrieved(UtecMapData theMap) {
|
||||||
System.out.println("@@@@@@@@@@@@@@@@@@ Got a map from the utec:" + theMap.getMapName());
|
System.out.println("@@@@@@@@@@@@@@@@@@ Got a map from the utec:" + theMap.getMapName());
|
||||||
this.currentMap = theMap;
|
this.currentMap = theMap;
|
||||||
this.boostMapPanel.updateData(theMap);
|
DataManager.setCurrentMap(theMap);
|
||||||
this.fuelMapPanel.updateData(theMap);
|
|
||||||
this.timingMapPanel.updateData(theMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyPressed(KeyEvent arg0) {
|
public void keyPressed(KeyEvent arg0) {
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package enginuity.logger.utec.gui.mapTabs;
|
||||||
|
|
||||||
|
import enginuity.logger.utec.mapData.UtecMapData;
|
||||||
|
|
||||||
|
public class DataManager {
|
||||||
|
private static UtecMapData currentData = null;
|
||||||
|
|
||||||
|
|
||||||
|
private static UtecTableModel fuelListener = null;
|
||||||
|
private static UtecTableModel timingListener = null;
|
||||||
|
private static UtecTableModel boostListener = null;
|
||||||
|
|
||||||
|
|
||||||
|
public static void setCurrentMap(UtecMapData newUtecMap){
|
||||||
|
currentData = newUtecMap;
|
||||||
|
fuelListener.replaceData(currentData.getFuelMap());
|
||||||
|
boostListener.replaceData(currentData.getBoostMap());
|
||||||
|
timingListener.replaceData(currentData.getTimingMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setBoostListener(UtecTableModel boostListener) {
|
||||||
|
DataManager.boostListener = boostListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setFuelListener(UtecTableModel fuelListener) {
|
||||||
|
DataManager.fuelListener = fuelListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setTimingListener(UtecTableModel timingListener) {
|
||||||
|
DataManager.timingListener = timingListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,8 @@ import java.awt.Dimension;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.event.TableModelEvent;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
import enginuity.logger.utec.mapData.UtecMapData;
|
import enginuity.logger.utec.mapData.UtecMapData;
|
||||||
|
|
||||||
|
@ -17,20 +19,29 @@ public class MapJPanel extends JPanel{
|
||||||
|
|
||||||
private int mapType = 0;
|
private int mapType = 0;
|
||||||
|
|
||||||
private UtecTableModel tableModel = new UtecTableModel();
|
private UtecTableModel tableModel = null;
|
||||||
|
|
||||||
|
private UtecJTable table = null;
|
||||||
|
|
||||||
public MapJPanel(int mapType){
|
public MapJPanel(int mapType){
|
||||||
super(new BorderLayout());
|
super(new BorderLayout());
|
||||||
|
|
||||||
this.mapType = mapType;
|
this.mapType = mapType;
|
||||||
|
|
||||||
|
double[][] initialData = new double[11][40];
|
||||||
|
for(int i=0; i < 40; i++){
|
||||||
|
for(int j = 0; j < 11 ; j++){
|
||||||
|
initialData[j][i] = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.tableModel = new UtecTableModel(this.mapType, initialData);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
JTable table = new JTable(tableModel);
|
table = new UtecJTable(tableModel, mapType);
|
||||||
//table.setPreferredScrollableViewportSize(new Dimension(500, 70));
|
//table.setPreferredScrollableViewportSize(new Dimension(500, 70));
|
||||||
|
|
||||||
//Create the scroll pane and add the table to it.
|
//Create the scroll pane and add the table to it.
|
||||||
|
@ -43,20 +54,21 @@ public class MapJPanel extends JPanel{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateData(UtecMapData utecMapData){
|
public void updateDaa(UtecMapData utecMapData){
|
||||||
if(this.mapType == MapJPanel.FUELMAP){
|
if(this.mapType == MapJPanel.FUELMAP){
|
||||||
System.out.println("Updating fuel map now.");
|
System.out.println("Updating fuel map now.");
|
||||||
this.tableModel.replaceData(utecMapData.getFuelMap());
|
//this.table.setModel(new UtecTableModel(this.mapType, utecMapData));
|
||||||
|
//this.tableModel.replaceData(utecMapData.getFuelMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.mapType == MapJPanel.TIMINGMAP){
|
if(this.mapType == MapJPanel.TIMINGMAP){
|
||||||
System.out.println("Updating timing map now.");
|
System.out.println("Updating timing map now.");
|
||||||
this.tableModel.replaceData(utecMapData.getTimingMap());
|
//this.tableModel.replaceData(utecMapData.getTimingMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.mapType == MapJPanel.BOOSTMAP){
|
if(this.mapType == MapJPanel.BOOSTMAP){
|
||||||
System.out.println("Updating boost map now.");
|
System.out.println("Updating boost map now.");
|
||||||
this.tableModel.replaceData(utecMapData.getBoostMap());
|
//this.tableModel.replaceData(utecMapData.getBoostMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package enginuity.logger.utec.gui.mapTabs;
|
||||||
|
|
||||||
|
import javax.swing.JTable;
|
||||||
|
|
||||||
|
public class UtecJTable extends JTable{
|
||||||
|
|
||||||
|
public UtecJTable(UtecTableModel theModel, int modelType){
|
||||||
|
super(theModel);
|
||||||
|
if(modelType == MapJPanel.FUELMAP){
|
||||||
|
System.out.println("Setting the fuel listener");
|
||||||
|
DataManager.setFuelListener(theModel);
|
||||||
|
}
|
||||||
|
else if(modelType == MapJPanel.BOOSTMAP){
|
||||||
|
DataManager.setBoostListener(theModel);
|
||||||
|
}
|
||||||
|
else if(modelType == MapJPanel.TIMINGMAP){
|
||||||
|
DataManager.setTimingListener(theModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateData(double[][] newData){
|
||||||
|
System.out.println("Hi ya spanky");
|
||||||
|
((UtecTableModel)this.dataModel).replaceData(newData);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,12 @@ public class UtecTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
private double[][] data = new double[11][40];
|
private double[][] data = new double[11][40];
|
||||||
|
|
||||||
public UtecTableModel() {
|
String test = "";
|
||||||
|
|
||||||
|
public UtecTableModel(int identifier, double[][] initialData) {
|
||||||
|
|
||||||
|
this.data = initialData;
|
||||||
|
|
||||||
for (int i = 0; i < columnNames.length; i++) {
|
for (int i = 0; i < columnNames.length; i++) {
|
||||||
columnNames[i] = i + "";
|
columnNames[i] = i + "";
|
||||||
}
|
}
|
||||||
|
@ -23,6 +28,7 @@ public class UtecTableModel extends AbstractTableModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getValueAt(int row, int col) {
|
public Object getValueAt(int row, int col) {
|
||||||
|
System.out.println(test+"->("+row+","+col+") "+data[col][row]);
|
||||||
return data[col][row];
|
return data[col][row];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +40,9 @@ public class UtecTableModel extends AbstractTableModel {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setValueAt(Object value, int row, int col) {
|
public void setValueAt(Object value, int row, int col) {
|
||||||
System.out.println("Updated:"+(String)value);
|
System.out.print(" Updated:"+(String)value+": ");
|
||||||
// Set new data in table
|
// Set new data in table
|
||||||
double temp = data[col][row];
|
double temp = data[col][row];
|
||||||
|
|
||||||
|
@ -45,22 +52,14 @@ public class UtecTableModel extends AbstractTableModel {
|
||||||
System.out.println("Not a valid number entered.");
|
System.out.println("Not a valid number entered.");
|
||||||
}
|
}
|
||||||
data[col][row] = temp;
|
data[col][row] = temp;
|
||||||
fireTableCellUpdated(row, col);
|
this.fireTableDataChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void replaceData(double[][] newData){
|
public void replaceData(double[][] newData){
|
||||||
System.out.println("Model data being replaced in full.");
|
System.out.println("Model data being replaced in full.");
|
||||||
|
this.data = newData;
|
||||||
for(int j = 0; j < 40; j++){
|
this.fireTableDataChanged();
|
||||||
for(int i = 0; i < 11; i++){
|
|
||||||
System.out.print(newData[i][j]+", ");
|
|
||||||
//this.data[i][j] = newData[i][j];
|
|
||||||
this.setValueAt(newData[i][j]+"", j, i);
|
|
||||||
}
|
|
||||||
System.out.print("\n");
|
|
||||||
}
|
|
||||||
//this.fireTableDataChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue