[#2385] Use plot colors for thrust curves
This commit is contained in:
parent
48d9532e2f
commit
30c7f63cf7
@ -48,6 +48,8 @@ class MotorInformationPanel extends JPanel {
|
|||||||
private static Color WITH_COMMENT_COLOR;
|
private static Color WITH_COMMENT_COLOR;
|
||||||
private static Color textColor;
|
private static Color textColor;
|
||||||
private static Color dimTextColor;
|
private static Color dimTextColor;
|
||||||
|
private static Color backgroundColor;
|
||||||
|
private static Color gridColor;
|
||||||
private static Border border;
|
private static Border border;
|
||||||
|
|
||||||
// Motors in set
|
// Motors in set
|
||||||
@ -203,9 +205,9 @@ class MotorInformationPanel extends JPanel {
|
|||||||
title.setPaint(textColor);
|
title.setPaint(textColor);
|
||||||
chart.setTitle(title);
|
chart.setTitle(title);
|
||||||
chart.setBackgroundPaint(this.getBackground());
|
chart.setBackgroundPaint(this.getBackground());
|
||||||
plot.setBackgroundPaint(Color.WHITE);
|
plot.setBackgroundPaint(backgroundColor);
|
||||||
plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
|
plot.setDomainGridlinePaint(gridColor);
|
||||||
plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
|
plot.setRangeGridlinePaint(gridColor);
|
||||||
|
|
||||||
chartPanel = new ChartPanel(chart,
|
chartPanel = new ChartPanel(chart,
|
||||||
false, // properties
|
false, // properties
|
||||||
@ -259,6 +261,8 @@ class MotorInformationPanel extends JPanel {
|
|||||||
WITH_COMMENT_COLOR = GUIUtil.getUITheme().getTextColor();
|
WITH_COMMENT_COLOR = GUIUtil.getUITheme().getTextColor();
|
||||||
textColor = GUIUtil.getUITheme().getTextColor();
|
textColor = GUIUtil.getUITheme().getTextColor();
|
||||||
dimTextColor = GUIUtil.getUITheme().getDimTextColor();
|
dimTextColor = GUIUtil.getUITheme().getDimTextColor();
|
||||||
|
backgroundColor = GUIUtil.getUITheme().getBackgroundColor();
|
||||||
|
gridColor = GUIUtil.getUITheme().getFinPointGridMajorLineColor();
|
||||||
border = GUIUtil.getUITheme().getBorder();
|
border = GUIUtil.getUITheme().getBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package net.sf.openrocket.gui.dialogs.motor.thrustcurve;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.Paint;
|
import java.awt.Paint;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@ -45,6 +44,7 @@ import javax.swing.event.RowSorterListener;
|
|||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
import javax.swing.table.TableRowSorter;
|
import javax.swing.table.TableRowSorter;
|
||||||
|
|
||||||
|
import net.sf.openrocket.gui.plot.Util;
|
||||||
import net.sf.openrocket.gui.util.UITheme;
|
import net.sf.openrocket.gui.util.UITheme;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
import org.jfree.chart.ChartColor;
|
import org.jfree.chart.ChartColor;
|
||||||
@ -609,7 +609,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
|||||||
|
|
||||||
|
|
||||||
public static Color getColor(int index) {
|
public static Color getColor(int index) {
|
||||||
Color color = (Color) CURVE_COLORS[index % CURVE_COLORS.length];
|
Color color = Util.getPlotColor(index);
|
||||||
if (UITheme.isLightTheme(GUIUtil.getUITheme())) {
|
if (UITheme.isLightTheme(GUIUtil.getUITheme())) {
|
||||||
return color;
|
return color;
|
||||||
} else {
|
} else {
|
||||||
@ -752,16 +752,22 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
|||||||
public Component getListCellRendererComponent(JList<? extends MotorHolder> list, MotorHolder value, int index,
|
public Component getListCellRendererComponent(JList<? extends MotorHolder> list, MotorHolder value, int index,
|
||||||
boolean isSelected, boolean cellHasFocus) {
|
boolean isSelected, boolean cellHasFocus) {
|
||||||
|
|
||||||
Component c = renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
JLabel label = (JLabel) renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
if (value instanceof MotorHolder) {
|
if (value != null) {
|
||||||
MotorHolder m = (MotorHolder) value;
|
Color color = getColor(value.getIndex());
|
||||||
c.setForeground(getColor(m.getIndex()));
|
if (isSelected || cellHasFocus) {
|
||||||
|
label.setBackground(color);
|
||||||
|
label.setOpaque(true);
|
||||||
|
Color fg = list.getBackground();
|
||||||
|
fg = new Color(fg.getRed(), fg.getGreen(), fg.getBlue()); // List background changes for some reason, so clone the color
|
||||||
|
label.setForeground(fg);
|
||||||
|
} else {
|
||||||
|
label.setBackground(list.getBackground());
|
||||||
|
label.setForeground(color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -240,13 +240,8 @@ public class SimulationPlot {
|
|||||||
plot.setDomainGridlinesVisible(true);
|
plot.setDomainGridlinesVisible(true);
|
||||||
plot.setDomainGridlinePaint(Color.lightGray);
|
plot.setDomainGridlinePaint(Color.lightGray);
|
||||||
|
|
||||||
Color[] colors = {new Color(0,114,189), // Colors for data lines
|
int cumulativeSeriesCount = 0;
|
||||||
new Color(217,83,25),
|
|
||||||
new Color(237,177,32),
|
|
||||||
new Color(126,49,142),
|
|
||||||
new Color(119,172,48),
|
|
||||||
new Color(77,190,238),
|
|
||||||
new Color(162,20,47)};
|
|
||||||
for (int axisno = 0; axisno < 2; axisno++) {
|
for (int axisno = 0; axisno < 2; axisno++) {
|
||||||
// Check whether axis has any data
|
// Check whether axis has any data
|
||||||
if (data[axisno].getSeriesCount() > 0) {
|
if (data[axisno].getSeriesCount() > 0) {
|
||||||
@ -299,13 +294,19 @@ public class SimulationPlot {
|
|||||||
plot.setRenderer(axisno, r);
|
plot.setRenderer(axisno, r);
|
||||||
r.setBaseShapesVisible(initialShowPoints);
|
r.setBaseShapesVisible(initialShowPoints);
|
||||||
r.setBaseShapesFilled(true);
|
r.setBaseShapesFilled(true);
|
||||||
r.setSeriesPaint(0, colors[axisno]);
|
|
||||||
r.setSeriesPaint(1, colors[axisno+2]);
|
// Set colors for all series of the current axis
|
||||||
r.setSeriesPaint(2, colors[axisno+4]);
|
for (int seriesIndex = 0; seriesIndex < data[axisno].getSeriesCount(); seriesIndex++) {
|
||||||
for (int j = 0; j < data[axisno].getSeriesCount(); j++) {
|
int colorIndex = cumulativeSeriesCount + seriesIndex;
|
||||||
|
r.setSeriesPaint(seriesIndex, Util.getPlotColor(colorIndex));
|
||||||
|
|
||||||
Stroke lineStroke = new BasicStroke(PLOT_STROKE_WIDTH);
|
Stroke lineStroke = new BasicStroke(PLOT_STROKE_WIDTH);
|
||||||
r.setSeriesStroke(j, lineStroke);
|
r.setSeriesStroke(seriesIndex, lineStroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the cumulative count for the next axis
|
||||||
|
cumulativeSeriesCount += data[axisno].getSeriesCount();
|
||||||
|
|
||||||
// Now we pull the colors for the legend.
|
// Now we pull the colors for the legend.
|
||||||
for (int j = 0; j < data[axisno].getSeriesCount(); j += branchCount) {
|
for (int j = 0; j < data[axisno].getSeriesCount(); j += branchCount) {
|
||||||
String name = data[axisno].getSeries(j).getDescription();
|
String name = data[axisno].getSeries(j).getDescription();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.sf.openrocket.gui.plot;
|
package net.sf.openrocket.gui.plot;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -7,6 +8,18 @@ import java.util.List;
|
|||||||
import net.sf.openrocket.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
|
|
||||||
public abstract class Util {
|
public abstract class Util {
|
||||||
|
private static final Color[] PLOT_COLORS = {
|
||||||
|
new Color(0,114,189),
|
||||||
|
new Color(217,83,25),
|
||||||
|
new Color(237,177,32),
|
||||||
|
new Color(126,49,142),
|
||||||
|
new Color(119,172,48),
|
||||||
|
new Color(77,190,238),
|
||||||
|
new Color(162,20,47),
|
||||||
|
new Color(197, 106, 122),
|
||||||
|
new Color(255, 127, 80),
|
||||||
|
new Color(85, 107, 47),
|
||||||
|
};
|
||||||
|
|
||||||
public static List<String> generateSeriesLabels( Simulation simulation ) {
|
public static List<String> generateSeriesLabels( Simulation simulation ) {
|
||||||
int size = simulation.getSimulatedData().getBranchCount();
|
int size = simulation.getSimulatedData().getBranchCount();
|
||||||
@ -33,4 +46,8 @@ public abstract class Util {
|
|||||||
}
|
}
|
||||||
return stages;
|
return stages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Color getPlotColor(int index) {
|
||||||
|
return PLOT_COLORS[index % PLOT_COLORS.length];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user