*/
package jalview.util;
+import jalview.bin.Cache;
import jalview.bin.Jalview;
import jalview.gui.IProgressIndicator;
import jalview.gui.LineartOptions;
public enum TYPE
{
- EPS("EPS", MessageManager.getString("label.eps_file"), getEPSChooser()),
- PNG("PNG", MessageManager.getString("label.png_image"),
- getPNGChooser()),
- SVG("SVG", "SVG", getSVGChooser());
+ EPS("EPS", MessageManager.getString("label.eps_file"), EPS_EXTENSION,
+ EPS_DESCRIPTION),
+ PNG("PNG", MessageManager.getString("label.png_image"), PNG_EXTENSION,
+ PNG_DESCRIPTION),
+ SVG("SVG", "SVG", SVG_EXTENSION, SVG_DESCRIPTION);
- private JalviewFileChooser chooser;
+ public final String name;
- private String name;
+ public final String label;
- private String label;
+ public final String extension;
- TYPE(String name, String label, JalviewFileChooser chooser)
+ public final String description;
+
+ TYPE(String name, String label, String ext, String desc)
{
this.name = name;
this.label = label;
- this.chooser = chooser;
+ this.extension = ext;
+ this.description = desc;
}
public String getName()
public JalviewFileChooser getChooser()
{
- return chooser;
+ return new JalviewFileChooser(extension, description);
}
public String getLabel()
}
+ /**
+ * Constructor builds the image and writes it to file. If the supplied file
+ * name is null, the user is prompted for the output file.
+ *
+ * @param parent
+ * @param type
+ * @param title
+ * @param width
+ * @param height
+ * @param file
+ * @param fileTitle
+ * @param pIndicator
+ * @param pSessionId
+ * @param headless
+ */
public ImageMaker(Component parent, TYPE type, String title, int width,
int height, File file, String fileTitle,
IProgressIndicator pIndicator, long pSessionId, boolean headless)
this.type = type;
this.pSessionId = pSessionId;
this.headless = headless;
- if (file == null)
+ if (file == null && !Jalview.isHeadlessMode())
{
- // TODO: JAL-3048 export SVG/EPS/PNG- not required for Jalview-JS
-
setProgressMessage(MessageManager.formatMessage(
"status.waiting_for_user_to_select_output_file", type.name));
JalviewFileChooser chooser;
chooser.setToolTipText(MessageManager.getString("action.save"));
int value = chooser.showSaveDialog(parent);
- if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
+ if (value == JalviewFileChooser.APPROVE_OPTION)
{
- jalview.bin.Cache.setProperty("LAST_DIRECTORY",
+ Cache.setProperty("LAST_DIRECTORY",
chooser.getSelectedFile().getParent());
file = chooser.getSelectedFile();
}
{
boolean accurateText = true;
- String renderStyle = jalview.bin.Cache.getDefault("EPS_RENDERING",
+ String renderStyle = Cache.getDefault("EPS_RENDERING",
"Prompt each time");
// If we need to prompt, and if the GUI is visible then
.formatMessage("status.export_complete", type.getName()));
} catch (Exception ex)
{
+ System.err.println("Error writing PNG: " + ex.toString());
}
}