From: Nicolas <ni...@us...> - 2004-11-30 20:28:50
|
Update of /cvsroot/jmol/Jmol/src/org/openscience/jmol/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26046/src/org/openscience/jmol/app Modified Files: PovrayDialog.java Log Message: PovrayDialog: option to use .ini file Index: PovrayDialog.java =================================================================== RCS file: /cvsroot/jmol/Jmol/src/org/openscience/jmol/app/PovrayDialog.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- PovrayDialog.java 24 Nov 2004 21:08:38 -0000 1.24 +++ PovrayDialog.java 30 Nov 2004 20:28:39 -0000 1.25 @@ -51,6 +51,8 @@ import javax.swing.InputVerifier; import java.io.FileNotFoundException; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.util.Vector; /** @@ -64,25 +66,22 @@ public class PovrayDialog extends JDialog { private JmolViewer viewer; - boolean callPovray = true; - boolean doAntiAlias = true; - boolean displayWhileRendering = true; - String savePath; - String basename = "I'm a bug"; - String commandLine = "Hello, I'm a bug!!"; - String povrayPath = "I'm a bug, lets party"; - JButton povrayPathButton; - JCheckBox antiAlias; - JCheckBox displayWhileRenderingBox; - JTextField commandLineField; - JButton goButton; - JTextField saveField; - private JTextField savePathLabel; - private int outputWidth = -1; - private int outputHeight = -1; - private JTextField povrayPathLabel; - private JCheckBox imageSizeBox; + protected JButton povrayPathButton; + protected JTextField commandLineField; + protected JButton goButton; + protected JTextField saveField; + protected JTextField savePathLabel; + private int outputWidth = -1; + private int outputHeight = -1; + protected JTextField povrayPathLabel; + + protected JCheckBox runPovCheck; + protected JCheckBox useIniCheck; + protected JCheckBox antiAliasCheck; + protected JCheckBox displayWhileRenderingCheck; + + private JCheckBox imageSizeCheck; private JLabel imageSizeWidth; private JFormattedTextField imageSizeTextWidth; private JLabel imageSizeHeight; @@ -90,16 +89,22 @@ private JCheckBox imageSizeRatioBox; private JComboBox imageSizeRatioCombo; - private JCheckBox outputFormatBox; + private JCheckBox outputFormatCheck; private JComboBox outputFormatCombo; - private JCheckBox outputAlphaBox; + private JCheckBox outputAlphaCheck; - private JCheckBox mosaicPreviewBox; + private JCheckBox mosaicPreviewCheck; private JLabel mosaicPreviewStart; private JComboBox mosaicPreviewComboStart; private JLabel mosaicPreviewEnd; private JComboBox mosaicPreviewComboEnd; + + // Event management + private ActionListener updateActionListener = null; + private InputVerifier updateInputVerifier = null; + private ItemListener updateItemListener = null; + /** * Creates a dialog for getting info related to output frames in @@ -112,7 +117,6 @@ super(f, JmolResourceHandler .getStringX("Povray.povrayDialogTitle"), true); this.viewer = viewer; - basename = "jmol"; // String text = null; @@ -120,9 +124,26 @@ //Take the height and width settings from the JFrame int screenWidth = viewer.getScreenWidth(); int screenHeight = viewer.getScreenHeight(); - getPathHistory(); setImageDimensions(screenWidth, screenHeight); + // Event management + updateActionListener = new ActionListener() { + public void actionPerformed(ActionEvent e) { + updateScreen(); + } + }; + updateInputVerifier = new InputVerifier() { + public boolean verify(JComponent component) { + updateScreen(); + return true; + } + }; + updateItemListener = new ItemListener() { + public void itemStateChanged(ItemEvent e) { + updateScreen(); + } + }; + //Box: Window Box windowBox = Box.createVerticalBox(); getContentPane().add(windowBox); @@ -140,22 +161,9 @@ saveBox.setBorder(new TitledBorder(text)); text = JmolResourceHandler.getStringX("Povray.workingNameTip"); saveBox.setToolTipText(text); - saveField = new JTextField(basename, 20); - saveField.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - basename = saveField.getText(); - updateCommandLine(); - } - }); - saveField.setInputVerifier(new InputVerifier() { - public boolean verify(JComponent component) { - JTextField fld = (JTextField)component; - basename = fld.getText(); - updateCommandLine(); - return true; - } - }); + saveField = new JTextField("jmol", 20); + saveField.addActionListener(updateActionListener); + saveField.setInputVerifier(updateInputVerifier); saveBox.add(saveField); justSavingBox.add(saveBox); @@ -165,7 +173,7 @@ savePathBox.setBorder(new TitledBorder(text)); text = JmolResourceHandler.getStringX("Povray.workingDirectoryTip"); savePathBox.setToolTipText(text); - savePathLabel = new JTextField(savePath); + savePathLabel = new JTextField(""); savePathLabel.setEditable(false); savePathLabel.setBorder(null); savePathBox.add(savePathLabel); @@ -189,89 +197,60 @@ // Run povray option Box runPovBox = Box.createHorizontalBox(); text = JmolResourceHandler.getStringX("Povray.runPov"); - JCheckBox runPovCheck = new JCheckBox(text, true); + runPovCheck = new JCheckBox(text, true); text = JmolResourceHandler.getStringX("Povray.runPovTip"); runPovCheck.setToolTipText(text); - runPovCheck.addItemListener(new ItemListener() { - - public void itemStateChanged(ItemEvent e) { - - if (e.getStateChange() == ItemEvent.SELECTED) { - callPovray = true; - String text = JmolResourceHandler.getStringX("Povray.goLabel"); - goButton.setText(text); - } else if (e.getStateChange() == ItemEvent.DESELECTED) { - callPovray = false; - String text = JmolResourceHandler.getStringX("Povray.saveLabel"); - goButton.setText(text); - } - povrayPathButton.setEnabled(callPovray); - antiAlias.setEnabled(callPovray); - displayWhileRenderingBox.setEnabled(callPovray); - commandLineField.setEnabled(callPovray); - } - }); + runPovCheck.addItemListener(updateItemListener); runPovBox.add(runPovCheck); runPovBox.add(Box.createGlue()); povOptionsBox.add(runPovBox); + // Use Ini option + Box useIniBox = Box.createHorizontalBox(); + text = JmolResourceHandler.getStringX("Povray.useIni"); + useIniCheck = new JCheckBox(text, true); + text = JmolResourceHandler.getStringX("Povray.useIniTip"); + useIniCheck.setToolTipText(text); + useIniCheck.addItemListener(updateItemListener); + useIniBox.add(useIniCheck); + useIniBox.add(Box.createGlue()); + povOptionsBox.add(useIniBox); + // Antialias option Box antiAliasBox = Box.createHorizontalBox(); text = JmolResourceHandler.getStringX("Povray.antiAlias"); - antiAlias = new JCheckBox(text, doAntiAlias); + antiAliasCheck = new JCheckBox(text, true); text = JmolResourceHandler.getStringX("Povray.antiAliasTip"); - antiAlias.setToolTipText(text); - antiAlias.addItemListener(new ItemListener() { - - public void itemStateChanged(ItemEvent e) { - - if (e.getStateChange() == ItemEvent.SELECTED) { - doAntiAlias = true; - } else if (e.getStateChange() == ItemEvent.DESELECTED) { - doAntiAlias = false; - } - updateCommandLine(); - } - }); - antiAliasBox.add(antiAlias); + antiAliasCheck.setToolTipText(text); + antiAliasCheck.addItemListener(updateItemListener); + antiAliasBox.add(antiAliasCheck); antiAliasBox.add(Box.createGlue()); povOptionsBox.add(antiAliasBox); // Display when rendering option Box displayBox = Box.createHorizontalBox(); text = JmolResourceHandler.getStringX("Povray.displayWhileRendering"); - displayWhileRenderingBox = new JCheckBox(text, displayWhileRendering); + displayWhileRenderingCheck = new JCheckBox(text, true); text = JmolResourceHandler.getStringX("Povray.displayWhileRenderingTip"); - displayWhileRenderingBox.setToolTipText(text); - displayWhileRenderingBox.addItemListener(new ItemListener() { - - public void itemStateChanged(ItemEvent e) { - - if (e.getStateChange() == ItemEvent.SELECTED) { - displayWhileRendering = true; - } else if (e.getStateChange() == ItemEvent.DESELECTED) { - displayWhileRendering = false; - } - updateCommandLine(); - } - }); - displayBox.add(displayWhileRenderingBox); + displayWhileRenderingCheck.setToolTipText(text); + displayWhileRenderingCheck.addItemListener(updateItemListener); + displayBox.add(displayWhileRenderingCheck); displayBox.add(Box.createGlue()); povOptionsBox.add(displayBox); // Image size option Box imageBox = Box.createHorizontalBox(); text = JmolResourceHandler.getStringX("Povray.imageSize"); - imageSizeBox = new JCheckBox(text, false); + imageSizeCheck = new JCheckBox(text, false); text = JmolResourceHandler.getStringX("Povray.imageSizeTip"); - imageSizeBox.setToolTipText(text); - imageSizeBox.addItemListener(new ItemListener() { + imageSizeCheck.setToolTipText(text); + imageSizeCheck.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { imageSizeChanged(); updateCommandLine(); } }); - imageBox.add(imageSizeBox); + imageBox.add(imageSizeCheck); imageBox.add(Box.createHorizontalStrut(10)); Box imageSizeDetailBox = Box.createVerticalBox(); Box imageSizeXYBox = Box.createHorizontalBox(); @@ -351,16 +330,16 @@ // Output format option Box outputBox = Box.createHorizontalBox(); text = JmolResourceHandler.getStringX("Povray.outputFormat"); - outputFormatBox = new JCheckBox(text, false); + outputFormatCheck = new JCheckBox(text, false); text = JmolResourceHandler.getStringX("Povray.outputFormatTip"); - outputFormatBox.setToolTipText(text); - outputFormatBox.addItemListener(new ItemListener() { + outputFormatCheck.setToolTipText(text); + outputFormatCheck.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { outputFormatChanged(); updateCommandLine(); } }); - outputBox.add(outputFormatBox); + outputBox.add(outputFormatCheck); outputFormatCombo = new JComboBox(); text = JmolResourceHandler.getStringX("Povray.outputFormatC"); outputFormatCombo.addItem(text); @@ -385,31 +364,31 @@ // Alpha option Box alphaBox = Box.createHorizontalBox(); text = JmolResourceHandler.getStringX("Povray.outputAlpha"); - outputAlphaBox = new JCheckBox(text, false); + outputAlphaCheck = new JCheckBox(text, false); text = JmolResourceHandler.getStringX("Povray.outputAlphaTip"); - outputAlphaBox.setToolTipText(text); - outputAlphaBox.addItemListener(new ItemListener() { + outputAlphaCheck.setToolTipText(text); + outputAlphaCheck.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { updateCommandLine(); } }); - alphaBox.add(outputAlphaBox); + alphaBox.add(outputAlphaCheck); alphaBox.add(Box.createGlue()); povOptionsBox.add(alphaBox); // Mosaic preview option Box mosaicBox = Box.createHorizontalBox(); text = JmolResourceHandler.getStringX("Povray.mosaicPreview"); - mosaicPreviewBox = new JCheckBox(text, false); + mosaicPreviewCheck = new JCheckBox(text, false); text = JmolResourceHandler.getStringX("Povray.mosaicPreviewTip"); - mosaicPreviewBox.setToolTipText(text); - mosaicPreviewBox.addItemListener(new ItemListener() { + mosaicPreviewCheck.setToolTipText(text); + mosaicPreviewCheck.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { mosaicPreviewChanged(); updateCommandLine(); } }); - mosaicBox.add(mosaicPreviewBox); + mosaicBox.add(mosaicPreviewCheck); mosaicBox.add(Box.createHorizontalStrut(10)); text = JmolResourceHandler.getStringX("Povray.mosaicPreviewStart"); mosaicPreviewStart = new JLabel(text); @@ -456,7 +435,7 @@ povrayPathBox.setBorder(new TitledBorder(text)); text = JmolResourceHandler.getStringX("Povray.povrayExecutableTip"); povrayPathBox.setToolTipText(text); - povrayPathLabel = new JTextField(povrayPath); + povrayPathLabel = new JTextField(""); povrayPathLabel.setEditable(false); povrayPathLabel.setBorder(null); povrayPathBox.add(povrayPathLabel); @@ -477,15 +456,10 @@ commandLineBox.setBorder(new TitledBorder(text)); text = JmolResourceHandler.getStringX("Povray.commandLineTip"); commandLineBox.setToolTipText(text); - commandLineField = new JTextField(commandLine, 30); + commandLineField = new JTextField(30); text = JmolResourceHandler.getStringX("Povray.commandLineTip"); commandLineField.setToolTipText(text); - commandLineField.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - commandLine = commandLineField.getText(); - } - }); + commandLineField.addActionListener(updateActionListener); commandLineBox.add(commandLineField); povOptionsBox.add(commandLineBox); mainBox.add(povOptionsBox); @@ -519,7 +493,8 @@ windowBox.add(mainBox); windowBox.add(buttonBox); - updateCommandLine(); + getPathHistory(); + updateScreen(); pack(); centerDialog(); setVisible(true); @@ -544,7 +519,9 @@ void goPressed() { // File theFile = new.getSelectedFile(); + String basename = saveField.getText(); String filename = basename + ".pov"; + String savePath = savePathLabel.getText(); File theFile = new File(savePath, filename); if (theFile != null) { try { @@ -557,14 +534,48 @@ return; } } - try { - if (callPovray) { - String[] commandLineArgs = getCommandLineArgs(); + + // Create INI file if needed + boolean useIniFile = useIniCheck.isSelected(); + if (useIniFile) { + filename = basename + ".ini"; + theFile = new File(savePath, filename); + try { + FileWriter os = new FileWriter(theFile); + saveIni(os); + os.close(); + } catch (FileNotFoundException fnf) { + System.out.println("Povray Dialog FileNotFoundException:" + theFile); + return; + } catch (IOException ioe) { + System.out.println("Povray Dialog IOException:" + theFile); + return; + } + } + + // Run Povray if needed + boolean callPovray = runPovCheck.isSelected(); + if (callPovray) { + String[] commandLineArgs = null; + if (useIniFile) { + if (!savePath.endsWith(java.io.File.separator)) { + savePath += java.io.File.separator; + } + commandLineArgs = new String[] { + povrayPathLabel.getText(), savePath + filename + }; + } else { + commandLineArgs = getCommandLineArgs(); + } + try { Runtime.getRuntime().exec(commandLineArgs); + } catch (java.io.IOException e) { + System.out.println("Caught IOException in povray exec: " + e); + System.out.println("CmdLine:"); + for (int i = 0; i < commandLineArgs.length; i++) { + System.out.println(" <" + commandLineArgs[i] + ">"); + } } - } catch (java.io.IOException e) { - System.out.println("Caught IOException in povray exec: " + e); - System.out.println("CmdLine: " + commandLine); } setVisible(false); saveHistory(); @@ -589,6 +600,7 @@ int button = myChooser.showDialog(this, "Select"); if (button == JFileChooser.APPROVE_OPTION) { java.io.File newFile = myChooser.getSelectedFile(); + String savePath; if (newFile.isDirectory()) { savePath = newFile.toString(); } else { @@ -609,8 +621,7 @@ int button = myChooser.showDialog(this, "Select"); if (button == JFileChooser.APPROVE_OPTION) { java.io.File newFile = myChooser.getSelectedFile(); - povrayPath = newFile.toString(); - povrayPathLabel.setText(povrayPath); + povrayPathLabel.setText(newFile.toString()); updateCommandLine(); pack(); } @@ -620,27 +631,29 @@ * Called when the ImageSize check box is modified */ void imageSizeChanged() { - if (imageSizeBox != null) { - boolean selected = imageSizeBox.isSelected(); + if (imageSizeCheck != null) { + boolean selected = imageSizeCheck.isSelected(); + boolean enabled = runPovCheck.isSelected() || useIniCheck.isSelected(); boolean ratioSelected = false; + imageSizeCheck.setEnabled(enabled); if (imageSizeRatioBox != null) { ratioSelected = imageSizeRatioBox.isSelected(); - imageSizeRatioBox.setEnabled(selected); + imageSizeRatioBox.setEnabled(selected && enabled); } if (imageSizeWidth != null) { - imageSizeWidth.setEnabled(selected); + imageSizeWidth.setEnabled(selected && enabled); } if (imageSizeTextWidth != null) { - imageSizeTextWidth.setEnabled(selected); + imageSizeTextWidth.setEnabled(selected && enabled); } if (imageSizeHeight != null) { - imageSizeHeight.setEnabled(selected && !ratioSelected); + imageSizeHeight.setEnabled(selected && !ratioSelected && enabled); } if (imageSizeTextHeight != null) { - imageSizeTextHeight.setEnabled(selected && !ratioSelected); + imageSizeTextHeight.setEnabled(selected && !ratioSelected && enabled); } if (imageSizeRatioCombo != null) { - imageSizeRatioCombo.setEnabled(selected && ratioSelected); + imageSizeRatioCombo.setEnabled(selected && ratioSelected && enabled); if ((imageSizeTextWidth != null) && (imageSizeTextHeight != null)) { int width = Integer.parseInt( imageSizeTextWidth.getValue().toString()); @@ -670,10 +683,12 @@ * Called when the OutputFormat check box is modified */ void outputFormatChanged() { - if (outputFormatBox != null) { - boolean selected = outputFormatBox.isSelected(); + if (outputFormatCheck != null) { + boolean selected = outputFormatCheck.isSelected(); + boolean enabled = runPovCheck.isSelected() || useIniCheck.isSelected(); + outputFormatCheck.setEnabled(enabled); if (outputFormatCombo != null) { - outputFormatCombo.setEnabled(selected); + outputFormatCombo.setEnabled(selected && enabled); } } } @@ -682,32 +697,103 @@ * Called when the MosaicPreview check box is modified */ void mosaicPreviewChanged() { - if (mosaicPreviewBox != null) { - boolean selected = mosaicPreviewBox.isSelected(); + if (mosaicPreviewCheck != null) { + boolean selected = mosaicPreviewCheck.isSelected(); + boolean enabled = runPovCheck.isSelected() || useIniCheck.isSelected(); + mosaicPreviewCheck.setEnabled(enabled); if (mosaicPreviewStart != null) { - mosaicPreviewStart.setEnabled(selected); + mosaicPreviewStart.setEnabled(selected && enabled); } if (mosaicPreviewComboStart != null) { - mosaicPreviewComboStart.setEnabled(selected); + mosaicPreviewComboStart.setEnabled(selected && enabled); } if (mosaicPreviewEnd != null) { - mosaicPreviewEnd.setEnabled(selected); + mosaicPreviewEnd.setEnabled(selected && enabled); } if (mosaicPreviewComboEnd != null) { - mosaicPreviewComboEnd.setEnabled(selected); + mosaicPreviewComboEnd.setEnabled(selected && enabled); } } } /** + * Update screen informations + */ + protected void updateScreen() { + + // Call povray ? + boolean callPovray = false; + if (runPovCheck != null) { + callPovray = runPovCheck.isSelected(); + } + String text = null; + if (callPovray) { + text = JmolResourceHandler.getStringX("Povray.goLabel"); + } else { + text = JmolResourceHandler.getStringX("Povray.saveLabel"); + } + if (goButton != null) { + goButton.setText(text); + } + + // Use INI ? + boolean useIni = false; + if (useIniCheck != null) { + useIni = useIniCheck.isSelected(); + } + + // Update state + if (antiAliasCheck != null) { + antiAliasCheck.setEnabled(callPovray || useIni); + } + if (povrayPathButton != null) { + povrayPathButton.setEnabled(callPovray || useIni); + } + if (displayWhileRenderingCheck != null) { + displayWhileRenderingCheck.setEnabled(callPovray || useIni); + } + if (antiAliasCheck != null) { + antiAliasCheck.setEnabled(callPovray || useIni); + } + if (commandLineField != null) { + commandLineField.setEnabled(callPovray && !useIni); + } + + // Various update + imageSizeChanged(); + outputFormatChanged(); + mosaicPreviewChanged(); + + // Update command line + updateCommandLine(); + } + + /** * Generates a commandline from the options set for povray path * etc and sets in the textField. */ protected void updateCommandLine() { - if ((savePath == null) || (povrayPath == null) || (basename == null) - || (commandLine == null)) { - commandLine = "null component string"; + // Check fields + String basename = null; + if (saveField != null) { + basename = saveField.getText(); + } + String savePath = null; + if (savePathLabel != null) { + savePath = savePathLabel.getText(); + } + String povrayPath = null; + if (povrayPathLabel != null) { + povrayPath = povrayPathLabel.getText(); + } + if ((savePath == null) || + (povrayPath == null) || + (basename == null)) { + if (commandLineField != null) { + commandLineField.setText("null component string"); + } + return; } //Append a file separator to the savePath is necessary @@ -715,17 +801,14 @@ savePath += java.io.File.separator; } - //Get the current setup - // commandLine = commandLineField.getText(); - - commandLine = + String commandLine = doubleQuoteIfContainsSpace(povrayPath) + " +I" + simpleQuoteIfContainsSpace(savePath + basename + ".pov"); // Output format options String outputExtension = ".tga"; String outputFileType = " +FT"; - if ((outputFormatBox != null) && (outputFormatBox.isSelected())) { + if ((outputFormatCheck != null) && (outputFormatCheck.isSelected())) { switch (outputFormatCombo.getSelectedIndex()) { case 0: // Compressed TARGA outputFileType = " +FC"; @@ -748,13 +831,13 @@ outputFileType; // Output alpha options - if ((outputAlphaBox != null) && (outputAlphaBox.isSelected())) { + if ((outputAlphaCheck != null) && (outputAlphaCheck.isSelected())) { commandLine += " +UA"; } // Image size options - if ((imageSizeBox != null) && (imageSizeBox.isSelected())) { + if ((imageSizeCheck != null) && (imageSizeCheck.isSelected())) { commandLine += " +H" + imageSizeTextHeight.getValue() + " +W" + imageSizeTextWidth.getValue(); @@ -766,16 +849,19 @@ } } - if (doAntiAlias) { + // Anti Alias + if ((antiAliasCheck != null) && (antiAliasCheck.isSelected())) { commandLine += " +A0.1"; } - if (displayWhileRendering) { + // Display while rendering + if ((displayWhileRenderingCheck != null) && + (displayWhileRenderingCheck.isSelected())) { commandLine += " +D +P"; } // Mosaic preview options - if ((mosaicPreviewBox != null) && (mosaicPreviewBox.isSelected())) { + if ((mosaicPreviewCheck != null) && (mosaicPreviewCheck.isSelected())) { commandLine += " +SP" + mosaicPreviewComboStart.getSelectedItem() + " +EP" + mosaicPreviewComboEnd.getSelectedItem(); @@ -789,12 +875,95 @@ } /** + * Save INI file + * + * @param os Output stream + * @throws IOException + */ + private void saveIni(FileWriter os) throws IOException { + if (os == null) { + return; + } + + // Save path + String savePath = savePathLabel.getText(); + if (!savePath.endsWith(java.io.File.separator)) { + savePath += java.io.File.separator; + } + String basename = saveField.getText(); + + // Input file + os.write("Input_File_Name=" + savePath + basename + ".pov\n"); + + // Output format options + String outputExtension = ".tga"; + String outputFileType = "T"; + if ((outputFormatCheck != null) && (outputFormatCheck.isSelected())) { + switch (outputFormatCombo.getSelectedIndex()) { + case 0: // Compressed TARGA + outputFileType = "C"; + break; + case 1: // PNG + outputExtension = ".png"; + outputFileType = "N"; + break; + case 2: // PPM + outputExtension = ".ppm"; + outputFileType = "P"; + break; + default: // Uncompressed TARGA + break; + } + } + os.write("Output_to_File=true\n"); + os.write("Output_File_Type=" + outputFileType + "\n"); + os.write("Output_File_Name=" + savePath + basename + outputExtension + "\n"); + + // Output alpha options + if ((outputAlphaCheck != null) && (outputAlphaCheck.isSelected())) { + os.write("Output_Alpha=true\n"); + } + + // Image size options + if ((imageSizeCheck != null) && (imageSizeCheck.isSelected())) { + os.write("Height=" + imageSizeTextHeight.getValue() + "\n"); + os.write("Width=" + imageSizeTextWidth.getValue() + "\n"); + } else { + if ((outputWidth > 0) && (outputHeight > 0)) { + os.write("Height=" + outputHeight + "\n"); + os.write("Width=" + outputWidth + "\n"); + } + } + + // Anti Alias + if ((antiAliasCheck != null) && (antiAliasCheck.isSelected())) { + os.write("Antialias=true\n"); + os.write("Antialias_Threshold=0.1\n"); + } + + // Display while rendering + if ((displayWhileRenderingCheck != null) && + (displayWhileRenderingCheck.isSelected())) { + os.write("Display=true\n"); + os.write("Pause_When_Done=true\n"); + } + + // Mosaic preview options + if ((mosaicPreviewCheck != null) && (mosaicPreviewCheck.isSelected())) { + os.write("Preview_Start_Size=" + mosaicPreviewComboStart.getSelectedItem() + "\n"); + os.write("Preview_End_Size=" + mosaicPreviewComboEnd.getSelectedItem() + "\n"); + } + + os.write("Verbose=false\n"); + } + + /** * @return Command line split into arguments */ private String[] getCommandLineArgs() { //Parsing command line - commandLine = commandLineField.getText(); + String commandLine = commandLineField.getText(); Vector vector = new Vector(); int begin = 0; int end = 0; @@ -875,20 +1044,29 @@ private void getPathHistory() { java.util.Properties props = Jmol.getHistoryFile().getProperties(); - povrayPath = props.getProperty("povrayPath", + if (povrayPathLabel != null) { + String povrayPath = props.getProperty("povrayPath", System.getProperty("user.home")); - savePath = props.getProperty("povraySavePath", + if (povrayPath != null) { + povrayPathLabel.setText(povrayPath); + } + } + if (savePathLabel != null) { + String savePath = props.getProperty("povraySavePath", System.getProperty("user.home")); + if (savePath != null) { + savePathLabel.setText(savePath); + } + } } /** * Just saves the path settings from this session. */ private void saveHistory() { - java.util.Properties props = new java.util.Properties(); - props.setProperty("povrayPath", povrayPath); - props.setProperty("povraySavePath", savePath); + props.setProperty("povrayPath", povrayPathLabel.getText()); + props.setProperty("povraySavePath", savePathLabel.getText()); Jmol.getHistoryFile().addProperties(props); } |