\r
import jalview.schemes.*;\r
\r
-import org.jibble.epsgraphics.*;\r
-\r
import java.awt.*;\r
import java.awt.event.*;\r
-import java.awt.image.*;\r
import java.awt.print.*;\r
\r
import java.io.*;\r
\r
-import javax.imageio.*;\r
-\r
import javax.swing.*;\r
\r
\r
public class AlignmentPanel extends GAlignmentPanel\r
implements AdjustmentListener, Printable\r
{\r
- public AlignViewport av;\r
- OverviewPanel overviewPanel;\r
- SeqPanel seqPanel;\r
- IdPanel idPanel;\r
- IdwidthAdjuster idwidthAdjuster;\r
-\r
- /** DOCUMENT ME!! */\r
- public AlignFrame alignFrame;\r
- ScalePanel scalePanel;\r
- AnnotationPanel annotationPanel;\r
- AnnotationLabels alabels;\r
-\r
- // this value is set false when selection area being dragged\r
- boolean fastPaint = true;\r
- int hextent = 0;\r
- int vextent = 0;\r
-\r
- /**\r
- * Creates a new AlignmentPanel object.\r
- *\r
- * @param af DOCUMENT ME!\r
- * @param av DOCUMENT ME!\r
- */\r
- public AlignmentPanel(AlignFrame af, final AlignViewport av)\r
+ public AlignViewport av;\r
+ OverviewPanel overviewPanel;\r
+ SeqPanel seqPanel;\r
+ IdPanel idPanel;\r
+ IdwidthAdjuster idwidthAdjuster;\r
+\r
+ /** DOCUMENT ME!! */\r
+ public AlignFrame alignFrame;\r
+ ScalePanel scalePanel;\r
+ AnnotationPanel annotationPanel;\r
+ AnnotationLabels alabels;\r
+\r
+ // this value is set false when selection area being dragged\r
+ boolean fastPaint = true;\r
+ int hextent = 0;\r
+ int vextent = 0;\r
+\r
+ /**\r
+ * Creates a new AlignmentPanel object.\r
+ *\r
+ * @param af DOCUMENT ME!\r
+ * @param av DOCUMENT ME!\r
+ */\r
+ public AlignmentPanel(AlignFrame af, final AlignViewport av)\r
+ {\r
+ alignFrame = af;\r
+ this.av = av;\r
+ seqPanel = new SeqPanel(av, this);\r
+ idPanel = new IdPanel(av, this);\r
+\r
+ scalePanel = new ScalePanel(av, this);\r
+\r
+ idPanelHolder.add(idPanel, BorderLayout.CENTER);\r
+ idwidthAdjuster = new IdwidthAdjuster(this);\r
+ idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);\r
+\r
+ annotationPanel = new AnnotationPanel(this);\r
+ alabels = new AnnotationLabels(this);\r
+\r
+ annotationSpaceFillerHolder.setPreferredSize(annotationPanel.\r
+ getPreferredSize());\r
+ annotationScroller.setPreferredSize(annotationPanel.getPreferredSize());\r
+ annotationScroller.setViewportView(annotationPanel);\r
+ annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);\r
+\r
+ fontChanged();\r
+\r
+ scalePanelHolder.add(scalePanel, BorderLayout.CENTER);\r
+ seqPanelHolder.add(seqPanel, BorderLayout.CENTER);\r
+\r
+ setScrollValues(0, 0);\r
+\r
+ annotationPanel.adjustPanelHeight();\r
+ annotationSpaceFillerHolder.setPreferredSize(annotationPanel.\r
+ getPreferredSize());\r
+ annotationScroller.setPreferredSize(annotationPanel.\r
+ getPreferredSize());\r
+ setAnnotationVisible(av.getShowAnnotation());\r
+\r
+ hscroll.addAdjustmentListener(this);\r
+ vscroll.addAdjustmentListener(this);\r
+\r
+ af.addKeyListener(new KeyAdapter()\r
{\r
- alignFrame = af;\r
- this.av = av;\r
- seqPanel = new SeqPanel(av, this);\r
- idPanel = new IdPanel(av, this);\r
+ public void keyPressed(KeyEvent evt)\r
+ {\r
+ switch (evt.getKeyCode())\r
+ {\r
+ case 27: // escape key\r
+ av.setSelectionGroup(null);\r
+ repaint();\r
\r
- scalePanel = new ScalePanel(av, this);\r
+ break;\r
\r
- idPanelHolder.add(idPanel, BorderLayout.CENTER);\r
- idwidthAdjuster = new IdwidthAdjuster(this);\r
- idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);\r
+ case KeyEvent.VK_DOWN:\r
+ alignFrame.moveSelectedSequences(false);\r
\r
- annotationPanel = new AnnotationPanel(this);\r
- alabels = new AnnotationLabels(this);\r
+ break;\r
\r
- annotationSpaceFillerHolder.setPreferredSize(annotationPanel.getPreferredSize());\r
- annotationScroller.setPreferredSize(annotationPanel.getPreferredSize());\r
- annotationScroller.setViewportView(annotationPanel);\r
- annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);\r
+ case KeyEvent.VK_UP:\r
+ alignFrame.moveSelectedSequences(true);\r
\r
- fontChanged();\r
+ break;\r
\r
- scalePanelHolder.add(scalePanel, BorderLayout.CENTER);\r
- seqPanelHolder.add(seqPanel, BorderLayout.CENTER);\r
+ case KeyEvent.VK_BACK_SPACE:\r
+ case KeyEvent.VK_DELETE:\r
+ alignFrame.cut_actionPerformed(null);\r
+ break;\r
\r
- setScrollValues(0, 0);\r
+ case KeyEvent.VK_P:\r
+ seqPanel.seqCanvas.increaseAARatio();\r
+ break;\r
+ case KeyEvent.VK_L:\r
+ seqPanel.seqCanvas.decreaseAARation();\r
+ break;\r
+ }\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ */\r
+ public void fontChanged()\r
+ {\r
+ // set idCanvas bufferedImage to null\r
+ // to prevent drawing old image\r
+ FontMetrics fm = getFontMetrics(av.getFont());\r
+\r
+ scalePanelHolder.setPreferredSize(new Dimension(10,\r
+ av.charHeight + fm.getDescent()));\r
+ idSpaceFillerPanel1.setPreferredSize(new Dimension(10,\r
+ av.charHeight + fm.getDescent()));\r
+\r
+ idPanel.idCanvas.gg = null;\r
+ seqPanel.seqCanvas.img = null;\r
+ annotationPanel.adjustPanelHeight();\r
+\r
+ Dimension d = calculateIdWidth();\r
+ d.setSize(d.width + 4, d.height);\r
+ idPanel.idCanvas.setPreferredSize(d);\r
+ hscrollFillerPanel.setPreferredSize(d);\r
+\r
+ if (av.getWrapAlignment())\r
+ {\r
+ int max = av.alignment.getWidth() /\r
+ seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
+ vscroll.setMaximum(max);\r
+ vscroll.setUnitIncrement(1);\r
+ vscroll.setVisibleAmount(1);\r
+ }\r
+ else\r
+ {\r
+ setScrollValues(av.getStartRes(), av.getStartSeq());\r
+ }\r
\r
- annotationPanel.adjustPanelHeight();\r
- annotationSpaceFillerHolder.setPreferredSize(annotationPanel.getPreferredSize());\r
- annotationScroller.setPreferredSize(annotationPanel.\r
- getPreferredSize());\r
- setAnnotationVisible(av.getShowAnnotation());\r
+ if (overviewPanel != null)\r
+ overviewPanel.setBoxPosition();\r
\r
+ repaint();\r
+ }\r
\r
- hscroll.addAdjustmentListener(this);\r
- vscroll.addAdjustmentListener(this);\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public Dimension calculateIdWidth()\r
+ {\r
+ Container c = new Container();\r
\r
- af.addKeyListener(new KeyAdapter()\r
- {\r
- public void keyPressed(KeyEvent evt)\r
- {\r
- switch (evt.getKeyCode())\r
- {\r
- case 27: // escape key\r
- av.setSelectionGroup(null);\r
- repaint();\r
-\r
- break;\r
-\r
- case KeyEvent.VK_DOWN:\r
- alignFrame.moveSelectedSequences(false);\r
-\r
- break;\r
-\r
- case KeyEvent.VK_UP:\r
- alignFrame.moveSelectedSequences(true);\r
-\r
- break;\r
-\r
- case KeyEvent.VK_BACK_SPACE:\r
- case KeyEvent.VK_DELETE:\r
- alignFrame.cut_actionPerformed(null);\r
- break;\r
-\r
- case KeyEvent.VK_P:\r
- seqPanel.seqCanvas.increaseAARatio();\r
- break;\r
- case KeyEvent.VK_L:\r
- seqPanel.seqCanvas.decreaseAARation();\r
- break;\r
- }\r
- }\r
- });\r
- }\r
+ FontMetrics fm = c.getFontMetrics(av.font);\r
+ AlignmentI al = av.getAlignment();\r
\r
+ int i = 0;\r
+ int idWidth = 0;\r
+ String id;\r
\r
- /**\r
- * DOCUMENT ME!\r
- */\r
- public void fontChanged()\r
+ while ( (i < al.getHeight()) && (al.getSequenceAt(i) != null))\r
{\r
- // set idCanvas bufferedImage to null\r
- // to prevent drawing old image\r
- FontMetrics fm = getFontMetrics(av.getFont());\r
-\r
- scalePanelHolder.setPreferredSize(new Dimension(10,\r
- av.charHeight + fm.getDescent()));\r
- idSpaceFillerPanel1.setPreferredSize(new Dimension(10,\r
- av.charHeight + fm.getDescent()));\r
+ SequenceI s = al.getSequenceAt(i);\r
\r
- idPanel.idCanvas.gg = null;\r
- seqPanel.seqCanvas.img = null;\r
- annotationPanel.adjustPanelHeight();\r
-\r
- Dimension d = calculateIdWidth();\r
- d.setSize(d.width + 4, d.height);\r
- idPanel.idCanvas.setPreferredSize(d);\r
- hscrollFillerPanel.setPreferredSize(d);\r
-\r
- if (av.getWrapAlignment())\r
- {\r
- int max = av.alignment.getWidth() /\r
- seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
- vscroll.setMaximum(max);\r
- vscroll.setUnitIncrement(1);\r
- vscroll.setVisibleAmount(1);\r
- }\r
- else\r
- {\r
- setScrollValues(av.getStartRes(), av.getStartSeq());\r
- }\r
+ id = s.getDisplayId(av.getShowDBPrefix(), av.getShowJVSuffix());\r
\r
- if(overviewPanel!=null)\r
- overviewPanel.setBoxPosition();\r
+ if (fm.stringWidth(id) > idWidth)\r
+ {\r
+ idWidth = fm.stringWidth(id);\r
+ }\r
\r
- repaint();\r
+ i++;\r
}\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- */\r
- public Dimension calculateIdWidth()\r
- {\r
- Container c = new Container();\r
+ // Also check annotation label widths\r
+ i = 0;\r
\r
- FontMetrics fm = c.getFontMetrics(av.font);\r
- AlignmentI al = av.getAlignment();\r
+ if (al.getAlignmentAnnotation() != null)\r
+ {\r
+ fm = c.getFontMetrics(alabels.getFont());\r
\r
- int i = 0;\r
- int idWidth = 0;\r
- String id;\r
+ while (i < al.getAlignmentAnnotation().length)\r
+ {\r
+ String label = al.getAlignmentAnnotation()[i].label;\r
\r
- while ((i < al.getHeight()) && (al.getSequenceAt(i) != null))\r
+ if (fm.stringWidth(label) > idWidth)\r
{\r
- SequenceI s = al.getSequenceAt(i);\r
-\r
- id = s.getDisplayId(av.getShowDBPrefix(), av.getShowJVSuffix());\r
-\r
- if (fm.stringWidth(id) > idWidth)\r
- {\r
- idWidth = fm.stringWidth(id);\r
- }\r
-\r
- i++;\r
+ idWidth = fm.stringWidth(label);\r
}\r
\r
- // Also check annotation label widths\r
- i = 0;\r
-\r
- if (al.getAlignmentAnnotation() != null)\r
- {\r
- fm = c.getFontMetrics(alabels.getFont());\r
+ i++;\r
+ }\r
+ }\r
\r
- while (i < al.getAlignmentAnnotation().length)\r
- {\r
- String label = al.getAlignmentAnnotation()[i].label;\r
+ return new Dimension(idWidth, 12);\r
+ }\r
\r
- if (fm.stringWidth(label) > idWidth)\r
- {\r
- idWidth = fm.stringWidth(label);\r
- }\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param results DOCUMENT ME!\r
+ */\r
+ public void highlightSearchResults(int[] results)\r
+ {\r
+ seqPanel.seqCanvas.highlightSearchResults(results);\r
\r
- i++;\r
- }\r
- }\r
+ // do we need to scroll the panel?\r
+ if (results != null)\r
+ {\r
+ SequenceI seq = av.alignment.getSequenceAt(results[0]);\r
+ int start = seq.findIndex(results[1]) - 1;\r
+ int end = seq.findIndex(results[2]) - 1;\r
\r
- return new Dimension(idWidth, 12);\r
+ if ( (av.getStartRes() > start) || (av.getEndRes() < end) ||\r
+ ( (av.getStartSeq() > results[0]) ||\r
+ (av.getEndSeq() < results[0])))\r
+ {\r
+ setScrollValues(start, results[0]);\r
+ }\r
}\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param results DOCUMENT ME!\r
- */\r
- public void highlightSearchResults(int[] results)\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public OverviewPanel getOverviewPanel()\r
+ {\r
+ return overviewPanel;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param op DOCUMENT ME!\r
+ */\r
+ public void setOverviewPanel(OverviewPanel op)\r
+ {\r
+ overviewPanel = op;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param b DOCUMENT ME!\r
+ */\r
+ public void setAnnotationVisible(boolean b)\r
+ {\r
+ if (!av.wrapAlignment)\r
{\r
- seqPanel.seqCanvas.highlightSearchResults(results);\r
-\r
- // do we need to scroll the panel?\r
- if (results != null)\r
- {\r
- SequenceI seq = av.alignment.getSequenceAt(results[0]);\r
- int start = seq.findIndex(results[1]) - 1;\r
- int end = seq.findIndex(results[2]) - 1;\r
-\r
- if ((av.getStartRes() > start) || (av.getEndRes() < end) ||\r
- ((av.getStartSeq() > results[0]) ||\r
- (av.getEndSeq() < results[0])))\r
- {\r
- setScrollValues(start, results[0]);\r
- }\r
- }\r
+ annotationSpaceFillerHolder.setVisible(b);\r
+ annotationScroller.setVisible(b);\r
}\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- */\r
- public OverviewPanel getOverviewPanel()\r
+ repaint();\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param wrap DOCUMENT ME!\r
+ */\r
+ public void setWrapAlignment(boolean wrap)\r
+ {\r
+ av.startSeq = 0;\r
+ scalePanelHolder.setVisible(!wrap);\r
+ hscroll.setVisible(!wrap);\r
+ idwidthAdjuster.setVisible(!wrap);\r
+\r
+ if (wrap)\r
{\r
- return overviewPanel;\r
+ annotationScroller.setVisible(false);\r
+ annotationSpaceFillerHolder.setVisible(false);\r
}\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param op DOCUMENT ME!\r
- */\r
- public void setOverviewPanel(OverviewPanel op)\r
+ else if (av.showAnnotation)\r
{\r
- overviewPanel = op;\r
+ annotationScroller.setVisible(true);\r
+ annotationSpaceFillerHolder.setVisible(true);\r
}\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param b DOCUMENT ME!\r
- */\r
- public void setAnnotationVisible(boolean b)\r
+ idSpaceFillerPanel1.setVisible(!wrap);\r
+\r
+ repaint();\r
+ }\r
+\r
+ // return value is true if the scroll is valid\r
+ public boolean scrollUp(boolean up)\r
+ {\r
+ if (up)\r
{\r
- if (!av.wrapAlignment)\r
+ if (vscroll.getValue() < 1)\r
{\r
- annotationSpaceFillerHolder.setVisible(b);\r
- annotationScroller.setVisible(b);\r
+ return false;\r
}\r
- repaint();\r
- }\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param wrap DOCUMENT ME!\r
- */\r
- public void setWrapAlignment(boolean wrap)\r
- {\r
- av.startSeq = 0;\r
- scalePanelHolder.setVisible(!wrap);\r
- hscroll.setVisible(!wrap);\r
- idwidthAdjuster.setVisible(!wrap);\r
-\r
- if(wrap)\r
- {\r
- annotationScroller.setVisible(false);\r
- annotationSpaceFillerHolder.setVisible(false);\r
- }\r
- else if(av.showAnnotation)\r
- {\r
- annotationScroller.setVisible(true);\r
- annotationSpaceFillerHolder.setVisible(true);\r
- }\r
-\r
- idSpaceFillerPanel1.setVisible(!wrap);\r
-\r
- repaint();\r
+ fastPaint = false;\r
+ vscroll.setValue(vscroll.getValue() - 1);\r
}\r
-\r
-\r
- // return value is true if the scroll is valid\r
- public boolean scrollUp(boolean up)\r
+ else\r
{\r
- if (up)\r
- {\r
- if (vscroll.getValue() < 1)\r
- {\r
- return false;\r
- }\r
-\r
- fastPaint = false;\r
- vscroll.setValue(vscroll.getValue() - 1);\r
- }\r
- else\r
- {\r
- if ((vextent + vscroll.getValue()) >= av.getAlignment().getHeight())\r
- {\r
- return false;\r
- }\r
-\r
- fastPaint = false;\r
- vscroll.setValue(vscroll.getValue() + 1);\r
- }\r
-\r
- fastPaint = true;\r
+ if ( (vextent + vscroll.getValue()) >= av.getAlignment().getHeight())\r
+ {\r
+ return false;\r
+ }\r
\r
- return true;\r
+ fastPaint = false;\r
+ vscroll.setValue(vscroll.getValue() + 1);\r
}\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param right DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- */\r
- public boolean scrollRight(boolean right)\r
+ fastPaint = true;\r
+\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param right DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public boolean scrollRight(boolean right)\r
+ {\r
+ if (right)\r
{\r
- if (right)\r
- {\r
- if (hscroll.getValue() < 1)\r
- {\r
- return false;\r
- }\r
-\r
- fastPaint = false;\r
- hscroll.setValue(hscroll.getValue() - 1);\r
- }\r
- else\r
- {\r
- if ((hextent + hscroll.getValue()) >= av.getAlignment().getWidth())\r
- {\r
- return false;\r
- }\r
-\r
- fastPaint = false;\r
- hscroll.setValue(hscroll.getValue() + 1);\r
- }\r
-\r
- fastPaint = true;\r
+ if (hscroll.getValue() < 1)\r
+ {\r
+ return false;\r
+ }\r
\r
- return true;\r
+ fastPaint = false;\r
+ hscroll.setValue(hscroll.getValue() - 1);\r
}\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param x DOCUMENT ME!\r
- * @param y DOCUMENT ME!\r
- */\r
- public void setScrollValues(int x, int y)\r
+ else\r
{\r
- av.setEndRes((x + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) -\r
- 1);\r
-\r
- hextent = seqPanel.seqCanvas.getWidth() / av.charWidth;\r
- vextent = seqPanel.seqCanvas.getHeight() / av.charHeight;\r
-\r
- if (hextent > av.alignment.getWidth())\r
- {\r
- hextent = av.alignment.getWidth();\r
- }\r
+ if ( (hextent + hscroll.getValue()) >= av.getAlignment().getWidth())\r
+ {\r
+ return false;\r
+ }\r
\r
- if (vextent > av.alignment.getHeight())\r
- {\r
- vextent = av.alignment.getHeight();\r
- }\r
+ fastPaint = false;\r
+ hscroll.setValue(hscroll.getValue() + 1);\r
+ }\r
\r
- if ((hextent + x) > av.getAlignment().getWidth())\r
- {\r
- x = av.getAlignment().getWidth() - hextent;\r
- }\r
+ fastPaint = true;\r
\r
- if ((vextent + y) > av.getAlignment().getHeight())\r
- {\r
- y = av.getAlignment().getHeight() - vextent;\r
- }\r
+ return true;\r
+ }\r
\r
- if (y < 0)\r
- {\r
- y = 0;\r
- }\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param x DOCUMENT ME!\r
+ * @param y DOCUMENT ME!\r
+ */\r
+ public void setScrollValues(int x, int y)\r
+ {\r
+ av.setEndRes( (x + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) -\r
+ 1);\r
\r
- if (x < 0)\r
- {\r
- x = 0;\r
- }\r
+ hextent = seqPanel.seqCanvas.getWidth() / av.charWidth;\r
+ vextent = seqPanel.seqCanvas.getHeight() / av.charHeight;\r
\r
- hscroll.setValues(x, hextent, 0, av.getAlignment().getWidth());\r
- vscroll.setValues(y, vextent, 0, av.getAlignment().getHeight());\r
+ if (hextent > av.alignment.getWidth())\r
+ {\r
+ hextent = av.alignment.getWidth();\r
}\r
\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param evt DOCUMENT ME!\r
- */\r
- public void adjustmentValueChanged(AdjustmentEvent evt)\r
+ if (vextent > av.alignment.getHeight())\r
{\r
-\r
- int oldX = av.getStartRes();\r
- int oldY = av.getStartSeq();\r
-\r
- if (evt.getSource() == hscroll)\r
- {\r
- int x = hscroll.getValue();\r
- av.setStartRes(x);\r
- av.setEndRes((x +\r
- (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1);\r
- }\r
-\r
- if (evt.getSource() == vscroll)\r
- {\r
- int offy = vscroll.getValue();\r
-\r
- if (av.getWrapAlignment())\r
- {\r
- int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
- av.setStartRes(vscroll.getValue() * rowSize);\r
- av.setEndRes((vscroll.getValue() + 1) * rowSize);\r
- }\r
- else\r
- {\r
- av.setStartSeq(offy);\r
- av.setEndSeq(offy +\r
- (seqPanel.seqCanvas.getHeight() / av.getCharHeight()));\r
- }\r
- }\r
-\r
- if (overviewPanel != null)\r
- {\r
- overviewPanel.setBoxPosition();\r
- }\r
-\r
- int xShift = av.getStartRes() - oldX;\r
- int yShift = av.getStartSeq() - oldY;\r
-\r
- if ( (xShift != 0 && yShift != 0) ||\r
- (Math.abs(xShift) > av.getEndRes() - av.getStartRes()\r
- || Math.abs(yShift) > av.getEndSeq() - av.getStartSeq())\r
- || av.getWrapAlignment()\r
- || !fastPaint)\r
- {\r
- // Either no shift at all, or shift greater than visible amount\r
- repaint();\r
- }\r
- else\r
- {\r
- idPanel.idCanvas.fastPaint(yShift);\r
- seqPanel.seqCanvas.fastPaint(xShift, yShift);\r
-\r
- scalePanel.repaint();\r
-\r
- if (av.getShowAnnotation())\r
- {\r
- annotationPanel.fastPaint(xShift);\r
- }\r
- }\r
+ vextent = av.alignment.getHeight();\r
}\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param g DOCUMENT ME!\r
- */\r
- public void paintComponent(Graphics g)\r
+ if ( (hextent + x) > av.getAlignment().getWidth())\r
{\r
- invalidate();\r
-\r
- Dimension d = idPanel.idCanvas.getPreferredSize();\r
- idPanelHolder.setPreferredSize(d);\r
- hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));\r
- validate();\r
-\r
- if (av.getWrapAlignment())\r
- {\r
- int max = av.alignment.getWidth() / seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
- vscroll.setMaximum(max);\r
- vscroll.setUnitIncrement(1);\r
- vscroll.setVisibleAmount(1);\r
- }\r
- else\r
- {\r
- setScrollValues(av.getStartRes(), av.getStartSeq());\r
- }\r
+ x = av.getAlignment().getWidth() - hextent;\r
}\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param pg DOCUMENT ME!\r
- * @param pf DOCUMENT ME!\r
- * @param pi DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- *\r
- * @throws PrinterException DOCUMENT ME!\r
- */\r
- public int print(Graphics pg, PageFormat pf, int pi)\r
- throws PrinterException\r
+ if ( (vextent + y) > av.getAlignment().getHeight())\r
{\r
- pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());\r
-\r
- int pwidth = (int) pf.getImageableWidth();\r
- int pheight = (int) pf.getImageableHeight();\r
-\r
- if (av.getWrapAlignment())\r
- {\r
- return printWrappedAlignment(pg, pwidth, pheight, pi);\r
- }\r
- else\r
- {\r
- return printUnwrapped(pg, pwidth, pheight, pi);\r
- }\r
+ y = av.getAlignment().getHeight() - vextent;\r
}\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param pg DOCUMENT ME!\r
- * @param pwidth DOCUMENT ME!\r
- * @param pheight DOCUMENT ME!\r
- * @param pi DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- *\r
- * @throws PrinterException DOCUMENT ME!\r
- */\r
- public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi)\r
- throws PrinterException\r
+ if (y < 0)\r
{\r
- int idWidth = calculateIdWidth().width + 4;\r
- FontMetrics fm = getFontMetrics(av.getFont());\r
- int scaleHeight = av.charHeight + fm.getDescent();\r
-\r
- pg.setColor(Color.white);\r
- pg.fillRect(0, 0, pwidth, pheight);\r
- pg.setFont(av.getFont());\r
-\r
- ////////////////////////////////////\r
- /// How many sequences and residues can we fit on a printable page?\r
- int totalRes = (pwidth - idWidth) / av.getCharWidth();\r
-\r
- int totalSeq = (int) ((pheight - scaleHeight) / av.getCharHeight()) -\r
- 1;\r
-\r
- int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;\r
-\r
- /////////////////////////////\r
- /// Only print these sequences and residues on this page\r
- int startRes;\r
+ y = 0;\r
+ }\r
\r
- /////////////////////////////\r
- /// Only print these sequences and residues on this page\r
- int endRes;\r
+ if (x < 0)\r
+ {\r
+ x = 0;\r
+ }\r
\r
- /////////////////////////////\r
- /// Only print these sequences and residues on this page\r
- int startSeq;\r
+ hscroll.setValues(x, hextent, 0, av.getAlignment().getWidth());\r
+ vscroll.setValues(y, vextent, 0, av.getAlignment().getHeight());\r
+ }\r
\r
- /////////////////////////////\r
- /// Only print these sequences and residues on this page\r
- int endSeq;\r
- startRes = (pi % pagesWide) * totalRes;\r
- endRes = (startRes + totalRes) - 1;\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param evt DOCUMENT ME!\r
+ */\r
+ public void adjustmentValueChanged(AdjustmentEvent evt)\r
+ {\r
\r
- if (endRes > (av.getAlignment().getWidth() - 1))\r
- {\r
- endRes = av.getAlignment().getWidth() - 1;\r
- }\r
+ int oldX = av.getStartRes();\r
+ int oldY = av.getStartSeq();\r
\r
- startSeq = (pi / pagesWide) * totalSeq;\r
- endSeq = startSeq + totalSeq;\r
+ if (evt.getSource() == hscroll)\r
+ {\r
+ int x = hscroll.getValue();\r
+ av.setStartRes(x);\r
+ av.setEndRes( (x +\r
+ (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1);\r
+ }\r
\r
- if (endSeq > av.getAlignment().getHeight())\r
- {\r
- endSeq = av.getAlignment().getHeight();\r
- }\r
+ if (evt.getSource() == vscroll)\r
+ {\r
+ int offy = vscroll.getValue();\r
\r
- int pagesHigh = ((av.alignment.getHeight() / totalSeq) + 1) * pheight;\r
+ if (av.getWrapAlignment())\r
+ {\r
+ int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.\r
+ seqCanvas.getWidth());\r
+ av.setStartRes(vscroll.getValue() * rowSize);\r
+ av.setEndRes( (vscroll.getValue() + 1) * rowSize);\r
+ }\r
+ else\r
+ {\r
+ av.setStartSeq(offy);\r
+ av.setEndSeq(offy +\r
+ (seqPanel.seqCanvas.getHeight() / av.getCharHeight()));\r
+ }\r
+ }\r
\r
- if (av.showAnnotation)\r
- {\r
- pagesHigh += annotationPanel.adjustPanelHeight()+3;\r
- }\r
+ if (overviewPanel != null)\r
+ {\r
+ overviewPanel.setBoxPosition();\r
+ }\r
\r
- pagesHigh /= pheight;\r
+ int xShift = av.getStartRes() - oldX;\r
+ int yShift = av.getStartSeq() - oldY;\r
\r
- if (pi >= (pagesWide * pagesHigh))\r
- {\r
- return Printable.NO_SUCH_PAGE;\r
- }\r
+ if ( (xShift != 0 && yShift != 0) ||\r
+ (Math.abs(xShift) > av.getEndRes() - av.getStartRes()\r
+ || Math.abs(yShift) > av.getEndSeq() - av.getStartSeq())\r
+ || av.getWrapAlignment()\r
+ || !fastPaint)\r
+ {\r
+ // Either no shift at all, or shift greater than visible amount\r
+ repaint();\r
+ }\r
+ else\r
+ {\r
+ idPanel.idCanvas.fastPaint(yShift);\r
+ seqPanel.seqCanvas.fastPaint(xShift, yShift);\r
\r
- //draw Scale\r
- pg.translate(idWidth, 0);\r
- scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight);\r
- pg.translate(-idWidth, scaleHeight);\r
+ scalePanel.repaint();\r
\r
- ////////////////\r
- // Draw the ids\r
- Color currentColor = null;\r
- Color currentTextColor = null;\r
+ if (av.getShowAnnotation())\r
+ {\r
+ annotationPanel.fastPaint(xShift);\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param g DOCUMENT ME!\r
+ */\r
+ public void paintComponent(Graphics g)\r
+ {\r
+ invalidate();\r
+\r
+ Dimension d = idPanel.idCanvas.getPreferredSize();\r
+ idPanelHolder.setPreferredSize(d);\r
+ hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));\r
+ validate();\r
+\r
+ if (av.getWrapAlignment())\r
+ {\r
+ int max = av.alignment.getWidth() /\r
+ seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
+ vscroll.setMaximum(max);\r
+ vscroll.setUnitIncrement(1);\r
+ vscroll.setVisibleAmount(1);\r
+ }\r
+ else\r
+ {\r
+ setScrollValues(av.getStartRes(), av.getStartSeq());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param pg DOCUMENT ME!\r
+ * @param pf DOCUMENT ME!\r
+ * @param pi DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ *\r
+ * @throws PrinterException DOCUMENT ME!\r
+ */\r
+ public int print(Graphics pg, PageFormat pf, int pi)\r
+ throws PrinterException\r
+ {\r
+ pg.translate( (int) pf.getImageableX(), (int) pf.getImageableY());\r
+\r
+ int pwidth = (int) pf.getImageableWidth();\r
+ int pheight = (int) pf.getImageableHeight();\r
+\r
+ if (av.getWrapAlignment())\r
+ {\r
+ return printWrappedAlignment(pg, pwidth, pheight, pi);\r
+ }\r
+ else\r
+ {\r
+ return printUnwrapped(pg, pwidth, pheight, pi);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param pg DOCUMENT ME!\r
+ * @param pwidth DOCUMENT ME!\r
+ * @param pheight DOCUMENT ME!\r
+ * @param pi DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ *\r
+ * @throws PrinterException DOCUMENT ME!\r
+ */\r
+ public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi)\r
+ throws PrinterException\r
+ {\r
+ int idWidth = calculateIdWidth().width + 4;\r
+ FontMetrics fm = getFontMetrics(av.getFont());\r
+ int scaleHeight = av.charHeight + fm.getDescent();\r
+\r
+ pg.setColor(Color.white);\r
+ pg.fillRect(0, 0, pwidth, pheight);\r
+ pg.setFont(av.getFont());\r
+\r
+ ////////////////////////////////////\r
+ /// How many sequences and residues can we fit on a printable page?\r
+ int totalRes = (pwidth - idWidth) / av.getCharWidth();\r
+\r
+ int totalSeq = (int) ( (pheight - scaleHeight) / av.getCharHeight()) -\r
+ 1;\r
+\r
+ int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;\r
+\r
+ /////////////////////////////\r
+ /// Only print these sequences and residues on this page\r
+ int startRes;\r
+\r
+ /////////////////////////////\r
+ /// Only print these sequences and residues on this page\r
+ int endRes;\r
+\r
+ /////////////////////////////\r
+ /// Only print these sequences and residues on this page\r
+ int startSeq;\r
+\r
+ /////////////////////////////\r
+ /// Only print these sequences and residues on this page\r
+ int endSeq;\r
+ startRes = (pi % pagesWide) * totalRes;\r
+ endRes = (startRes + totalRes) - 1;\r
+\r
+ if (endRes > (av.getAlignment().getWidth() - 1))\r
+ {\r
+ endRes = av.getAlignment().getWidth() - 1;\r
+ }\r
\r
- for (int i = startSeq; i < endSeq; i++)\r
- {\r
- if ((av.getSelectionGroup() != null) &&\r
- av.getSelectionGroup().sequences.contains(\r
- av.getAlignment().getSequenceAt(i)))\r
- {\r
- currentColor = Color.gray;\r
- currentTextColor = Color.black;\r
- }\r
- else\r
- {\r
- currentColor = av.getAlignment().getSequenceAt(i).getColor();\r
- currentTextColor = Color.black;\r
- }\r
+ startSeq = (pi / pagesWide) * totalSeq;\r
+ endSeq = startSeq + totalSeq;\r
\r
- pg.setColor(currentColor);\r
- pg.fillRect(0, (i-startSeq) * av.charHeight, idWidth,\r
- av.getCharHeight());\r
+ if (endSeq > av.getAlignment().getHeight())\r
+ {\r
+ endSeq = av.getAlignment().getHeight();\r
+ }\r
\r
- pg.setColor(currentTextColor);\r
+ int pagesHigh = ( (av.alignment.getHeight() / totalSeq) + 1) * pheight;\r
\r
- String string = av.getAlignment().getSequenceAt(i).getDisplayId\r
- (av.getShowDBPrefix(), av.getShowJVSuffix());\r
+ if (av.showAnnotation)\r
+ {\r
+ pagesHigh += annotationPanel.adjustPanelHeight() + 3;\r
+ }\r
\r
- pg.drawString(string, 0,\r
- (((i-startSeq) * av.charHeight) + av.getCharHeight()) -\r
- (av.getCharHeight() / 5));\r
- }\r
+ pagesHigh /= pheight;\r
\r
- // draw main sequence panel\r
- pg.translate(idWidth, 0);\r
- seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq,\r
- startRes, startSeq, 0);\r
+ if (pi >= (pagesWide * pagesHigh))\r
+ {\r
+ return Printable.NO_SUCH_PAGE;\r
+ }\r
\r
- if (av.showAnnotation && (endSeq == av.alignment.getHeight()))\r
- {\r
- pg.translate(-idWidth, (endSeq - startSeq) * av.charHeight +3);\r
- alabels.drawComponent((Graphics2D) pg, idWidth);\r
- pg.translate(idWidth, 0);\r
- annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes +\r
- 1);\r
- }\r
+ //draw Scale\r
+ pg.translate(idWidth, 0);\r
+ scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight);\r
+ pg.translate( -idWidth, scaleHeight);\r
\r
- return Printable.PAGE_EXISTS;\r
- }\r
+ ////////////////\r
+ // Draw the ids\r
+ Color currentColor = null;\r
+ Color currentTextColor = null;\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param pg DOCUMENT ME!\r
- * @param pwidth DOCUMENT ME!\r
- * @param pheight DOCUMENT ME!\r
- * @param pi DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- *\r
- * @throws PrinterException DOCUMENT ME!\r
- */\r
- public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,\r
- int pi) throws PrinterException\r
+ for (int i = startSeq; i < endSeq; i++)\r
{\r
-\r
- int annotationHeight = 0;\r
- AnnotationLabels labels = null;\r
- if (av.showAnnotation)\r
+ if ( (av.getSelectionGroup() != null) &&\r
+ av.getSelectionGroup().sequences.contains(\r
+ av.getAlignment().getSequenceAt(i)))\r
{\r
- annotationHeight = annotationPanel.adjustPanelHeight();\r
- labels = new AnnotationLabels(av);\r
+ currentColor = Color.gray;\r
+ currentTextColor = Color.black;\r
+ }\r
+ else\r
+ {\r
+ currentColor = av.getAlignment().getSequenceAt(i).getColor();\r
+ currentTextColor = Color.black;\r
}\r
\r
- int hgap = av.charHeight;\r
- if (av.scaleAboveWrapped)\r
- hgap += av.charHeight;\r
-\r
- int cHeight = av.getAlignment().getHeight() * av.charHeight\r
- + hgap\r
- + annotationHeight;\r
-\r
-\r
- int idWidth = calculateIdWidth().width + 4;\r
+ pg.setColor(currentColor);\r
+ pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth,\r
+ av.getCharHeight());\r
\r
- int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth -\r
- idWidth);\r
+ pg.setColor(currentTextColor);\r
\r
- int totalHeight = cHeight * (av.alignment.getWidth() / resWidth +1);\r
+ String string = av.getAlignment().getSequenceAt(i).getDisplayId\r
+ (av.getShowDBPrefix(), av.getShowJVSuffix());\r
\r
- pg.setColor(Color.white);\r
- pg.fillRect(0, 0, pwidth, pheight);\r
- pg.setFont(av.getFont());\r
+ pg.drawString(string, 0,\r
+ ( ( (i - startSeq) * av.charHeight) + av.getCharHeight()) -\r
+ (av.getCharHeight() / 5));\r
+ }\r
\r
+ // draw main sequence panel\r
+ pg.translate(idWidth, 0);\r
+ seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq,\r
+ startRes, startSeq, 0);\r
\r
- ////////////////\r
- // Draw the ids\r
- pg.setColor(Color.black);\r
+ if (av.showAnnotation && (endSeq == av.alignment.getHeight()))\r
+ {\r
+ pg.translate( -idWidth, (endSeq - startSeq) * av.charHeight + 3);\r
+ alabels.drawComponent( (Graphics2D) pg, idWidth);\r
+ pg.translate(idWidth, 0);\r
+ annotationPanel.drawComponent( (Graphics2D) pg, startRes, endRes +\r
+ 1);\r
+ }\r
\r
- pg.translate(0, -pi * pheight);\r
+ return Printable.PAGE_EXISTS;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param pg DOCUMENT ME!\r
+ * @param pwidth DOCUMENT ME!\r
+ * @param pheight DOCUMENT ME!\r
+ * @param pi DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ *\r
+ * @throws PrinterException DOCUMENT ME!\r
+ */\r
+ public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,\r
+ int pi)\r
+ throws PrinterException\r
+ {\r
+\r
+ int annotationHeight = 0;\r
+ AnnotationLabels labels = null;\r
+ if (av.showAnnotation)\r
+ {\r
+ annotationHeight = annotationPanel.adjustPanelHeight();\r
+ labels = new AnnotationLabels(av);\r
+ }\r
\r
- pg.setClip(0, pi * pheight, pwidth, pheight);\r
+ int hgap = av.charHeight;\r
+ if (av.scaleAboveWrapped)\r
+ hgap += av.charHeight;\r
\r
- int ypos = hgap;\r
- Font italic = new Font(av.getFont().getName(), Font.ITALIC,\r
- av.getFont().getSize());\r
- pg.setFont(italic);\r
+ int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+ + hgap\r
+ + annotationHeight;\r
\r
+ int idWidth = calculateIdWidth().width + 4;\r
\r
- do\r
- {\r
- for (int i = 0; i < av.alignment.getHeight(); i++)\r
- {\r
- SequenceI s = av.alignment.getSequenceAt(i);\r
- String string = s.getDisplayId(av.getShowDBPrefix(), av.getShowJVSuffix());\r
+ int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth -\r
+ idWidth);\r
\r
- pg.drawString(string, 0,\r
- ( (i * av.charHeight) + ypos + av.charHeight) -\r
- (av.charHeight / 5));\r
- }\r
- if (labels != null)\r
- {\r
- pg.translate(0,\r
- ypos +\r
- (av.getAlignment().getHeight() * av.charHeight));\r
-\r
- pg.setFont(av.getFont());\r
- labels.drawComponent( pg, idWidth );\r
- pg.setFont(italic);\r
- pg.translate(0,\r
- -ypos -\r
- (av.getAlignment().getHeight() * av.charHeight));\r
- }\r
+ int totalHeight = cHeight * (av.alignment.getWidth() / resWidth + 1);\r
\r
- ypos += cHeight;\r
- }\r
- while (ypos < totalHeight);\r
+ pg.setColor(Color.white);\r
+ pg.fillRect(0, 0, pwidth, pheight);\r
+ pg.setFont(av.getFont());\r
\r
- pg.translate(idWidth, 0);\r
+ ////////////////\r
+ // Draw the ids\r
+ pg.setColor(Color.black);\r
\r
- seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight, 0);\r
+ pg.translate(0, -pi * pheight);\r
\r
- if ((pi * pheight) < totalHeight)\r
- {\r
- return Printable.PAGE_EXISTS;\r
+ pg.setClip(0, pi * pheight, pwidth, pheight);\r
\r
- }\r
- else\r
- {\r
- return Printable.NO_SUCH_PAGE;\r
- }\r
- }\r
+ int ypos = hgap;\r
+ Font italic = new Font(av.getFont().getName(), Font.ITALIC,\r
+ av.getFont().getSize());\r
+ pg.setFont(italic);\r
\r
- /**\r
- * DOCUMENT ME!\r
- */\r
- public void makeEPS(File epsFile)\r
+ do\r
{\r
- boolean accurateText = true;\r
-\r
- String renderStyle = jalview.bin.Cache.getDefault("EPS_RENDERING",\r
- "Prompt each time");\r
-\r
- // If we need to prompt, and if the GUI is visible then\r
- // Prompt for EPS rendering style\r
- if (renderStyle.equalsIgnoreCase("Prompt each time")\r
- && !\r
- (System.getProperty("java.awt.headless") != null\r
- && System.getProperty("java.awt.headless").equals("true")))\r
+ for (int i = 0; i < av.alignment.getHeight(); i++)\r
{\r
- EPSOptions eps = new EPSOptions();\r
- renderStyle = eps.getValue();\r
+ SequenceI s = av.alignment.getSequenceAt(i);\r
+ String string = s.getDisplayId(av.getShowDBPrefix(), av.getShowJVSuffix());\r
\r
- if(eps.cancelled || renderStyle==null)\r
- return;\r
-\r
- renderStyle = eps.getValue();\r
+ pg.drawString(string, 0,\r
+ ( (i * av.charHeight) + ypos + av.charHeight) -\r
+ (av.charHeight / 5));\r
}\r
-\r
- if (renderStyle.equalsIgnoreCase("text"))\r
+ if (labels != null)\r
{\r
- accurateText = false;\r
- }\r
-\r
-\r
- if(epsFile == null)\r
- {\r
- jalview.io.JalviewFileChooser chooser = new jalview.io.\r
- JalviewFileChooser(jalview.bin.Cache.getProperty(\r
- "LAST_DIRECTORY"), new String[]\r
- {"eps"},\r
- new String[]\r
- {"Encapsulated Postscript"},\r
- "Encapsulated Postscript");\r
- chooser.setFileView(new jalview.io.JalviewFileView());\r
- chooser.setDialogTitle("Create EPS file from alignment");\r
- chooser.setToolTipText("Save");\r
-\r
- int value = chooser.showSaveDialog(this);\r
-\r
- if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)\r
- {\r
- return;\r
- }\r
-\r
- epsFile = chooser.getSelectedFile();\r
-\r
- jalview.bin.Cache.setProperty("LAST_DIRECTORY",\r
- chooser.getSelectedFile().getParent());\r
- }\r
-\r
-\r
- int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;\r
- int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);\r
+ pg.translate(0,\r
+ ypos +\r
+ (av.getAlignment().getHeight() * av.charHeight));\r
\r
+ pg.setFont(av.getFont());\r
+ labels.drawComponent(pg, idWidth);\r
+ pg.setFont(italic);\r
+ pg.translate(0,\r
+ -ypos -\r
+ (av.getAlignment().getHeight() * av.charHeight));\r
+ }\r
\r
- if (av.getWrapAlignment())\r
- {\r
- height = getWrappedHeight();\r
- width = seqPanel.getWidth() + idPanel.getWidth();\r
- }\r
- else if (av.getShowAnnotation())\r
- {\r
- height += annotationPanel.adjustPanelHeight()+3;\r
- }\r
-\r
+ ypos += cHeight;\r
+ }\r
+ while (ypos < totalHeight);\r
\r
- try\r
- {\r
- FileOutputStream out = new FileOutputStream(epsFile);\r
- EpsGraphics2D pg = new EpsGraphics2D("Example", out, 0, 0, width,\r
- height);\r
+ pg.translate(idWidth, 0);\r
\r
- pg.setAccurateTextMode(accurateText);\r
+ seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight, 0);\r
\r
- if (av.getWrapAlignment())\r
- {\r
- printWrappedAlignment(pg, width, height, 0);\r
- }\r
- else\r
- {\r
- printUnwrapped(pg, width, height, 0);\r
- }\r
+ if ( (pi * pheight) < totalHeight)\r
+ {\r
+ return Printable.PAGE_EXISTS;\r
\r
- pg.flush();\r
- pg.close();\r
- }\r
- catch (OutOfMemoryError err)\r
- {\r
- System.out.println("########################\n"\r
- + "OUT OF MEMORY " + epsFile + "\n"\r
- + "########################");\r
-\r
- JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
- "Out of memory creating EPS file!!"\r
- +\r
- "\nSee help files for increasing Java Virtual Machine memory."\r
- , "Out of memory",\r
- JOptionPane.WARNING_MESSAGE);\r
- System.out.println("Create EPS: " + err);\r
- System.gc();\r
- }\r
- catch (Exception ex)\r
- {\r
- ex.printStackTrace();\r
- }\r
}\r
+ else\r
+ {\r
+ return Printable.NO_SUCH_PAGE;\r
+ }\r
+ }\r
\r
+ void makeAlignmentImage(int type, File file)\r
+ {\r
+ int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;\r
+ int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);\r
\r
- public void makePNGImageMap(File imgMapFile, String imageName)\r
+ if (av.getWrapAlignment())\r
{\r
- ///////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS\r
- //////////////////////////////////////////////\r
- int idWidth = calculateIdWidth().width + 4;\r
- FontMetrics fm = getFontMetrics(av.getFont());\r
- int scaleHeight = av.charHeight + fm.getDescent();\r
-\r
- // Gen image map\r
- //////////////////////////////////\r
- if(imgMapFile!=null)\r
- {\r
- try\r
- {\r
- PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));\r
- out.println(jalview.io.HTMLOutput.getImageMapHTML());\r
- out.println("<img src=\"" + imageName +\r
- "\" border=\"0\" usemap=\"#Map\" >"\r
- +"<map name=\"Map\">");\r
-\r
- for (int s = 0; s < av.alignment.getHeight(); s++)\r
- {\r
- SequenceI seq = av.alignment.getSequenceAt(s);\r
- SequenceGroup[] groups = av.alignment.findAllGroups(seq);\r
- for (int i = 0; i < groups.length; i++)\r
- {\r
- int sy = s * av.charHeight + scaleHeight;\r
- for (int res = groups[i].getStartRes();\r
- res < groups[i].getEndRes() + 1; res++)\r
- {\r
- int alIndex = seq.findPosition(res);\r
- Object obj = ResidueProperties.aa2Triplet.get(\r
- seq.getCharAt(res) + "");\r
- if (obj == null)\r
- continue;\r
-\r
- String triplet = obj.toString();\r
-\r
- out.println(\r
- "<area shape=\"rect\" coords=\""\r
- + (idWidth + res * av.charWidth) + ","\r
- + sy + ","\r
- + (idWidth + (res + 1) * av.charWidth) + ","\r
- + (av.charHeight + sy) + "\""\r
- + " onMouseOver=\"toolTip('"\r
- + alIndex + " " + triplet +\r
- "<br><em>" + groups[i].getName() +\r
- "</em>')\"; onMouseOut=\"toolTip()\"; "\r
- + " href=\"#\">");\r
- }\r
- }\r
- }\r
-\r
- out.println("</map></body></html>");\r
- out.close();\r
-\r
- }\r
- catch (Exception ex)\r
- {\r
- ex.printStackTrace();\r
- }\r
- }///////////END OF IMAGE MAP\r
-\r
+ height = getWrappedHeight();\r
+ width = seqPanel.getWidth() + idPanel.getWidth();\r
}\r
-\r
- int getWrappedHeight()\r
+ else if (av.getShowAnnotation())\r
{\r
+ height += annotationPanel.adjustPanelHeight() + 3;\r
+ }\r
\r
- int chunkWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(\r
- seqPanel.seqCanvas.getWidth());\r
-\r
- int hgap = av.charHeight;\r
- if (av.scaleAboveWrapped)\r
- hgap += av.charHeight;\r
-\r
- int annotationHeight = 0;\r
- if (av.showAnnotation)\r
+ jalview.util.ImageMaker im;\r
+ if(type==jalview.util.ImageMaker.PNG)\r
+ im = new jalview.util.ImageMaker(this,\r
+ jalview.util.ImageMaker.PNG,\r
+ "Create PNG image from alignment",\r
+ width, height, file, null);\r
+ else\r
+ im = new jalview.util.ImageMaker(this,\r
+ jalview.util.ImageMaker.EPS,\r
+ "Create EPS file from alignment",\r
+ width, height, file, alignFrame.getTitle() );\r
+\r
+ try\r
+ {\r
+ if (av.getWrapAlignment())\r
{\r
- annotationHeight = annotationPanel.adjustPanelHeight();\r
+ if(im.getGraphics()!=null)\r
+ printWrappedAlignment(im.getGraphics(), width, height, 0);\r
+ }\r
+ else\r
+ {\r
+ if(im.getGraphics()!=null)\r
+ printUnwrapped(im.getGraphics(), width, height, 0);\r
}\r
\r
- int cHeight = av.getAlignment().getHeight() * av.charHeight\r
- + hgap\r
- + annotationHeight;\r
-\r
-\r
- int height = ( (av.alignment.getWidth() / chunkWidth) + 1) * cHeight;\r
-\r
- return height;\r
+ im.writeImage();\r
}\r
+ catch (OutOfMemoryError err)\r
+ {\r
+ System.out.println("########################\n"\r
+ + "OUT OF MEMORY " + file + "\n"\r
+ + "########################");\r
+\r
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+ "Out of Memory Creating Image!!"\r
+ +\r
+ "\nSee help files for increasing Java Virtual Machine memory."\r
+ , "Out of memory",\r
+ JOptionPane.WARNING_MESSAGE);\r
+ System.out.println("Create IMAGE: " + err);\r
+ System.gc();\r
\r
- /**\r
- * DOCUMENT ME!\r
- */\r
- public void makePNG(File pngFile)\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ }\r
+ }\r
+ /**\r
+ * DOCUMENT ME!\r
+ */\r
+ public void makeEPS(File epsFile)\r
+ {\r
+ makeAlignmentImage(jalview.util.ImageMaker.EPS, epsFile);\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ */\r
+ public void makePNG(File pngFile)\r
+ {\r
+ makeAlignmentImage(jalview.util.ImageMaker.PNG, pngFile);\r
+ }\r
+\r
+ public void makePNGImageMap(File imgMapFile, String imageName)\r
+ {\r
+ ///////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS\r
+ //////////////////////////////////////////////\r
+ int idWidth = calculateIdWidth().width + 4;\r
+ FontMetrics fm = getFontMetrics(av.getFont());\r
+ int scaleHeight = av.charHeight + fm.getDescent();\r
+\r
+ // Gen image map\r
+ //////////////////////////////////\r
+ if (imgMapFile != null)\r
{\r
- if(pngFile==null)\r
+ try\r
{\r
- jalview.io.JalviewFileChooser chooser = new jalview.io.\r
- JalviewFileChooser(jalview.bin.Cache.getProperty(\r
- "LAST_DIRECTORY"), new String[]\r
- {"png"},\r
- new String[]\r
- {"Portable network graphics"},\r
- "Portable network graphics");\r
- chooser.setFileView(new jalview.io.JalviewFileView());\r
- chooser.setDialogTitle("Create EPS file from alignment");\r
- chooser.setToolTipText("Save");\r
-\r
- int value = chooser.showSaveDialog(this);\r
-\r
- if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)\r
+ PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));\r
+ out.println(jalview.io.HTMLOutput.getImageMapHTML());\r
+ out.println("<img src=\"" + imageName +\r
+ "\" border=\"0\" usemap=\"#Map\" >"\r
+ + "<map name=\"Map\">");\r
+\r
+ for (int s = 0; s < av.alignment.getHeight(); s++)\r
{\r
- return;\r
+ SequenceI seq = av.alignment.getSequenceAt(s);\r
+ SequenceGroup[] groups = av.alignment.findAllGroups(seq);\r
+ for (int i = 0; i < groups.length; i++)\r
+ {\r
+ int sy = s * av.charHeight + scaleHeight;\r
+ for (int res = groups[i].getStartRes();\r
+ res < groups[i].getEndRes() + 1; res++)\r
+ {\r
+ int alIndex = seq.findPosition(res);\r
+ Object obj = ResidueProperties.aa2Triplet.get(\r
+ seq.getCharAt(res) + "");\r
+ if (obj == null)\r
+ continue;\r
+\r
+ String triplet = obj.toString();\r
+\r
+ out.println(\r
+ "<area shape=\"rect\" coords=\""\r
+ + (idWidth + res * av.charWidth) + ","\r
+ + sy + ","\r
+ + (idWidth + (res + 1) * av.charWidth) + ","\r
+ + (av.charHeight + sy) + "\""\r
+ + " onMouseOver=\"toolTip('"\r
+ + alIndex + " " + triplet +\r
+ "<br><em>" + groups[i].getName() +\r
+ "</em>')\"; onMouseOut=\"toolTip()\"; "\r
+ + " href=\"#\">");\r
+ }\r
+ }\r
}\r
\r
- pngFile = chooser.getSelectedFile();\r
+ out.println("</map></body></html>");\r
+ out.close();\r
\r
- jalview.bin.Cache.setProperty("LAST_DIRECTORY",\r
- chooser.getSelectedFile().getParent());\r
}\r
-\r
-\r
-\r
- int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;\r
- int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);\r
-\r
- if (av.getWrapAlignment())\r
+ catch (Exception ex)\r
{\r
- height = getWrappedHeight();\r
- width = seqPanel.getWidth() + idPanel.getWidth();\r
+ ex.printStackTrace();\r
}\r
- else if (av.getShowAnnotation())\r
- {\r
- height += annotationPanel.adjustPanelHeight()+3;\r
- }\r
+ } ///////////END OF IMAGE MAP\r
\r
- try\r
- {\r
+ }\r
\r
- FileOutputStream out = new FileOutputStream(pngFile);\r
+ int getWrappedHeight()\r
+ {\r
\r
- BufferedImage bi = new BufferedImage(width, height,\r
- BufferedImage.TYPE_INT_RGB);\r
- Graphics2D png = (Graphics2D) bi.getGraphics();\r
+ int chunkWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(\r
+ seqPanel.seqCanvas.getWidth());\r
\r
- png.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
- RenderingHints.VALUE_ANTIALIAS_ON);\r
+ int hgap = av.charHeight;\r
+ if (av.scaleAboveWrapped)\r
+ hgap += av.charHeight;\r
\r
- if (av.getWrapAlignment())\r
- {\r
- printWrappedAlignment(png, width, height, 0);\r
- }\r
- else\r
- {\r
- printUnwrapped(png, width, height, 0);\r
- }\r
+ int annotationHeight = 0;\r
+ if (av.showAnnotation)\r
+ {\r
+ annotationHeight = annotationPanel.adjustPanelHeight();\r
+ }\r
\r
- ImageIO.write(bi, "png", out);\r
- out.close();\r
- }\r
- catch (OutOfMemoryError err)\r
- {\r
- System.out.println("########################\n"\r
- + "OUT OF MEMORY " + pngFile + "\n"\r
- + "########################");\r
-\r
- JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
- "Out of memory creating PNG!!"\r
- +\r
- "\nSee help files for increasing Java Virtual Machine memory."\r
- , "Out of memory",\r
- JOptionPane.WARNING_MESSAGE);\r
- System.out.println("Create PNG: " + err);\r
- System.gc();\r
+ int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+ + hgap\r
+ + annotationHeight;\r
\r
- }\r
- catch (Exception ex)\r
- {\r
- ex.printStackTrace();\r
- }\r
- }\r
-}\r
+ int height = ( (av.alignment.getWidth() / chunkWidth) + 1) * cHeight;\r
\r
+ return height;\r
+ }\r
\r
-/**\r
- * DOCUMENT ME!\r
- *\r
- * @author $author$\r
- * @version $Revision$\r
- */\r
-class Preview extends JFrame\r
-{\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @author $author$\r
+ * @version $Revision$\r
+ */\r
+ class Preview\r
+ extends JFrame\r
+ {\r
/**\r
* Creates a new Preview object.\r
*\r
*/\r
public Preview(Image image)\r
{\r
- setResizable(true);\r
- setSize(image.getWidth(this), image.getHeight(this));\r
- setVisible(true);\r
- getContentPane().setLayout(new BorderLayout());\r
- getContentPane().add(new PreviewPanel(image), BorderLayout.CENTER);\r
- validate();\r
- repaint();\r
+ setResizable(true);\r
+ setSize(image.getWidth(this), image.getHeight(this));\r
+ setVisible(true);\r
+ getContentPane().setLayout(new BorderLayout());\r
+ getContentPane().add(new PreviewPanel(image), BorderLayout.CENTER);\r
+ validate();\r
+ repaint();\r
}\r
-}\r
-\r
-\r
-/**\r
- * DOCUMENT ME!\r
- *\r
- * @author $author$\r
- * @version $Revision$\r
- */\r
-class PreviewPanel extends JPanel\r
-{\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @author $author$\r
+ * @version $Revision$\r
+ */\r
+ class PreviewPanel\r
+ extends JPanel\r
+ {\r
Image image;\r
\r
/**\r
*/\r
public PreviewPanel(Image image)\r
{\r
- this.image = image;\r
+ this.image = image;\r
}\r
\r
/**\r
*/\r
public void paintComponent(Graphics g)\r
{\r
- if (image != null)\r
- {\r
- g.drawImage(image, 0, 0, this);\r
- }\r
- else\r
- {\r
- System.out.println("DEBUG:image is null");\r
- }\r
+ if (image != null)\r
+ {\r
+ g.drawImage(image, 0, 0, this);\r
+ }\r
+ else\r
+ {\r
+ System.out.println("DEBUG:image is null");\r
+ }\r
}\r
+ }\r
}\r