X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=76020c716d79f4eec4df52b1eeeb23fde229dfb8;hb=5640ec0623c6d1205e62f9fe15292f32bfdab7d9;hp=d9997a0278c79c875032f445e20f677aea80f470;hpb=15c3c0e89d9157187e1ccc6962b115cb255dd04a;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index d9997a0..76020c7 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -199,7 +199,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI gg.translate(0, transY); - drawIds(gg, av, ss, es, searchResults); + drawIds(gg, av, ss, es, searchResults, true, getWidth()); gg.translate(0, -transY); @@ -256,7 +256,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI gg.fillRect(0, 0, getWidth(), imgHeight); drawIds(gg, av, av.getRanges().getStartSeq(), - av.getRanges().getEndSeq(), searchResults); + av.getRanges().getEndSeq(), searchResults, true, getWidth()); gg.dispose(); @@ -274,9 +274,16 @@ public class IdCanvas extends JPanel implements ViewportListenerI * @param startSeq * @param endSeq * @param selection + * @param forGUI + * when false rendering for print + * @param panelWidth + * width used to calculate righthand margin - usually + * idCanvas.getWidth() + * */ void drawIds(Graphics2D g, AlignViewport alignViewport, - final int startSeq, final int endSeq, List selection) + final int startSeq, final int endSeq, List selection, + boolean forGUI, int panelWidth) { Font font = alignViewport.getFont(); if (alignViewport.isSeqNameItalics()) @@ -304,12 +311,12 @@ public class IdCanvas extends JPanel implements ViewportListenerI if (alignViewport.getWrapAlignment()) { - drawIdsWrapped(g, alignViewport, startSeq, getHeight()); + drawIdsWrapped(g, alignViewport, startSeq, getHeight(), + manuallyAdjusted ? panelWidth : -1, forGUI); return; } // Now draw the id strings - int panelWidth = getWidth(); int xPos = 0; // Now draw the id strings @@ -383,11 +390,25 @@ public class IdCanvas extends JPanel implements ViewportListenerI void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport, int startSeq, int pageHeight) { - drawIdsWrapped(g, alignViewport, startSeq, pageHeight, -1); + drawIdsWrapped(g, alignViewport, startSeq, pageHeight, -1, true); } - void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport, - int startSeq, int pageHeight, int idWidth) + /** + * render sequence IDs and annotation labels when wrapped - without GUI junk + * + * @param g + * @param av2 + * @param startSeq + * @param totalHeight + */ + public void drawIdsWrappedNoGUI(Graphics2D g, AlignViewport av2, + int startSeq, int totalHeight) + { + drawIdsWrapped(g, av2, startSeq, totalHeight, -1, false); + } + + public void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport, + int startSeq, int pageHeight, int idWidth, boolean forGUI) { int alignmentWidth = alignViewport.getAlignment().getWidth(); final int alheight = alignViewport.getAlignment().getHeight(); @@ -403,6 +424,9 @@ public class IdCanvas extends JPanel implements ViewportListenerI AnnotationLabels labels = null; if (alignViewport.isShowAnnotation()) { + // in wrapped mode, no alignPanel reference is available + // FIXME: make the renderer not create a new object in wrapped mode + // everytime! labels = new AnnotationLabels(alignViewport); } @@ -435,17 +459,23 @@ public class IdCanvas extends JPanel implements ViewportListenerI if (labels != null && alignViewport.isShowAnnotation()) { + int getWidth = getWidth(); + int thisIdWidth = getWidth; g.translate(0, ypos + (alheight * charHeight)); - int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false, - null); - int thisIdWidth = idWidth < 0 ? getAnnotationsIdWidth : idWidth; - if (thisIdWidth > getWidth()) + if (!isManuallyAdjusted()) { - this.setPreferredSize( - new Dimension(this.getHeight(), thisIdWidth)); - this.repaint(); + int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false, + forGUI, null, false); + thisIdWidth = idWidth < 0 ? getAnnotationsIdWidth : idWidth; + if (thisIdWidth > getWidth) + { + this.setPreferredSize( + new Dimension(thisIdWidth, this.getHeight())); + this.repaint(); + alignViewport.setIdWidth(thisIdWidth); + } } - labels.drawComponent(g, false, thisIdWidth); + labels.drawComponent(g, false, thisIdWidth, forGUI); g.translate(0, -ypos - (alheight * charHeight)); } @@ -601,4 +631,17 @@ public class IdCanvas extends JPanel implements ViewportListenerI repaint(); } } + + private boolean manuallyAdjusted = false; + + public boolean isManuallyAdjusted() + { + return manuallyAdjusted; + } + + public void setManuallyAdjusted(boolean b) + { + manuallyAdjusted = b; + } + }