X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=c94dee0adb121747100cca97e0955dd8af10b0c3;hb=a7bc89415a6749ff89eb97f75fbc950a433a4935;hp=b3e8119da2746ce68a3b9189c0fdaebfcaa03a0e;hpb=0b573ed90b14079f7326281f50c0c9cffdace586;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index b3e8119..c94dee0 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -20,10 +20,6 @@ */ package jalview.gui; -import jalview.datamodel.SequenceI; -import jalview.viewmodel.ViewportListenerI; -import jalview.viewmodel.ViewportRanges; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; @@ -37,6 +33,10 @@ import java.util.List; import javax.swing.JPanel; +import jalview.datamodel.SequenceI; +import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; + /** * DOCUMENT ME! * @@ -55,7 +55,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI BufferedImage image; -// Graphics2D gg; + // Graphics2D gg; int imgHeight = 0; @@ -79,7 +79,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI this.av = av; PaintRefresher.Register(this, av.getSequenceSetId()); av.getRanges().addPropertyChangeListener(this); - } + } /** * DOCUMENT ME! @@ -137,7 +137,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI g.drawString(s.getDisplayId(av.getShowJVSuffix()), xPos, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); - if (hiddenRows) + if (hiddenRows && av.getShowHiddenMarkers()) { drawMarker(g, av, i, starty, ypos); } @@ -203,7 +203,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI gg.translate(0, -transY); gg.dispose(); - + fastPaint = true; // Call repaint on alignment panel so that repaints from other alignment @@ -223,41 +223,42 @@ public class IdCanvas extends JPanel implements ViewportListenerI { g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); - + if (fastPaint) { fastPaint = false; g.drawImage(image, 0, 0, this); - + return; } - + int oldHeight = imgHeight; - + imgHeight = getHeight(); imgHeight -= (imgHeight % av.getCharHeight()); - + if (imgHeight < 1) { return; } - + if (oldHeight != imgHeight || image.getWidth(this) != getWidth()) { - image = new BufferedImage(getWidth(), imgHeight, - BufferedImage.TYPE_INT_RGB); + image = new BufferedImage(getWidth(), imgHeight, + BufferedImage.TYPE_INT_RGB); } - + Graphics2D gg = image.createGraphics(); - + // Fill in the background gg.setColor(Color.white); gg.fillRect(0, 0, getWidth(), imgHeight); - - drawIds(gg, av, av.getRanges().getStartSeq(), av.getRanges().getEndSeq(), searchResults); + + drawIds(gg, av, av.getRanges().getStartSeq(), + av.getRanges().getEndSeq(), searchResults); gg.dispose(); - + g.drawImage(image, 0, 0, this); } @@ -273,14 +274,13 @@ public class IdCanvas extends JPanel implements ViewportListenerI * @param endSeq * @param selection */ - void drawIds(Graphics2D g, AlignViewport alignViewport, final int startSeq, - final int endSeq, List selection) + void drawIds(Graphics2D g, AlignViewport alignViewport, + final int startSeq, final int endSeq, List selection) { Font font = alignViewport.getFont(); if (alignViewport.isSeqNameItalics()) { - setIdfont(new Font(font.getName(), Font.ITALIC, - font.getSize())); + setIdfont(new Font(font.getName(), Font.ITALIC, font.getSize())); } else { @@ -324,6 +324,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI if (hasHiddenRows || alignViewport.isDisplayReferenceSeq()) { g.setFont(getHiddenFont(sequence, alignViewport)); + fm = g.getFontMetrics(); } // Selected sequence colours @@ -347,8 +348,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI g.setColor(currentColor); int charHeight = alignViewport.getCharHeight(); - g.fillRect(0, (i - startSeq) * charHeight, - getWidth(), charHeight); + g.fillRect(0, (i - startSeq) * charHeight, getWidth(), charHeight); g.setColor(currentTextColor); @@ -360,10 +360,11 @@ public class IdCanvas extends JPanel implements ViewportListenerI xPos = panelWidth - fm.stringWidth(string) - 4; } - g.drawString(string, xPos, (((i - startSeq) * charHeight) + charHeight) - - (charHeight / 5)); + g.drawString(string, xPos, + (((i - startSeq) * charHeight) + charHeight) + - (charHeight / 5)); - if (hasHiddenRows) + if (hasHiddenRows && av.getShowHiddenMarkers()) { drawMarker(g, alignViewport, i, startSeq, 0); } @@ -447,7 +448,8 @@ public class IdCanvas extends JPanel implements ViewportListenerI * @param starty * @param yoffset */ - void drawMarker(Graphics2D g, AlignViewport alignViewport, int seqIndex, int starty, int yoffset) + void drawMarker(Graphics2D g, AlignViewport alignViewport, int seqIndex, + int starty, int yoffset) { SequenceI[] hseqs = alignViewport.getAlignment() .getHiddenSequences().hiddenSequences; @@ -490,8 +492,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI /* * vertices of the triangle, below or above hidden seqs */ - int[] xPoints = new int[] - { getWidth() - charHeight, + int[] xPoints = new int[] { getWidth() - charHeight, getWidth() - charHeight, getWidth() }; int yShift = seqIndex - starty;