1 package tim.prune.threedee;
3 import java.awt.BorderLayout;
4 import java.awt.FlowLayout;
5 import java.awt.event.ActionEvent;
6 import java.awt.event.ActionListener;
8 import javax.swing.BorderFactory;
9 import javax.swing.JButton;
10 import javax.swing.JDialog;
11 import javax.swing.JEditorPane;
12 import javax.swing.JFrame;
13 import javax.swing.JPanel;
15 import tim.prune.I18nManager;
16 import tim.prune.data.Latitude;
17 import tim.prune.data.Longitude;
20 * Class to show a dialog displaying the line coordinates
21 * for a 3d view (either java3d or povray)
23 public class LineDialog
25 private JDialog _dialog = null;
26 private JFrame _parent = null;
27 private double[] _latLines = null;
28 private double[] _lonLines = null;
32 * Constructor giving parent frame, latitude and longitude lines
33 * @param inParent parent frame for dialog
34 * @param inLatLines latitude lines as doubles
35 * @param inLonLines longitude lines as doubles
37 public LineDialog(JFrame inParent, double[] inLatLines, double[] inLonLines)
40 _latLines = inLatLines;
41 _lonLines = inLonLines;
46 * Show the dialog with the lines
48 public void showDialog()
50 _dialog = new JDialog(_parent, I18nManager.getText("dialog.3dlines.title"), true);
51 _dialog.setLocationRelativeTo(_parent);
52 _dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
53 _dialog.getContentPane().add(makeDialogComponents());
55 _dialog.setVisible(true);
60 * @return dialog components
62 private JPanel makeDialogComponents()
64 JPanel panel = new JPanel();
65 panel.setLayout(new BorderLayout());
66 StringBuffer descBuffer = new StringBuffer();
67 if (_latLines == null || _latLines.length == 0 || _lonLines == null || _lonLines.length == 0)
69 descBuffer.append("<p>").append(I18nManager.getText("dialog.3dlines.empty")).append("</p>");
73 descBuffer.append("<p>").append(I18nManager.getText("dialog.3dlines.intro")).append(":</p>");
74 descBuffer.append("<p>").append(I18nManager.getText("fieldname.latitude")).append("<ul>");
76 for (int i=0; i<_latLines.length; i++)
78 lat = new Latitude(_latLines[i], Latitude.FORMAT_DEG);
79 descBuffer.append("<li>").append(lat.output(Latitude.FORMAT_DEG_WHOLE_MIN)).append("</li>");
81 descBuffer.append("</ul></p>");
82 descBuffer.append("<p>").append(I18nManager.getText("fieldname.longitude")).append("<ul>");
84 for (int i=0; i<_lonLines.length; i++)
86 lon = new Longitude(_lonLines[i], Longitude.FORMAT_DEG);
87 descBuffer.append("<li>").append(lon.output(Longitude.FORMAT_DEG_WHOLE_MIN)).append("</li>");
89 descBuffer.append("</ul></p>");
91 JEditorPane descPane = new JEditorPane("text/html", descBuffer.toString());
92 descPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
93 descPane.setEditable(false);
94 descPane.setOpaque(false);
95 panel.add(descPane, BorderLayout.CENTER);
97 JPanel buttonPanel = new JPanel();
98 buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
99 JButton okButton = new JButton(I18nManager.getText("button.ok"));
100 okButton.addActionListener(new ActionListener() {
101 public void actionPerformed(ActionEvent e)
107 buttonPanel.add(okButton);
108 panel.add(buttonPanel, BorderLayout.SOUTH);