X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignmentPanel.java;h=8c935992ed529e658cc29d37de942ccc87518a7f;hb=37a5dfc3c72a42689e90ad8a0e118e8855d9868b;hp=ed88418c0ecf42a60cc4c258c38e6c2c7e5fb887;hpb=1ed150e97b6a7df6ebe5cf92ead96cd147a58b7e;p=jalview.git diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index ed88418..8c93599 100755 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -63,13 +63,15 @@ public class AlignmentPanel extends Panel implements AdjustmentListener scalePanel = new ScalePanel(av, this); idwidthAdjuster = new IdwidthAdjuster(this); annotationPanel = new AnnotationPanel(this); + + sequenceHolderPanel.add(annotationPanel, BorderLayout.SOUTH); + alabels = new AnnotationLabels(this); setAnnotationVisible(av.showAnnotation); idPanelHolder.add(idPanel, BorderLayout.CENTER); idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER); - annotationScroller.add(annotationPanel); annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER); scalePanelHolder.add(scalePanel, BorderLayout.CENTER); seqPanelHolder.add(seqPanel, BorderLayout.CENTER); @@ -93,7 +95,6 @@ public class AlignmentPanel extends Panel implements AdjustmentListener idPanel.idCanvas.setSize(d); hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height); - annotationScroller.setSize(annotationPanel.getSize()); idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height); annotationSpaceFillerHolder.setSize(d.width, @@ -107,13 +108,13 @@ public class AlignmentPanel extends Panel implements AdjustmentListener { // set idCanvas bufferedImage to null // to prevent drawing old image - idPanel.idCanvas.image =null; + idPanel.idCanvas.image = null; FontMetrics fm = getFontMetrics(av.getFont()); scalePanel.setSize(new Dimension(10, av.charHeight + fm.getDescent())); idwidthAdjuster.setSize(new Dimension(10, av.charHeight + fm.getDescent())); -annotationPanel.image = null; + annotationPanel.image = null; int ap = annotationPanel.adjustPanelHeight(); annotationPanel.repaint(); Dimension d = calculateIdWidth(); @@ -139,16 +140,14 @@ annotationPanel.image = null; Dimension calculateIdWidth() { - Frame frame = new Frame(); - frame.addNotify(); - Graphics g = frame.getGraphics(); - if (g == null) + if (av.nullFrame == null) { - Frame f = new Frame(); - f.addNotify(); - g = f.getGraphics(); + av.nullFrame = new Frame(); + av.nullFrame.addNotify(); } + Graphics g = av.nullFrame.getGraphics(); + FontMetrics fm = g.getFontMetrics(av.font); AlignmentI al = av.getAlignment(); @@ -171,7 +170,7 @@ annotationPanel.image = null; i = 0; if (al.getAlignmentAnnotation() != null) { - fm = g.getFontMetrics(frame.getFont()); + fm = g.getFontMetrics(av.nullFrame.getFont()); while (i < al.getAlignmentAnnotation().length) { String label = al.getAlignmentAnnotation()[i].label; @@ -253,7 +252,7 @@ annotationPanel.image = null; if (!av.wrapAlignment) { annotationSpaceFillerHolder.setVisible(b); - annotationScroller.setVisible(b); + annotationPanel.setVisible(b); } validate(); repaint(); @@ -270,12 +269,12 @@ annotationPanel.image = null; if (wrap) { - annotationScroller.setVisible(false); + annotationPanel.setVisible(false); annotationSpaceFillerHolder.setVisible(false); } else if (av.showAnnotation) { - annotationScroller.setVisible(true); + annotationPanel.setVisible(true); annotationSpaceFillerHolder.setVisible(true); } @@ -342,30 +341,38 @@ annotationPanel.image = null; public void setScrollValues(int x, int y) { + int width = av.alignment.getWidth(); + int height = av.alignment.getHeight(); + + if(av.hasHiddenColumns) + width = av.getColumnSelection().findColumnPosition(width); + av.setStartRes(x); av.setStartSeq(y); - av.setEndRes(x + seqPanel.seqCanvas.getSize().width / av.getCharWidth() - 1); + + av.setEndRes( (x + (seqPanel.seqCanvas.getSize().width / av.charWidth)) -1); hextent = seqPanel.seqCanvas.getSize().width / av.charWidth; vextent = seqPanel.seqCanvas.getSize().height / av.charHeight; - if (hextent > av.alignment.getWidth()) + if (hextent > width) { - hextent = av.alignment.getWidth(); + hextent = width; } - if (vextent > av.alignment.getHeight()) + + if (vextent > height) { - vextent = av.alignment.getHeight(); + vextent = height; } - if (hextent + x > av.getAlignment().getWidth()) + if ( (hextent + x) > width) { - x = av.getAlignment().getWidth() - hextent; + x = width - hextent; } - if (vextent + y > av.getAlignment().getHeight()) + if ( (vextent + y) > height) { - y = av.getAlignment().getHeight() - vextent; + y = height - vextent; } if (y < 0) @@ -390,6 +397,7 @@ annotationPanel.image = null; if(overviewPanel!=null) overviewPanel.setBoxPosition(); + } public void adjustmentValueChanged(AdjustmentEvent evt) @@ -478,9 +486,15 @@ annotationPanel.image = null; if (av.getWrapAlignment()) { - int max = av.alignment.getWidth() / - seqPanel.seqCanvas. - getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width) +1; + int maxwidth = av.alignment.getWidth(); + + if (av.hasHiddenColumns) + maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; + + int max = maxwidth / + seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width) + + 1; + vscroll.setMaximum(max); vscroll.setUnitIncrement(1); vscroll.setVisibleAmount(1); @@ -522,7 +536,6 @@ annotationPanel.image = null; BorderLayout borderLayout10 = new BorderLayout(); protected Panel hscrollFillerPanel = new Panel(); BorderLayout borderLayout11 = new BorderLayout(); - public Panel annotationScroller = new Panel(); BorderLayout borderLayout4 = new BorderLayout(); BorderLayout borderLayout2 = new BorderLayout(); @@ -557,11 +570,9 @@ annotationPanel.image = null; // this.setPreferredSize(new Dimension(220, 166)); seqPanelHolder.setBackground(Color.white); idPanelHolder.setBackground(Color.white); - annotationScroller.setLayout(borderLayout2); sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH); sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER); seqPanelHolder.add(vscroll, BorderLayout.EAST); - sequenceHolderPanel.add(annotationScroller, BorderLayout.SOUTH); // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH); this.add(idPanelHolder, BorderLayout.WEST);