Implement clamping in while panning. Don't allow panning past the min
or max.
This commit is contained in:
parent
d9c0f68e64
commit
06e702839f
@ -49,41 +49,41 @@ import org.jfree.ui.RectangleAnchor;
|
|||||||
import org.jfree.ui.TextAnchor;
|
import org.jfree.ui.TextAnchor;
|
||||||
|
|
||||||
public class SimulationPlot {
|
public class SimulationPlot {
|
||||||
|
|
||||||
private static final float PLOT_STROKE_WIDTH = 1.5f;
|
private static final float PLOT_STROKE_WIDTH = 1.5f;
|
||||||
|
|
||||||
private final JFreeChart chart;
|
private final JFreeChart chart;
|
||||||
|
|
||||||
private final PlotConfiguration config;
|
private final PlotConfiguration config;
|
||||||
private final Simulation simulation;
|
private final Simulation simulation;
|
||||||
private final PlotConfiguration filled;
|
private final PlotConfiguration filled;
|
||||||
|
|
||||||
private final List<EventDisplayInfo> eventList;
|
private final List<EventDisplayInfo> eventList;
|
||||||
private final List<ModifiedXYItemRenderer> renderers = new ArrayList<ModifiedXYItemRenderer>();
|
private final List<ModifiedXYItemRenderer> renderers = new ArrayList<ModifiedXYItemRenderer>();
|
||||||
|
|
||||||
int branchCount;
|
int branchCount;
|
||||||
|
|
||||||
void setShowPoints( boolean showPoints ) {
|
void setShowPoints(boolean showPoints) {
|
||||||
for (ModifiedXYItemRenderer r : renderers) {
|
for (ModifiedXYItemRenderer r : renderers) {
|
||||||
r.setBaseShapesVisible(showPoints);
|
r.setBaseShapesVisible(showPoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setShowBranch( int branch ) {
|
void setShowBranch(int branch) {
|
||||||
XYPlot plot = (XYPlot) chart.getPlot();
|
XYPlot plot = (XYPlot) chart.getPlot();
|
||||||
int datasetcount = plot.getDatasetCount();
|
int datasetcount = plot.getDatasetCount();
|
||||||
for( int i =0; i< datasetcount; i++ ) {
|
for (int i = 0; i < datasetcount; i++) {
|
||||||
int seriescount = ((XYSeriesCollection)plot.getDataset(i)).getSeriesCount();
|
int seriescount = ((XYSeriesCollection) plot.getDataset(i)).getSeriesCount();
|
||||||
XYItemRenderer r = ((XYPlot)chart.getPlot()).getRenderer(i);
|
XYItemRenderer r = ((XYPlot) chart.getPlot()).getRenderer(i);
|
||||||
for( int j=0; j<seriescount; j++) {
|
for (int j = 0; j < seriescount; j++) {
|
||||||
boolean show = (branch<0) || (j % branchCount == branch);
|
boolean show = (branch < 0) || (j % branchCount == branch);
|
||||||
r.setSeriesVisible(j, show);
|
r.setSeriesVisible(j, show);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawDomainMarkers(branch);
|
drawDomainMarkers(branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulationPlot( Simulation simulation, PlotConfiguration config, boolean initialShowPoints ) {
|
SimulationPlot(Simulation simulation, PlotConfiguration config, boolean initialShowPoints) {
|
||||||
this.simulation = simulation;
|
this.simulation = simulation;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
@ -98,31 +98,31 @@ public class SimulationPlot {
|
|||||||
true,
|
true,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
chart.addSubtitle(new TextTitle(config.getName()));
|
chart.addSubtitle(new TextTitle(config.getName()));
|
||||||
|
|
||||||
this.branchCount = simulation.getSimulatedData().getBranchCount();
|
this.branchCount = simulation.getSimulatedData().getBranchCount();
|
||||||
|
|
||||||
// Fill the auto-selections based on first branch selected.
|
// Fill the auto-selections based on first branch selected.
|
||||||
FlightDataBranch mainBranch = simulation.getSimulatedData().getBranch( 0 );
|
FlightDataBranch mainBranch = simulation.getSimulatedData().getBranch(0);
|
||||||
this.filled = config.fillAutoAxes(mainBranch);
|
this.filled = config.fillAutoAxes(mainBranch);
|
||||||
List<Axis> axes = filled.getAllAxes();
|
List<Axis> axes = filled.getAllAxes();
|
||||||
|
|
||||||
// Create the data series for both axes
|
// Create the data series for both axes
|
||||||
XYSeriesCollection[] data = new XYSeriesCollection[2];
|
XYSeriesCollection[] data = new XYSeriesCollection[2];
|
||||||
data[0] = new XYSeriesCollection();
|
data[0] = new XYSeriesCollection();
|
||||||
data[1] = new XYSeriesCollection();
|
data[1] = new XYSeriesCollection();
|
||||||
|
|
||||||
// Get the domain axis type
|
// Get the domain axis type
|
||||||
final FlightDataType domainType = filled.getDomainAxisType();
|
final FlightDataType domainType = filled.getDomainAxisType();
|
||||||
final Unit domainUnit = filled.getDomainAxisUnit();
|
final Unit domainUnit = filled.getDomainAxisUnit();
|
||||||
if (domainType == null) {
|
if (domainType == null) {
|
||||||
throw new IllegalArgumentException("Domain axis type not specified.");
|
throw new IllegalArgumentException("Domain axis type not specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get plot length (ignore trailing NaN's)
|
// Get plot length (ignore trailing NaN's)
|
||||||
int typeCount = filled.getTypeCount();
|
int typeCount = filled.getTypeCount();
|
||||||
|
|
||||||
// Create the XYSeries objects from the flight data and store into the collections
|
// Create the XYSeries objects from the flight data and store into the collections
|
||||||
String[] axisLabel = new String[2];
|
String[] axisLabel = new String[2];
|
||||||
for (int i = 0; i < typeCount; i++) {
|
for (int i = 0; i < typeCount; i++) {
|
||||||
@ -131,34 +131,34 @@ public class SimulationPlot {
|
|||||||
Unit unit = filled.getUnit(i);
|
Unit unit = filled.getUnit(i);
|
||||||
int axis = filled.getAxis(i);
|
int axis = filled.getAxis(i);
|
||||||
String name = getLabel(type, unit);
|
String name = getLabel(type, unit);
|
||||||
|
|
||||||
List<String> seriesNames = Util.generateSeriesLabels(simulation);
|
List<String> seriesNames = Util.generateSeriesLabels(simulation);
|
||||||
for( int branchIndex=0; branchIndex<branchCount; branchIndex++ ) {
|
for (int branchIndex = 0; branchIndex < branchCount; branchIndex++) {
|
||||||
FlightDataBranch thisBranch = simulation.getSimulatedData().getBranch(branchIndex);
|
FlightDataBranch thisBranch = simulation.getSimulatedData().getBranch(branchIndex);
|
||||||
// Store data in provided units
|
// Store data in provided units
|
||||||
List<Double> plotx = thisBranch.get(domainType);
|
List<Double> plotx = thisBranch.get(domainType);
|
||||||
List<Double> ploty = thisBranch.get(type);
|
List<Double> ploty = thisBranch.get(type);
|
||||||
XYSeries series = new XYSeries(seriesNames.get(branchIndex) + ": " + name, false, true);
|
XYSeries series = new XYSeries(seriesNames.get(branchIndex) + ": " + name, false, true);
|
||||||
series.setDescription(thisBranch.getBranchName()+": " + name);
|
series.setDescription(thisBranch.getBranchName() + ": " + name);
|
||||||
int pointCount = plotx.size();
|
int pointCount = plotx.size();
|
||||||
for (int j = 0; j < pointCount; j++) {
|
for (int j = 0; j < pointCount; j++) {
|
||||||
series.add(domainUnit.toUnit(plotx.get(j)), unit.toUnit(ploty.get(j)));
|
series.add(domainUnit.toUnit(plotx.get(j)), unit.toUnit(ploty.get(j)));
|
||||||
}
|
}
|
||||||
data[axis].addSeries(series);
|
data[axis].addSeries(series);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update axis label
|
// Update axis label
|
||||||
if (axisLabel[axis] == null)
|
if (axisLabel[axis] == null)
|
||||||
axisLabel[axis] = type.getName();
|
axisLabel[axis] = type.getName();
|
||||||
else
|
else
|
||||||
axisLabel[axis] += "; " + type.getName();
|
axisLabel[axis] += "; " + type.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the data and formatting to the plot
|
// Add the data and formatting to the plot
|
||||||
XYPlot plot = chart.getXYPlot();
|
XYPlot plot = chart.getXYPlot();
|
||||||
plot.setDomainPannable(true);
|
plot.setDomainPannable(true);
|
||||||
plot.setRangePannable(true);
|
plot.setRangePannable(true);
|
||||||
|
|
||||||
int axisno = 0;
|
int axisno = 0;
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
// Check whether axis has any data
|
// Check whether axis has any data
|
||||||
@ -170,7 +170,12 @@ public class SimulationPlot {
|
|||||||
axis.setLabel(axisLabel[i]);
|
axis.setLabel(axisLabel[i]);
|
||||||
// axis.setRange(axes.get(i).getMinValue(), axes.get(i).getMaxValue());
|
// axis.setRange(axes.get(i).getMinValue(), axes.get(i).getMaxValue());
|
||||||
plot.setRangeAxis(axisno, axis);
|
plot.setRangeAxis(axisno, axis);
|
||||||
|
|
||||||
|
double domainMin = data[i].getDomainLowerBound(true);
|
||||||
|
double domainMax = data[i].getDomainUpperBound(true);
|
||||||
|
|
||||||
|
plot.setDomainAxis(new PresetNumberAxis(domainMin, domainMax));
|
||||||
|
|
||||||
// Add data and map to the axis
|
// Add data and map to the axis
|
||||||
plot.setDataset(axisno, data[i]);
|
plot.setDataset(axisno, data[i]);
|
||||||
ModifiedXYItemRenderer r = new ModifiedXYItemRenderer(branchCount);
|
ModifiedXYItemRenderer r = new ModifiedXYItemRenderer(branchCount);
|
||||||
@ -185,25 +190,25 @@ public class SimulationPlot {
|
|||||||
axisno++;
|
axisno++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plot.getDomainAxis().setLabel(getLabel(domainType, domainUnit));
|
plot.getDomainAxis().setLabel(getLabel(domainType, domainUnit));
|
||||||
plot.addDomainMarker(new ValueMarker(0));
|
plot.addDomainMarker(new ValueMarker(0));
|
||||||
plot.addRangeMarker(new ValueMarker(0));
|
plot.addRangeMarker(new ValueMarker(0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create list of events to show (combine event too close to each other)
|
// Create list of events to show (combine event too close to each other)
|
||||||
this.eventList = buildEventInfo();
|
this.eventList = buildEventInfo();
|
||||||
|
|
||||||
// Create the event markers
|
// Create the event markers
|
||||||
drawDomainMarkers(-1);
|
drawDomainMarkers(-1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JFreeChart getJFreeChart() {
|
JFreeChart getJFreeChart() {
|
||||||
return chart;
|
return chart;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getLabel(FlightDataType type, Unit unit) {
|
private String getLabel(FlightDataType type, Unit unit) {
|
||||||
String name = type.getName();
|
String name = type.getName();
|
||||||
if (unit != null && !UnitGroup.UNITS_NONE.contains(unit) &&
|
if (unit != null && !UnitGroup.UNITS_NONE.contains(unit) &&
|
||||||
@ -211,16 +216,16 @@ public class SimulationPlot {
|
|||||||
name += " (" + unit.getUnit() + ")";
|
name += " (" + unit.getUnit() + ")";
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawDomainMarkers( int stage ) {
|
private void drawDomainMarkers(int stage) {
|
||||||
XYPlot plot = chart.getXYPlot();
|
XYPlot plot = chart.getXYPlot();
|
||||||
FlightDataBranch mainBranch = simulation.getSimulatedData().getBranch( 0 );
|
FlightDataBranch mainBranch = simulation.getSimulatedData().getBranch(0);
|
||||||
|
|
||||||
// Clear existing domain markers
|
// Clear existing domain markers
|
||||||
plot.clearDomainMarkers();
|
plot.clearDomainMarkers();
|
||||||
|
|
||||||
// Construct domain marker lists collapsing based on time.
|
// Construct domain marker lists collapsing based on time.
|
||||||
|
|
||||||
List<Double> eventTimes = new ArrayList<Double>();
|
List<Double> eventTimes = new ArrayList<Double>();
|
||||||
List<String> eventLabels = new ArrayList<String>();
|
List<String> eventLabels = new ArrayList<String>();
|
||||||
List<Color> eventColors = new ArrayList<Color>();
|
List<Color> eventColors = new ArrayList<Color>();
|
||||||
@ -231,25 +236,25 @@ public class SimulationPlot {
|
|||||||
String text = null;
|
String text = null;
|
||||||
Color color = null;
|
Color color = null;
|
||||||
Image image = null;
|
Image image = null;
|
||||||
for( EventDisplayInfo info : eventList ) {
|
for (EventDisplayInfo info : eventList) {
|
||||||
if ( stage >=0 && stage != info.stage ) {
|
if (stage >= 0 && stage != info.stage) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double t = info.time;
|
double t = info.time;
|
||||||
FlightEvent.Type type = info.event.getType();
|
FlightEvent.Type type = info.event.getType();
|
||||||
|
|
||||||
if (Math.abs(t - prevTime) <= 0.05) {
|
if (Math.abs(t - prevTime) <= 0.05) {
|
||||||
|
|
||||||
if (!typeSet.contains(type)) {
|
if (!typeSet.contains(type)) {
|
||||||
text = text + ", " + type.toString();
|
text = text + ", " + type.toString();
|
||||||
color = EventGraphics.getEventColor(type);
|
color = EventGraphics.getEventColor(type);
|
||||||
image = EventGraphics.getEventImage(type);
|
image = EventGraphics.getEventImage(type);
|
||||||
typeSet.add(type);
|
typeSet.add(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
eventTimes.add(prevTime);
|
eventTimes.add(prevTime);
|
||||||
eventLabels.add(text);
|
eventLabels.add(text);
|
||||||
@ -263,7 +268,7 @@ public class SimulationPlot {
|
|||||||
typeSet.clear();
|
typeSet.clear();
|
||||||
typeSet.add(type);
|
typeSet.add(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
eventTimes.add(prevTime);
|
eventTimes.add(prevTime);
|
||||||
@ -275,13 +280,13 @@ public class SimulationPlot {
|
|||||||
|
|
||||||
// Plot the markers
|
// Plot the markers
|
||||||
if (config.getDomainAxisType() == FlightDataType.TYPE_TIME) {
|
if (config.getDomainAxisType() == FlightDataType.TYPE_TIME) {
|
||||||
|
|
||||||
// Domain time is plotted as vertical markers
|
// Domain time is plotted as vertical markers
|
||||||
for ( int i=0; i<eventTimes.size(); i++ ) {
|
for (int i = 0; i < eventTimes.size(); i++) {
|
||||||
double t = eventTimes.get(i);
|
double t = eventTimes.get(i);
|
||||||
String event = eventLabels.get(i);
|
String event = eventLabels.get(i);
|
||||||
Color color = eventColors.get(i);
|
Color color = eventColors.get(i);
|
||||||
|
|
||||||
ValueMarker m = new ValueMarker(t);
|
ValueMarker m = new ValueMarker(t);
|
||||||
m.setLabel(event);
|
m.setLabel(event);
|
||||||
m.setPaint(color);
|
m.setPaint(color);
|
||||||
@ -289,41 +294,41 @@ public class SimulationPlot {
|
|||||||
m.setAlpha(0.7f);
|
m.setAlpha(0.7f);
|
||||||
plot.addDomainMarker(m);
|
plot.addDomainMarker(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Other domains are plotted as image annotations
|
// Other domains are plotted as image annotations
|
||||||
List<Double> time = mainBranch.get(FlightDataType.TYPE_TIME);
|
List<Double> time = mainBranch.get(FlightDataType.TYPE_TIME);
|
||||||
List<Double> domain = mainBranch.get(config.getDomainAxisType());
|
List<Double> domain = mainBranch.get(config.getDomainAxisType());
|
||||||
|
|
||||||
LinearInterpolator domainInterpolator = new LinearInterpolator( time, domain );
|
LinearInterpolator domainInterpolator = new LinearInterpolator(time, domain);
|
||||||
|
|
||||||
for ( int i=0; i<eventTimes.size(); i++ ) {
|
for (int i = 0; i < eventTimes.size(); i++) {
|
||||||
double t = eventTimes.get(i);
|
double t = eventTimes.get(i);
|
||||||
String event = eventLabels.get(i);
|
String event = eventLabels.get(i);
|
||||||
Image image = eventImages.get(i);
|
Image image = eventImages.get(i);
|
||||||
|
|
||||||
if (image == null)
|
if (image == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
double xcoord = domainInterpolator.getValue(t);
|
double xcoord = domainInterpolator.getValue(t);
|
||||||
for (int index = 0; index < config.getTypeCount(); index++) {
|
for (int index = 0; index < config.getTypeCount(); index++) {
|
||||||
FlightDataType type = config.getType(index);
|
FlightDataType type = config.getType(index);
|
||||||
List<Double> range = mainBranch.get(type);
|
List<Double> range = mainBranch.get(type);
|
||||||
|
|
||||||
LinearInterpolator rangeInterpolator = new LinearInterpolator(time, range);
|
LinearInterpolator rangeInterpolator = new LinearInterpolator(time, range);
|
||||||
// Image annotations are not supported on the right-side axis
|
// Image annotations are not supported on the right-side axis
|
||||||
// TODO: LOW: Can this be achieved by JFreeChart?
|
// TODO: LOW: Can this be achieved by JFreeChart?
|
||||||
if (filled.getAxis(index) != SimulationPlotPanel.LEFT) {
|
if (filled.getAxis(index) != SimulationPlotPanel.LEFT) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double ycoord = rangeInterpolator.getValue(t);
|
double ycoord = rangeInterpolator.getValue(t);
|
||||||
|
|
||||||
// Convert units
|
// Convert units
|
||||||
xcoord = config.getDomainAxisUnit().toUnit(xcoord);
|
xcoord = config.getDomainAxisUnit().toUnit(xcoord);
|
||||||
ycoord = config.getUnit(index).toUnit(ycoord);
|
ycoord = config.getUnit(index).toUnit(ycoord);
|
||||||
|
|
||||||
XYImageAnnotation annotation =
|
XYImageAnnotation annotation =
|
||||||
new XYImageAnnotation(xcoord, ycoord, image, RectangleAnchor.CENTER);
|
new XYImageAnnotation(xcoord, ycoord, image, RectangleAnchor.CENTER);
|
||||||
annotation.setToolTipText(event);
|
annotation.setToolTipText(event);
|
||||||
@ -335,12 +340,12 @@ public class SimulationPlot {
|
|||||||
|
|
||||||
private List<EventDisplayInfo> buildEventInfo() {
|
private List<EventDisplayInfo> buildEventInfo() {
|
||||||
ArrayList<EventDisplayInfo> eventList = new ArrayList<EventDisplayInfo>();
|
ArrayList<EventDisplayInfo> eventList = new ArrayList<EventDisplayInfo>();
|
||||||
|
|
||||||
for( int branch=0; branch<branchCount; branch++ ) {
|
for (int branch = 0; branch < branchCount; branch++) {
|
||||||
List<FlightEvent> events = simulation.getSimulatedData().getBranch(branch).getEvents();
|
List<FlightEvent> events = simulation.getSimulatedData().getBranch(branch).getEvents();
|
||||||
for( FlightEvent event : events ) {
|
for (FlightEvent event : events) {
|
||||||
FlightEvent.Type type = event.getType();
|
FlightEvent.Type type = event.getType();
|
||||||
if ( type != FlightEvent.Type.ALTITUDE && config.isEventActive(type)) {
|
if (type != FlightEvent.Type.ALTITUDE && config.isEventActive(type)) {
|
||||||
EventDisplayInfo info = new EventDisplayInfo();
|
EventDisplayInfo info = new EventDisplayInfo();
|
||||||
info.stage = branch;
|
info.stage = branch;
|
||||||
info.time = event.getTime();
|
info.time = event.getTime();
|
||||||
@ -351,11 +356,13 @@ public class SimulationPlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(eventList, new Comparator<EventDisplayInfo>() {
|
Collections.sort(eventList, new Comparator<EventDisplayInfo>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(EventDisplayInfo o1, EventDisplayInfo o2) {
|
public int compare(EventDisplayInfo o1, EventDisplayInfo o2) {
|
||||||
if ( o1.time< o2.time) return -1;
|
if (o1.time < o2.time)
|
||||||
if ( o1.time == o2.time)return 0;
|
return -1;
|
||||||
|
if (o1.time == o2.time)
|
||||||
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,61 +370,8 @@ public class SimulationPlot {
|
|||||||
|
|
||||||
return eventList;
|
return eventList;
|
||||||
|
|
||||||
/*
|
|
||||||
double prevTime = -100;
|
|
||||||
String text = null;
|
|
||||||
Color color = null;
|
|
||||||
Image image = null;
|
|
||||||
for ( int branch=0; branch<branchCount; branch++ ) {
|
|
||||||
List<FlightEvent> events = simulation.getSimulatedData().getBranch(branch).getEvents();
|
|
||||||
for (int i = 0; i < events.size(); i++) {
|
|
||||||
FlightEvent event = events.get(i);
|
|
||||||
double t = event.getTime();
|
|
||||||
FlightEvent.Type type = event.getType();
|
|
||||||
|
|
||||||
if (type != FlightEvent.Type.ALTITUDE && config.isEventActive(type)) {
|
|
||||||
if (Math.abs(t - prevTime) <= 0.05) {
|
|
||||||
|
|
||||||
if (!typeSet.contains(type)) {
|
|
||||||
text = text + ", " + type.toString();
|
|
||||||
color = EventGraphics.getEventColor(type);
|
|
||||||
image = EventGraphics.getEventImage(type);
|
|
||||||
typeSet.add(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (text != null) {
|
|
||||||
EventDisplayInfo info = new EventDisplayInfo();
|
|
||||||
info.time = prevTime;
|
|
||||||
info.event = text;
|
|
||||||
info.color = color;
|
|
||||||
info.image = image;
|
|
||||||
eventList.add(info);
|
|
||||||
}
|
|
||||||
prevTime = t;
|
|
||||||
text = type.toString();
|
|
||||||
color = EventGraphics.getEventColor(type);
|
|
||||||
image = EventGraphics.getEventImage(type);
|
|
||||||
typeSet.clear();
|
|
||||||
typeSet.add(type);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (text != null) {
|
|
||||||
EventDisplayInfo info = new EventDisplayInfo();
|
|
||||||
info.time = prevTime;
|
|
||||||
info.event = text;
|
|
||||||
info.color = color;
|
|
||||||
info.image = image;
|
|
||||||
eventList.add(info);
|
|
||||||
}
|
|
||||||
return eventList;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A modification to the standard renderer that renders the domain marker
|
* A modification to the standard renderer that renders the domain marker
|
||||||
* labels vertically instead of horizontally.
|
* labels vertically instead of horizontally.
|
||||||
@ -435,68 +389,68 @@ public class SimulationPlot {
|
|||||||
* series c stage 1
|
* series c stage 1
|
||||||
*/
|
*/
|
||||||
private static class ModifiedXYItemRenderer extends XYLineAndShapeRenderer {
|
private static class ModifiedXYItemRenderer extends XYLineAndShapeRenderer {
|
||||||
|
|
||||||
private final int branchCount;
|
private final int branchCount;
|
||||||
|
|
||||||
private ModifiedXYItemRenderer( int branchCount ) {
|
private ModifiedXYItemRenderer(int branchCount) {
|
||||||
this.branchCount = branchCount;
|
this.branchCount = branchCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Paint lookupSeriesPaint(int series) {
|
public Paint lookupSeriesPaint(int series) {
|
||||||
return super.lookupSeriesPaint(series/branchCount);
|
return super.lookupSeriesPaint(series / branchCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Paint lookupSeriesFillPaint(int series) {
|
public Paint lookupSeriesFillPaint(int series) {
|
||||||
return super.lookupSeriesFillPaint(series/branchCount);
|
return super.lookupSeriesFillPaint(series / branchCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Paint lookupSeriesOutlinePaint(int series) {
|
public Paint lookupSeriesOutlinePaint(int series) {
|
||||||
return super.lookupSeriesOutlinePaint(series/branchCount);
|
return super.lookupSeriesOutlinePaint(series / branchCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stroke lookupSeriesStroke(int series) {
|
public Stroke lookupSeriesStroke(int series) {
|
||||||
return super.lookupSeriesStroke(series/branchCount);
|
return super.lookupSeriesStroke(series / branchCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stroke lookupSeriesOutlineStroke(int series) {
|
public Stroke lookupSeriesOutlineStroke(int series) {
|
||||||
return super.lookupSeriesOutlineStroke(series/branchCount);
|
return super.lookupSeriesOutlineStroke(series / branchCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Shape lookupSeriesShape(int series) {
|
public Shape lookupSeriesShape(int series) {
|
||||||
return DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[series%branchCount%DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE.length];
|
return DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[series % branchCount % DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Shape lookupLegendShape(int series) {
|
public Shape lookupLegendShape(int series) {
|
||||||
return DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[series%branchCount%DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE.length];
|
return DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[series % branchCount % DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Font lookupLegendTextFont(int series) {
|
public Font lookupLegendTextFont(int series) {
|
||||||
return super.lookupLegendTextFont(series/branchCount);
|
return super.lookupLegendTextFont(series / branchCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Paint lookupLegendTextPaint(int series) {
|
public Paint lookupLegendTextPaint(int series) {
|
||||||
return super.lookupLegendTextPaint(series/branchCount);
|
return super.lookupLegendTextPaint(series / branchCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawDomainMarker(Graphics2D g2, XYPlot plot, ValueAxis domainAxis,
|
public void drawDomainMarker(Graphics2D g2, XYPlot plot, ValueAxis domainAxis,
|
||||||
Marker marker, Rectangle2D dataArea) {
|
Marker marker, Rectangle2D dataArea) {
|
||||||
|
|
||||||
if (!(marker instanceof ValueMarker)) {
|
if (!(marker instanceof ValueMarker)) {
|
||||||
// Use parent for all others
|
// Use parent for all others
|
||||||
super.drawDomainMarker(g2, plot, domainAxis, marker, dataArea);
|
super.drawDomainMarker(g2, plot, domainAxis, marker, dataArea);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Draw the normal marker, but with rotated text.
|
* Draw the normal marker, but with rotated text.
|
||||||
* Copied from the overridden method.
|
* Copied from the overridden method.
|
||||||
@ -507,9 +461,9 @@ public class SimulationPlot {
|
|||||||
if (!range.contains(value)) {
|
if (!range.contains(value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double v = domainAxis.valueToJava2D(value, dataArea, plot.getDomainAxisEdge());
|
double v = domainAxis.valueToJava2D(value, dataArea, plot.getDomainAxisEdge());
|
||||||
|
|
||||||
PlotOrientation orientation = plot.getOrientation();
|
PlotOrientation orientation = plot.getOrientation();
|
||||||
Line2D line = null;
|
Line2D line = null;
|
||||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||||
@ -517,14 +471,14 @@ public class SimulationPlot {
|
|||||||
} else {
|
} else {
|
||||||
line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
|
line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
|
||||||
}
|
}
|
||||||
|
|
||||||
final Composite originalComposite = g2.getComposite();
|
final Composite originalComposite = g2.getComposite();
|
||||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker
|
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker
|
||||||
.getAlpha()));
|
.getAlpha()));
|
||||||
g2.setPaint(marker.getPaint());
|
g2.setPaint(marker.getPaint());
|
||||||
g2.setStroke(marker.getStroke());
|
g2.setStroke(marker.getStroke());
|
||||||
g2.draw(line);
|
g2.draw(line);
|
||||||
|
|
||||||
String label = marker.getLabel();
|
String label = marker.getLabel();
|
||||||
RectangleAnchor anchor = marker.getLabelAnchor();
|
RectangleAnchor anchor = marker.getLabelAnchor();
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
@ -533,8 +487,8 @@ public class SimulationPlot {
|
|||||||
g2.setPaint(marker.getLabelPaint());
|
g2.setPaint(marker.getLabelPaint());
|
||||||
Point2D coordinates = calculateDomainMarkerTextAnchorPoint(g2,
|
Point2D coordinates = calculateDomainMarkerTextAnchorPoint(g2,
|
||||||
orientation, dataArea, line.getBounds2D(), marker
|
orientation, dataArea, line.getBounds2D(), marker
|
||||||
.getLabelOffset(), LengthAdjustmentType.EXPAND, anchor);
|
.getLabelOffset(), LengthAdjustmentType.EXPAND, anchor);
|
||||||
|
|
||||||
// Changed:
|
// Changed:
|
||||||
TextAnchor textAnchor = TextAnchor.TOP_RIGHT;
|
TextAnchor textAnchor = TextAnchor.TOP_RIGHT;
|
||||||
TextUtilities.drawRotatedString(label, g2, (float) coordinates.getX() + 2,
|
TextUtilities.drawRotatedString(label, g2, (float) coordinates.getX() + 2,
|
||||||
@ -543,29 +497,42 @@ public class SimulationPlot {
|
|||||||
}
|
}
|
||||||
g2.setComposite(originalComposite);
|
g2.setComposite(originalComposite);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PresetNumberAxis extends NumberAxis {
|
private static class PresetNumberAxis extends NumberAxis {
|
||||||
private final double min;
|
private final double min;
|
||||||
private final double max;
|
private final double max;
|
||||||
|
|
||||||
public PresetNumberAxis(double min, double max) {
|
public PresetNumberAxis(double min, double max) {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
autoAdjustRange();
|
autoAdjustRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void autoAdjustRange() {
|
protected void autoAdjustRange() {
|
||||||
this.setRange(min, max);
|
this.setRange(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRange(Range range) {
|
||||||
|
double lowerValue = range.getLowerBound();
|
||||||
|
double upperValue = range.getUpperBound();
|
||||||
|
if (lowerValue < min || upperValue > max) {
|
||||||
|
// Don't blow past the min & max of the range this is important to keep
|
||||||
|
// panning constrained within the current bounds.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.setRange(new Range(lowerValue, upperValue));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EventDisplayInfo {
|
private static class EventDisplayInfo {
|
||||||
int stage;
|
int stage;
|
||||||
double time;
|
double time;
|
||||||
FlightEvent event;
|
FlightEvent event;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user