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 enginuity.Settings;
|
||||
import enginuity.logger.utec.gui.mapTabs.DataManager;
|
||||
import enginuity.logger.utec.gui.mapTabs.MapJPanel;
|
||||
import enginuity.logger.utec.gui.realtimeData.*;
|
||||
import enginuity.logger.utec.gui.bottomControl.*;
|
||||
|
@ -133,6 +134,9 @@ public class JutecGUI extends JFrame implements ActionListener,
|
|||
fileMenu.add(exitItem);
|
||||
menuBar.add(fileMenu);
|
||||
|
||||
// ****************************************
|
||||
// Add menu item to pull maps from the utec
|
||||
// ****************************************
|
||||
JMenu getMapsMenu = new JMenu("Load Map");
|
||||
loadMapOne.addActionListener(this);
|
||||
loadMapTwo.addActionListener(this);
|
||||
|
@ -146,9 +150,9 @@ public class JutecGUI extends JFrame implements ActionListener,
|
|||
getMapsMenu.add(loadMapFive);
|
||||
menuBar.add(getMapsMenu);
|
||||
|
||||
// ----------------------------------
|
||||
// ***************************************
|
||||
// Add a menu item for comm port selection
|
||||
// ----------------------------------
|
||||
// ***************************************
|
||||
JMenu portsMenu = new JMenu("Ports");
|
||||
|
||||
// Gather list of ports from interface
|
||||
|
@ -170,6 +174,7 @@ public class JutecGUI extends JFrame implements ActionListener,
|
|||
}
|
||||
}
|
||||
menuBar.add(portsMenu);
|
||||
|
||||
|
||||
// Add menu item to the JFrame
|
||||
this.setJMenuBar(menuBar);
|
||||
|
@ -325,6 +330,7 @@ public class JutecGUI extends JFrame implements ActionListener,
|
|||
// Close out the application
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
// Only non explicitly defined actions are those generated by 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) {
|
||||
System.out.println("@@@@@@@@@@@@@@@@@@ Got a map from the utec:" + theMap.getMapName());
|
||||
this.currentMap = theMap;
|
||||
this.boostMapPanel.updateData(theMap);
|
||||
this.fuelMapPanel.updateData(theMap);
|
||||
this.timingMapPanel.updateData(theMap);
|
||||
DataManager.setCurrentMap(theMap);
|
||||
}
|
||||
|
||||
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.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import enginuity.logger.utec.mapData.UtecMapData;
|
||||
|
||||
|
@ -17,20 +19,29 @@ public class MapJPanel extends JPanel{
|
|||
|
||||
private int mapType = 0;
|
||||
|
||||
private UtecTableModel tableModel = new UtecTableModel();
|
||||
private UtecTableModel tableModel = null;
|
||||
|
||||
private UtecJTable table = null;
|
||||
|
||||
public MapJPanel(int mapType){
|
||||
super(new BorderLayout());
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
public void init(){
|
||||
JTable table = new JTable(tableModel);
|
||||
table = new UtecJTable(tableModel, mapType);
|
||||
//table.setPreferredScrollableViewportSize(new Dimension(500, 70));
|
||||
|
||||
//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){
|
||||
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){
|
||||
System.out.println("Updating timing map now.");
|
||||
this.tableModel.replaceData(utecMapData.getTimingMap());
|
||||
//this.tableModel.replaceData(utecMapData.getTimingMap());
|
||||
}
|
||||
|
||||
if(this.mapType == MapJPanel.BOOSTMAP){
|
||||
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];
|
||||
|
||||
public UtecTableModel() {
|
||||
String test = "";
|
||||
|
||||
public UtecTableModel(int identifier, double[][] initialData) {
|
||||
|
||||
this.data = initialData;
|
||||
|
||||
for (int i = 0; i < columnNames.length; i++) {
|
||||
columnNames[i] = i + "";
|
||||
}
|
||||
|
@ -23,6 +28,7 @@ public class UtecTableModel extends AbstractTableModel {
|
|||
}
|
||||
|
||||
public Object getValueAt(int row, int col) {
|
||||
System.out.println(test+"->("+row+","+col+") "+data[col][row]);
|
||||
return data[col][row];
|
||||
}
|
||||
|
||||
|
@ -34,8 +40,9 @@ public class UtecTableModel extends AbstractTableModel {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
double temp = data[col][row];
|
||||
|
||||
|
@ -45,22 +52,14 @@ public class UtecTableModel extends AbstractTableModel {
|
|||
System.out.println("Not a valid number entered.");
|
||||
}
|
||||
data[col][row] = temp;
|
||||
fireTableCellUpdated(row, col);
|
||||
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
|
||||
public void replaceData(double[][] newData){
|
||||
System.out.println("Model data being replaced in full.");
|
||||
|
||||
for(int j = 0; j < 40; j++){
|
||||
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();
|
||||
this.data = newData;
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue