diff --git a/.classpath b/.classpath index 35f5db1..a7f93a7 100644 --- a/.classpath +++ b/.classpath @@ -2,8 +2,12 @@ + + + + + - @@ -11,6 +15,6 @@ - + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index c55ccba..6ab0c3b 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -6,6 +6,7 @@ org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore org.eclipse.jdt.core.builder.resourceCopyExclusionFilter= org.eclipse.jdt.core.circularClasspath=error org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 diff --git a/.settings/org.eclipse.jdt.launching.prefs b/.settings/org.eclipse.jdt.launching.prefs index d211d32..f8a131b 100644 --- a/.settings/org.eclipse.jdt.launching.prefs +++ b/.settings/org.eclipse.jdt.launching.prefs @@ -1,2 +1,3 @@ eclipse.preferences.version=1 +org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning diff --git a/MafScaling.jar b/MafScaling.jar index dff8ce4..206899a 100644 Binary files a/MafScaling.jar and b/MafScaling.jar differ diff --git a/lib/jfreechart-1.0.17.jar b/lib/jfreechart-1.0.17.jar deleted file mode 100644 index 2a1ba4d..0000000 Binary files a/lib/jfreechart-1.0.17.jar and /dev/null differ diff --git a/lib/jfreechart-1.5.3.jar b/lib/jfreechart-1.5.3.jar new file mode 100644 index 0000000..0f73437 Binary files /dev/null and b/lib/jfreechart-1.5.3.jar differ diff --git a/src/com/vgi/mafscaling/ACompCalc.java b/src/com/vgi/mafscaling/ACompCalc.java index 963c98e..c3a3ff3 100644 --- a/src/com/vgi/mafscaling/ACompCalc.java +++ b/src/com/vgi/mafscaling/ACompCalc.java @@ -60,13 +60,13 @@ import org.jfree.chart.renderer.xy.XYDotRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.function.Function2D; import org.jfree.data.function.LineFunction2D; import org.jfree.data.statistics.Regression; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.jfree.ui.RectangleEdge; import org.jfree.util.ShapeUtilities; import org.math.plot.Plot3DPanel; @@ -446,7 +446,13 @@ protected void createChart(JPanel plotPanel, String xAxisName, String yAxisName) chartPanel = new ChartPanel(chart, true, true, true, true, true); chartPanel.setAutoscrolls(true); - chartPanel.setMouseZoomable(false); + chartPanel.setMouseWheelEnabled(true); + chartPanel.restoreAutoBounds(); + chartPanel.setZoomInFactor(0.8); + chartPanel.setZoomOutFactor(1.2); + chartPanel.setZoomAroundAnchor(true); + chartPanel.setDomainZoomable(true); + chartPanel.setRangeZoomable(true); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.CENTER; @@ -465,7 +471,7 @@ protected void createChart(JPanel plotPanel, String xAxisName, String yAxisName) XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(); lineRenderer.setUseFillPaint(true); - lineRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( + lineRenderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); diff --git a/src/com/vgi/mafscaling/AMafScaling.java b/src/com/vgi/mafscaling/AMafScaling.java index 8f87743..9572fb0 100644 --- a/src/com/vgi/mafscaling/AMafScaling.java +++ b/src/com/vgi/mafscaling/AMafScaling.java @@ -46,10 +46,10 @@ import org.jfree.chart.renderer.xy.XYDotRenderer; import org.jfree.chart.renderer.xy.XYSplineRenderer; import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.jfree.ui.RectangleEdge; import org.jfree.util.ShapeUtilities; public abstract class AMafScaling extends FCTabbedPane implements IMafChartHolder, ActionListener { @@ -96,7 +96,7 @@ public abstract class AMafScaling extends FCTabbedPane implements IMafChartHolde protected Insets insets1 = new Insets(1, 1, 1, 1); protected Insets insets2 = new Insets(2, 2, 2, 2); protected Insets insets3 = new Insets(3, 3, 3, 3); - protected String[] optionButtons = { "Yes", "No", "No to all" }; + protected String[] optionButtons = { "Yes", "No" }; public AMafScaling(int tabPlacement, PrimaryOpenLoopFuelingTable table, MafCompare comparer) { super(tabPlacement); @@ -259,7 +259,7 @@ protected void createChart(JPanel plotPanel, String y2AxisName) { XYSplineRenderer lineRenderer = new XYSplineRenderer(3); lineRenderer.setUseFillPaint(true); - lineRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( + lineRenderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); diff --git a/src/com/vgi/mafscaling/ClosedLoop.java b/src/com/vgi/mafscaling/ClosedLoop.java index ea75b4b..b0a85b5 100644 --- a/src/com/vgi/mafscaling/ClosedLoop.java +++ b/src/com/vgi/mafscaling/ClosedLoop.java @@ -1026,6 +1026,7 @@ private boolean getColumnsFilters(String[] elements, boolean isPolfTableMap) { protected void loadLogFile() { boolean displayDialog = true; + boolean isPolfSet = polfTable.isSet(); boolean isPolfTableMap = polfTable.isMap(); File[] files = fileChooser.getSelectedFiles(); for (File file : files) { @@ -1034,26 +1035,23 @@ protected void loadLogFile() { br = new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsoluteFile()), Config.getEncoding())); String line = null; String [] elements = null; - while ((line = br.readLine()) != null && (elements = line.split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) + while ((line = br.readLine()) != null && (elements = line.trim().split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) continue; getColumnsFilters(elements, isPolfTableMap); - boolean resetColumns = false; - if (logClOlStatusColIdx >= 0 || logAfLearningColIdx >= 0 || logAfCorrectionColIdx >= 0 || logAfrColIdx >= 0 || - logRpmColIdx >= 0 || logLoadColIdx >=0 || logTimeColIdx >=0 || logMafvColIdx >= 0 || logIatColIdx >= 0 || logMapColIdx >= 0) { - if (displayDialog) { - int rc = JOptionPane.showOptionDialog(null, "Would you like to reset column names or filter values?", "Columns/Filters Reset", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionButtons, optionButtons[0]); - if (rc == 0) - resetColumns = true; - else if (rc == 2) - displayDialog = false; - } + boolean resetColumns = logClOlStatusColIdx < 0 || logAfLearningColIdx < 0 || logAfCorrectionColIdx < 0 || logAfrColIdx < 0 || logRpmColIdx < 0 || + logLoadColIdx < 0 || logTimeColIdx < 0 || logMafvColIdx < 0 || logIatColIdx < 0 || (isPolfSet && isPolfTableMap && logMapColIdx < 0); + if (false == resetColumns && true == displayDialog) { + if (JOptionPane.NO_OPTION == JOptionPane.showOptionDialog(null, "Would you like to reset column names or filter values?", "Columns/Filters Reset", + JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionButtons, optionButtons[1])) + displayDialog = false; + else + resetColumns = true; } - - if (resetColumns || logClOlStatusColIdx < 0 || logAfLearningColIdx < 0 || logAfCorrectionColIdx < 0 || logAfrColIdx < 0 || - logRpmColIdx < 0 || logLoadColIdx < 0 || logTimeColIdx < 0 || logMafvColIdx < 0 || logIatColIdx < 0 || (isPolfTableMap && logMapColIdx < 0)) { + if (true == resetColumns) { ColumnsFiltersSelection selectionWindow = new CLColumnsFiltersSelection(isPolfTableMap); if (!selectionWindow.getUserSettings(elements) || !getColumnsFilters(elements, isPolfTableMap)) return; + displayDialog = false; } String[] flds; @@ -1072,7 +1070,7 @@ else if (rc == 2) setCursor(new Cursor(Cursor.WAIT_CURSOR)); while (line != null) { - flds = line.split(Utils.fileFieldSplitter, -1); + flds = line.trim().split(Utils.fileFieldSplitter, -1); try { // Calculate dV/dt prevTime = time; diff --git a/src/com/vgi/mafscaling/ColumnsFiltersSelection.java b/src/com/vgi/mafscaling/ColumnsFiltersSelection.java index 3a05d5c..cd66ae2 100644 --- a/src/com/vgi/mafscaling/ColumnsFiltersSelection.java +++ b/src/com/vgi/mafscaling/ColumnsFiltersSelection.java @@ -23,6 +23,8 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.NumberFormat; @@ -33,6 +35,7 @@ import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; +import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JFormattedTextField; import javax.swing.JLabel; @@ -46,6 +49,7 @@ import javax.swing.ScrollPaneConstants; import javax.swing.SpinnerNumberModel; import javax.swing.SwingUtilities; +import javax.swing.TransferHandler; import javax.swing.UIDefaults; import javax.swing.border.Border; import javax.swing.table.DefaultTableModel; @@ -171,6 +175,37 @@ abstract class ColumnsFiltersSelection implements ActionListener { protected int colrow; protected int filtrow; + protected TransferHandler textTransferHandler = new TextTransferHandler(); + + private class TextTransferHandler extends TransferHandler { + private static final long serialVersionUID = 1L; + public boolean importData(TransferHandler.TransferSupport support) { + if (!canImport(support)) + return false; + String data; + try { + data = (String) support.getTransferable().getTransferData(DataFlavor.stringFlavor); + } + catch (UnsupportedFlavorException e) { + return false; + } + catch (java.io.IOException e) { + return false; + } + JTextField tc = (JTextField) support.getComponent(); + tc.setText(data); + return true; + } + public int getSourceActions(JComponent c) { + return COPY; + } + public boolean canImport(TransferHandler.TransferSupport support) { + if (!support.isDataFlavorSupported(DataFlavor.stringFlavor)) + return false; + return true; + } + } + public ColumnsFiltersSelection() { doubleFmt.setMaximumFractionDigits(2); doubleFmt.setGroupingUsed(false); @@ -227,7 +262,7 @@ protected void createColumnsPanel(String[] elements) { // Optional Note addNote(columnsPanel, colrow, 4, "NOTE: Fields marked with asterisk (*) are optional"); // columns note - addCommentLabel(columnsPanel, ++colrow, 4, "Columns Selection - use blank row to clear optional columns."); + addCommentLabel(columnsPanel, ++colrow, 4, "Columns Selection - Use drag-n-drop. Use blank row to clear optional columns."); // custom columns note addColumnsNote(); int colRowStart = colrow + 1; @@ -246,6 +281,7 @@ protected void createColumnsPanel(String[] elements) { columnsTable.setTableHeader(null); columnsTable.setModel(new DefaultTableModel(columns.length + 1, 1)); columnsTable.setValueAt("", 0, 0); + columnsTable.setDragEnabled(true); Arrays.sort(columns); for (int i = 0; i < columns.length; ++i) columnsTable.setValueAt(columns[i], i + 1, 0); @@ -270,6 +306,8 @@ protected void addRPMColSelection() { // RPM addLabel(columnsPanel, ++colrow, rpmLabelText); rpmName = addColumn(colrow, Config.getRpmColumnName()); + rpmName.setDragEnabled(true); + rpmName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "rpm"); } @@ -277,6 +315,8 @@ protected void addThrottleAngleColSelection() { // Throttle Angle addLabel(columnsPanel, ++colrow, thrtlAngleLabelText); thrtlAngleName = addColumn(colrow, Config.getThrottleAngleColumnName()); + thrtlAngleName.setDragEnabled(true); + thrtlAngleName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "thrtlAngle"); } @@ -284,6 +324,8 @@ protected void addLoadColSelection() { // Load addLabel(columnsPanel, ++colrow, loadLabelText); loadName = addColumn(colrow, Config.getLoadColumnName()); + loadName.setDragEnabled(true); + loadName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "load"); } @@ -291,6 +333,8 @@ protected void addAFLearningColSelection() { // LTFT addLabel(columnsPanel, ++colrow, afLearningLabelText); afLearningName = addColumn(colrow, Config.getAfLearningColumnName()); + afLearningName.setDragEnabled(true); + afLearningName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "afrlearn"); } @@ -298,6 +342,8 @@ protected void addAFCorrectionColSelection() { // STFT addLabel(columnsPanel, ++colrow, afCorrectionLabelText); afCorrectionName = addColumn(colrow, Config.getAfCorrectionColumnName()); + afCorrectionName.setDragEnabled(true); + afCorrectionName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "afrcorr"); } @@ -305,6 +351,8 @@ protected void addMAFVoltageColSelection() { // MAF Voltage addLabel(columnsPanel, ++colrow, mafVLabelText); mafVName = addColumn(colrow, Config.getMafVoltageColumnName()); + mafVName.setDragEnabled(true); + mafVName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "mafv"); } @@ -312,6 +360,8 @@ protected void addMAFColSelection() { // MAF addLabel(columnsPanel, ++colrow, mafLabelText); mafName = addColumn(colrow, Config.getMassAirflowColumnName()); + mafName.setDragEnabled(true); + mafName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "maf"); } @@ -319,6 +369,8 @@ protected void addWidebandAFRColSelection() { // Wideband AFR addLabel(columnsPanel, ++colrow, wbAfrLabelText); wbAfrName = addColumn(colrow, Config.getWidebandAfrColumnName()); + wbAfrName.setDragEnabled(true); + wbAfrName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "wbafr"); } @@ -326,6 +378,8 @@ protected void addCommandedAFRColSelection(boolean isOptional) { // Commanded AFR addLabel(columnsPanel, ++colrow, commAfrLabelText + (isOptional ? " *" : "")); commAfrName = addColumn(colrow, Config.getCommandedAfrColumnName()); + commAfrName.setDragEnabled(true); + commAfrName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "cmdafr"); } @@ -333,6 +387,8 @@ protected void addStockAFRColSelection() { // Stock AFR addLabel(columnsPanel, ++colrow, stockAfrLabelText); stockAfrName = addColumn(colrow, Config.getAfrColumnName()); + stockAfrName.setDragEnabled(true); + stockAfrName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "afr"); } @@ -340,6 +396,8 @@ protected void addClOlStatusColSelection() { // Closed/Open Loop Status addLabel(columnsPanel, ++colrow, clolStatusLabelText); clolStatusName = addColumn(colrow, Config.getClOlStatusColumnName()); + clolStatusName.setDragEnabled(true); + clolStatusName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "clolstat"); } @@ -347,6 +405,8 @@ protected void addCruiseStatusColSelection() { // Cruise/Non-cruise Status addLabel(columnsPanel, ++colrow, cruiseStatusLabelText); cruiseStatusName = addColumn(colrow, Config.getCruiseStatusColumnName()); + cruiseStatusName.setDragEnabled(true); + cruiseStatusName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "cruisestat"); } @@ -354,6 +414,8 @@ protected void addManifoldPressureColSelection() { // Manifold Pressure addLabel(columnsPanel, ++colrow, mpLabelText); mpName = addColumn(colrow, Config.getMpColumnName()); + mpName.setDragEnabled(true); + mpName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "mp"); } @@ -361,6 +423,8 @@ protected void addManifoldAbsolutePressureColSelection() { // Manifold Absolute Pressure addLabel(columnsPanel, ++colrow, mapLabelText); mapName = addColumn(colrow, Config.getMapColumnName()); + mapName.setDragEnabled(true); + mapName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "map"); } @@ -368,6 +432,8 @@ protected void addVVTSystem1ColSelection() { // Manifold Absolute Pressure addLabel(columnsPanel, ++colrow, vvt1LabelText); vvt1Name = addColumn(colrow, Config.getVvt1ColumnName()); + vvt1Name.setDragEnabled(true); + vvt1Name.setTransferHandler(textTransferHandler); addCopyButton(colrow, "vvt1"); } @@ -375,6 +441,8 @@ protected void addVVTSystem2ColSelection() { // Manifold Absolute Pressure addLabel(columnsPanel, ++colrow, vvt2LabelText); vvt2Name = addColumn(colrow, Config.getVvt2ColumnName()); + vvt2Name.setDragEnabled(true); + vvt2Name.setTransferHandler(textTransferHandler); addCopyButton(colrow, "vvt2"); } @@ -382,6 +450,8 @@ protected void addTimeColSelection() { // Time addLabel(columnsPanel, ++colrow, timeLabelText); timeName = addColumn(colrow, Config.getTimeColumnName()); + timeName.setDragEnabled(true); + timeName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "time"); } @@ -389,6 +459,8 @@ protected void addIATColSelection() { // IAT addLabel(columnsPanel, ++colrow, iatLabelText); iatName = addColumn(colrow, Config.getIatColumnName()); + iatName.setDragEnabled(true); + iatName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "iat"); } @@ -396,6 +468,8 @@ protected void addFFBColSelection() { // FFB addLabel(columnsPanel, ++colrow, ffbLabelText); ffbName = addColumn(colrow, Config.getFinalFuelingBaseColumnName()); + ffbName.setDragEnabled(true); + ffbName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "ffb"); } @@ -403,6 +477,8 @@ protected void addVEFlowColSelection() { // VE Flow addLabel(columnsPanel, ++colrow, veFlowLabelText); veFlowName = addColumn(colrow, Config.getVEFlowColumnName()); + veFlowName.setDragEnabled(true); + veFlowName.setTransferHandler(textTransferHandler); addCopyButton(colrow, "veflow"); } diff --git a/src/com/vgi/mafscaling/LoadComp.java b/src/com/vgi/mafscaling/LoadComp.java index 0438315..00eb447 100644 --- a/src/com/vgi/mafscaling/LoadComp.java +++ b/src/com/vgi/mafscaling/LoadComp.java @@ -259,7 +259,7 @@ protected void loadLogFile() { br = new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsoluteFile()), Config.getEncoding())); String line = null; String [] elements = null; - while ((line = br.readLine()) != null && (elements = line.split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) + while ((line = br.readLine()) != null && (elements = line.trim().split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) continue; getColumnsFilters(elements); boolean resetColumns = false; @@ -309,7 +309,7 @@ else if (rc == 2) if (-1 == logCruiseStatusColIdx) cruiseValue = -1; while (line != null) { - flds = line.split(Utils.fileFieldSplitter, -1); + flds = line.trim().split(Utils.fileFieldSplitter, -1); ppThrottle = pThrottle; pThrottle = throttle; try { diff --git a/src/com/vgi/mafscaling/LogPlayTable.java b/src/com/vgi/mafscaling/LogPlayTable.java index 08af9f5..b60918d 100644 --- a/src/com/vgi/mafscaling/LogPlayTable.java +++ b/src/com/vgi/mafscaling/LogPlayTable.java @@ -505,7 +505,7 @@ private void load() { int row = 0; String[] elements; while (line != null) { - elements = line.split(Utils.fileFieldSplitter, -1); + elements = line.trim().split(Utils.fileFieldSplitter, -1); Utils.ensureRowCount(row + 1, playTable); Utils.ensureColumnCount(elements.length - 1, playTable); for (int i = 0; i < elements.length - 1; ++i) diff --git a/src/com/vgi/mafscaling/LogStats.java b/src/com/vgi/mafscaling/LogStats.java index 07da704..33d40d4 100644 --- a/src/com/vgi/mafscaling/LogStats.java +++ b/src/com/vgi/mafscaling/LogStats.java @@ -40,6 +40,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.ResourceBundle; @@ -80,7 +81,6 @@ private enum DataFilter {NONE, LESS, LESS_EQUAL, EQUAL, GREATER_EQUAL, GREATER}; private static final int ColumnWidth = 50; private static final int DataTableRowCount = 50; private static final int DataTableColumnCount = 25; - private static final String timeMatchString = "^\\s*time\\s*(\\(.*\\))?$"; private static final String SetFilters = "
Set
Filters
"; private static final String ViewFilters = "
View
Filters
"; @@ -536,43 +536,35 @@ private void getLogColumns() { logFiles = fileChooser.getSelectedFiles(); logFilesTodo = new ArrayList(); BufferedReader br = null; - HashSet columns = new HashSet(); - String logTimeColName = Config.getLogTimeColumnName(); + TreeSet columns = new TreeSet(); for (File logFile : logFiles) { try { br = new BufferedReader(new InputStreamReader(new FileInputStream(logFile.getAbsoluteFile()), Config.getEncoding())); String line = null; String [] elements = null; - while ((line = br.readLine()) != null && (elements = line.split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) + while ((line = br.readLine()) != null && (elements = line.trim().split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) continue; if (logFilesTodo.size() == 0) { logFilesTodo.add(logFile); - Arrays.sort(elements); - for (String item : elements) { - if (logFiles.length > 1 && (item.equals(logTimeColName) || item.toLowerCase().matches(timeMatchString))) - continue; - xAxisColumn.addItem(item); - yAxisColumn.addItem(item); - dataColumn.addItem(item); - for (int k = 0; k < filterButtonList.size(); ++k) - filterColumnList.get(k).addItem(item); - } - } - else { - columns.clear(); for (String item : elements) columns.add(item); - boolean skipFile = false; - for (int i = 1; i < xAxisColumn.getItemCount(); ++i) { - if (!columns.contains(xAxisColumn.getItemAt(i))) { - skipFile = true; - JOptionPane.showMessageDialog(null, "File " + logFile.getName() + " does not have column '" + xAxisColumn.getItemAt(i) + "'\nSkipping file...", "Missing column", JOptionPane.WARNING_MESSAGE); - break; + } + else { + HashSet columnsCurrent = new HashSet(); + for (String item : elements) { + if (!columns.contains(item)) + JOptionPane.showMessageDialog(null, "File " + logFile.getName() + " has extra column '" + item + "'\nThis columns will be ignored", "Extra column", JOptionPane.WARNING_MESSAGE); + else + columnsCurrent.add(item); + } + for (Iterator it = columns.iterator(); it.hasNext();) { + String item = it.next(); + if (!columnsCurrent.contains(item)) { + JOptionPane.showMessageDialog(null, "File " + logFile.getName() + " is missing column '" + item + "'\nThis columns will be ignored", "Missing column", JOptionPane.WARNING_MESSAGE); + it.remove(); } } - if (skipFile) - continue; logFilesTodo.add(logFile); } } @@ -591,6 +583,13 @@ private void getLogColumns() { } } } + for (String item : columns) { + xAxisColumn.addItem(item); + yAxisColumn.addItem(item); + dataColumn.addItem(item); + for (int k = 0; k < filterButtonList.size(); ++k) + filterColumnList.get(k).addItem(item); + } if (xAxis != null) xAxisColumn.setSelectedItem(xAxis); if (yAxis != null) @@ -782,7 +781,7 @@ private void processLog() { br = new BufferedReader(new InputStreamReader(new FileInputStream(logFile.getAbsoluteFile()), Config.getEncoding())); String line = null; String [] elements = null; - while ((line = br.readLine()) != null && (elements = line.split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) + while ((line = br.readLine()) != null && (elements = line.trim().split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) continue; ArrayList columns = new ArrayList(Arrays.asList(elements)); int xColIdx = columns.indexOf(xAxisColName); @@ -807,7 +806,7 @@ private void processLog() { try { line = br.readLine(); while (line != null) { - elements = line.split(Utils.fileFieldSplitter, -1); + elements = line.trim().split(Utils.fileFieldSplitter, -1); if (i == 2) { boolean found = false; for (int k = 0; !found && k < filterButtonList.size(); ++k) { diff --git a/src/com/vgi/mafscaling/LogStatsFilters.java b/src/com/vgi/mafscaling/LogStatsFilters.java index 41b3bcf..bde2dbc 100644 --- a/src/com/vgi/mafscaling/LogStatsFilters.java +++ b/src/com/vgi/mafscaling/LogStatsFilters.java @@ -18,12 +18,23 @@ package com.vgi.mafscaling; +import java.awt.Component; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.Writer; import java.math.RoundingMode; import java.text.NumberFormat; import java.util.ArrayList; @@ -31,6 +42,7 @@ import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JFileChooser; import javax.swing.JFormattedTextField; import javax.swing.JLabel; import javax.swing.JOptionPane; @@ -38,7 +50,12 @@ import javax.swing.JScrollPane; import javax.swing.UIDefaults; -public class LogStatsFilters implements ActionListener { +import org.apache.log4j.Logger; + +public class LogStatsFilters extends Component implements ActionListener { + private static final long serialVersionUID = 1L; + private static final Logger logger = Logger.getLogger(LogStatsFilters.class); + private static final String SaveDataFileHeader = "[filters data]"; private String[] colNames = null; private ArrayList filterButtonList = null; private ArrayList> filterComboBoxList = null; @@ -112,9 +129,9 @@ private void initialize() { private void createControlPanel() { JPanel panel = new JPanel(); GridBagLayout gbl_panel = new GridBagLayout(); - gbl_panel.columnWidths = new int[]{0, 0}; + gbl_panel.columnWidths = new int[]{0, 0, 0, 0}; gbl_panel.rowHeights = new int[] {0}; - gbl_panel.columnWeights = new double[]{0.0, 1.0}; + gbl_panel.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0}; gbl_panel.rowWeights = new double[]{0.0}; panel.setLayout(gbl_panel); @@ -131,12 +148,32 @@ private void createControlPanel() { JButton remButton = new JButton("Remove Selected"); GridBagConstraints gbc_remButton = new GridBagConstraints(); gbc_remButton.anchor = GridBagConstraints.EAST; - gbc_remButton.insets = new Insets(3, 3, 3, 0); + gbc_remButton.insets = new Insets(3, 0, 3, 3); gbc_remButton.gridx = 1; gbc_remButton.gridy = 0; remButton.setActionCommand("remove"); remButton.addActionListener(this); panel.add(remButton, gbc_remButton); + + JButton saveButton = new JButton("Save"); + GridBagConstraints gbc_saveButton = new GridBagConstraints(); + gbc_saveButton.anchor = GridBagConstraints.EAST; + gbc_saveButton.insets = new Insets(3, 3, 3, 0); + gbc_saveButton.gridx = 2; + gbc_saveButton.gridy = 0; + saveButton.setActionCommand("save"); + saveButton.addActionListener(this); + panel.add(saveButton, gbc_saveButton); + + JButton loadButton = new JButton("Load"); + GridBagConstraints gbc_loadButton = new GridBagConstraints(); + gbc_loadButton.anchor = GridBagConstraints.EAST; + gbc_loadButton.insets = new Insets(3, 3, 3, 0); + gbc_loadButton.gridx = 3; + gbc_loadButton.gridy = 0; + loadButton.setActionCommand("load"); + loadButton.addActionListener(this); + panel.add(loadButton, gbc_loadButton); GridBagConstraints gbc_fullWidth = new GridBagConstraints(); gbc_fullWidth.anchor = GridBagConstraints.PAGE_START; @@ -281,7 +318,8 @@ private void remove() { } } if (removed) { - tmpFilterButtonList.set(0, null); + if (tmpFilterButtonList.size() > 0) + tmpFilterButtonList.set(0, null); filtersPanel.removeAll(); addExistingFilters(); filtersPanel.revalidate(); @@ -289,6 +327,100 @@ private void remove() { } } + + private void save() { + if (tmpFilterButtonList.size() == 0 || !validateFilters()) + return; + JFileChooser fileChooser = new JFileChooser(); + if (JFileChooser.APPROVE_OPTION != fileChooser.showSaveDialog(this)) + return; + File file = fileChooser.getSelectedFile(); + setCursor(new Cursor(Cursor.WAIT_CURSOR)); + Writer out = null; + try { + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Config.getEncoding())); + out.write(SaveDataFileHeader + "\n"); + for (int i = 0; i < tmpFilterButtonList.size() ; ++i) { + String andOr = tmpFilterButtonList.get(i) == null ? "" : tmpFilterButtonList.get(i).getText(); + String column = (String) tmpFilterColumnList.get(i).getSelectedItem(); + String condition = (String) tmpFilterComboBoxList.get(i).getSelectedItem(); + String value = tmpFilterTextBoxList.get(i).getValue().toString(); + out.write(andOr + "," + column + "," + condition + "," + value + "\n"); + } + } + catch (Exception e) { + logger.error(e); + JOptionPane.showMessageDialog(null, "Failed to save filters to file", "Error", JOptionPane.ERROR_MESSAGE); + } + finally { + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + if (out != null) { + try { + out.close(); + } + catch (IOException e) { + logger.error(e); + } + } + } + } + + + private void load() { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setMultiSelectionEnabled(false); + if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this)) + return; + File file = fileChooser.getSelectedFile(); + setCursor(new Cursor(Cursor.WAIT_CURSOR)); + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsoluteFile()), Config.getEncoding())); + String line = br.readLine(); + if (line == null || !line.equals(SaveDataFileHeader)) { + JOptionPane.showMessageDialog(null, "Invalid saved data file!", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + line = br.readLine(); + String[] elements; + tmpFilterButtonList.clear(); + tmpFilterColumnList.clear(); + tmpFilterComboBoxList.clear(); + tmpFilterTextBoxList.clear(); + filtersPanel.removeAll(); + int i = 0; + while (line != null) { + elements = line.trim().split(Utils.fileFieldSplitter, -1); + addFilter(); + if (tmpFilterButtonList.get(i) != null) + tmpFilterButtonList.get(i).setText(elements[0]); + tmpFilterColumnList.get(i).setSelectedItem(elements[1]); + tmpFilterComboBoxList.get(i).setSelectedItem(elements[2]); + tmpFilterTextBoxList.get(i).setValue(Long.parseLong(elements[3])); + i += 1; + line = br.readLine(); + } + filtersPanel.revalidate(); + filtersPanel.repaint(); + } + catch (Exception e) { + e.printStackTrace(); + logger.error(e); + JOptionPane.showMessageDialog(null, "Failed to load filters from file", "Error", JOptionPane.ERROR_MESSAGE); + } + finally { + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + if (br != null) { + try { + br.close(); + } + catch (IOException e) { + logger.error(e); + } + } + } + } + private boolean validateFilters() { for (int k = 0; k < tmpFilterButtonList.size(); ++k) { if (tmpFilterComboBoxList.get(k).getSelectedItem() == null || @@ -310,6 +442,10 @@ public void actionPerformed(ActionEvent e) { add(); else if ("remove".equals(e.getActionCommand())) remove(); + else if ("save".equals(e.getActionCommand())) + save(); + else if ("load".equals(e.getActionCommand())) + load(); else { boolean handled = false; for (int k = 1; !handled && k < tmpFilterButtonList.size(); ++k) { diff --git a/src/com/vgi/mafscaling/LogView.java b/src/com/vgi/mafscaling/LogView.java index 8202091..c911601 100644 --- a/src/com/vgi/mafscaling/LogView.java +++ b/src/com/vgi/mafscaling/LogView.java @@ -124,11 +124,11 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.ui.RectangleAnchor; -import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; import org.math.plot.Plot3DPanel; import org.scijava.swing.checkboxtree.CheckBoxNodeData; @@ -741,7 +741,13 @@ private void createGraghPanel() { chartPanel = new ChartPanel(chart, true, true, true, true, true); chartPanel.setFocusable(true); chartPanel.setAutoscrolls(true); - chartPanel.setPopupMenu(null); + chartPanel.setMouseWheelEnabled(true); + chartPanel.restoreAutoBounds(); + chartPanel.setZoomInFactor(0.8); + chartPanel.setZoomOutFactor(1.2); + chartPanel.setZoomAroundAnchor(true); + chartPanel.setDomainZoomable(true); + chartPanel.setRangeZoomable(true); chart.setBackgroundPaint(chartColor); rpmDataset = new XYSeriesCollection(); @@ -1161,6 +1167,13 @@ protected void createWotChart() { wotChartPanel = new ChartPanel(chart, true, true, true, true, true); wotChartPanel.setFocusable(true); wotChartPanel.setAutoscrolls(true); + wotChartPanel.setMouseWheelEnabled(true); + wotChartPanel.restoreAutoBounds(); + wotChartPanel.setZoomInFactor(0.8); + wotChartPanel.setZoomOutFactor(1.2); + wotChartPanel.setZoomAroundAnchor(true); + wotChartPanel.setDomainZoomable(true); + wotChartPanel.setRangeZoomable(true); chart.setBackgroundPaint(chartColor); wotPlot = chart.getXYPlot(); @@ -1940,7 +1953,7 @@ private void loadWotLogFiles() { br = new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsoluteFile()), Config.getEncoding())); String line = null; String [] elements = null; - while ((line = br.readLine()) != null && (elements = line.split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) + while ((line = br.readLine()) != null && (elements = line.trim().split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) continue; if (line.charAt(line.length() - 1) == ',') Arrays.copyOf(elements, elements.length - 1); @@ -1958,7 +1971,7 @@ private void loadWotLogFiles() { while ((line = br.readLine()) != null) { if (line.length() > 0 && line.charAt(line.length() - 1) == ',') line = line.substring(0, line.length() - 1); - flds = line.split(Utils.fileFieldSplitter, -1); + flds = line.trim().split(Utils.fileFieldSplitter, -1); val = Double.valueOf(flds[logThtlAngleColIdx]); if (row == 0 && val < 99) wotFlag = false; @@ -2173,7 +2186,7 @@ private void viewWotPlotsByTime() { yAxis.setTickLabelPaint(Color.WHITE); yAxis.setLabelPaint(Color.LIGHT_GRAY); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(); - lineRenderer.setBaseShapesVisible(showWotCurvePoints); + lineRenderer.setDefaultShapesVisible(showWotCurvePoints); wotPlot.setRenderer(i, lineRenderer); wotPlot.setRangeAxis(i, yAxis, false); wotPlot.setDataset(i, dataset); @@ -2248,7 +2261,7 @@ private void viewWotPlotsByRpm(boolean skipDrops) { yAxis.setTickLabelPaint(Color.WHITE); yAxis.setLabelPaint(Color.LIGHT_GRAY); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(); - lineRenderer.setBaseShapesVisible(showWotCurvePoints); + lineRenderer.setDefaultShapesVisible(showWotCurvePoints); wotPlot.setRenderer(i, lineRenderer); wotPlot.setRangeAxis(i, yAxis, false); wotPlot.setDataset(i, dataset); @@ -2376,13 +2389,19 @@ private void exportSelectedWotPulls() { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } - + public void disposeLogView() { + if (startMarker != null) { + plot.removeDomainMarker(startMarker); + startMarker = null; + } + if (endMarker != null) { + plot.removeDomainMarker(endMarker); + endMarker = null; + } logPlayButton.setEnabled(true); logPlayWindow.dispose(); logPlayWindow = null; - startMarker = null; - endMarker = null; disableMouseListener(); enableMouseListener(); chartPanel.repaint(); @@ -2478,7 +2497,7 @@ else if ("showpts".equals(e.getActionCommand())) { XYSeriesCollection dataset = (XYSeriesCollection)wotPlot.getDataset(i); if (lineRenderer == null || dataset == null) continue; - lineRenderer.setBaseShapesVisible(showWotCurvePoints); + lineRenderer.setDefaultShapesVisible(showWotCurvePoints); } } else if ("linkyaxis".equals(e.getActionCommand())) { diff --git a/src/com/vgi/mafscaling/MafCompare.java b/src/com/vgi/mafscaling/MafCompare.java index 4dc5b87..89a8137 100644 --- a/src/com/vgi/mafscaling/MafCompare.java +++ b/src/com/vgi/mafscaling/MafCompare.java @@ -64,10 +64,10 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYSplineRenderer; import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.jfree.ui.RectangleEdge; import org.jfree.util.ShapeUtilities; public class MafCompare extends JFrame { @@ -422,7 +422,7 @@ public void actionPerformed(ActionEvent e) { XYSplineRenderer lineRenderer = new XYSplineRenderer(3); lineRenderer.setUseFillPaint(true); - lineRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( + lineRenderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f); diff --git a/src/com/vgi/mafscaling/MafIatComp.java b/src/com/vgi/mafscaling/MafIatComp.java index 67e3bbe..59f6941 100644 --- a/src/com/vgi/mafscaling/MafIatComp.java +++ b/src/com/vgi/mafscaling/MafIatComp.java @@ -284,7 +284,7 @@ protected void loadLogFile() { br = new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsoluteFile()), Config.getEncoding())); String line = null; String [] elements = null; - while ((line = br.readLine()) != null && (elements = line.split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) + while ((line = br.readLine()) != null && (elements = line.trim().split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) continue; getColumnsFilters(elements, isPolfSet, isPolfMap); boolean resetColumns = false; @@ -339,7 +339,7 @@ else if (rc == 2) for (int k = 0; k <= afrRowOffset && line != null; ++k) { line = br.readLine(); if (line != null) - buffer.addFirst(line.split(Utils.fileFieldSplitter, -1)); + buffer.addFirst(line.trim().split(Utils.fileFieldSplitter, -1)); } try { while (line != null && buffer.size() > afrRowOffset) { @@ -347,7 +347,7 @@ else if (rc == 2) flds = buffer.removeLast(); line = br.readLine(); if (line != null) - buffer.addFirst(line.split(Utils.fileFieldSplitter, -1)); + buffer.addFirst(line.trim().split(Utils.fileFieldSplitter, -1)); ppThrottle = pThrottle; pThrottle = throttle; diff --git a/src/com/vgi/mafscaling/MafOLCLMerge.java b/src/com/vgi/mafscaling/MafOLCLMerge.java index d62fa83..7aa945c 100644 --- a/src/com/vgi/mafscaling/MafOLCLMerge.java +++ b/src/com/vgi/mafscaling/MafOLCLMerge.java @@ -59,9 +59,9 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYSplineRenderer; import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.jfree.ui.RectangleEdge; import org.jfree.util.ShapeUtilities; import ij.measure.CurveFitter; @@ -347,7 +347,7 @@ private void createGraghPanel(JPanel dataPanel) { XYSplineRenderer lineRenderer = new XYSplineRenderer(3); lineRenderer.setUseFillPaint(true); - lineRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( + lineRenderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); @@ -382,7 +382,6 @@ private void createGraghPanel(JPanel dataPanel) { plot.setRangeAxis(0, mafgsRange); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); - LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setItemFont(new Font("Arial", 0, 10)); diff --git a/src/com/vgi/mafscaling/MafRescale.java b/src/com/vgi/mafscaling/MafRescale.java index 510d11a..2fdd491 100644 --- a/src/com/vgi/mafscaling/MafRescale.java +++ b/src/com/vgi/mafscaling/MafRescale.java @@ -61,9 +61,9 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYSplineRenderer; import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.jfree.ui.RectangleEdge; import org.jfree.util.ShapeUtilities; public class MafRescale extends JTabbedPane implements IMafChartHolder { @@ -339,7 +339,7 @@ private void createGraghPanel(JPanel dataPanel) { XYSplineRenderer lineRenderer = new XYSplineRenderer(3); lineRenderer.setUseFillPaint(true); - lineRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( + lineRenderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); diff --git a/src/com/vgi/mafscaling/MafScaling.java b/src/com/vgi/mafscaling/MafScaling.java index 273244e..afca80d 100644 --- a/src/com/vgi/mafscaling/MafScaling.java +++ b/src/com/vgi/mafscaling/MafScaling.java @@ -36,7 +36,7 @@ public class MafScaling { private static final Logger logger = Logger.getLogger(MafScaling.class); - private static final String Title = "MAF Scaling - v2.7.0"; + private static final String Title = "MAF Scaling - v2.7.1"; private static final String OLTabName = "Open Loop"; private static final String CLTabName = "Closed Loop"; private static final String MMTabName = "MAF OL/CL Merge"; diff --git a/src/com/vgi/mafscaling/OpenLoop.java b/src/com/vgi/mafscaling/OpenLoop.java index 2c2d3c3..ab74d0c 100644 --- a/src/com/vgi/mafscaling/OpenLoop.java +++ b/src/com/vgi/mafscaling/OpenLoop.java @@ -609,7 +609,7 @@ public void loadData() { JTable table = null; i = k = l = 0; while (line != null) { - elements = line.split(Utils.fileFieldSplitter, -1); + elements = line.trim().split(Utils.fileFieldSplitter, -1); switch (i) { case 0: Utils.ensureColumnCount(elements.length - 1, mafTable); @@ -709,6 +709,11 @@ protected void loadLogFile() { boolean displayDialog = true; boolean isPolfSet = polfTable.isSet(); boolean isPolfMap = polfTable.isMap(); + if (!isPolfSet && logCommandedAfrColIdx < 0) { + if (JOptionPane.NO_OPTION == JOptionPane.showOptionDialog(null, "Primary Open Loop Fueling is not set.\nUnless you have ECU Target AFR (Commanded AFR)) in log you must set POLF table first.\nWould you like to continue?", "POLF is not set", + JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionButtons, optionButtons[1])) + return; + } File[] files = fileChooser.getSelectedFiles(); for (File file : files) { BufferedReader br = null; @@ -717,27 +722,24 @@ protected void loadLogFile() { br = new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsoluteFile()), Config.getEncoding())); String line = null; String [] elements = null; - while ((line = br.readLine()) != null && (elements = line.split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) + while ((line = br.readLine()) != null && (elements = line.trim().split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) continue; getColumnsFilters(elements, isPolfSet, isPolfMap); - boolean resetColumns = false; - if (logThtlAngleColIdx >= 0 || logAfLearningColIdx >= 0 || logAfCorrectionColIdx >= 0 || logMafvColIdx >= 0 || - logAfrColIdx >= 0 || logRpmColIdx >= 0 || logLoadColIdx >= 0 || logCommandedAfrColIdx >= 0 || logMapColIdx >= 0) { - if (displayDialog) { - int rc = JOptionPane.showOptionDialog(null, "Would you like to reset column names or filter values?", "Columns/Filters Reset", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionButtons, optionButtons[0]); - if (rc == 0) - resetColumns = true; - else if (rc == 2) - displayDialog = false; - } + boolean resetColumns = logThtlAngleColIdx < 0 || logAfLearningColIdx < 0 || logAfCorrectionColIdx < 0 || logMafvColIdx < 0 || + logAfrColIdx < 0 || logRpmColIdx < 0 || (isPolfSet && !isPolfMap && logLoadColIdx < 0) || (isPolfSet && isPolfMap && logMapColIdx < 0) || + (!isPolfSet && logCommandedAfrColIdx < 0); + if (false == resetColumns && true == displayDialog) { + if (JOptionPane.NO_OPTION == JOptionPane.showOptionDialog(null, "Would you like to reset column names or filter values?", "Columns/Filters Reset", + JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionButtons, optionButtons[1])) + displayDialog = false; + else + resetColumns = true; } - - if (resetColumns || logThtlAngleColIdx < 0 || logAfLearningColIdx < 0 || logAfCorrectionColIdx < 0 || - logMafvColIdx < 0 || logAfrColIdx < 0 || logRpmColIdx < 0 || (logLoadColIdx < 0 && !isPolfMap && isPolfSet) || - (logMapColIdx < 0 && isPolfMap) || (logCommandedAfrColIdx < 0 && !isPolfSet)) { + if (true == resetColumns) { ColumnsFiltersSelection selectionWindow = new OLColumnsFiltersSelection(isPolfSet, isPolfMap); if (!selectionWindow.getUserSettings(elements) || !getColumnsFilters(elements, isPolfSet, isPolfMap)) return; + displayDialog = false; } String[] flds; @@ -766,14 +768,14 @@ else if (rc == 2) for (int k = 0; k <= afrRowOffset && line != null; ++k) { line = br.readLine(); if (line != null) - buffer.addFirst(line.split(Utils.fileFieldSplitter, -1)); + buffer.addFirst(line.trim().split(Utils.fileFieldSplitter, -1)); } while (line != null && buffer.size() > afrRowOffset) { afrflds = buffer.getFirst(); flds = buffer.removeLast(); line = br.readLine(); if (line != null) - buffer.addFirst(line.split(Utils.fileFieldSplitter, -1)); + buffer.addFirst(line.trim().split(Utils.fileFieldSplitter, -1)); try { throttle = Double.valueOf(flds[logThtlAngleColIdx]); diff --git a/src/com/vgi/mafscaling/PrimaryOpenLoopFuelingTable.java b/src/com/vgi/mafscaling/PrimaryOpenLoopFuelingTable.java index db18cf9..cd9315d 100644 --- a/src/com/vgi/mafscaling/PrimaryOpenLoopFuelingTable.java +++ b/src/com/vgi/mafscaling/PrimaryOpenLoopFuelingTable.java @@ -435,7 +435,7 @@ private JTable loadPolFueling(JTable fuelingTable, String fileName) { isPolfMap = true; } else - fuelingTable = setValueAtRow(fuelingTable, i++, line.split(Utils.fileFieldSplitter, -1)); + fuelingTable = setValueAtRow(fuelingTable, i++, line.trim().split(Utils.fileFieldSplitter, -1)); line = br.readLine(); } if (i > 0 && validateFuelingData(fuelingTable)) diff --git a/src/com/vgi/mafscaling/VECalc.java b/src/com/vgi/mafscaling/VECalc.java index 0942333..7e32f80 100644 --- a/src/com/vgi/mafscaling/VECalc.java +++ b/src/com/vgi/mafscaling/VECalc.java @@ -55,10 +55,10 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.jfree.ui.RectangleEdge; import org.jfree.util.ShapeUtilities; public class VECalc extends ACompCalc { @@ -218,7 +218,13 @@ protected void createChart(JPanel plotPanel, String xAxisName, String yAxisName) chartPanel = new ChartPanel(chart, true, true, true, true, true); chartPanel.setAutoscrolls(true); - chartPanel.setMouseZoomable(false); + chartPanel.setMouseWheelEnabled(true); + chartPanel.restoreAutoBounds(); + chartPanel.setZoomInFactor(0.8); + chartPanel.setZoomOutFactor(1.2); + chartPanel.setZoomAroundAnchor(true); + chartPanel.setDomainZoomable(true); + chartPanel.setRangeZoomable(true); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.CENTER; @@ -232,7 +238,7 @@ protected void createChart(JPanel plotPanel, String xAxisName, String yAxisName) XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(); lineRenderer.setUseFillPaint(true); - lineRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( + lineRenderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); @@ -360,7 +366,7 @@ protected void loadLogFile() { br = new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsoluteFile()), Config.getEncoding())); String line = null; String [] elements = null; - while ((line = br.readLine()) != null && (elements = line.split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) + while ((line = br.readLine()) != null && (elements = line.trim().split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) continue; getColumnsFilters(elements); boolean resetColumns = false; @@ -406,7 +412,7 @@ else if (rc == 2) for (int k = 0; k <= afrRowOffset && line != null; ++k) { line = br.readLine(); if (line != null) - buffer.addFirst(line.split(Utils.fileFieldSplitter, -1)); + buffer.addFirst(line.trim().split(Utils.fileFieldSplitter, -1)); } try { while (line != null && buffer.size() > afrRowOffset) { @@ -414,7 +420,7 @@ else if (rc == 2) flds = buffer.removeLast(); line = br.readLine(); if (line != null) - buffer.addFirst(line.split(Utils.fileFieldSplitter, -1)); + buffer.addFirst(line.trim().split(Utils.fileFieldSplitter, -1)); ppThrottle = pThrottle; pThrottle = throttle; throttle = Double.valueOf(flds[logThrottleAngleColIdx]); diff --git a/src/com/vgi/mafscaling/VVTCalc.java b/src/com/vgi/mafscaling/VVTCalc.java index c375407..e3811f4 100644 --- a/src/com/vgi/mafscaling/VVTCalc.java +++ b/src/com/vgi/mafscaling/VVTCalc.java @@ -73,10 +73,10 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.jfree.ui.RectangleEdge; import org.math.plot.Plot3DPanel; import org.scijava.swing.checkboxtree.CheckBoxNodeData; import org.scijava.swing.checkboxtree.CheckBoxNodeEditor; @@ -464,6 +464,13 @@ protected void createChart(int index, JPanel plotPanel, String xAxisName, String chartPanels[index] = chartPanel; chartPanel.setFocusable(true); chartPanel.setAutoscrolls(true); + chartPanel.setMouseWheelEnabled(true); + chartPanel.restoreAutoBounds(); + chartPanel.setZoomInFactor(0.8); + chartPanel.setZoomOutFactor(1.2); + chartPanel.setZoomAroundAnchor(true); + chartPanel.setDomainZoomable(true); + chartPanel.setRangeZoomable(true); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.CENTER; @@ -477,7 +484,7 @@ protected void createChart(int index, JPanel plotPanel, String xAxisName, String XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(); lineRenderer.setUseFillPaint(true); - lineRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( + lineRenderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00")) ); @@ -494,7 +501,7 @@ public String generateLabel(XYDataset dataset, int series) { XYLineAndShapeRenderer lineRendererBest = new XYLineAndShapeRenderer(); lineRendererBest.setUseFillPaint(true); - lineRendererBest.setBaseToolTipGenerator(new StandardXYToolTipGenerator( + lineRendererBest.setDefaultToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00")) ); @@ -816,7 +823,7 @@ protected void loadLogFile() { br = new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsoluteFile()), Config.getEncoding())); String line = null; String [] elements = null; - while ((line = br.readLine()) != null && (elements = line.split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) + while ((line = br.readLine()) != null && (elements = line.trim().split(Utils.fileFieldSplitter, -1)) != null && elements.length < 2) continue; getColumnsFilters(elements); boolean resetColumns = false; @@ -866,7 +873,7 @@ else if (rc == 2) JTable table = runTables.get(i); setCursor(new Cursor(Cursor.WAIT_CURSOR)); while ((line = br.readLine()) != null) { - flds = line.split(Utils.fileFieldSplitter, -1); + flds = line.trim().split(Utils.fileFieldSplitter, -1); try { throttle = Double.valueOf(flds[logThtlAngleColIdx]); if (row == 0 && throttle < 99) @@ -1221,7 +1228,7 @@ private void saveConfig() { } private void loadConfig() { - String[] vvt1RpmColumn = Config.getVVT1RPMColumn().split(Utils.fileFieldSplitter, -1); + String[] vvt1RpmColumn = Config.getVVT1RPMColumn().trim().split(Utils.fileFieldSplitter, -1); if (vvt1RpmColumn != null) { for (int i = 0; i < vvt1RpmColumn.length; ++i) { Utils.ensureRowCount(i + 1, origTable); @@ -1230,7 +1237,7 @@ private void loadConfig() { } validateTable(origTable); } - String[] vvt2RpmColumn = Config.getVVT1RPMColumn().split(Utils.fileFieldSplitter, -1); + String[] vvt2RpmColumn = Config.getVVT1RPMColumn().trim().split(Utils.fileFieldSplitter, -1); if (vvt2RpmColumn != null) { for (int i = 0; i < vvt2RpmColumn.length; ++i) { Utils.ensureRowCount(i + 1, newTable); diff --git a/src/com/vgi/mafscaling/XYDomainMutilineAnnotation.java b/src/com/vgi/mafscaling/XYDomainMutilineAnnotation.java index 1fc7ad9..f5b365b 100644 --- a/src/com/vgi/mafscaling/XYDomainMutilineAnnotation.java +++ b/src/com/vgi/mafscaling/XYDomainMutilineAnnotation.java @@ -21,10 +21,10 @@ import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.ui.RectangleEdge; import org.jfree.text.TextUtilities; import org.jfree.ui.LengthAdjustmentType; import org.jfree.ui.RectangleAnchor; -import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import org.jfree.util.ShapeUtilities; diff --git a/src/com/vgi/mafscaling/closedloop.properties b/src/com/vgi/mafscaling/closedloop.properties index 8b1fb58..3c2afa7 100644 --- a/src/com/vgi/mafscaling/closedloop.properties +++ b/src/com/vgi/mafscaling/closedloop.properties @@ -29,7 +29,7 @@ The usage guide is based on wrxsti-l's post. Big thanks to all who have been act \
  • Open your tune in RomRaider.
  • \
  • Expand "Mass Airflow /Engine Load" tables group and copy "MAF Sensor Scaling" table by clicking "Edit"->"Copy Table" into the first cell of "Current MAF Scaling" table on the tool. If you copy MAF scaling from a vertically laid out table then use "Paste Vertical" right click menu option.
  • \ -
  • Click "POL Fueling" button to set open loop fueling data (optional). Open loop fueling table data is used to display "AFR Average" and "AFR Cell Hit Count" tables which serve only informational purpose.
    \ +
  • Click "POL Fueling" button to set open loop fueling data (optional, does not affect scaling calculations). Open loop fueling table X/Y-Axis are used to display "AFR Average" and "AFR Cell Hit Count" tables which serve only informational purpose.
    \
      \
    • Open your tune in RomRaider.
    • \
    • Expand "Fueling - Primary Open Loop" tables group and copy "Primary Open Loop Fueling" table by clicking "Edit"->"Copy Table" into the first cell of "Primary Open Loop Fueling" table on the tool.
    • \ diff --git a/src/com/vgi/mafscaling/logview.properties b/src/com/vgi/mafscaling/logview.properties index 933ae4d..300f454 100644 --- a/src/com/vgi/mafscaling/logview.properties +++ b/src/com/vgi/mafscaling/logview.properties @@ -23,6 +23,7 @@ note that curves are displayed based on filtered data set but disregards applied
    • To zoom in the plot use mouse to select area from top-left to right-bottom by clicking and dragging the cursor.
    • \
    • To zoom out the plot use mouse to select area from right to left by clicking and dragging the cursor.
    • \
    • Use zoom to increase performance, when the plot is zoomed in the program works faster.
    • \ +
    • Use Ctrl + left mouse button click and drag the mouse to move the chart.
    • \
    • If plot is zoomed in then adding or removing columns to plot do not automatically rescale the plot. So please zoom out first.
    • \
    • Drag the splitter bar to increase/decrease the panels. You can also click on arrows on the left-hand side of the splitter bar to extend desired panel
    • \
    • Log Replay:
    • \ diff --git a/src/ij/measure/CurveFitter.java b/src/ij/measure/CurveFitter.java index 75c9016..b7d62b1 100644 --- a/src/ij/measure/CurveFitter.java +++ b/src/ij/measure/CurveFitter.java @@ -84,10 +84,6 @@ public class CurveFitter { "y = a+b*Math.erf((x-c)/d)" //ERF; note that the c parameter is sqrt2 times the Gaussian sigma }; - /** @deprecated now in the Minimizer class (since ImageJ 1.46f). - * (probably of not much value for anyone anyhow?) */ - public static final int IterFactor = 500; - private static final int GAUSSIAN_INTERNAL = 101; // Gaussian with separate offset & multiplier private static final int RODBARD_INTERNAL = 102; // Rodbard with separate offset & multiplier