package jalview.ext.archaeopteryx;
+import jalview.bin.Cache;
import jalview.ext.treeviewer.ExternalTreeControlsI;
import jalview.ext.treeviewer.ExternalTreeFrame;
import jalview.ext.treeviewer.ExternalTreeI;
import jalview.ext.treeviewer.ExternalTreePanel;
import jalview.gui.Desktop;
+import jalview.gui.EPSOptions;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.util.ImageMaker;
+import jalview.util.MessageManager;
import java.awt.Component;
import java.awt.Container;
import java.awt.MenuComponent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.io.FileOutputStream;
import javax.accessibility.AccessibleContext;
import javax.swing.JLayeredPane;
import javax.swing.event.InternalFrameListener;
import org.forester.archaeopteryx.MainFrame;
+import org.jibble.epsgraphics.EpsGraphics2D;
public class AptxFrame implements ExternalTreeFrame
{
@Override
public void actionPerformed(ActionEvent e)
{
- // TODO Auto-generated method stub
+ epsTree_actionPerformed(e);
}
aptxFrame.validate();
}
+ public void epsTree_actionPerformed(ActionEvent e)
+ {
+ boolean accurateText = true;
+
+ String renderStyle = jalview.bin.Cache.getDefault("EPS_RENDERING",
+ "Prompt each time");
+
+ // If we need to prompt, and if the GUI is visible then
+ // Prompt for EPS rendering style
+ if (renderStyle.equalsIgnoreCase("Prompt each time")
+ && !(System.getProperty("java.awt.headless") != null && System
+ .getProperty("java.awt.headless").equals("true")))
+ {
+ EPSOptions eps = new EPSOptions();
+ renderStyle = eps.getValue();
+
+ if (renderStyle == null || eps.cancelled)
+ {
+ return;
+ }
+
+ }
+
+ if (renderStyle.equalsIgnoreCase("text"))
+ {
+ accurateText = false;
+ }
+
+ int width = getTreePanel().getWidth();
+ int height = getTreePanel().getHeight();
+
+ try
+ {
+ 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(aptxFrame);
+
+ if (value != JalviewFileChooser.APPROVE_OPTION)
+ {
+ return;
+ }
+
+ Cache.setProperty("LAST_DIRECTORY",
+ chooser.getSelectedFile().getParent());
+
+ FileOutputStream out = new FileOutputStream(
+ chooser.getSelectedFile());
+ EpsGraphics2D pg = new EpsGraphics2D("Tree", out, 0, 0, width,
+ height);
+
+ pg.setAccurateTextMode(accurateText);
+
+ getTreePanel().paintToFile(pg, width, height);
+
+ pg.flush();
+ pg.close();
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
@Override
public ExternalTreePanel getTreePanel()
{
package jalview.ext.treeviewer;
+import java.awt.Graphics2D;
import java.awt.MenuContainer;
import java.awt.event.MouseListener;
import java.io.File;
public interface ExternalTreePanel extends Accessible, MenuContainer
{
+
public abstract void setTreeFile(File file);
public abstract File getTreeFile();
public void notifyPaintRefresher(String newSeqSetIdentifier,
boolean alignmentChanged, boolean validateSequences);
+ public int getWidth();
+
+ public int getHeight();
+
+ public abstract void paintToFile(Graphics2D pg, int width, int height);
+
}