\r
protected void saveAs_actionPerformed(ActionEvent e)\r
{\r
- JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"));\r
+ String suffix = "";\r
+ if(e.getActionCommand().equals("FASTA"))\r
+ suffix = "fa";\r
+ else if(e.getActionCommand().equals("MSF"))\r
+ suffix = "msf";\r
+ else if(e.getActionCommand().equals("CLUSTAL"))\r
+ suffix = "aln";\r
+ else if(e.getActionCommand().equals("BLC"))\r
+ suffix = "blc";\r
+ else if(e.getActionCommand().equals("PIR"))\r
+ suffix = "pir";\r
+ else if(e.getActionCommand().equals("PFAM"))\r
+ suffix = "pfam";\r
+\r
+ JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY")\r
+ , new String[]{suffix}, e.getActionCommand()+" file");\r
chooser.setFileView(new JalviewFileView());\r
chooser.setDialogTitle("Save Alignment to file - "+e.getActionCommand() +" format.");\r
chooser.setToolTipText("Save");\r
htmlOutput = null;\r
}\r
\r
- protected void createJPG_actionPerformed(ActionEvent e)\r
+ protected void createPNG_actionPerformed(ActionEvent e)\r
{\r
-\r
int height = (viewport.alignment.getWidth() / viewport.getChunkWidth() +1) * viewport.chunkHeight;\r
int width = alignPanel.seqPanel.getWidth() + alignPanel.idPanel.getWidth();\r
\r
+ if(!viewport.getWrapAlignment())\r
+ {\r
+ height = viewport.alignment.getHeight() * viewport.charHeight;\r
+ width = alignPanel.idPanel.getWidth() + viewport.alignment.getWidth() * viewport.charWidth;\r
+ }\r
+\r
+ alignPanel.makePNG( width, height);\r
+ }\r
+\r
+ protected void epsFile_actionPerformed(ActionEvent e)\r
+ {\r
+ int height = (viewport.alignment.getWidth() / viewport.getChunkWidth() +1) * viewport.chunkHeight;\r
+ int width = alignPanel.seqPanel.getWidth() + alignPanel.idPanel.getWidth();\r
\r
if(!viewport.getWrapAlignment())\r
{\r
width = alignPanel.idPanel.getWidth() + viewport.alignment.getWidth() * viewport.charWidth;\r
}\r
\r
- alignPanel.makeJPG( width, height);\r
+ alignPanel.makeEPS( width, height);\r
+\r
}\r
\r
\r
import java.io.*;\r
import java.awt.image.*;\r
\r
-import gnu.jpdf.*;\r
+import org.jibble.epsgraphics.*;\r
+import javax.imageio.*;\r
\r
\r
public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListener, Printable\r
IdwidthAdjuster iap = new IdwidthAdjuster(this);\r
idSpaceFillerPanel1.add(iap, BorderLayout.CENTER);\r
\r
- idPanel.idCanvas.setPreferredSize(calculateIdWidth());\r
- hscrollFillerPanel.setPreferredSize(calculateIdWidth());\r
+ Dimension d = calculateIdWidth();\r
+ d.setSize( d.width+4, d.height);\r
+ idPanel.idCanvas.setPreferredSize( d );\r
+ hscrollFillerPanel.setPreferredSize( d );\r
\r
scalePanelHolder.add(scalePanel, BorderLayout.CENTER);\r
scorePanelHolder.add(scorePanel, BorderLayout.CENTER);\r
\r
hscroll.setVisible(!wrap);\r
\r
- // idSpaceFillerPanel.setVisible(!wrap);\r
- // idWidthAdjusterPanel.setVisible(!wrap);\r
+ idSpaceFillerPanel.setVisible(!wrap);\r
+ idSpaceFillerPanel1.setVisible(!wrap);\r
\r
RefreshPanels();\r
\r
\r
////////////////\r
//draw Scale\r
- pg.translate(idWidth,0);\r
+ pg.translate(30,0);\r
scalePanel.drawScale(pg, startRes, endRes, pwidth-idWidth);\r
\r
- pg.translate(-idWidth, 30);\r
+ pg.translate(-30, 30);\r
////////////////\r
// Draw the ids\r
Color currentColor=null;\r
\r
pg.setColor(currentTextColor);\r
\r
- String string = av.getAlignment().getSequenceAt(i).getDisplayId();\r
+ String string = av.getAlignment().getSequenceAt(i).getName();\r
+ if(av.getShowFullId())\r
+ string = av.getAlignment().getSequenceAt(i).getDisplayId();\r
+\r
pg.drawString(string, 0, jalview.analysis.AlignmentUtil.getPixelHeight\r
(startSeq, i, av.getCharHeight()) + av.getCharHeight() - (av.getCharHeight() / 5));\r
}\r
for (int i = 0; i < endy; i++)\r
{\r
SequenceI s = da.getSequenceAt(i);\r
- pg.drawString(s.getDisplayId(), 0,\r
+ String string = s.getName();\r
+ if (av.getShowFullId())\r
+ string = s.getDisplayId();\r
+\r
+ pg.drawString(string, 0,\r
AlignmentUtil.getPixelHeight(0, i, av.charHeight) + ypos +\r
av.charHeight - (av.charHeight / 5));\r
}\r
\r
}\r
\r
- public void makeJPG(int width, int height)\r
+\r
+ public void makeEPS(int width, int height)\r
{\r
try\r
{\r
+ jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(jalview.bin.Cache.getProperty(\r
+ "LAST_DIRECTORY"), new String[]{"eps"}, "Encapsulated Postscript");\r
+ chooser.setFileView(new jalview.io.JalviewFileView());\r
+ chooser.setDialogTitle("Create EPS file from alignment");\r
+ chooser.setToolTipText("Save");\r
\r
- BufferedImage bi = new BufferedImage(width, height,\r
- BufferedImage.TYPE_INT_RGB);\r
- Graphics pg = bi.getGraphics();\r
+ int value = chooser.showSaveDialog(this);\r
+ if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)\r
+ return;\r
+\r
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY",chooser.getSelectedFile().getPath());\r
+ FileOutputStream out = new FileOutputStream(chooser.getSelectedFile());\r
+ EpsGraphics2D pg = new EpsGraphics2D("Example", out, 0, 0, width, height);\r
\r
- try\r
- {\r
if (av.getWrapAlignment())\r
printWrappedAlignment(pg, width, height, 0);\r
else\r
printUnwrapped(pg, width, height, 0);\r
- }\r
- catch (Exception ex)\r
- {}\r
\r
+\r
+ pg.flush();\r
+ pg.close();\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ }\r
+ }\r
+\r
+ public void makePNG(int width, int height)\r
+ {\r
+ try\r
+ {\r
jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(jalview.bin.Cache.getProperty(\r
- "LAST_DIRECTORY"));\r
+ "LAST_DIRECTORY"), new String[]{"png"}, "Portable network graphics");\r
chooser.setFileView(new jalview.io.JalviewFileView());\r
- chooser.setDialogTitle("Create JPG image from alignment");\r
+ chooser.setDialogTitle("Create EPS file from alignment");\r
chooser.setToolTipText("Save");\r
\r
int value = chooser.showSaveDialog(this);\r
- if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)\r
- {\r
+ if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)\r
+ return;\r
\r
- FileOutputStream out = new FileOutputStream(chooser.getSelectedFile());\r
- JPEGImageEncoder jie = JPEGCodec.createJPEGEncoder(out);\r
- JPEGEncodeParam param = JPEGCodec.getDefaultJPEGEncodeParam(bi);\r
- param.setQuality(1.0f, true);\r
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY",chooser.getSelectedFile().getPath());\r
+ FileOutputStream out = new FileOutputStream(chooser.getSelectedFile());\r
\r
- jie.encode(bi, param);\r
- out.close();\r
- }\r
+ BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);\r
+ Graphics png = bi.getGraphics();\r
\r
+\r
+ if (av.getWrapAlignment())\r
+ printWrappedAlignment(png, width, height, 0);\r
+ else\r
+ printUnwrapped(png, width, height, 0);\r
+\r
+ ImageIO.write(bi, "png", out);\r
+ out.close();\r
}\r
- catch (IOException ex)\r
+ catch (Exception ex)\r
{\r
- System.out.println("ex Writing image ");\r
+ ex.printStackTrace();\r
}\r
}\r
\r