Skip to content

Commit

Permalink
Fixed 3D plots for Load/IAT/VE tabs broken after moving to merged 3D …
Browse files Browse the repository at this point in the history
…library
  • Loading branch information
vimsh committed Mar 24, 2016
1 parent 22c4836 commit 080c17c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
Binary file modified MafScaling.jar
Binary file not shown.
6 changes: 5 additions & 1 deletion src/com/vgi/mafscaling/ACompCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,11 @@ protected void plot3dCorrection() {
for (i = 0; i < yAxisArray.size(); ++i)
y[i] = yAxisArray.get(i);
double[][] z = Utils.doubleZArray(corrTable, x, y);
Color[][] colors = Utils.generateTableColorMatrix(corrTable, 1, 1);
Color[][] tableColors = Utils.generateTableColorMatrix(corrTable, 1, 1, y.length + 1, x.length + 1);
Color[][] colors = new Color[y.length][x.length];
for (int j = 1; j < tableColors.length; ++j)
for (i = 1; i < tableColors[j].length; ++i)
colors[j - 1][i - 1] = tableColors[j][i];
plot3d.addGridPlot("Average Error % Plot", colors, x, y, z);
}
catch (Exception e) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/vgi/mafscaling/MafScaling.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

public class MafScaling {
private static final Logger logger = Logger.getLogger(MafScaling.class);
private static final String Title = "MAF Scaling - v2.2.2";
private static final String Title = "MAF Scaling - v2.2.3";
private static final String OLTabName = "<html>Open Loop</html>";
private static final String CLTabName = "<html>Closed Loop</html>";
private static final String RTabName = "<html>Rescale</html>";
Expand Down
47 changes: 28 additions & 19 deletions src/com/vgi/mafscaling/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public final class Utils {
public final static String onOffRegex = "(?i)^\\s*(ON|OFF|OPENED|OPEN|CLOSED|CLOSE)\\s*$";
public final static Pattern offPattern = Pattern.compile("^\\s*(OFF|CLOSED|CLOSE)\\s*$", Pattern.CASE_INSENSITIVE);
public final static Pattern onPattern = Pattern.compile("^\\s*(ON|OPENED|OPEN)\\s*$", Pattern.CASE_INSENSITIVE);
public final static Color ZeroColor = new Color(255, 255, 255, 0);

private static long baseTime = 0;

Expand Down Expand Up @@ -107,33 +108,41 @@ public static Color[] getColorArray(Color begin, Color end, int numColors) {
* @param startColumn, column to begin coloring from
*/
public static Color[][] generateTableColorMatrix(JTable table, int startRow, int startColumn) {
return generateTableColorMatrix(table, startRow, startColumn, table.getRowCount(), table.getColumnCount());
}

/**
* Methods return table gradient colors matrix
* @param table, table to get matrix for
* @param startRow, row to begin coloring from
* @param startColumn, column to begin coloring from
* @param endRow, row to finish coloring on
* @param endColumn, column to finish coloring on
* @return
*/
public static Color[][] generateTableColorMatrix(JTable table, int startRow, int startColumn, int endRow, int endColumn) {
Color[][] colorMatrix = null;
TreeSet<Double> uniqueValues = new TreeSet<Double>();
int i, j;
Object cellValue;
String value;
for (i = startRow; i < table.getRowCount(); ++i) {
for (j = startColumn; j < table.getColumnCount(); ++j) {
cellValue = table.getValueAt(i, j);
if (cellValue != null) {
value = cellValue.toString();
if (!value.isEmpty() && Pattern.matches(Utils.fpRegex, value))
uniqueValues.add(Double.valueOf(value));
}
for (i = startRow; i < endRow; ++i) {
for (j = startColumn; j < endColumn; ++j) {
value = table.getValueAt(i, j).toString();
if (!value.isEmpty() && Pattern.matches(Utils.fpRegex, value))
uniqueValues.add(Double.valueOf(value));
}
}
if (uniqueValues.size() > 0) {
List<Color> colors = Arrays.asList(Utils.getColorArray(uniqueValues.size()));
Collections.reverse(colors);
colorMatrix = new Color[table.getRowCount()][table.getColumnCount()];
for (i = startRow; i < table.getRowCount(); ++i) {
for (j = startColumn; j < table.getColumnCount(); ++j) {
cellValue = table.getValueAt(i, j);
if (cellValue != null) {
value = cellValue.toString();
if (!value.isEmpty() && Pattern.matches(Utils.fpRegex, value))
colorMatrix[i][j] = colors.get(uniqueValues.headSet(Double.valueOf(value)).size());
}
colorMatrix = new Color[endRow][endColumn];
for (i = startRow; i < endRow; ++i) {
for (j = startColumn; j < endColumn; ++j) {
value = table.getValueAt(i, j).toString();
if (!value.isEmpty() && Pattern.matches(Utils.fpRegex, value))
colorMatrix[i][j] = colors.get(uniqueValues.headSet(Double.valueOf(value)).size());
else
colorMatrix[i][j] = ZeroColor;
}
}
}
Expand Down Expand Up @@ -421,7 +430,7 @@ public static Color[][] doubleColorArray(JTable dataTable, double[] x, double[]
if (!dataTable.getValueAt(j + 1, i + 1).toString().isEmpty())
z[j][i] = renderer.getColorAt(j + 1, i + 1);
else
z[j][i] = new Color(255, 255, 255, 0);
z[j][i] = ZeroColor;
}
}
return z;
Expand Down
6 changes: 5 additions & 1 deletion src/com/vgi/mafscaling/VECalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,11 @@ private boolean plotCorrectionData() {
for (i = 0; i < yAxisArray.size(); ++i)
y[i] = yAxisArray.get(i);
double[][] z = Utils.doubleZArray(corrTable, x, y);
Color[][] colors = Utils.generateTableColorMatrix(corrTable, 1, 1);
Color[][] tableColors = Utils.generateTableColorMatrix(corrTable, 1, 1, y.length + 1, x.length + 1);
Color[][] colors = new Color[y.length][x.length];
for (j = 1; j < tableColors.length; ++j)
for (i = 1; i < tableColors[j].length; ++i)
colors[j - 1][i - 1] = tableColors[j][i];
plot3d.addGridPlot("Average Error % Plot", colors, x, y, z);
}
catch (NumberFormatException e) {
Expand Down

0 comments on commit 080c17c

Please sign in to comment.