X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignmentPanel.java;h=0307a96f9e3120fe08292b495193ee5ebec85fa9;hb=07c1edb779cfa11d19ea6e5dc731333e5dfd2250;hp=ed88418c0ecf42a60cc4c258c38e6c2c7e5fb887;hpb=1ed150e97b6a7df6ebe5cf92ead96cd147a58b7e;p=jalview.git diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index ed88418..0307a96 100755 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -40,7 +40,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener // this value is set false when selection area being dragged boolean fastPaint = true; - boolean MAC = false; + public AlignmentPanel(AlignFrame af, final AlignViewport av) { @@ -53,8 +53,6 @@ public class AlignmentPanel extends Panel implements AdjustmentListener e.printStackTrace(); } - if(System.getProperty("os.name").startsWith("Mac")) - MAC = true; alignFrame = af; this.av = av; @@ -63,13 +61,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,27 +93,54 @@ 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, annotationPanel.getSize().height); alabels.setSize(d.width, annotationPanel.getSize().height); + final AlignmentPanel ap = this; + av.addPropertyChangeListener(new java.beans.PropertyChangeListener() + { + public void propertyChange(java.beans.PropertyChangeEvent evt) + { + if (evt.getPropertyName().equals("alignment")) + { + PaintRefresher.Refresh(ap, + av.getSequenceSetId(), + true, + true); + alignmentChanged(); + } + } + }); + } + public void alignmentChanged() + { + av.alignmentChanged(this); + + if (overviewPanel != null) + overviewPanel.updateOverviewImage(); + + alignFrame.updateEditMenuBar(); + + repaint(); + } + public void fontChanged() { // 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 +166,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 +196,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 +278,7 @@ annotationPanel.image = null; if (!av.wrapAlignment) { annotationSpaceFillerHolder.setVisible(b); - annotationScroller.setVisible(b); + annotationPanel.setVisible(b); } validate(); repaint(); @@ -270,12 +295,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 +367,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 +423,7 @@ annotationPanel.image = null; if(overviewPanel!=null) overviewPanel.setBoxPosition(); + } public void adjustmentValueChanged(AdjustmentEvent evt) @@ -433,7 +467,7 @@ annotationPanel.image = null; int scrollX = av.startRes - oldX; int scrollY = av.startSeq - oldY; - if (av.getWrapAlignment() || !fastPaint || MAC) + if (av.getWrapAlignment() || !fastPaint || av.MAC) { repaint(); } @@ -478,12 +512,21 @@ annotationPanel.image = null; if (av.getWrapAlignment()) { - int max = av.alignment.getWidth() / - seqPanel.seqCanvas. - getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width) +1; - vscroll.setMaximum(max); - vscroll.setUnitIncrement(1); - vscroll.setVisibleAmount(1); + int maxwidth = av.alignment.getWidth(); + + if (av.hasHiddenColumns) + maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; + + int canvasWidth = seqPanel.seqCanvas.getWrappedCanvasWidth + (seqPanel.seqCanvas.getSize().width); + + if(canvasWidth>0) + { + int max = maxwidth / canvasWidth; + vscroll.setMaximum(max); + vscroll.setUnitIncrement(1); + vscroll.setVisibleAmount(1); + } } else { @@ -522,7 +565,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 +599,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);