Only add CADataTypes that have a component tied to it
This commit is contained in:
parent
3598efd773
commit
32a2fcc849
@ -42,10 +42,10 @@ public class CAPlotPanel extends PlotPanel<CADataType, CADataBranch, CADataTypeG
|
||||
updatePlots();
|
||||
}
|
||||
|
||||
public static CAPlotPanel create(ComponentAnalysisPlotExportDialog parent) {
|
||||
public static CAPlotPanel create(ComponentAnalysisPlotExportDialog parent, CADataType[] typesY) {
|
||||
CADomainDataType[] typesX = new CADomainDataType[] { parent.getSelectedParameter() };
|
||||
|
||||
return new CAPlotPanel(parent, typesX, CADataType.ALL_TYPES);
|
||||
return new CAPlotPanel(parent, typesX, typesY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,7 +66,7 @@ public class CAPlotPanel extends PlotPanel<CADataType, CADataBranch, CADataTypeG
|
||||
|
||||
@Override
|
||||
protected CAPlotTypeSelector createSelector(int i, CADataType type, Unit unit, int axis) {
|
||||
return new CAPlotTypeSelector(parent, i, type, unit, axis, List.of(CADataType.ALL_TYPES),
|
||||
return new CAPlotTypeSelector(parent, i, type, unit, axis, List.of(typesY),
|
||||
parent.getComponentsForType(type), configuration);
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ public class ComponentAnalysisPlotExportDialog extends JDialog {
|
||||
private final CAParameters parameters;
|
||||
private final CAParameterSweep parameterSweep;
|
||||
|
||||
private final CADataType[] types;
|
||||
private final Map<CADataType, List<RocketComponent>> componentCache;
|
||||
private boolean isCacheValid;
|
||||
|
||||
@ -69,6 +70,8 @@ public class ComponentAnalysisPlotExportDialog extends JDialog {
|
||||
this.componentCache = new HashMap<>();
|
||||
this.isCacheValid = false;
|
||||
|
||||
this.types = getValidTypes();
|
||||
|
||||
// ======== Top panel ========
|
||||
addTopPanel(contentPanel);
|
||||
|
||||
@ -76,11 +79,11 @@ public class ComponentAnalysisPlotExportDialog extends JDialog {
|
||||
this.tabbedPane = new JTabbedPane();
|
||||
|
||||
//// Plot data
|
||||
this.plotTab = CAPlotPanel.create(this);
|
||||
this.plotTab = CAPlotPanel.create(this, types);
|
||||
this.tabbedPane.addTab(trans.get("CAPlotExportDialog.tab.Plot"), this.plotTab);
|
||||
|
||||
//// Export data
|
||||
this.exportTab = CAExportPanel.create(CADataType.ALL_TYPES);
|
||||
this.exportTab = CAExportPanel.create(types);
|
||||
this.tabbedPane.addTab(trans.get("CAPlotExportDialog.tab.Export"), this.exportTab);
|
||||
|
||||
contentPanel.add(tabbedPane, "grow, wrap");
|
||||
@ -280,6 +283,22 @@ public class ComponentAnalysisPlotExportDialog extends JDialog {
|
||||
isCacheValid = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the valid types for the current rocket, i.e. types that have at least once component bound to it.
|
||||
* @return all valid Component Analysis types for the current rocket
|
||||
*/
|
||||
private CADataType[] getValidTypes() {
|
||||
List<CADataType> validTypes = new ArrayList<>();
|
||||
List<RocketComponent> components;
|
||||
for (CADataType type : CADataType.ALL_TYPES) {
|
||||
components = getComponentsForType(type);
|
||||
if (!components.isEmpty()) {
|
||||
validTypes.add(type);
|
||||
}
|
||||
}
|
||||
return validTypes.toArray(new CADataType[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the parameter sweep and return the data branch.
|
||||
* @return the data branch containing the results of the parameter sweep
|
||||
|
@ -46,8 +46,8 @@ public class PlotPanel<T extends DataType & Groupable<G>,
|
||||
private C defaultConfiguration;
|
||||
|
||||
// Data types for the x and y axis + plot configuration
|
||||
private final T[] typesX;
|
||||
private final T[] typesY;
|
||||
protected final T[] typesX;
|
||||
protected final T[] typesY;
|
||||
protected C configuration;
|
||||
|
||||
private final JComboBox<C> configurationSelector;
|
||||
|
Loading…
x
Reference in New Issue
Block a user