import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
+import javax.swing.JLabel;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.document.Simulation;
+import net.sf.openrocket.gui.components.StyledLabel;
+import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.simulation.FlightDataBranch;
import net.sf.openrocket.simulation.FlightDataType;
import net.sf.openrocket.simulation.FlightEvent;
+import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.Unit;
import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.BugException;
public class PlotDialog extends JDialog {
private static final float PLOT_STROKE_WIDTH = 1.5f;
+ private static final Translator trans = Application.getTranslator();
private static final Color DEFAULT_EVENT_COLOR = new Color(0, 0, 0);
private static final Map<FlightEvent.Type, Color> EVENT_COLORS =
new ArrayList<ModifiedXYItemRenderer>();
private PlotDialog(Window parent, Simulation simulation, PlotConfiguration config) {
- super(parent, "Flight data plot");
+ //// Flight data plot
+ super(parent, trans.get("PlotDialog.title.Flightdataplot"));
this.setModalityType(ModalityType.DOCUMENT_MODAL);
final boolean initialShowPoints = Prefs.getBoolean(Prefs.PLOT_SHOW_POINTS, false);
// Create the chart using the factory to get all default settings
JFreeChart chart = ChartFactory.createXYLineChart(
- "Simulated flight",
+ //// Simulated flight
+ trans.get("PlotDialog.Chart.Simulatedflight"),
null,
null,
null,
}
}
- final double xcoord;
+ double xcoord;
if (a == 0) {
xcoord = domain.get(tindex);
} else {
FlightDataType type = config.getType(index);
List<Double> range = branch.get(type);
- final double ycoord;
+ // Image annotations are not supported on the right-side axis
+ // TODO: LOW: Can this be achieved by JFreeChart?
+ if (filled.getAxis(index) != SimulationPlotPanel.LEFT) {
+ continue;
+ }
+
+ double ycoord;
if (a == 0) {
ycoord = range.get(tindex);
} else {
ycoord = a * range.get(tindex) + (1 - a) * range.get(tindex + 1);
}
+ // Convert units
+ xcoord = config.getDomainAxisUnit().toUnit(xcoord);
+ ycoord = config.getUnit(index).toUnit(ycoord);
+
XYImageAnnotation annotation =
- new XYImageAnnotation(xcoord, ycoord, image, RectangleAnchor.CENTER);
+ new XYImageAnnotation(xcoord, ycoord, image, RectangleAnchor.CENTER);
annotation.setToolTipText(event);
plot.addAnnotation(annotation);
}
panel.add(chartPanel, "grow, wrap 20lp");
- final JCheckBox check = new JCheckBox("Show data points");
+ //// Show data points
+ final JCheckBox check = new JCheckBox(trans.get("PlotDialog.CheckBox.Showdatapoints"));
check.setSelected(initialShowPoints);
check.addActionListener(new ActionListener() {
@Override
});
panel.add(check, "split, left");
+
+ JLabel label = new StyledLabel(trans.get("PlotDialog.lbl.Chart"), -2);
+ panel.add(label, "gapleft para");
+
+
panel.add(new JPanel(), "growx");
- JButton button = new JButton("Close");
+ //// Close button
+ JButton button = new JButton(trans.get("dlg.but.close"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
GUIUtil.setDisposableDialogOptions(this, button);
}
-
private String getLabel(FlightDataType type, Unit unit) {
String name = type.getName();
if (unit != null && !UnitGroup.UNITS_NONE.contains(unit) &&