label.select_startup_file = Select startup file
label.select_default_browser = Select default web browser
label.save_tree_as_newick = Save tree as newick file
-label.create_eps_from_tree = Create EPS file from tree
-label.create_png_from_tree = Create PNG image from tree
label.save_colour_scheme = Save colour scheme
label.edit_params_for = Edit parameters for {0}
label.choose_filename_for_param_file = Choose a filename for this parameter file
label.cancelled_params = Cancelled {0}
error.implementation_error_cannot_show_view_alignment_frame = Implementation error: cannot show a view from another alignment in an AlignFrame.
error.implementation_error_dont_know_about_threshold_setting = Implementation error: don't know about threshold setting for current AnnotationColourGradient.
-error.eps_generation_not_implemented = EPS Generation not yet implemented
-error.png_generation_not_implemented = PNG Generation not yet implemented
error.try_join_vamsas_session_another = Trying to join a vamsas session when another is already connected
error.invalid_vamsas_session_id = Invalid vamsas session id
label.groovy_support_failed = Jalview Groovy Support Failed
exception.jobsubmission_invalid_params_set = Invalid parameter set. Check Jalview implementation
exception.notvaliddata_group_contains_less_than_min_seqs = Group contains less than {0} sequences.
exception.outofmemory_loading_pdb_file = Out of memory loading PDB File
-exception.eps_coudnt_write_output_file = Could not write to the output file: {0}
exception.eps_method_not_supported = Method not currently supported by EpsGraphics2D version {0}
exception.eps_unable_to_get_inverse_matrix = Unable to get inverse of matrix: {0}
warn.job_cannot_be_cancelled_close_window = This job cannot be cancelled.\nJust close the window.
status.finished_searching_for_sequences_from = Finished searching for sequences from {0}
label.eps_file = EPS file
label.png_image = PNG image
-status.saving_file = Saving {0}
-status.export_complete = {0} Export completed.
+status.export_complete = {0} Export completed
status.fetching_pdb = Fetching PDB {0}
status.refreshing_news = Refreshing news
status.importing_vamsas_session_from = Importing VAMSAS session from {0}
label.nw_mapping = Needleman & Wunsch Alignment
label.sifts_mapping = SIFTs Mapping
label.mapping_method = Sequence \u27f7 Structure mapping method
-status.waiting_for_user_to_select_output_file = Waiting for user to select {0} file
status.cancelled_image_export_operation = Cancelled {0} export operation
info.error_creating_file = Error creating {0} file
exception.outofmemory_loading_mmcif_file = Out of memory loading mmCIF File
label.annotation_name = Annotation Name
label.annotation_description = Annotation Description
label.edit_annotation_name_description = Edit Annotation Name/Description
+label.alignment = alignment
+label.pca = PCA
+label.create_image_of = Create {0} image of {1}
label.select_startup_file = Seleccionar fichero de arranque
label.select_default_browser = Seleccionar navegador web por defecto
label.save_tree_as_newick = Guardar árbol como fichero newick
-label.create_eps_from_tree = Crear un fichero EPS a partir de un árbol
-label.create_png_from_tree = Crear una imagen PNG a partir de un árbol
label.save_colour_scheme = Guardar esquema cromático
label.edit_params_for = Editar los parámetros de {0}
label.choose_filename_for_param_file = Escoja un nombre de fichero para este fichero de parámetros
label.cancelled_params = {0} cancelado
error.implementation_error_cannot_show_view_alignment_frame = Error de implementación: no es posible mostrar una vista de otro alineamiento en un AlignFrame.
error.implementation_error_dont_know_about_threshold_setting = Error de implementación: no se conoce la configuración del umbral para el AnnotationColourGradient actual.
-error.eps_generation_not_implemented = La generación de EPS no se ha implementado todavía
-error.png_generation_not_implemented = La generación de PNG no se ha implementado todavía
error.try_join_vamsas_session_another = Tratando de establecer una sesión VAMSAS cuando ya había otra conectada
error.invalid_vamsas_session_id = Identificador de sesión VAMSAS no válido
label.groovy_support_failed = El soporte Groovy de Jalview ha fallado
exception.jobsubmission_invalid_params_set = Conjunto de parámetros no válido. Comprueba la implementación de Jalview
exception.notvaliddata_group_contains_less_than_min_seqs = El grupo contiene menos de {0} secuencias.
exception.outofmemory_loading_pdb_file = Sin memoria al cargar el fichero PDB
-exception.eps_coudnt_write_output_file = No es posible escribir el fichero de salida: {0}
exception.eps_method_not_supported = Método actualmente no suportado por la versión {0} de EpsGraphics2D
exception.eps_unable_to_get_inverse_matrix = Imposible obtener la inversa de la matrix: {0}
warn.job_cannot_be_cancelled_close_window = Este trabajo no se puede cancelar.\nSimplemente, cierre la ventana.
status.finished_searching_for_sequences_from = Finalizada la búsqueda de secuencias en {0}
label.eps_file = Fichero EPS
label.png_image = Imagen PNG
-status.saving_file = Guardando {0}
-status.export_complete = Exportación completada.
+status.export_complete = Exportación completada
status.fetching_pdb = Recuperando PDB {0}
status.refreshing_news = Refrescando noticias
status.importing_vamsas_session_from = Importando sesión VAMSAS de {0}
label.pdb_sequence_fetcher=Recuperador de secuencias PDB
exception.fts_server_error=Parece que hay un error desde el servidor {0}
exception.service_not_available=Servicio no disponible. El servidor se está actualizando, vuelva a intentarlo más tarde.
-status.waiting_for_user_to_select_output_file=Esperando que el usuario seleccione el fichero {0}
action.prev_page=<<
status.cancelled_image_export_operation=Operación de exportación {0} cancelada
label.couldnt_run_groovy_script=No se ha podido ejecutar el script Groovy
label.annotation_name = Nombre de la anotación
label.annotation_description = Descripción de la anotación
label.edit_annotation_name_description = Editar el nombre/descripción de la anotación
+label.alignment = alineamiento
+label.pca = ACP
+label.create_image_of = Crear imagen {0} de {1}
+++ /dev/null
-/*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ The Jalview Authors
- *
- * This file is part of Jalview.
- *
- * Jalview is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3
- * of the License, or (at your option) any later version.
- *
- * Jalview is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
- * The Jalview Authors are detailed in the 'AUTHORS' file.
- */
-package jalview.exceptions;
-
-@SuppressWarnings("serial")
-public class NoFileSelectedException extends JalviewException
-{
- public NoFileSelectedException(String msg)
- {
- super(msg);
- }
-}
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.gui.ImageExporter.ImageWriterI;
import jalview.io.HTMLOutput;
import jalview.jbgui.GAlignmentPanel;
import jalview.math.AlignmentDimension;
private IdPanel idPanel;
- private boolean headless;
-
IdwidthAdjuster idwidthAdjuster;
- /** DOCUMENT ME!! */
public AlignFrame alignFrame;
private ScalePanel scalePanel;
*/
void makeAlignmentImage(ImageMaker.TYPE type, File file)
{
- int borderBottomOffset = 5;
- long pSessionId = System.currentTimeMillis();
- headless = (System.getProperty("java.awt.headless") != null
- && System.getProperty("java.awt.headless").equals("true"));
- if (alignFrame != null && !headless)
- {
- if (file != null)
- {
- alignFrame.setProgressBar(MessageManager
- .formatMessage("status.saving_file", new Object[]
- { type.getLabel() }), pSessionId);
- }
- }
- try
+ final int borderBottomOffset = 5;
+
+ AlignmentDimension aDimension = getAlignmentDimension();
+ // todo use a lambda function in place of callback here?
+ ImageWriterI writer = new ImageWriterI()
{
- AlignmentDimension aDimension = getAlignmentDimension();
- String imageAction = "Create " + type.getName()
- + " image from alignment";
- String imageTitle = alignFrame.getTitle();
-
- ImageMaker im = new ImageMaker(this, type, imageAction,
- aDimension.getWidth(),
- aDimension.getHeight() + borderBottomOffset, file, imageTitle,
- alignFrame, pSessionId, headless);
- Graphics graphics = im.getGraphics();
- if (graphics != null)
+ @Override
+ public void exportImage(Graphics graphics) throws Exception
{
if (av.getWrapAlignment())
{
printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
graphics, graphics);
}
- im.writeImage();
}
- } catch (OutOfMemoryError err)
- {
- // Be noisy here.
- System.out.println("########################\n" + "OUT OF MEMORY "
- + file + "\n" + "########################");
- new OOMWarning("Creating Image for " + file, err);
- // System.out.println("Create IMAGE: " + err);
- } catch (Exception ex)
- {
- ex.printStackTrace();
- }
+ };
+
+ String fileTitle = alignFrame.getTitle();
+ ImageExporter exporter = new ImageExporter(writer, alignFrame, type,
+ fileTitle);
+ int imageWidth = aDimension.getWidth();
+ int imageHeight = aDimension.getHeight() + borderBottomOffset;
+ String of = MessageManager.getString("label.alignment");
+ exporter.doExport(file, this, imageWidth, imageHeight, of);
}
+ /**
+ * Calculates and returns a suitable width and height (in pixels) for an
+ * exported image
+ *
+ * @return
+ */
public AlignmentDimension getAlignmentDimension()
{
int maxwidth = av.getAlignment().getWidth();
if (av.getWrapAlignment())
{
height = getWrappedHeight();
- if (headless)
+ if (Jalview.isHeadlessMode())
{
// need to obtain default alignment width and then add in any
// additional allowance for id margin
import jalview.datamodel.AlignmentI;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.gui.ImageExporter.ImageWriterI;
import jalview.gui.StructureViewer.ViewerType;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.BrowserLauncher;
+import jalview.util.ImageMaker;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.ws.dbsources.Pdb;
return files;
}
- @Override
- public void eps_actionPerformed(ActionEvent e)
- {
- makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
- }
-
- @Override
- public void png_actionPerformed(ActionEvent e)
- {
- makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
- }
-
- void makePDBImage(jalview.util.ImageMaker.TYPE type)
+ /**
+ * Outputs the Jmol viewer image as an image file, after prompting the user to
+ * choose a file and (for EPS) choice of Text or Lineart character rendering
+ * (unless a preference for this is set)
+ *
+ * @param type
+ */
+ public void makePDBImage(ImageMaker.TYPE type)
{
int width = getWidth();
int height = getHeight();
-
- jalview.util.ImageMaker im;
-
- if (type == jalview.util.ImageMaker.TYPE.PNG)
+ ImageWriterI writer = new ImageWriterI()
{
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view",
- width, height, null, null, null, 0, false);
- }
- else if (type == jalview.util.ImageMaker.TYPE.EPS)
- {
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view",
- width, height, null, this.getTitle(), null, 0, false);
- }
- else
- {
-
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
- width, height, null, this.getTitle(), null, 0, false);
- }
-
- if (im.getGraphics() != null)
- {
- jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
- im.writeImage();
- }
+ @Override
+ public void exportImage(Graphics g) throws Exception
+ {
+ jmb.viewer.renderScreenImage(g, width, height);
+ }
+ };
+ String view = MessageManager.getString("action.view").toLowerCase();
+ ImageExporter exporter = new ImageExporter(writer,
+ jmb.getIProgressIndicator(), type, getTitle());
+ exporter.doExport(null, this, width, height, view);
}
@Override
import jalview.io.StructureFile;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.BrowserLauncher;
+import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.ws.dbsources.Pdb;
}
@Override
- public void eps_actionPerformed(ActionEvent e)
+ public void makePDBImage(TYPE imageType)
{
- throw new Error(MessageManager
- .getString("error.eps_generation_not_implemented"));
- }
-
- @Override
- public void png_actionPerformed(ActionEvent e)
- {
- throw new Error(MessageManager
- .getString("error.png_generation_not_implemented"));
+ throw new UnsupportedOperationException(
+ "Image export for Chimera is not implemented");
}
@Override
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.bin.Jalview;
+import jalview.gui.ImageExporter.ImageWriterI;
import jalview.io.DataSourceType;
import jalview.io.FileFormat;
import jalview.io.FileFormatException;
import jalview.jbgui.GStructureViewer;
import jalview.structure.StructureSelectionManager;
import jalview.urls.IdOrgSettings;
-import jalview.util.ImageMaker;
+import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.util.UrlConstants;
block.release();
}
+ /**
+ * Outputs an image of the desktop to file in EPS format, after prompting the
+ * user for choice of Text or Lineart character rendering (unless a preference
+ * has been set). The file name is generated as
+ *
+ * <pre>
+ * Jalview_snapshot_nnnnn.eps where nnnnn is the current timestamp in milliseconds
+ * </pre>
+ */
@Override
protected void snapShotWindow_actionPerformed(ActionEvent e)
{
+ // currently the menu option to do this is not shown
invalidate();
- File of;
- ImageMaker im = new jalview.util.ImageMaker(
- this, ImageMaker.TYPE.EPS, "View of Desktop", getWidth(),
- getHeight(), of = new File("Jalview_snapshot"
- + System.currentTimeMillis() + ".eps"),
- "View of desktop", null, 0, false);
- try
- {
- paintAll(im.getGraphics());
- im.writeImage();
- } catch (Exception q)
+
+ int width = getWidth();
+ int height = getHeight();
+ File of = new File(
+ "Jalview_snapshot_" + System.currentTimeMillis() + ".eps");
+ ImageWriterI writer = new ImageWriterI()
{
- Cache.log.error("Couldn't write snapshot to " + of.getAbsolutePath(),
- q);
- return;
- }
- Cache.log.info("Successfully written snapshot to file "
- + of.getAbsolutePath());
+ @Override
+ public void exportImage(Graphics g) throws Exception
+ {
+ paintAll(g);
+ Cache.log.info("Successfully written snapshot to file "
+ + of.getAbsolutePath());
+ }
+ };
+ String title = "View of desktop";
+ ImageExporter exporter = new ImageExporter(writer, null, TYPE.EPS,
+ title);
+ exporter.doExport(of, this, width, height, title);
}
/**
--- /dev/null
+package jalview.gui;
+
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.util.ImageMaker;
+import jalview.util.ImageMaker.TYPE;
+import jalview.util.MessageManager;
+import jalview.util.dialogrunner.RunResponse;
+
+import java.awt.Component;
+import java.awt.Graphics;
+import java.io.File;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.swing.JOptionPane;
+
+/**
+ * A class that marshals steps in exporting a view in image graphics format
+ * <ul>
+ * <li>prompts the user for the output file, if not already specified</li>
+ * <li>prompts the user for Text or Lineart character rendering, if
+ * necessary</li>
+ * <li>instantiates an ImageMaker to create the appropriate Graphics output
+ * context for the image format</li>
+ * <li>invokes a callback to do the work of writing to the graphics</li>
+ * </ul>
+ *
+ * @author gmcarstairs
+ *
+ */
+public class ImageExporter
+{
+ // todo move interface to jalview.api? or replace with lambda?
+ /**
+ * An interface for the callback that can be run to write the image on to the
+ * graphics object. The callback should throw any exceptions arising so they
+ * can be reported by this class.
+ */
+ public interface ImageWriterI
+ {
+ void exportImage(Graphics g)
+ throws Exception;
+ }
+
+ private IProgressIndicator messageBoard;
+
+ private ImageWriterI imageWriter;
+
+ TYPE imageType;
+
+ private String title;
+
+ /**
+ * Constructor given a callback handler to write graphics data, an (optional)
+ * target for status messages, image type and (optional) title for output file
+ *
+ * @param writer
+ * @param statusBar
+ * @param type
+ * @param fileTitle
+ */
+ public ImageExporter(ImageWriterI writer, IProgressIndicator statusBar,
+ TYPE type, String fileTitle)
+ {
+ this.imageWriter = writer;
+ this.messageBoard = statusBar;
+ this.imageType = type;
+ this.title = fileTitle;
+ }
+
+ /**
+ * Prompts the user for output file and Text/Lineart options as required,
+ * configures a Graphics context for output, and makes a callback to the
+ * client code to perform the image output
+ *
+ * @param file
+ * output file (if null, user is prompted to choose)
+ * @param parent
+ * parent component for any dialogs shown
+ * @param width
+ * @param height
+ * @param imageSource
+ * what the image is of e.g. Tree, Alignment
+ */
+ public void doExport(File file, Component parent, int width, int height,
+ String imageSource)
+ {
+ final long messageId = System.currentTimeMillis();
+
+ /*
+ * prompt user for output file if not provided
+ */
+ if (file == null && !Jalview.isHeadlessMode())
+ {
+ JalviewFileChooser chooser = imageType.getFileChooser();
+ chooser.setFileView(new JalviewFileView());
+ MessageManager.formatMessage("label.create_image_of",
+ imageType.getName(), imageSource);
+ String title = "Create " + imageType.getName()
+ + " image from alignment";
+ chooser.setDialogTitle(title);
+ chooser.setToolTipText(MessageManager.getString("action.save"));
+ int value = chooser.showSaveDialog(parent);
+ if (value != JalviewFileChooser.APPROVE_OPTION)
+ {
+ String msg = MessageManager.formatMessage(
+ "status.cancelled_image_export_operation", imageType.name);
+ setStatus(msg, messageId);
+ return;
+ }
+ Cache.setProperty("LAST_DIRECTORY",
+ chooser.getSelectedFile().getParent());
+ file = chooser.getSelectedFile();
+ }
+
+ /*
+ * Prompt for Text or Lineart (EPS/SVG) unless a preference is already set
+ * for this as EPS_RENDERING / SVG_RENDERING
+ */
+ String renderStyle = Cache.getDefault(
+ imageType.getName() + "_RENDERING",
+ LineartOptions.PROMPT_EACH_TIME);
+ AtomicBoolean textSelected = new AtomicBoolean(
+ !"Lineart".equals(renderStyle));
+ if ((imageType == TYPE.EPS || imageType == TYPE.SVG)
+ && LineartOptions.PROMPT_EACH_TIME.equals(renderStyle)
+ && !Jalview.isHeadlessMode())
+ {
+ final File chosenFile = file;
+ RunResponse okAction = new RunResponse(JOptionPane.OK_OPTION)
+ {
+ @Override
+ public void run()
+ {
+ exportImage(chosenFile, !textSelected.get(), width, height,
+ messageId);
+ }
+ };
+ LineartOptions epsOption = new LineartOptions(TYPE.EPS.getName(),
+ textSelected);
+ epsOption.setResponseAction(new RunResponse(JOptionPane.NO_OPTION)
+ {
+ @Override
+ public void run()
+ {
+ setStatus(MessageManager.formatMessage(
+ "status.cancelled_image_export_operation",
+ imageType.getName()), messageId);
+ }
+ });
+ epsOption.setResponseAction(okAction);
+ epsOption.showDialog();
+ /* no code here - JalviewJS cannot execute it */
+ }
+ else
+ {
+ /*
+ * character rendering not required, or preference already set
+ * - just do the export
+ */
+ exportImage(file, !textSelected.get(), width, height, messageId);
+ }
+ }
+
+ /**
+ * Constructs a suitable graphics context and passes it to the callback
+ * handler for the image to be written. Shows status messages for export in
+ * progress, complete, or failed as appropriate.
+ *
+ * @param chosenFile
+ * @param asLineart
+ * @param width
+ * @param height
+ * @param messageId
+ */
+ protected void exportImage(File chosenFile, boolean asLineart, int width,
+ int height, long messageId)
+ {
+ String type = imageType.getName();
+ try
+ {
+ setStatus(
+ MessageManager.formatMessage(
+ "status.exporting_alignment_as_x_file", type),
+ messageId);
+ ImageMaker im = new ImageMaker(imageType, width, height, chosenFile,
+ title, asLineart);
+ imageWriter.exportImage(im.getGraphics());
+ im.writeImage();
+ setStatus(
+ MessageManager.formatMessage("status.export_complete", type),
+ messageId);
+ } catch (Exception e)
+ {
+ System.out
+ .println(String.format("Error creating %s file: %s", type,
+ e.toString()));
+ setStatus(MessageManager.formatMessage("info.error_creating_file",
+ type), messageId);
+ }
+ }
+
+ /**
+ * Asks the callback to show a status message with given id
+ *
+ * @param msg
+ * @param id
+ */
+ void setStatus(String msg, long id)
+ {
+ if (messageBoard != null)
+ {
+ messageBoard.setProgressBar(msg, id);
+ }
+ }
+
+}
\ No newline at end of file
/**
* A dialog where the user may choose Text or Lineart rendering, and optionally
- * save this as a preference
+ * save this as a preference ("Don't ask me again")
*/
public class LineartOptions extends JPanel
{
+ static final String PROMPT_EACH_TIME = "Prompt each time";
+
JvOptionPane dialog;
public boolean cancelled = false;
* mutable boolean object. User action in the dialog should update this
* object, and the <em>same</em> object should be used in any action handler
* set by calling <code>setResponseAction</code>.
+ * <p>
+ * If the user chooses an option and also "Don't ask me again", the chosen
+ * option is saved as a property with key type_RENDERING i.e. "EPS_RENDERING",
+ * "SVG_RENDERING" or "HTML_RENDERING".
*
- * @param preferencesKey
- * the key under which the choice is saved as a user preference, if
- * 'Don't ask me again' is selected
* @param formatType
* image type e.g. EPS, SVG
* @param textOption
* true to select Text, false for Lineart
*/
- public LineartOptions(String preferencesKey, String formatType,
- AtomicBoolean textOption)
+ public LineartOptions(String formatType, AtomicBoolean textOption)
{
this.asText = textOption;
dialogTitle = MessageManager.formatMessage(
"label.select_character_style_title", formatType);
-
+ String preferencesKey = formatType + "_RENDERING";
try
{
jbInit(preferencesKey, formatType);
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
-import jalview.datamodel.Annotation;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
+import jalview.gui.ImageExporter.ImageWriterI;
import jalview.gui.JalviewColourChooser.ColourChooserListener;
import jalview.jbgui.GPCAPanel;
+import jalview.util.ImageMaker;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
import jalview.viewmodel.PCAModel;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JColorChooser;
-import javax.swing.JDialog;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.event.InternalFrameAdapter;
}
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- @Override
- public void eps_actionPerformed(ActionEvent e)
- {
- makePCAImage(jalview.util.ImageMaker.TYPE.EPS);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- @Override
- public void png_actionPerformed(ActionEvent e)
- {
- makePCAImage(jalview.util.ImageMaker.TYPE.PNG);
- }
-
- void makePCAImage(jalview.util.ImageMaker.TYPE type)
+ public void makePCAImage(ImageMaker.TYPE type)
{
int width = rc.getWidth();
int height = rc.getHeight();
-
- jalview.util.ImageMaker im;
-
- if (type == jalview.util.ImageMaker.TYPE.PNG)
- {
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from PCA",
- width, height, null, null, null, 0, false);
- }
- else if (type == jalview.util.ImageMaker.TYPE.EPS)
- {
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from PCA",
- width, height, null, this.getTitle(), null, 0, false);
- }
- else
- {
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
- width, height, null, this.getTitle(), null, 0, false);
-
- }
-
- if (im.getGraphics() != null)
+ ImageWriterI writer = new ImageWriterI()
{
- rc.drawBackground(im.getGraphics(), Color.black);
- rc.drawScene(im.getGraphics());
- if (rc.drawAxes == true)
+ @Override
+ public void exportImage(Graphics g) throws Exception
{
- rc.drawAxes(im.getGraphics());
+ rc.drawBackground(g, Color.black);
+ rc.drawScene(g);
+ if (rc.drawAxes)
+ {
+ rc.drawAxes(g);
+ }
}
- im.writeImage();
- }
+ };
+ String pca = MessageManager.getString("label.pca");
+ ImageExporter exporter = new ImageExporter(writer, null, type, pca);
+ exporter.doExport(null, this, width, height, pca);
}
@Override
import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.SimilarityParamsI;
-import jalview.bin.Cache;
import jalview.commands.CommandI;
import jalview.commands.OrderCommand;
import jalview.datamodel.Alignment;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.datamodel.SequenceNode;
+import jalview.gui.ImageExporter.ImageWriterI;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.io.NewickFile;
import jalview.jbgui.GTreePanel;
-import jalview.util.ImageMaker;
+import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
-import jalview.util.dialogrunner.RunResponse;
import jalview.viewmodel.AlignmentViewport;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.imageio.ImageIO;
import javax.swing.ButtonGroup;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
}
/**
- * Outputs the Tree in EPS format. The user is prompted for the file to save
- * to, and (unless a preference is already set) for the choice of Text or
- * Lineart for character rendering.
+ * Outputs the Tree in image format (currently EPS or PNG). The user is
+ * prompted for the file to save to, and for EPS (unless a preference is
+ * already set) for the choice of Text or Lineart for character rendering.
*/
@Override
- public void epsTree_actionPerformed()
- {
- JalviewFileChooser chooser = new JalviewFileChooser(
- ImageMaker.EPS_EXTENSION, ImageMaker.EPS_EXTENSION);
- chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle(
- MessageManager.getString("label.create_eps_from_tree"));
- chooser.setToolTipText(MessageManager.getString("action.save"));
-
- int value = chooser.showSaveDialog(this);
-
- if (value != JalviewFileChooser.APPROVE_OPTION)
- {
- return;
- }
- File outFile = chooser.getSelectedFile();
- Cache.setProperty("LAST_DIRECTORY", outFile.getParent());
-
- String renderStyle = Cache.getDefault("EPS_RENDERING",
- "Prompt each time");
- AtomicBoolean textOption = new AtomicBoolean(
- !"Lineart".equals(renderStyle));
-
- /*
- * configure the export action to run on OK in the dialog
- */
- RunResponse okAction = new RunResponse(JOptionPane.OK_OPTION)
- {
- @Override
- public void run()
- {
- writeEpsFile(outFile, textOption.get());
- }
- };
-
- /*
- * Prompt for character rendering style if preference is not set
- */
- if (renderStyle.equalsIgnoreCase("Prompt each time")
- && !(System.getProperty("java.awt.headless") != null && System
- .getProperty("java.awt.headless").equals("true")))
- {
- LineartOptions eps = new LineartOptions("EPS_RENDERING", "EPS",
- textOption);
- eps.setResponseAction(okAction);
- eps.showDialog();
- /* no code here - JalviewJS won't execute it */
- }
- else
- {
- /*
- * if preference set, just run the export action
- */
- writeEpsFile(outFile, textOption.get());
- }
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- @Override
- public void pngTree_actionPerformed(ActionEvent e)
+ public void writeTreeImage(TYPE imageFormat)
{
int width = treeCanvas.getWidth();
int height = treeCanvas.getHeight();
-
- try
+ ImageWriterI writer = new ImageWriterI()
{
- JalviewFileChooser chooser = new JalviewFileChooser(
- ImageMaker.PNG_EXTENSION, ImageMaker.PNG_DESCRIPTION);
-
- chooser.setFileView(new jalview.io.JalviewFileView());
- chooser.setDialogTitle(
- MessageManager.getString("label.create_png_from_tree"));
- chooser.setToolTipText(MessageManager.getString("action.save"));
-
- int value = chooser.showSaveDialog(this);
-
- if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)
+ @Override
+ public void exportImage(Graphics g) throws Exception
{
- return;
+ treeCanvas.draw(g, width, height);
}
-
- jalview.bin.Cache.setProperty("LAST_DIRECTORY",
- chooser.getSelectedFile().getParent());
-
- FileOutputStream out = new FileOutputStream(
- chooser.getSelectedFile());
-
- BufferedImage bi = new BufferedImage(width, height,
- BufferedImage.TYPE_INT_RGB);
- Graphics png = bi.getGraphics();
-
- treeCanvas.draw(png, width, height);
-
- ImageIO.write(bi, "png", out);
- out.close();
- } catch (Exception ex)
- {
- ex.printStackTrace();
- }
+ };
+ String tree = MessageManager.getString("label.tree");
+ ImageExporter exporter = new ImageExporter(writer, null, imageFormat,
+ tree);
+ exporter.doExport(null, this, width, height, tree.toLowerCase());
}
/**
*/
package jalview.io;
-import jalview.exceptions.NoFileSelectedException;
import jalview.gui.AlignmentPanel;
import jalview.gui.OOMWarning;
import jalview.json.binding.biojs.BioJSReleasePojo;
public class BioJsHTMLOutput extends HTMLOutput
{
-
private static File currentBJSTemplateFile;
private static TreeMap<String, File> bioJsMSAVersions;
super(ap);
}
- @Override
- public void exportHTML(String outputFile)
- {
- exportStarted();
- try
- {
- if (outputFile == null)
- {
- outputFile = getOutputFile();
- }
- generatedFile = new File(outputFile);
- } catch (NoFileSelectedException e)
- {
- setProgressMessage(MessageManager.formatMessage(
- "status.cancelled_image_export_operation", "BioJS MSA"));
- return;
- } catch (Exception e)
- {
- setProgressMessage(MessageManager
- .formatMessage("info.error_creating_file", "BioJS MSA"));
- e.printStackTrace();
- return;
- }
- new Thread(this).start();
-
- }
-
public static void refreshVersionInfo(String dirName)
throws URISyntaxException
{
}
@Override
- public File getExportedFile()
- {
- return generatedFile;
- }
-
- @Override
public void run()
{
try
out.flush();
out.close();
setProgressMessage(MessageManager
- .formatMessage("status.export_complete", "BioJS"));
+ .formatMessage("status.export_complete", getDescription()));
exportCompleted();
} catch (OutOfMemoryError err)
} catch (Exception e)
{
setProgressMessage(MessageManager
- .formatMessage("info.error_creating_file", "HTML"));
+ .formatMessage("info.error_creating_file", getDescription()));
e.printStackTrace();
}
}
+ @Override
+ protected String getDescription()
+ {
+ return "BioJS MSA";
+ }
+
}
package jalview.io;
import jalview.api.AlignExportSettingsI;
+import jalview.bin.Cache;
import jalview.datamodel.AlignExportSettingsAdapter;
import jalview.datamodel.AlignmentExportData;
-import jalview.exceptions.NoFileSelectedException;
import jalview.gui.AlignmentPanel;
import jalview.gui.IProgressIndicator;
import jalview.util.MessageManager;
}
- public String getOutputFile() throws NoFileSelectedException
+ /**
+ * Prompts the user to choose an output file and returns the file path, or
+ * null on Cancel
+ *
+ * @return
+ */
+ public String getOutputFile()
{
String selectedFile = null;
- if (pIndicator != null && !isHeadless())
- {
- pIndicator.setProgressBar(MessageManager.formatMessage(
- "status.waiting_for_user_to_select_output_file", "HTML"),
- pSessionId);
- }
// TODO: JAL-3048 generate html rendered view (requires SvgGraphics and/or
// Jalview HTML rendering system- probably not required for Jalview-JS)
int fileChooserOpt = jvFileChooser.showSaveDialog(null);
if (fileChooserOpt == JalviewFileChooser.APPROVE_OPTION)
{
- jalview.bin.Cache.setProperty("LAST_DIRECTORY",
+ Cache.setProperty("LAST_DIRECTORY",
jvFileChooser.getSelectedFile().getParent());
selectedFile = jvFileChooser.getSelectedFile().getPath();
}
- else
- {
- throw new NoFileSelectedException("No file was selected.");
- }
+
return selectedFile;
}
*
* @return
*/
- public abstract File getExportedFile();
+ public File getExportedFile()
+ {
+ return generatedFile;
+ }
+
+ public void exportHTML(String outputFile)
+ {
+ exportStarted();
+ try
+ {
+ if (outputFile == null)
+ {
+ /*
+ * prompt for output file
+ */
+ outputFile = getOutputFile();
+ if (outputFile == null)
+ {
+ setProgressMessage(MessageManager.formatMessage(
+ "status.cancelled_image_export_operation",
+ getDescription()));
+ return;
+ }
+ }
+ generatedFile = new File(outputFile);
+ } catch (Exception e)
+ {
+ setProgressMessage(MessageManager
+ .formatMessage("info.error_creating_file", getDescription()));
+ e.printStackTrace();
+ return;
+ }
+ new Thread(this).start();
+
+ }
/**
- * This is the main method to handle the HTML generation.
+ * Answers a short description of the image format suitable for display in
+ * messages
*
- * @param outputFile
- * the file path of the generated HTML
+ * @return
*/
- public abstract void exportHTML(String outputFile);
+ protected abstract String getDescription();
}
\ No newline at end of file
package jalview.io;
import jalview.bin.Cache;
-import jalview.exceptions.NoFileSelectedException;
import jalview.gui.AlignmentPanel;
import jalview.gui.LineartOptions;
import jalview.gui.OOMWarning;
public class HtmlSvgOutput extends HTMLOutput
{
-
public HtmlSvgOutput(AlignmentPanel ap)
{
super(ap);
if (outputFile == null)
{
outputFile = getOutputFile();
+ if (outputFile == null)
+ {
+ setProgressMessage(MessageManager.formatMessage(
+ "status.cancelled_image_export_operation", "HTML"));
+ return;
+ }
}
generatedFile = new File(outputFile);
- } catch (NoFileSelectedException e)
- {
- setProgressMessage(MessageManager.formatMessage(
- "status.cancelled_image_export_operation", "HTML"));
- return;
} catch (Exception e)
{
setProgressMessage(MessageManager
}
@Override
- public File getExportedFile()
- {
- return generatedFile;
- }
-
- @Override
public void run()
{
try
{
setProgressMessage(null);
setProgressMessage(MessageManager.formatMessage(
- "status.exporting_alignment_as_x_file", "HTML"));
+ "status.exporting_alignment_as_x_file", getDescription()));
String renderStyle = Cache.getDefault("HTML_RENDERING",
"Prompt each time");
*/
if (renderStyle.equalsIgnoreCase("Prompt each time") && !isHeadless())
{
- LineartOptions svgOption = new LineartOptions("HTML_RENDERING",
- "HTML", textOption);
+ LineartOptions svgOption = new LineartOptions("HTML", textOption);
svgOption.setResponseAction(new RunResponse(JOptionPane.NO_OPTION)
{
@Override
public void run()
{
setProgressMessage(MessageManager.formatMessage(
- "status.cancelled_image_export_operation", "HTML"));
+ "status.cancelled_image_export_operation",
+ getDescription()));
}
});
svgOption.setResponseAction(okAction);
{
e.printStackTrace();
setProgressMessage(MessageManager
- .formatMessage("info.error_creating_file", "HTML"));
+ .formatMessage("info.error_creating_file", getDescription()));
}
}
out.flush();
out.close();
setProgressMessage(MessageManager
- .formatMessage("status.export_complete", "HTML"));
+ .formatMessage("status.export_complete", getDescription()));
exportCompleted();
} catch (Exception e)
{
e.printStackTrace();
setProgressMessage(MessageManager
- .formatMessage("info.error_creating_file", "HTML"));
+ .formatMessage("info.error_creating_file", getDescription()));
}
}
+
+ @Override
+ protected String getDescription()
+ {
+ return "HTML";
+ }
}
*/
package jalview.jbgui;
+import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
@Override
public void actionPerformed(ActionEvent e)
{
- eps_actionPerformed(e);
+ makePCAImage(TYPE.EPS);
}
});
JMenuItem png = new JMenuItem("PNG");
@Override
public void actionPerformed(ActionEvent e)
{
- png_actionPerformed(e);
+ makePCAImage(TYPE.PNG);
}
});
JMenuItem outputValues = new JMenuItem();
{
}
- public void eps_actionPerformed(ActionEvent e)
+ public void makePCAImage(TYPE imageType)
{
-
- }
-
- public void png_actionPerformed(ActionEvent e)
- {
-
}
public void outputValues_actionPerformed(ActionEvent e)
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.gui.ColourMenuHelper.ColourChangeListener;
+import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
@Override
public void actionPerformed(ActionEvent actionEvent)
{
- png_actionPerformed(actionEvent);
+ makePDBImage(TYPE.PNG);
}
});
@Override
public void actionPerformed(ActionEvent actionEvent)
{
- eps_actionPerformed(actionEvent);
+ makePDBImage(TYPE.EPS);
}
});
}
- public void png_actionPerformed(ActionEvent actionEvent)
- {
-
- }
-
- public void eps_actionPerformed(ActionEvent actionEvent)
+ public void makePDBImage(TYPE imageType)
{
}
*/
package jalview.jbgui;
+import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
{
public void actionPerformed(ActionEvent e)
{
- epsTree_actionPerformed();
+ writeTreeImage(TYPE.EPS);
}
});
pngTree.setText("PNG");
{
public void actionPerformed(ActionEvent e)
{
- pngTree_actionPerformed(e);
+ writeTreeImage(TYPE.PNG);
}
});
saveAsMenu.setText(MessageManager.getString("action.save_as"));
{
}
- public void pngTree_actionPerformed(ActionEvent e)
- {
- }
-
- public void epsTree_actionPerformed()
+ public void writeTreeImage(TYPE imageType)
{
}
*/
package jalview.util;
-import jalview.bin.Cache;
-import jalview.bin.Jalview;
-import jalview.gui.IProgressIndicator;
-import jalview.gui.LineartOptions;
import jalview.io.JalviewFileChooser;
-import jalview.util.dialogrunner.RunResponse;
-import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
-import java.util.concurrent.atomic.AtomicBoolean;
+import java.io.IOException;
import javax.imageio.ImageIO;
-import javax.swing.JOptionPane;
import org.jfree.graphics2d.svg.SVGGraphics2D;
import org.jfree.graphics2d.svg.SVGHints;
public static final String PNG_DESCRIPTION = "Portable network graphics";
- public static final String HTML_EXTENSION = "html";
-
- public static final String HTML_DESCRIPTION = "Hypertext Markup Language";
-
EpsGraphics2D pg;
Graphics graphics;
TYPE type;
- private IProgressIndicator pIndicator;
-
- private long pSessionId;
-
- private boolean headless;
-
public enum TYPE
{
EPS("EPS", MessageManager.getString("label.eps_file"), EPS_EXTENSION,
}
/**
- * Constructor builds the image and writes it to file. If the supplied file
- * name is null, the user is prompted for the output file.
+ * Constructor configures the graphics context ready for writing to
*
- * @param parent
- * @param type
- * @param title
+ * @param imageType
* @param width
* @param height
* @param file
* @param fileTitle
- * @param pIndicator
- * @param pSessionId
- * @param headless
+ * @param useLineart
+ * @throws IOException
*/
- public ImageMaker(Component parent, TYPE type, String title, int width,
- int height, File file, String fileTitle,
- IProgressIndicator pIndicator, long pSessionId, boolean headless)
+ public ImageMaker(TYPE imageType, int width, int height,
+ File file, String fileTitle, boolean useLineart)
+ throws IOException
{
- this.pIndicator = pIndicator;
- this.type = type;
- this.pSessionId = pSessionId;
- this.headless = headless;
- if (file == null && !Jalview.isHeadlessMode())
+ this.type = imageType;
+
+ out = new FileOutputStream(file);
+ if (imageType == TYPE.SVG)
{
- setProgressMessage(MessageManager.formatMessage(
- "status.waiting_for_user_to_select_output_file", type.name));
- JalviewFileChooser chooser = type.getFileChooser();
- chooser.setFileView(new jalview.io.JalviewFileView());
- chooser.setDialogTitle(title);
- chooser.setToolTipText(MessageManager.getString("action.save"));
- int value = chooser.showSaveDialog(parent);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
- {
- Cache.setProperty("LAST_DIRECTORY",
- chooser.getSelectedFile().getParent());
- file = chooser.getSelectedFile();
- }
- else
- {
- setProgressMessage(MessageManager.formatMessage(
- "status.cancelled_image_export_operation", type.name));
- }
+ setupSVG(width, height, useLineart);
}
-
- if (file != null)
+ else if (imageType == TYPE.EPS)
{
- try
- {
- out = new FileOutputStream(file);
- setProgressMessage(null);
- setProgressMessage(MessageManager.formatMessage(
- "status.exporting_alignment_as_x_file", type.getName()));
- if (type == TYPE.SVG)
- {
- setupSVG(width, height, fileTitle);
- }
- else if (type == TYPE.EPS)
- {
- setupEPS(width, height, fileTitle);
- }
- else if (type == TYPE.PNG)
- {
- setupPNG(width, height);
- }
-
- } catch (Exception ex)
- {
- System.out.println("Error creating " + type.getName() + " file.");
-
- setProgressMessage(MessageManager
- .formatMessage("info.error_creating_file", type.getName()));
- }
+ setupEPS(width, height, fileTitle, useLineart);
+ }
+ else if (imageType == TYPE.PNG)
+ {
+ setupPNG(width, height);
}
}
}
/**
- * Generates an EPS image and writes it to the (previously set) output buffer.
- * The user is first prompted for choice of Text or Lineart rendering, unless
- * a preference for this has been set.
- *
- * @param width
- * @param height
- * @param title
- */
- void setupEPS(int width, int height, String title)
- {
- String renderStyle = Cache.getDefault("EPS_RENDERING",
- "Prompt each time");
- AtomicBoolean textOption = new AtomicBoolean(
- !"Lineart".equals(renderStyle));
-
- /*
- * configure the action to run on OK in the dialog
- */
- RunResponse okAction = new RunResponse(JOptionPane.OK_OPTION)
- {
- @Override
- public void run()
- {
- writeEPS(width, height, title, textOption.get());
- }
- };
-
- /*
- * Prompt for character rendering style if preference is not set
- */
- if (renderStyle.equalsIgnoreCase("Prompt each time")
- && !(System.getProperty("java.awt.headless") != null && System
- .getProperty("java.awt.headless").equals("true")))
- {
- LineartOptions epsOption = new LineartOptions("EPS_RENDERING",
- TYPE.EPS.getName(), textOption);
- epsOption.setResponseAction(new RunResponse(JOptionPane.NO_OPTION)
- {
- @Override
- public void run()
- {
- setProgressMessage(MessageManager.formatMessage(
- "status.cancelled_image_export_operation", "EPS"));
- }
- });
- epsOption.setResponseAction(okAction);
- epsOption.showDialog();
- /* no code here - JalviewJS cannot execute it */
- }
- else
- {
- /*
- * else (if preference set) just do the export action
- */
- writeEPS(width, height, title, textOption.get());
- }
- }
-
- /**
* Sets up a graphics object for the PNG image to be written on
*
* @param width
* @param height
*/
- void setupPNG(int width, int height)
+ protected void setupPNG(int width, int height)
{
bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
graphics = bi.getGraphics();
Graphics2D ig2 = (Graphics2D) graphics;
ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- setProgressMessage(MessageManager
- .formatMessage("status.export_complete", type.getName()));
- }
-
- /**
- * Sets up a graphics object for the SVG image to be written on. The user is
- * first prompted for choice of Text or Lineart rendering, unless a preference
- * for this has been set.
- *
- * @param width
- * @param height
- * @param title
- */
- void setupSVG(int width, int height, String title)
- {
- String renderStyle = Cache.getDefault("SVG_RENDERING",
- "Prompt each time");
- AtomicBoolean textOption = new AtomicBoolean(
- !"Lineart".equals(renderStyle));
-
- /*
- * configure the action to run on OK in the dialog
- */
- RunResponse okAction = new RunResponse(JOptionPane.OK_OPTION)
- {
- @Override
- public void run()
- {
- setupSVG(width, height, textOption.get());
- }
- };
-
- /*
- * Prompt for character rendering style if preference is not set
- */
- if (renderStyle.equalsIgnoreCase("Prompt each time")
- && !(System.getProperty("java.awt.headless") != null && System
- .getProperty("java.awt.headless").equals("true")))
- {
- LineartOptions svgOption = new LineartOptions("SVG_RENDERING",
- TYPE.SVG.getName(), textOption);
- svgOption.setResponseAction(new RunResponse(JOptionPane.NO_OPTION)
- {
- @Override
- public void run()
- {
- setProgressMessage(MessageManager.formatMessage(
- "status.cancelled_image_export_operation", "SVG"));
- }
- });
- svgOption.setResponseAction(okAction);
- svgOption.showDialog();
- /* no code here - JalviewJS cannot execute it */
- }
- else
- {
- /*
- * else (if preference set) just do the export action
- */
- setupSVG(width, height, textOption.get());
- }
- }
-
- void setProgressMessage(String message)
- {
- if (pIndicator != null && !headless)
- {
- pIndicator.setProgressBar(message, pSessionId);
- }
}
/**
*
* @param width
* @param height
- * @param textOption
- * true for Text, false for Lineart
+ * @param useLineart
+ * true for Lineart character rendering, false for Text
*/
- protected void setupSVG(int width, int height, boolean textOption)
+ protected void setupSVG(int width, int height, boolean useLineart)
{
SVGGraphics2D g2 = new SVGGraphics2D(width, height);
- if (!textOption) // Lineart selected
+ if (useLineart)
{
g2.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
}
- setProgressMessage(MessageManager
- .formatMessage("status.export_complete", type.getName()));
graphics = g2;
}
* @param width
* @param height
* @param title
- * @param textOption
- * true for Text, false for Lineart
+ * @param useLineart
+ * true for Lineart character rendering, false for Text
+ * @throws IOException
*/
- protected void writeEPS(int width, int height, String title,
- boolean textOption)
+ protected void setupEPS(int width, int height, String title,
+ boolean useLineart) throws IOException
{
- try
- {
- pg = new EpsGraphics2D(title, out, 0, 0, width, height);
- Graphics2D ig2 = pg;
- ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- pg.setAccurateTextMode(!textOption); // true = Lineart
- graphics = pg;
- setProgressMessage(MessageManager
- .formatMessage("status.export_complete", type.getName()));
- } catch (Exception ex)
- {
- System.err.println("Error writing PNG: " + ex.toString());
- }
- }
-
- static JalviewFileChooser getSVGChooser()
- {
- if (Jalview.isHeadlessMode())
- {
- return null;
- }
- return new JalviewFileChooser(SVG_EXTENSION, SVG_DESCRIPTION);
+ pg = new EpsGraphics2D(title, out, 0, 0, width, height);
+ Graphics2D ig2 = pg;
+ ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ pg.setAccurateTextMode(useLineart);
+ graphics = pg;
}
}
case 1:
return "DialogRunner str: '" + stringresp + "'";
case 2:
- return "DialogRunner obj: " + objresp.toString();
+ return "DialogRunner obj: " + String.valueOf(objresp);
}
return "Unconfigured response.";
}
*/
package org.jibble.epsgraphics;
-import jalview.util.MessageManager;
-
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
_bufferedWriter.write(line + "\n");
} catch (IOException e)
{
- throw new EpsException(MessageManager.formatMessage(
- "exception.eps_coudnt_write_output_file",
- new String[] { e.getMessage() }));
+ throw new EpsException("Could not write to the output file: " + e);
}
}