2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.gui;
\r
21 import jalview.analysis.*;
\r
23 import jalview.datamodel.*;
\r
25 import jalview.jbgui.*;
\r
27 import jalview.schemes.*;
\r
29 import org.jibble.epsgraphics.*;
\r
32 import java.awt.event.*;
\r
33 import java.awt.image.*;
\r
34 import java.awt.print.*;
\r
38 import javax.imageio.*;
\r
40 import javax.swing.*;
\r
47 * @version $Revision$
\r
49 public class AlignmentPanel extends GAlignmentPanel
\r
50 implements AdjustmentListener, Printable
\r
53 OverviewPanel overviewPanel;
\r
56 IdwidthAdjuster idwidthAdjuster;
\r
58 /** DOCUMENT ME!! */
\r
59 public AlignFrame alignFrame;
\r
60 ScalePanel scalePanel;
\r
61 AnnotationPanel annotationPanel;
\r
62 AnnotationLabels alabels;
\r
64 // this value is set false when selection area being dragged
\r
65 boolean fastPaint = true;
\r
70 * Creates a new AlignmentPanel object.
\r
72 * @param af DOCUMENT ME!
\r
73 * @param av DOCUMENT ME!
\r
75 public AlignmentPanel(AlignFrame af, final AlignViewport av)
\r
79 seqPanel = new SeqPanel(av, this);
\r
80 idPanel = new IdPanel(av, this);
\r
82 scalePanel = new ScalePanel(av, this);
\r
84 idPanelHolder.add(idPanel, BorderLayout.CENTER);
\r
85 idwidthAdjuster = new IdwidthAdjuster(this);
\r
86 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
\r
88 annotationPanel = new AnnotationPanel(this);
\r
89 alabels = new AnnotationLabels(this);
\r
91 annotationSpaceFillerHolder.setPreferredSize(annotationPanel.getPreferredSize());
\r
92 annotationScroller.setPreferredSize(annotationPanel.getPreferredSize());
\r
93 annotationScroller.setViewportView(annotationPanel);
\r
94 annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
\r
98 scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
\r
99 seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
\r
101 setScrollValues(0, 0);
\r
103 hscroll.addAdjustmentListener(this);
\r
104 vscroll.addAdjustmentListener(this);
\r
106 setFocusable(true);
\r
107 addKeyListener(new KeyAdapter()
\r
109 public void keyPressed(KeyEvent evt)
\r
111 switch (evt.getKeyCode())
\r
113 case 27: // escape key
\r
114 av.setSelectionGroup(null);
\r
119 case KeyEvent.VK_DOWN:
\r
120 alignFrame.moveSelectedSequences(false);
\r
124 case KeyEvent.VK_UP:
\r
125 alignFrame.moveSelectedSequences(true);
\r
129 case KeyEvent.VK_BACK_SPACE:
\r
130 case KeyEvent.VK_DELETE:
\r
131 alignFrame.cut_actionPerformed(null);
\r
142 public void fontChanged()
\r
144 // set idCanvas bufferedImage to null
\r
145 // to prevent drawing old image
\r
146 FontMetrics fm = getFontMetrics(av.getFont());
\r
148 scalePanelHolder.setPreferredSize(new Dimension(10,
\r
149 av.charHeight + fm.getDescent()));
\r
150 idSpaceFillerPanel1.setPreferredSize(new Dimension(10,
\r
151 av.charHeight + fm.getDescent()));
\r
153 idPanel.idCanvas.gg = null;
\r
154 annotationPanel.adjustPanelHeight();
\r
156 Dimension d = calculateIdWidth();
\r
157 d.setSize(d.width + 4, d.height);
\r
158 idPanel.idCanvas.setPreferredSize(d);
\r
159 hscrollFillerPanel.setPreferredSize(d);
\r
166 * @return DOCUMENT ME!
\r
168 public Dimension calculateIdWidth()
\r
170 Graphics g = this.getGraphics();
\r
174 javax.swing.JFrame f = new javax.swing.JFrame();
\r
176 g = f.getGraphics();
\r
179 FontMetrics fm = g.getFontMetrics(av.font);
\r
180 AlignmentI al = av.getAlignment();
\r
186 while ((i < al.getHeight()) && (al.getSequenceAt(i) != null))
\r
188 SequenceI s = al.getSequenceAt(i);
\r
190 if (av.getShowFullId())
\r
192 id = s.getDisplayId();
\r
199 if (fm.stringWidth(id) > idWidth)
\r
201 idWidth = fm.stringWidth(id);
\r
207 // Also check annotation label widths
\r
210 if (al.getAlignmentAnnotation() != null)
\r
212 fm = g.getFontMetrics(alabels.getFont());
\r
214 while (i < al.getAlignmentAnnotation().length)
\r
216 String label = al.getAlignmentAnnotation()[i].label;
\r
218 if (fm.stringWidth(label) > idWidth)
\r
220 idWidth = fm.stringWidth(label);
\r
227 return new Dimension(idWidth, 12);
\r
233 * @param results DOCUMENT ME!
\r
235 public void highlightSearchResults(int[] results)
\r
237 seqPanel.seqCanvas.highlightSearchResults(results);
\r
239 // do we need to scroll the panel?
\r
240 if (results != null)
\r
242 SequenceI seq = av.alignment.getSequenceAt(results[0]);
\r
243 int start = seq.findIndex(results[1]) - 1;
\r
244 int end = seq.findIndex(results[2]) - 1;
\r
246 if ((av.getStartRes() > start) || (av.getEndRes() < end) ||
\r
247 ((av.getStartSeq() > results[0]) ||
\r
248 (av.getEndSeq() < results[0])))
\r
250 setScrollValues(start, results[0]);
\r
258 * @return DOCUMENT ME!
\r
260 public OverviewPanel getOverviewPanel()
\r
262 return overviewPanel;
\r
268 * @param op DOCUMENT ME!
\r
270 public void setOverviewPanel(OverviewPanel op)
\r
272 overviewPanel = op;
\r
278 * @param b DOCUMENT ME!
\r
280 public void setAnnotationVisible(boolean b)
\r
282 annotationSpaceFillerHolder.setVisible(b);
\r
283 annotationScroller.setVisible(b);
\r
289 * @param wrap DOCUMENT ME!
\r
291 public void setWrapAlignment(boolean wrap)
\r
293 scalePanelHolder.setVisible(!wrap);
\r
294 hscroll.setVisible(!wrap);
\r
295 idwidthAdjuster.setVisible(!wrap);
\r
297 av.setShowAnnotation(!wrap);
\r
298 annotationScroller.setVisible(!wrap);
\r
299 annotationSpaceFillerHolder.setVisible(!wrap);
\r
300 idSpaceFillerPanel1.setVisible(!wrap);
\r
308 public void setColourScheme()
\r
310 ColourSchemeI cs = av.getGlobalColourScheme();
\r
312 if (av.getConservationSelected())
\r
314 Alignment al = (Alignment) av.getAlignment();
\r
315 Conservation c = new Conservation("All",
\r
316 ResidueProperties.propHash, 3, al.getSequences(), 0,
\r
320 c.verdict(false, av.ConsPercGaps);
\r
322 ConservationColourScheme ccs = new ConservationColourScheme(c, cs);
\r
324 av.setGlobalColourScheme(ccs);
\r
330 // return value is true if the scroll is valid
\r
331 public boolean scrollUp(boolean up)
\r
335 if (vscroll.getValue() < 1)
\r
341 vscroll.setValue(vscroll.getValue() - 1);
\r
345 if ((vextent + vscroll.getValue()) >= av.getAlignment().getHeight())
\r
351 vscroll.setValue(vscroll.getValue() + 1);
\r
362 * @param right DOCUMENT ME!
\r
364 * @return DOCUMENT ME!
\r
366 public boolean scrollRight(boolean right)
\r
370 if (hscroll.getValue() < 1)
\r
376 hscroll.setValue(hscroll.getValue() - 1);
\r
380 if ((hextent + hscroll.getValue()) >= av.getAlignment().getWidth())
\r
386 hscroll.setValue(hscroll.getValue() + 1);
\r
397 * @param x DOCUMENT ME!
\r
398 * @param y DOCUMENT ME!
\r
400 public void setScrollValues(int x, int y)
\r
402 av.setEndRes((x + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) -
\r
405 hextent = seqPanel.seqCanvas.getWidth() / av.charWidth;
\r
406 vextent = seqPanel.seqCanvas.getHeight() / av.charHeight;
\r
408 if (hextent > av.alignment.getWidth())
\r
410 hextent = av.alignment.getWidth();
\r
413 if (vextent > av.alignment.getHeight())
\r
415 vextent = av.alignment.getHeight();
\r
418 if ((hextent + x) > av.getAlignment().getWidth())
\r
420 x = av.getAlignment().getWidth() - hextent;
\r
423 if ((vextent + y) > av.getAlignment().getHeight())
\r
425 y = av.getAlignment().getHeight() - vextent;
\r
438 hscroll.setValues(x, hextent, 0, av.getAlignment().getWidth());
\r
439 vscroll.setValues(y, vextent, 0, av.getAlignment().getHeight());
\r
442 public void this_mouseWheelMoved(MouseWheelEvent e)
\r
444 if(e.getWheelRotation()>0)
\r
454 * @param evt DOCUMENT ME!
\r
456 public void adjustmentValueChanged(AdjustmentEvent evt)
\r
458 int oldX = av.getStartRes();
\r
459 int oldY = av.getStartSeq();
\r
461 if (evt.getSource() == hscroll)
\r
463 int x = hscroll.getValue();
\r
466 (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1);
\r
469 if (evt.getSource() == vscroll)
\r
471 int offy = vscroll.getValue();
\r
473 if (av.getWrapAlignment())
\r
475 int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
\r
476 av.setStartRes(vscroll.getValue() * rowSize);
\r
477 av.setEndRes((vscroll.getValue() + 1) * rowSize);
\r
481 av.setStartSeq(offy);
\r
482 av.setEndSeq(offy +
\r
483 (seqPanel.seqCanvas.getHeight() / av.getCharHeight()));
\r
487 if (overviewPanel != null)
\r
489 overviewPanel.setBoxPosition();
\r
492 if (av.getWrapAlignment() || !fastPaint)
\r
498 idPanel.idCanvas.fastPaint(av.getStartSeq() - oldY);
\r
499 seqPanel.seqCanvas.fastPaint(av.getStartRes() - oldX,
\r
500 av.getStartSeq() - oldY);
\r
502 scalePanel.repaint();
\r
504 if (av.getShowAnnotation())
\r
506 annotationPanel.fastPaint(av.getStartRes() - oldX);
\r
514 * @param g DOCUMENT ME!
\r
516 public void paintComponent(Graphics g)
\r
520 Dimension d = idPanel.idCanvas.getPreferredSize();
\r
521 idPanelHolder.setPreferredSize(d);
\r
522 hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));
\r
525 if (av.getWrapAlignment())
\r
527 int max = av.alignment.getWidth() / seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
\r
528 vscroll.setMaximum(max);
\r
529 vscroll.setUnitIncrement(1);
\r
530 vscroll.setVisibleAmount(1);
\r
534 setScrollValues(av.getStartRes(), av.getStartSeq());
\r
541 * @param pg DOCUMENT ME!
\r
542 * @param pf DOCUMENT ME!
\r
543 * @param pi DOCUMENT ME!
\r
545 * @return DOCUMENT ME!
\r
547 * @throws PrinterException DOCUMENT ME!
\r
549 public int print(Graphics pg, PageFormat pf, int pi)
\r
550 throws PrinterException
\r
552 pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());
\r
554 int pwidth = (int) pf.getImageableWidth();
\r
555 int pheight = (int) pf.getImageableHeight();
\r
557 if (av.getWrapAlignment())
\r
559 return printWrappedAlignment(pg, pwidth, pheight, pi);
\r
563 return printUnwrapped(pg, pwidth, pheight, pi);
\r
570 * @param pg DOCUMENT ME!
\r
571 * @param pwidth DOCUMENT ME!
\r
572 * @param pheight DOCUMENT ME!
\r
573 * @param pi DOCUMENT ME!
\r
575 * @return DOCUMENT ME!
\r
577 * @throws PrinterException DOCUMENT ME!
\r
579 public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi)
\r
580 throws PrinterException
\r
582 int idWidth = calculateIdWidth().width + 4;
\r
583 FontMetrics fm = getFontMetrics(av.getFont());
\r
584 int scaleHeight = av.charHeight + fm.getDescent();
\r
586 pg.setColor(Color.white);
\r
587 pg.fillRect(0, 0, pwidth, pheight);
\r
588 pg.setFont(av.getFont());
\r
590 ////////////////////////////////////
\r
591 /// How many sequences and residues can we fit on a printable page?
\r
592 int totalRes = (pwidth - idWidth) / av.getCharWidth();
\r
594 int totalSeq = (int) ((pheight - scaleHeight) / av.getCharHeight()) -
\r
597 int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;
\r
599 /////////////////////////////
\r
600 /// Only print these sequences and residues on this page
\r
603 /////////////////////////////
\r
604 /// Only print these sequences and residues on this page
\r
607 /////////////////////////////
\r
608 /// Only print these sequences and residues on this page
\r
611 /////////////////////////////
\r
612 /// Only print these sequences and residues on this page
\r
614 startRes = (pi % pagesWide) * totalRes;
\r
615 endRes = (startRes + totalRes) - 1;
\r
617 if (endRes > (av.getAlignment().getWidth() - 1))
\r
619 endRes = av.getAlignment().getWidth() - 1;
\r
622 startSeq = (pi / pagesWide) * totalSeq;
\r
623 endSeq = startSeq + totalSeq;
\r
625 if (endSeq > av.getAlignment().getHeight())
\r
627 endSeq = av.getAlignment().getHeight();
\r
630 int pagesHigh = ((av.alignment.getHeight() / totalSeq) + 1) * pheight;
\r
632 if (av.showAnnotation)
\r
634 pagesHigh += annotationPanel.getHeight();
\r
637 pagesHigh /= pheight;
\r
639 if (pi >= (pagesWide * pagesHigh))
\r
641 return Printable.NO_SUCH_PAGE;
\r
645 pg.translate(idWidth, 0);
\r
646 scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight);
\r
647 pg.translate(-idWidth, scaleHeight);
\r
651 Color currentColor = null;
\r
652 Color currentTextColor = null;
\r
654 for (int i = startSeq; i < endSeq; i++)
\r
656 if ((av.getSelectionGroup() != null) &&
\r
657 av.getSelectionGroup().sequences.contains(
\r
658 av.getAlignment().getSequenceAt(i)))
\r
660 currentColor = Color.gray;
\r
661 currentTextColor = Color.black;
\r
665 currentColor = av.getAlignment().getSequenceAt(i).getColor();
\r
666 currentTextColor = Color.black;
\r
669 pg.setColor(currentColor);
\r
670 pg.fillRect(0, (i-startSeq) * av.charHeight, idWidth,
\r
671 av.getCharHeight());
\r
673 pg.setColor(currentTextColor);
\r
675 String string = av.getAlignment().getSequenceAt(i).getName();
\r
677 if (av.getShowFullId())
\r
679 string = av.getAlignment().getSequenceAt(i).getDisplayId();
\r
682 pg.drawString(string, 0,
\r
683 (((i-startSeq) * av.charHeight) + av.getCharHeight()) -
\r
684 (av.getCharHeight() / 5));
\r
687 // draw main sequence panel
\r
688 pg.translate(idWidth, 0);
\r
689 seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq,
\r
690 startRes, startSeq, 0);
\r
692 if (av.showAnnotation && (endSeq == av.alignment.getHeight()))
\r
694 pg.translate(-idWidth, (endSeq - startSeq) * av.charHeight);
\r
695 alabels.drawComponent((Graphics2D) pg);
\r
696 pg.translate(idWidth, 0);
\r
697 annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes +
\r
701 return Printable.PAGE_EXISTS;
\r
707 * @param pg DOCUMENT ME!
\r
708 * @param pwidth DOCUMENT ME!
\r
709 * @param pheight DOCUMENT ME!
\r
710 * @param pi DOCUMENT ME!
\r
712 * @return DOCUMENT ME!
\r
714 * @throws PrinterException DOCUMENT ME!
\r
716 public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,
\r
717 int pi) throws PrinterException
\r
719 int idWidth = calculateIdWidth().width + 4;
\r
721 int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth -
\r
723 int totalHeight = totalHeight = (av.alignment.getHeight() + 2) * ((av.alignment.getWidth() / resWidth) +
\r
724 1) * av.charHeight;
\r
726 pg.setColor(Color.white);
\r
727 pg.fillRect(0, 0, pwidth, pheight);
\r
728 pg.setFont(av.getFont());
\r
732 pg.setColor(Color.black);
\r
734 pg.translate(0, -pi * pheight);
\r
736 pg.setClip(0, pi * pheight, pwidth, pheight);
\r
738 int ypos = 2 * av.charHeight;
\r
742 for (int i = 0; i < av.alignment.getHeight(); i++)
\r
744 SequenceI s = av.alignment.getSequenceAt(i);
\r
745 String string = s.getName();
\r
747 if (av.getShowFullId())
\r
749 string = s.getDisplayId();
\r
752 pg.drawString(string, 0,
\r
753 ((i * av.charHeight) + ypos + av.charHeight) -
\r
754 (av.charHeight / 5));
\r
757 ypos += ((av.alignment.getHeight() + 2) * av.charHeight);
\r
759 while (ypos < totalHeight);
\r
761 pg.translate(idWidth, 0);
\r
763 seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight, 0);
\r
765 if ((pi * pheight) < totalHeight)
\r
767 return Printable.PAGE_EXISTS;
\r
771 return Printable.NO_SUCH_PAGE;
\r
778 public void makeEPS(File epsFile)
\r
780 if(epsFile == null)
\r
782 jalview.io.JalviewFileChooser chooser = new jalview.io.
\r
783 JalviewFileChooser(jalview.bin.Cache.getProperty(
\r
784 "LAST_DIRECTORY"), new String[]
\r
787 {"Encapsulated Postscript"},
\r
788 "Encapsulated Postscript");
\r
789 chooser.setFileView(new jalview.io.JalviewFileView());
\r
790 chooser.setDialogTitle("Create EPS file from alignment");
\r
791 chooser.setToolTipText("Save");
\r
793 int value = chooser.showSaveDialog(this);
\r
795 if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)
\r
800 epsFile = chooser.getSelectedFile();
\r
802 jalview.bin.Cache.setProperty("LAST_DIRECTORY",
\r
803 chooser.getSelectedFile().getParent());
\r
806 int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;
\r
807 int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);
\r
809 if (av.getWrapAlignment())
\r
811 height = ( (av.alignment.getWidth() / av.getChunkWidth()) + 1) *
\r
813 width = seqPanel.getWidth() + idPanel.getWidth();
\r
818 if (av.getShowAnnotation())
\r
820 height += annotationPanel.getPreferredSize().height;
\r
825 FileOutputStream out = new FileOutputStream(epsFile);
\r
826 EpsGraphics2D pg = new EpsGraphics2D("Example", out, 0, 0, width,
\r
829 if (av.getWrapAlignment())
\r
831 printWrappedAlignment(pg, width, height, 0);
\r
835 printUnwrapped(pg, width, height, 0);
\r
841 catch (Exception ex)
\r
843 ex.printStackTrace();
\r
848 public void makePNGImageMap(File imgMapFile, String imageName)
\r
850 ///////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS
\r
851 //////////////////////////////////////////////
\r
852 int idWidth = calculateIdWidth().width + 4;
\r
853 FontMetrics fm = getFontMetrics(av.getFont());
\r
854 int scaleHeight = av.charHeight + fm.getDescent();
\r
857 //////////////////////////////////
\r
858 if(imgMapFile!=null)
\r
862 PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
\r
863 out.println(jalview.io.HTMLOutput.getImageMapHTML());
\r
864 out.println("<img src=\"" + imageName +
\r
865 "\" border=\"0\" usemap=\"#Map\" >"
\r
866 +"<map name=\"Map\">");
\r
868 for (int s = 0; s < av.alignment.getHeight(); s++)
\r
870 SequenceI seq = av.alignment.getSequenceAt(s);
\r
871 SequenceGroup[] groups = av.alignment.findAllGroups(seq);
\r
872 for (int i = 0; i < groups.length; i++)
\r
874 int sy = s * av.charHeight + scaleHeight;
\r
875 for (int res = groups[i].getStartRes();
\r
876 res < groups[i].getEndRes() + 1; res++)
\r
878 int alIndex = seq.findPosition(res);
\r
879 Object obj = ResidueProperties.aa2Triplet.get(
\r
880 seq.getCharAt(res) + "");
\r
884 String triplet = obj.toString();
\r
887 "<area shape=\"rect\" coords=\""
\r
888 + (idWidth + res * av.charWidth) + ","
\r
890 + (idWidth + (res + 1) * av.charWidth) + ","
\r
891 + (av.charHeight + sy) + "\""
\r
892 + " onMouseOver=\"toolTip('"
\r
893 + alIndex + " " + triplet +
\r
894 "<br><em>" + groups[i].getName() +
\r
895 "</em>')\"; onMouseOut=\"toolTip()\"; "
\r
901 out.println("</map></body></html>");
\r
905 catch (Exception ex)
\r
907 ex.printStackTrace();
\r
909 }///////////END OF IMAGE MAP
\r
916 public void makePNG(File pngFile)
\r
920 jalview.io.JalviewFileChooser chooser = new jalview.io.
\r
921 JalviewFileChooser(jalview.bin.Cache.getProperty(
\r
922 "LAST_DIRECTORY"), new String[]
\r
925 {"Portable network graphics"},
\r
926 "Portable network graphics");
\r
927 chooser.setFileView(new jalview.io.JalviewFileView());
\r
928 chooser.setDialogTitle("Create EPS file from alignment");
\r
929 chooser.setToolTipText("Save");
\r
931 int value = chooser.showSaveDialog(this);
\r
933 if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)
\r
938 pngFile = chooser.getSelectedFile();
\r
940 jalview.bin.Cache.setProperty("LAST_DIRECTORY",
\r
941 chooser.getSelectedFile().getParent());
\r
946 int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;
\r
947 int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);
\r
949 if (av.getWrapAlignment())
\r
951 height = ( (av.alignment.getWidth() / av.getChunkWidth()) + 1) *
\r
953 width = seqPanel.getWidth() + idPanel.getWidth();
\r
958 if (av.getShowAnnotation())
\r
960 height += annotationPanel.getPreferredSize().height;
\r
966 FileOutputStream out = new FileOutputStream(pngFile);
\r
968 BufferedImage bi = new BufferedImage(width, height,
\r
969 BufferedImage.TYPE_INT_RGB);
\r
970 Graphics2D png = (Graphics2D) bi.getGraphics();
\r
972 png.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
\r
973 RenderingHints.VALUE_ANTIALIAS_ON);
\r
975 if (av.getWrapAlignment())
\r
977 printWrappedAlignment(png, width, height, 0);
\r
981 printUnwrapped(png, width, height, 0);
\r
984 ImageIO.write(bi, "png", out);
\r
987 catch(OutOfMemoryError err)
\r
989 System.out.println("########################\n"
\r
990 +"OUT OF MEMORY "+pngFile+"\n"
\r
991 +"########################");
\r
993 catch (Exception ex)
\r
995 ex.printStackTrace();
\r
1004 * @author $author$
\r
1005 * @version $Revision$
\r
1007 class Preview extends JFrame
\r
1010 * Creates a new Preview object.
\r
1012 * @param image DOCUMENT ME!
\r
1014 public Preview(Image image)
\r
1016 setResizable(true);
\r
1017 setSize(image.getWidth(this), image.getHeight(this));
\r
1019 getContentPane().setLayout(new BorderLayout());
\r
1020 getContentPane().add(new PreviewPanel(image), BorderLayout.CENTER);
\r
1030 * @author $author$
\r
1031 * @version $Revision$
\r
1033 class PreviewPanel extends JPanel
\r
1038 * Creates a new PreviewPanel object.
\r
1040 * @param image DOCUMENT ME!
\r
1042 public PreviewPanel(Image image)
\r
1044 this.image = image;
\r
1050 * @param g DOCUMENT ME!
\r
1052 public void paintComponent(Graphics g)
\r
1054 if (image != null)
\r
1056 g.drawImage(image, 0, 0, this);
\r
1060 System.out.println("DEBUG:image is null");
\r