diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 2e3bbdc1c..615319afe 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -1504,6 +1504,7 @@ TCMotorSelPan.btn.close = Close ! PlotDialog PlotDialog.CheckBox.Showdatapoints = Show data points PlotDialog.lbl.Chart = left click drag to zoom area. mouse wheel to zoom. ctrl-mouse wheel to zoom x axis only. ctrl-left click drag to pan. right click drag to zoom dynamically. +PlotDialog.lbl.timeSeriesWarning = The data is plotted in time order even though the X axis type is not time. PlotDialog.btn.exportImage = Export Image ComponentTree.ttip.massoverride = mass overriden diff --git a/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java b/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java index b60d4f6ad..2c666eff2 100644 --- a/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java +++ b/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java @@ -18,6 +18,9 @@ import java.io.FileOutputStream; import javax.swing.JTextPane; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledDocument; import javax.swing.JEditorPane; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -188,6 +191,7 @@ public class DescriptionArea extends JScrollPane { } }); + setForeground(editorPane.getForeground()); editorPane.scrollRectToVisible(new Rectangle(0, 0, 1, 1)); } @@ -202,5 +206,23 @@ public class DescriptionArea extends JScrollPane { editorPane.setFont(font); } } + + public void setBackground(Color color) { + if (editorPane == null) return; + editorPane.setBackground(color); + StyledDocument styledDocument = (StyledDocument) editorPane.getDocument(); + SimpleAttributeSet attributeSet = new SimpleAttributeSet(); + StyleConstants.setForeground(attributeSet, color); + styledDocument.setCharacterAttributes(0, styledDocument.getLength(), attributeSet, false); + } + + public void setForeground(Color color) { + if (editorPane == null) return; + editorPane.setForeground(color); + StyledDocument styledDocument = (StyledDocument) editorPane.getDocument(); + SimpleAttributeSet attributeSet = new SimpleAttributeSet(); + StyleConstants.setForeground(attributeSet, color); + styledDocument.setCharacterAttributes(0, styledDocument.getLength(), attributeSet, false); + } } diff --git a/swing/src/net/sf/openrocket/gui/plot/SimulationPlotDialog.java b/swing/src/net/sf/openrocket/gui/plot/SimulationPlotDialog.java index d9c1724ea..db19ab496 100644 --- a/swing/src/net/sf/openrocket/gui/plot/SimulationPlotDialog.java +++ b/swing/src/net/sf/openrocket/gui/plot/SimulationPlotDialog.java @@ -28,8 +28,10 @@ import net.sf.openrocket.gui.util.Icons; import net.sf.openrocket.gui.util.SwingPreferences; import net.sf.openrocket.gui.widgets.SaveFileChooser; import net.sf.openrocket.l10n.Translator; +import net.sf.openrocket.simulation.FlightDataType; import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Preferences; +import net.sf.openrocket.util.Color; import net.sf.openrocket.gui.widgets.SelectColorButton; import org.jfree.chart.ChartPanel; @@ -71,6 +73,13 @@ public class SimulationPlotDialog extends JDialog { //// Description text JLabel label = new StyledLabel(trans.get("PlotDialog.lbl.Chart"), -2); panel.add(label, "wrap"); + + // Add warning if X axis type is not time + if (config.getDomainAxisType() != FlightDataType.TYPE_TIME) { + JLabel msg = new StyledLabel(trans.get("PlotDialog.lbl.timeSeriesWarning"), -2); + msg.setForeground(Color.DARK_RED.toAWTColor()); + panel.add(msg, "wrap"); + } //// Show data points final JCheckBox check = new JCheckBox(trans.get("PlotDialog.CheckBox.Showdatapoints")); diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java index c28cc606c..d926118a9 100644 --- a/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java +++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java @@ -40,6 +40,7 @@ import net.sf.openrocket.simulation.FlightEvent; import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Preferences; import net.sf.openrocket.unit.Unit; +import net.sf.openrocket.util.Color; import net.sf.openrocket.util.Utils; import net.sf.openrocket.gui.widgets.SelectColorButton; @@ -105,7 +106,8 @@ public class SimulationPlotPanel extends JPanel { private int modifying = 0; - + + private DescriptionArea simPlotPanelDesc; public SimulationPlotPanel(final Simulation simulation) { super(new MigLayout("fill")); @@ -170,6 +172,14 @@ public class SimulationPlotPanel extends JPanel { if (modifying > 0) return; FlightDataType type = (FlightDataType) domainTypeSelector.getSelectedItem(); + if (type == FlightDataType.TYPE_TIME) { + simPlotPanelDesc.setVisible(false); + simPlotPanelDesc.setText(""); + } + else { + simPlotPanelDesc.setVisible(true); + simPlotPanelDesc.setText(trans.get("simplotpanel.Desc")); + } configuration.setDomainAxisType(type); domainUnitSelector.setUnitGroup(type.getUnitGroup()); domainUnitSelector.setSelectedUnit(configuration.getDomainAxisUnit()); @@ -193,9 +203,12 @@ public class SimulationPlotPanel extends JPanel { this.add(domainUnitSelector, "width 40lp, gapright para"); //// The data will be plotted in time order even if the X axis type is not time. - DescriptionArea desc = new DescriptionArea(trans.get("simplotpanel.Desc"), 2, -2f); - desc.setViewportBorder(BorderFactory.createEmptyBorder()); - this.add(desc, "width 1px, growx 1, wrap unrel"); + simPlotPanelDesc = new DescriptionArea("", 2, -2f, false); + simPlotPanelDesc.setVisible(false); + simPlotPanelDesc.setForeground(Color.DARK_RED.toAWTColor()); + simPlotPanelDesc.setViewportBorder(BorderFactory.createEmptyBorder()); + this.add(simPlotPanelDesc, "width 1px, growx 1, wrap unrel"); +