import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
-import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
-import tim.prune.Config;
+import tim.prune.App;
+import tim.prune.GenericFunction;
import tim.prune.I18nManager;
import tim.prune.UpdateMessageBroker;
+import tim.prune.config.Config;
import tim.prune.data.Track;
import tim.prune.load.GenericFileFilter;
import tim.prune.threedee.LineDialog;
* Class to export track information
* into a specified Pov file
*/
-public class PovExporter
+public class PovExporter extends GenericFunction
{
- private JFrame _parentFrame = null;
private Track _track = null;
private JDialog _dialog = null;
private JFileChooser _fileChooser = null;
/**
* Constructor giving frame and track
- * @param inParentFrame parent frame
- * @param inTrack track object to save
+ * @param inApp App object
*/
- public PovExporter(JFrame inParentFrame, Track inTrack)
+ public PovExporter(App inApp)
{
- _parentFrame = inParentFrame;
- _track = inTrack;
+ super(inApp);
+ _track = inApp.getTrackInfo().getTrack();
// Set default camera coordinates
_cameraX = "17"; _cameraY = "13"; _cameraZ = "-20";
}
+ /** Get the name key */
+ public String getNameKey() {
+ return "function.exportpov";
+ }
/**
* Set the coordinates for the camera (can be any scale)
/**
* Show the dialog to select options and export file
*/
- public void showDialog()
+ public void begin()
{
// Make dialog window to select angles, colours etc
if (_dialog == null)
{
- _dialog = new JDialog(_parentFrame, I18nManager.getText("dialog.exportpov.title"), true);
+ _dialog = new JDialog(_parentFrame, I18nManager.getText(getNameKey()), true);
_dialog.setLocationRelativeTo(_parentFrame);
_dialog.getContentPane().add(makeDialogComponents());
}
_altitudeCapField.setText("" + _altitudeCap);
// Show dialog
_dialog.pack();
- _dialog.show();
+ _dialog.setVisible(true);
}
JLabel fontLabel = new JLabel(I18nManager.getText("dialog.exportpov.font"));
fontLabel.setHorizontalAlignment(SwingConstants.TRAILING);
centralPanel.add(fontLabel);
- String defaultFont = Config.getPovrayFont();
+ String defaultFont = Config.getConfigString(Config.KEY_POVRAY_FONT);
if (defaultFont == null || defaultFont.equals("")) {
defaultFont = DEFAULT_FONT_FILE;
}
_fileChooser.setFileFilter(new GenericFileFilter("filetype.pov", new String[] {"pov"}));
_fileChooser.setAcceptAllFileFilterUsed(false);
// start from directory in config which should be set
- File configDir = Config.getWorkingDirectory();
- if (configDir != null) {_fileChooser.setCurrentDirectory(configDir);}
+ final String configDir = Config.getConfigString(Config.KEY_TRACK_DIR);
+ if (configDir != null) {_fileChooser.setCurrentDirectory(new File(configDir));}
}
// Allow choose again if an existing file is selected
{
// file saved
// Store directory in config for later
- Config.setWorkingDirectory(file.getParentFile());
+ Config.setConfigString(Config.KEY_TRACK_DIR, file.getParentFile().getAbsolutePath());
}
else
{
}
catch (IOException ioe)
{
- JOptionPane.showMessageDialog(_parentFrame, I18nManager.getText("error.save.failed") + ioe.getMessage(),
+ JOptionPane.showMessageDialog(_parentFrame, I18nManager.getText("error.save.failed") + " : " + ioe.getMessage(),
I18nManager.getText("error.save.dialogtitle"), JOptionPane.ERROR_MESSAGE);
}
finally
{
fontPath = DEFAULT_FONT_FILE;
}
+ else {
+ Config.setConfigString(Config.KEY_POVRAY_FONT, fontPath);
+ }
// Set up output
String[] outputLines = {
"global_settings { ambient_light rgb <4, 4, 4> }", "",
" open",
" pigment { color rgb <0.5 0.5 0.5> }",
" }", "",
- // TODO: Export rods to POV? How to store in data?
+ // MAYBE: Export rods to POV? How to store in data?
"#declare waypoint_sphere =",
" sphere {",
" <0, 0, 0>, 0.4",
" pigment { color rgb <1 1 1> }",
" translate <-" + (inModelSize * 1.03) + ", 0.2, 0>",
"}", "",
- // TODO: Light positions should relate to model size
+ // MAYBE: Light positions should relate to model size
"// lights",
"light_source { <-1, 9, -4> color rgb <0.5 0.5 0.5>}",
"light_source { <1, 6, -14> color rgb <0.6 0.6 0.6>}",
inWriter.write(inLineSeparator);
// Loop over all the track segments
- ArrayList segmentList = getSegmentList(inModel);
- Iterator segmentIterator = segmentList.iterator();
+ ArrayList<ModelSegment> segmentList = getSegmentList(inModel);
+ Iterator<ModelSegment> segmentIterator = segmentList.iterator();
while (segmentIterator.hasNext())
{
- ModelSegment segment = (ModelSegment) segmentIterator.next();
+ ModelSegment segment = segmentIterator.next();
int segLength = segment.getNumTrackPoints();
// if the track segment is long enough, do a cubic spline sphere sweep
* @param inModel model containing data
* @return list of ModelSegment objects
*/
- private static ArrayList getSegmentList(ThreeDModel inModel)
+ private static ArrayList<ModelSegment> getSegmentList(ThreeDModel inModel)
{
- ArrayList segmentList = new ArrayList();
+ ArrayList<ModelSegment> segmentList = new ArrayList<ModelSegment>();
if (inModel != null && inModel.getNumPoints() > 0)
{
ModelSegment currSegment = null;