Failed to add net.sf.openrocket.gui.plot.Util class to support
SimulationPlot changes.
This commit is contained in:
parent
2c7fcdb87c
commit
fbf5d3af03
36
core/src/net/sf/openrocket/gui/plot/Util.java
Normal file
36
core/src/net/sf/openrocket/gui/plot/Util.java
Normal file
@ -0,0 +1,36 @@
|
||||
package net.sf.openrocket.gui.plot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.openrocket.document.Simulation;
|
||||
|
||||
public abstract class Util {
|
||||
|
||||
public static List<String> generateSeriesLabels( Simulation simulation ) {
|
||||
int size = simulation.getSimulatedData().getBranchCount();
|
||||
ArrayList<String> stages = new ArrayList<String>(size);
|
||||
// we need to generate unique strings for each of the branches. Since the branch names are based
|
||||
// on the stage name there is no guarantee they are unique. In order to address this, we first assume
|
||||
// all the names are unique, then go through them looking for duplicates.
|
||||
for (int i = 0; i < simulation.getSimulatedData().getBranchCount(); i++) {
|
||||
stages.add(simulation.getSimulatedData().getBranch(i).getBranchName());
|
||||
}
|
||||
// check for duplicates:
|
||||
for( int i = 0; i< stages.size(); i++ ) {
|
||||
String stagename = stages.get(i);
|
||||
int numberDuplicates = Collections.frequency(stages, stagename);
|
||||
if ( numberDuplicates > 1 ) {
|
||||
int index = i;
|
||||
int count = 1;
|
||||
while( count <= numberDuplicates ) {
|
||||
stages.set(index, stagename + "(" + count + ")" );
|
||||
count ++;
|
||||
for( index++; index < stages.size() && !stagename.equals(stages.get(index)); index++ );
|
||||
}
|
||||
}
|
||||
}
|
||||
return stages;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user