From: jprocter Date: Wed, 29 Aug 2012 20:01:31 +0000 (+0100) Subject: JAL-1155 fix panel length calculation for grouped graphs and refactor to alignment... X-Git-Tag: Jalview_2_9~371 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e8ede151da126e8fe205392c64f1604d80adda6d;p=jalview.git JAL-1155 fix panel length calculation for grouped graphs and refactor to alignment view model --- diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index ab9efb1..54a1d6f 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -28,6 +28,14 @@ public interface AlignViewportI int getCharHeight(); + /** + * calculate the height for visible annotation, revalidating bounds where + * necessary ABSTRACT GUI METHOD + * + * @return total height of annotation + */ + public int calcPanelHeight(); + boolean hasHiddenColumns(); boolean isValidCharWidth(); diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index e9d418e..ba6d873 100644 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -464,7 +464,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme */ protected void validateAnnotationDimensions(boolean adjustPanelHeight) { boolean modified=false; - int height = annotationPanel.calcPanelHeight(); + int height = av.calcPanelHeight(); int minsize=0; if (hscroll.isVisible()) { diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index 635535c..5393b07 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -290,7 +290,7 @@ public class AnnotationLabels extends Panel implements ActionListener, ap.annotationPanelHolder.setSize(new Dimension(d.width, d.height - dif)); ap.apvscroll.setValues(ap.apvscroll.getValue(), d.height - dif, 0, - ap.annotationPanel.calcPanelHeight()); + av.calcPanelHeight()); f.height += dif; ap.seqPanelHolder.setPreferredSize(f); ap.setScrollValues(av.getStartRes(), av.getStartSeq()); diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index 492683d..45a5f1e 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -390,7 +390,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight = 0; } graphStretchY = evt.getY(); - calcPanelHeight(); + av.calcPanelHeight(); needValidating = true; ap.paintAlignment(true); } @@ -464,7 +464,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen public int adjustPanelHeight(boolean repaint) { - int height = calcPanelHeight(); + int height = av.calcPanelHeight(); this.setSize(new Dimension(getSize().width, height)); if (repaint) { @@ -477,54 +477,6 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen * ABSTRACT GUI METHOD * @return total height of annotation */ - public int calcPanelHeight() - { - // setHeight of panels - AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation(); - int height = 0; - - if (aa != null) - { - for (int i = 0; i < aa.length; i++) - { - if (!aa[i].visible) - { - continue; - } - - aa[i].height = 0; - - if (aa[i].hasText) - { - aa[i].height += av.charHeight; - } - - if (aa[i].hasIcons) - { - aa[i].height += 16; - } - - if (aa[i].graph > 0) - { - aa[i].height += aa[i].graphHeight; - } - - if (aa[i].height == 0) - { - aa[i].height = 20; - } - - height += aa[i].height; - } - } - if (height == 0) - { - height = 20; - } - - return height; - - } public void addEditableColumn(int i) { diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index c8784a5..03670d2 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -146,7 +146,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, */ public int adjustPanelHeight() { - int height = calcPanelHeight(); + int height = av.calcPanelHeight(); this.setPreferredSize(new Dimension(1, height)); if (ap != null) { @@ -158,65 +158,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } /** - * calculate the height for visible annotation, revalidating bounds where - * necessary ABSTRACT GUI METHOD - * - * @return total height of annotation - */ - public int calcPanelHeight() - { - // setHeight of panels - AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation(); - int height = 0; - - if (aa != null) - { - for (int i = 0; i < aa.length; i++) - { - if (aa[i] == null) - { - System.err.println("Null annotation row: ignoring."); - continue; - } - if (!aa[i].visible) - { - continue; - } - - aa[i].height = 0; - - if (aa[i].hasText) - { - aa[i].height += av.charHeight; - } - - if (aa[i].hasIcons) - { - aa[i].height += 16; - } - - if (aa[i].graph > 0) - { - aa[i].height += aa[i].graphHeight; - } - - if (aa[i].height == 0) - { - aa[i].height = 20; - } - - height += aa[i].height; - } - } - if (height == 0) - { - // set minimum - height = 20; - } - return height; - } - - /** * DOCUMENT ME! * * @param evt diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 8c34f31..27af11e 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -1374,4 +1374,75 @@ public abstract class AlignmentViewport implements AlignViewportI } } + /* + * (non-Javadoc) + * @see jalview.api.AlignViewportI#calcPanelHeight() + */ + public int calcPanelHeight() + { + // setHeight of panels + AlignmentAnnotation[] aa = getAlignment().getAlignmentAnnotation(); + int height = 0; + int charHeight=getCharHeight(); + if (aa != null) + { + boolean graphgrp[] = null; + for (int i = 0; i < aa.length; i++) + { + if (aa[i] == null) + { + System.err.println("Null annotation row: ignoring."); + continue; + } + if (!aa[i].visible) + { + continue; + } + if (aa[i].graphGroup > -1) + { + if (graphgrp == null) + { + graphgrp = new boolean[aa.length]; + } + if (graphgrp[aa[i].graphGroup]) + { + continue; + } + else + { + graphgrp[aa[i].graphGroup] = true; + } + } + aa[i].height = 0; + + if (aa[i].hasText) + { + aa[i].height += charHeight; + } + + if (aa[i].hasIcons) + { + aa[i].height += 16; + } + + if (aa[i].graph > 0) + { + aa[i].height += aa[i].graphHeight; + } + + if (aa[i].height == 0) + { + aa[i].height = 20; + } + + height += aa[i].height; + } + } + if (height == 0) + { + // set minimum + height = 20; + } + return height; + } }