Skip to content

Commit

Permalink
Merge pull request #6 from ajayyy/multi-data-source
Browse files Browse the repository at this point in the history
Multi data source UI improvements
  • Loading branch information
ajayyy authored May 24, 2020
2 parents f22b54b + 127ea98 commit 501dad3
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 103 deletions.
Binary file added libs/XChart-source-3.6.1.zip
Binary file not shown.
10 changes: 5 additions & 5 deletions src/uorocketry/basestation/DataChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ public class DataChart {
/** The snap panel for this chart */
SnapPanel snapPanel;

Window window;
Main main;

// The active chart series on this chart
String[] activeSeries = new String[0];

DataType[] xTypes = {DataHandler.ALTITUDE};
DataType yType = DataHandler.TIMESTAMP;

public DataChart(Window window, XYChart xyChart, XChartPanel<XYChart> chartPanel) {
this.window = window;
public DataChart(Main main, XYChart xyChart, XChartPanel<XYChart> chartPanel) {
this.main = main;

this.xyChart = xyChart;
this.chartPanel = chartPanel;
Expand All @@ -32,8 +32,8 @@ public DataChart(Window window, XYChart xyChart, XChartPanel<XYChart> chartPanel
}
}

public DataChart(Window window, XYChart xyChart, XChartPanel<XYChart> chartPanel, DataType[] xTypes) {
this(window, xyChart, chartPanel);
public DataChart(Main main, XYChart xyChart, XChartPanel<XYChart> chartPanel, DataType[] xTypes) {
this(main, xyChart, chartPanel);

this.xTypes = xTypes;
}
Expand Down
17 changes: 16 additions & 1 deletion src/uorocketry/basestation/DataHandler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package uorocketry.basestation;

import java.util.LinkedList;
import java.util.List;

import javax.swing.JTable;
import javax.swing.table.TableModel;

Expand All @@ -24,6 +27,10 @@ public class DataHandler {
static final DataType GPS_FIX_QUALITY = new DataType(14, 0);

Data[] data;
DataType[] types;

/** Which of this data should be hidden for any reason */
List<DataType> hiddenDataTypes = new LinkedList<DataType>();

/**
* This chooses which table this data is displayed in
Expand All @@ -34,6 +41,11 @@ public DataHandler(int tableIndex) {
this.tableIndex = tableIndex;

this.data = new Data[Main.dataLength.get(tableIndex)];

types = new DataType[Main.dataLength.get(tableIndex)];
for (int i = 0; i < types.length; i++) {
types[i] = new DataType(i, tableIndex);
}
}

public void updateTableUIWithData(JTable table, String[] labels) {
Expand All @@ -43,8 +55,11 @@ public void updateTableUIWithData(JTable table, String[] labels) {
// Set label
tableModel.setValueAt(labels[i], i, 0);

String dataText = data[i].getFormattedString();
if (hiddenDataTypes.contains(types[i])) dataText = "Hidden Data";

// Set data
tableModel.setValueAt(data[i].getFormattedString(), i, 1);
tableModel.setValueAt(dataText, i, 1);
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/uorocketry/basestation/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ public DataType(int index, int tableIndex) {
this.tableIndex = tableIndex;
}

@Override
public boolean equals(Object object) {
if (object != null && object.getClass() == getClass()) {
DataType other = (DataType) object;

return equals(other.index, other.tableIndex);
}

return false;
}

public boolean equals(int index, int tableIndex) {
return this.index == index && this.tableIndex == tableIndex;
}
Expand Down
Loading

0 comments on commit 501dad3

Please sign in to comment.