/dist
/classes
.externalToolBuilders/Jalview Release indices [Builder].launch
-/.DS_Store
+.DS_Store
/.com.apple.timemachine.supported
*/
package MCview;
-import java.io.*;
-
-import java.awt.event.*;
-import javax.swing.*;
-
-import jalview.datamodel.*;
-import jalview.gui.*;
-import jalview.io.*;
-import jalview.schemes.*;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.Desktop;
+import jalview.gui.OOMWarning;
+import jalview.gui.UserDefinedColours;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.UserColourScheme;
+import jalview.schemes.ZappoColourScheme;
import jalview.util.MessageManager;
import jalview.ws.ebi.EBIFetchClient;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.PrintWriter;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
+import javax.swing.JInternalFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.SwingUtilities;
+
public class PDBViewer extends JInternalFrame implements Runnable
{
.getAbsolutePath());
if (pdbentry.getFile() != null)
+ {
pdbcanvas.init(pdbentry, seq, chains, ap, protocol);
+ }
} catch (Exception ex)
{
pdbcanvas.errorMessage = "Error retrieving file: " + pdbentry.getId();
*/
public void eps_actionPerformed(ActionEvent e)
{
- makePDBImage(jalview.util.ImageMaker.EPS);
+ makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
}
/**
*/
public void png_actionPerformed(ActionEvent e)
{
- makePDBImage(jalview.util.ImageMaker.PNG);
+ makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
}
- void makePDBImage(int type)
+ void makePDBImage(jalview.util.ImageMaker.TYPE type)
{
int width = pdbcanvas.getWidth();
int height = pdbcanvas.getHeight();
jalview.util.ImageMaker im;
- if (type == jalview.util.ImageMaker.PNG)
+ if (type == jalview.util.ImageMaker.TYPE.PNG)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.PNG,
"Make PNG image from view", width, height, null, null);
}
- else
+ else if (type == jalview.util.ImageMaker.TYPE.EPS)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.EPS,
"Make EPS file from view", width, height, null,
this.getTitle());
}
+ else
+ {
+
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
+ width, height, null, this.getTitle());
+ }
if (im.getGraphics() != null)
{
.getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt
.getKeyCode() <= KeyEvent.VK_NUMPAD9))
&& Character.isDigit(evt.getKeyChar()))
+ {
alignPanel.seqPanel.numberPressed(evt.getKeyChar());
+ }
switch (evt.getKeyCode())
{
case KeyEvent.VK_DOWN:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
moveSelectedSequences(false);
+ }
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(0, 1);
+ }
break;
case KeyEvent.VK_UP:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
moveSelectedSequences(true);
+ }
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(0, -1);
+ }
break;
case KeyEvent.VK_LEFT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
slideSequences(false, alignPanel.seqPanel.getKeyboardNo1());
+ }
else
+ {
alignPanel.seqPanel.moveCursor(-1, 0);
+ }
break;
case KeyEvent.VK_RIGHT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
slideSequences(true, alignPanel.seqPanel.getKeyboardNo1());
+ }
else
+ {
alignPanel.seqPanel.moveCursor(1, 0);
+ }
break;
case KeyEvent.VK_SPACE:
{
case KeyEvent.VK_LEFT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
viewport.firePropertyChange("alignment", null, viewport
.getAlignment().getSequences());
+ }
break;
case KeyEvent.VK_RIGHT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
viewport.firePropertyChange("alignment", null, viewport
.getAlignment().getSequences());
+ }
break;
}
}
alignPanel.makeEPS(f);
}
+ public void createSVG(File f)
+ {
+ alignPanel.makeSVG(f);
+ }
@Override
public void pageSetup_actionPerformed(ActionEvent e)
{
protected void undoMenuItem_actionPerformed(ActionEvent e)
{
if (viewport.historyList.empty())
+ {
return;
+ }
CommandI command = (CommandI) viewport.historyList.pop();
viewport.redoList.push(command);
command.undoCommand(getViewAlignments());
for (int i = 0; i < viewport.getAlignment().getHeight(); i++)
{
if (!sg.contains(viewport.getAlignment().getSequenceAt(i)))
+ {
invertGroup.add(viewport.getAlignment().getSequenceAt(i));
+ }
}
SequenceI[] seqs1 = sg.toArray(new SequenceI[0]);
SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
for (int i = 0; i < invertGroup.size(); i++)
+ {
seqs2[i] = (SequenceI) invertGroup.elementAt(i);
+ }
SlideSequencesCommand ssc;
if (right)
+ {
ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1,
size, viewport.getGapCharacter());
+ }
else
+ {
ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2,
size, viewport.getGapCharacter());
+ }
int groupAdjustment = 0;
if (ssc.getGapsInsertedBegin() && right)
{
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(size, 0);
+ }
else
+ {
groupAdjustment = size;
+ }
}
else if (!ssc.getGapsInsertedBegin() && !right)
{
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(-size, 0);
+ }
else
+ {
groupAdjustment = -size;
+ }
}
if (groupAdjustment != 0)
}
if (!appendHistoryItem)
+ {
addHistoryItem(ssc);
+ }
repaint();
}
{
AlignmentAnnotation sann[] = sequences[i].getAnnotation();
if (sann == null)
+ {
continue;
+ }
for (int avnum = 0; avnum < alview.length; avnum++)
{
if (alview[avnum] != alignment)
if (ds.getSequences() == null
|| !ds.getSequences().contains(
sprods[s].getDatasetSequence()))
+ {
ds.addSequence(sprods[s].getDatasetSequence());
+ }
sprods[s].updatePDBIds();
}
Alignment al = new Alignment(sprods);
*/
package jalview.gui;
-import java.beans.*;
-import java.io.*;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.print.*;
-import javax.swing.*;
-
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
-import jalview.datamodel.*;
-import jalview.jbgui.*;
-import jalview.schemes.*;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.jbgui.GAlignmentPanel;
+import jalview.schemes.ResidueProperties;
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.event.AdjustmentEvent;
+import java.awt.event.AdjustmentListener;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+
+import javax.swing.SwingUtilities;
+
/**
* DOCUMENT ME!
*
int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
int maxwidth = Math.max(20,
- Math.min(afwidth - 200, (int) 2 * afwidth / 3));
+ Math.min(afwidth - 200, 2 * afwidth / 3));
return calculateIdWidth(maxwidth);
}
// / How many sequences and residues can we fit on a printable page?
int totalRes = (pwidth - idWidth) / av.getCharWidth();
- int totalSeq = (int) ((pheight - scaleHeight) / av.getCharHeight()) - 1;
+ int totalSeq = (pheight - scaleHeight) / av.getCharHeight() - 1;
int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;
int offset = -alabels.scrollOffset;
pg.translate(0, offset);
pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
- alabels.drawComponent((Graphics2D) pg, idWidth);
+ alabels.drawComponent(pg, idWidth);
pg.translate(idWidth + 3, 0);
annotationPanel.renderer.drawComponent(annotationPanel, av,
- (Graphics2D) pg, -1, startRes, endRes + 1);
+ pg, -1, startRes, endRes + 1);
pg.translate(0, -offset);
}
return idwidth.intValue() + 4;
}
- void makeAlignmentImage(int type, File file)
+ void makeAlignmentImage(jalview.util.ImageMaker.TYPE type, File file)
{
long progress = System.currentTimeMillis();
boolean headless = (System.getProperty("java.awt.headless") != null && System
.getProperty("java.awt.headless").equals("true"));
if (alignFrame != null && !headless)
{
- alignFrame.setProgressBar(MessageManager.formatMessage("status.saving_file", new String[]{(type == jalview.util.ImageMaker.PNG ? MessageManager.getString("label.png_image") : MessageManager.getString("label.eps_file"))}), progress);
+ alignFrame.setProgressBar(MessageManager.formatMessage(
+ "status.saving_file",
+ new String[]
+ { type.getLabel() }), progress);
}
try
{
jalview.util.ImageMaker im;
final String imageAction, imageTitle;
- if (type == jalview.util.ImageMaker.PNG)
+ if (type == jalview.util.ImageMaker.TYPE.PNG)
{
imageAction = "Create PNG image from alignment";
imageTitle = null;
}
- else
+ else if (type == jalview.util.ImageMaker.TYPE.EPS)
{
imageAction = "Create EPS file from alignment";
imageTitle = alignFrame.getTitle();
}
+ else
+ {
+ imageAction = "Create SVG file from alignment";
+ imageTitle = alignFrame.getTitle();
+ }
+
im = new jalview.util.ImageMaker(this, type, imageAction, width,
height, file, imageTitle);
if (av.getWrapAlignment())
*/
public void makeEPS(File epsFile)
{
- makeAlignmentImage(jalview.util.ImageMaker.EPS, epsFile);
+ makeAlignmentImage(jalview.util.ImageMaker.TYPE.EPS, epsFile);
}
/**
*/
public void makePNG(File pngFile)
{
- makeAlignmentImage(jalview.util.ImageMaker.PNG, pngFile);
+ makeAlignmentImage(jalview.util.ImageMaker.TYPE.PNG, pngFile);
}
+ public void makeSVG(File svgFile)
+ {
+ makeAlignmentImage(jalview.util.ImageMaker.TYPE.SVG, svgFile);
+ }
public void makePNGImageMap(File imgMapFile, String imageName)
{
// /////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS
*/
package jalview.gui;
-import java.util.*;
-import java.awt.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-
-import java.awt.event.*;
-import java.io.*;
-
-import jalview.jbgui.GStructureViewer;
-import jalview.api.SequenceStructureBinding;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
-import jalview.datamodel.*;
-import jalview.gui.ViewSelectionMenu.ViewSetProvider;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JalviewJmolBinding;
-import jalview.io.*;
-import jalview.schemes.*;
+import jalview.gui.ViewSelectionMenu.ViewSetProvider;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.jbgui.GStructureViewer;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.ZappoColourScheme;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
+import javax.swing.JInternalFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JSplitPane;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
+import javax.swing.event.MenuEvent;
+import javax.swing.event.MenuListener;
+
public class AppJmol extends GStructureViewer implements Runnable,
ViewSetProvider, JalviewStructureDisplayI
* @param bounds
* @deprecated defaults to AppJmol(String[] files, ... , viewid);
*/
+ @Deprecated
public AppJmol(String file, String id, SequenceI[] seq,
AlignmentPanel ap, String loadStatus, Rectangle bounds)
{
/**
* @deprecated
*/
+ @Deprecated
public AppJmol(String file, String id, SequenceI[] seq,
AlignmentPanel ap, String loadStatus, Rectangle bounds,
String viewid)
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
+ }
}
centerViewer();
allChainsSelected = false;
public void itemStateChanged(ItemEvent evt)
{
if (!allChainsSelected)
+ {
centerViewer();
+ }
}
});
*/
public void eps_actionPerformed(ActionEvent e)
{
- makePDBImage(jalview.util.ImageMaker.EPS);
+ makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
}
/**
*/
public void png_actionPerformed(ActionEvent e)
{
- makePDBImage(jalview.util.ImageMaker.PNG);
+ makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
}
- void makePDBImage(int type)
+ void makePDBImage(jalview.util.ImageMaker.TYPE type)
{
int width = getWidth();
int height = getHeight();
jalview.util.ImageMaker im;
- if (type == jalview.util.ImageMaker.PNG)
+ if (type == jalview.util.ImageMaker.TYPE.PNG)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.PNG,
"Make PNG image from view", width, height, null, null);
}
- else
+ else if (type == jalview.util.ImageMaker.TYPE.EPS)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.EPS,
"Make EPS file from view", width, height, null,
this.getTitle());
}
+ else
+ {
+
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
+ width, height, null, this.getTitle());
+ }
if (im.getGraphics() != null)
{
if (showMemoryUsage && g != null && df != null)
{
if (percentUsage < 20)
+ {
g.setColor(Color.red);
+ }
FontMetrics fm = g.getFontMetrics();
if (fm != null)
{
{
invalidate();
File of;
- ImageMaker im = new jalview.util.ImageMaker(this, ImageMaker.EPS, "View of Desktop", getWidth(), getHeight(), of=new File("Jalview_snapshot"+System.currentTimeMillis()+".eps"), "View of desktop");
+ 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");
try {
paintAll(im.getGraphics());
im.writeImage();
*/
package jalview.gui;
-import java.util.*;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.print.*;
-
-import javax.swing.*;
-
-import jalview.datamodel.*;
-import jalview.jbgui.*;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SeqCigar;
+import jalview.datamodel.SequenceI;
+import jalview.jbgui.GPCAPanel;
import jalview.schemes.ResidueProperties;
import jalview.util.MessageManager;
import jalview.viewmodel.PCAModel;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import java.util.Hashtable;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JRadioButtonMenuItem;
+
/**
* DOCUMENT ME!
*
@Override
public void actionPerformed(ActionEvent e)
{
- if (!pcaModel.getScore_matrix().equals((String) sm))
+ if (!pcaModel.getScore_matrix().equals(sm))
{
- pcaModel.setScore_matrix((String) sm);
+ pcaModel.setScore_matrix(sm);
Thread worker = new Thread(us);
worker.start();
}
*/
public void eps_actionPerformed(ActionEvent e)
{
- makePCAImage(jalview.util.ImageMaker.EPS);
+ makePCAImage(jalview.util.ImageMaker.TYPE.EPS);
}
/**
*/
public void png_actionPerformed(ActionEvent e)
{
- makePCAImage(jalview.util.ImageMaker.PNG);
+ makePCAImage(jalview.util.ImageMaker.TYPE.PNG);
}
- void makePCAImage(int type)
+ void makePCAImage(jalview.util.ImageMaker.TYPE type)
{
int width = rc.getWidth();
int height = rc.getHeight();
jalview.util.ImageMaker im;
- if (type == jalview.util.ImageMaker.PNG)
+ if (type == jalview.util.ImageMaker.TYPE.PNG)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.PNG,
"Make PNG image from PCA", width, height, null, null);
}
- else
+ else if (type == jalview.util.ImageMaker.TYPE.EPS)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.EPS,
"Make EPS file from PCA", width, height, null,
this.getTitle());
}
+ else
+ {
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
+ width, height, null, this.getTitle());
+
+ }
if (im.getGraphics() != null)
{
JMenuItem createPNG = new JMenuItem();
+ JMenuItem createSVG = new JMenuItem();
+
protected JMenuItem font = new JMenuItem();
public JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem();
createPNG.setActionCommand(MessageManager
.getString("label.save_png_image"));
createPNG.setText("PNG");
+
font.setText(MessageManager.getString("action.font"));
font.addActionListener(new java.awt.event.ActionListener()
{
createEPS(null);
}
});
+
+ createSVG.setText("SVG");
+ createSVG.addActionListener(new java.awt.event.ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ createSVG(null);
+ }
+ });
+
LoadtreeMenuItem.setActionCommand(MessageManager
.getString("label.load_tree_for_sequence_set"));
LoadtreeMenuItem.setText(MessageManager
jMenu2.add(htmlMenuItem);
jMenu2.add(epsFile);
jMenu2.add(createPNG);
+ jMenu2.add(createSVG);
addSequenceMenu.add(addFromFile);
addSequenceMenu.add(addFromText);
addSequenceMenu.add(addFromURL);
{
}
+ public void createSVG(java.io.File f)
+ {
+
+ }
protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
{
*/
package jalview.util;
-import java.io.*;
-import javax.imageio.*;
+import jalview.gui.EPSOptions;
+import jalview.io.JalviewFileChooser;
-import java.awt.*;
-import java.awt.image.*;
+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 org.jibble.epsgraphics.*;
-import jalview.gui.*;
-import jalview.io.*;
+import javax.imageio.ImageIO;
+
+import org.jfree.graphics2d.svg.SVGGraphics2D;
+import org.jibble.epsgraphics.EpsGraphics2D;
public class ImageMaker
{
- public static final int EPS = 0;
-
- public static final int PNG = 1;
-
- int type = -1;
+ // public static final int EPS = 0;
+ //
+ // public static final int PNG = 1;
+ //
+ // public static final int SVG = 2;
+ //
+ // int type = -1;
EpsGraphics2D pg;
+ SVGGraphics2D g2;
+
Graphics graphics;
FileOutputStream out;
BufferedImage bi;
- public ImageMaker(Component parent, int type, String title, int width,
- int height, File file, String EPStitle)
+ TYPE type;
+
+ public enum TYPE
+ {
+ EPS("EPS", MessageManager.getString("label.eps_file"), getEPSChooser()), PNG(
+ "PNG", MessageManager.getString("label.png_image"),
+ getPNGChooser()), SVG("SVG", "SVG", getSVGChooser());
+
+ private JalviewFileChooser chooser;
+
+ private String name;
+
+ private String label;
+
+ TYPE(String name, String label, JalviewFileChooser chooser)
+ {
+ this.name = name;
+ this.label = label;
+ this.chooser = chooser;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public JalviewFileChooser getChooser()
+ {
+ return chooser;
+ }
+
+ public String getLabel()
+ {
+ return label;
+ }
+
+ }
+
+
+ public ImageMaker(Component parent, TYPE type, String title, int width,
+ int height, File file, String fileTitle)
{
this.type = type;
if (file == null)
{
JalviewFileChooser chooser;
- chooser = type == EPS ? getEPSChooser() : getPNGChooser();
+ // chooser = type == EPS ? getEPSChooser() : getPNGChooser();
+ chooser = type.getChooser();
chooser.setFileView(new jalview.io.JalviewFileView());
chooser.setDialogTitle(title);
try
{
out = new FileOutputStream(file);
-
- if (type == EPS)
+ if (type == TYPE.SVG)
+ {
+ setupSVG(width, height, fileTitle);
+ }
+ else if (type == TYPE.EPS)
{
- setupEPS(width, height, EPStitle);
+ setupEPS(width, height, fileTitle);
}
- else
+ else if (type == TYPE.PNG)
{
setupPNG(width, height);
}
+
} catch (Exception ex)
{
System.out.println("Error creating "
- + (type == EPS ? "EPS" : "PNG") + " file.");
+ + type.getName() + " file.");
}
}
}
return graphics;
}
- 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);
- }
+
public void writeImage()
{
pg.flush();
pg.close();
break;
+ case SVG:
+ String svg = ((SVGGraphics2D) getGraphics()).getSVGDocument();
+ out.write(svg.getBytes());
+ out.close();
+ break;
case PNG:
ImageIO.write(bi, "png", out);
out.close();
try
{
pg = new EpsGraphics2D(title, out, 0, 0, width, height);
- Graphics2D ig2 = (Graphics2D) pg;
+ Graphics2D ig2 = pg;
ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
}
- JalviewFileChooser getPNGChooser()
+ 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);
+ }
+
+ void setupSVG(int width, int height, String title)
+ {
+ g2 = new SVGGraphics2D(width, height);
+ graphics = g2;
+ }
+
+ static JalviewFileChooser getPNGChooser()
{
return new jalview.io.JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
{ "Portable network graphics" }, "Portable network graphics");
}
- JalviewFileChooser getEPSChooser()
+ static JalviewFileChooser getEPSChooser()
{
return new jalview.io.JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
{ "eps" }, new String[]
{ "Encapsulated Postscript" }, "Encapsulated Postscript");
}
+
+ static JalviewFileChooser getSVGChooser()
+ {
+ return new jalview.io.JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
+ { "svg" }, new String[]
+ { "Scalable Vector Graphics" }, "Scalable Vector Graphics");
+ }
}