X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignmentPanel.java;h=8e02a9c3c7cbce6c68e5ada9b25730e11b81d724;hb=d2f3c59deebfd9ea52b0021ab31467c18b9d2c14;hp=00f27aaac335738f261495cec9644fc724b1c073;hpb=8f56279671fd43b29887fcb33efb52795287342c;p=jalview.git diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 00f27aa..8e02a9c 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -32,6 +32,8 @@ import java.io.*; import javax.swing.*; +import org.biojava.dasobert.eventmodel.*; + /** * DOCUMENT ME! @@ -40,7 +42,7 @@ import javax.swing.*; * @version $Revision$ */ public class AlignmentPanel extends GAlignmentPanel - implements AdjustmentListener, Printable + implements AdjustmentListener, Printable, FeatureListener { public AlignViewport av; OverviewPanel overviewPanel; @@ -92,11 +94,8 @@ public class AlignmentPanel extends GAlignmentPanel setScrollValues(0, 0); - annotationPanel.adjustPanelHeight(); - annotationSpaceFillerHolder.setPreferredSize(annotationPanel. - getPreferredSize()); - annotationScroller.setPreferredSize(annotationPanel. - getPreferredSize()); + adjustAnnotationHeight(); + setAnnotationVisible(av.getShowAnnotation()); hscroll.addAdjustmentListener(this); @@ -161,18 +160,15 @@ public class AlignmentPanel extends GAlignmentPanel break; case KeyEvent.VK_DELETE: - if(av.cursorMode) - { - seqPanel.deleteGapAtCursor(evt.isControlDown() || evt.isShiftDown()); - } - break; - case KeyEvent.VK_BACK_SPACE: if(!av.cursorMode) { alignFrame.cut_actionPerformed(null); seqPanel.seqCanvas.repaint(); } + else + seqPanel.deleteGapAtCursor(evt.isControlDown() || evt.isShiftDown()); + break; case KeyEvent.VK_S: @@ -249,6 +245,22 @@ public class AlignmentPanel extends GAlignmentPanel }); } + public void comeBackLater(FeatureEvent evt) + {} + + public void newFeatures(FeatureEvent evt) + { + if (evt.getFeatures().length > 0) + { + seqPanel.seqCanvas.fr.featuresAdded(); + repaint(); + } + else + { + System.out.println("No Features found for "+evt.getDasSource().getNickname()); + } + } + /** * DOCUMENT ME! */ @@ -371,16 +383,21 @@ public class AlignmentPanel extends GAlignmentPanel } else { - int cwidth = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth()); - if( start(av.getStartRes()+cwidth) ) - { - vscroll.setValue(start / cwidth); - av.startRes = vscroll.getValue() * cwidth; - } + scrollToWrappedVisible(start); } } } + void scrollToWrappedVisible(int res) + { + int cwidth = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth()); + if( res<=av.getStartRes() || res>=(av.getStartRes()+cwidth) ) + { + vscroll.setValue(res / cwidth); + av.startRes = vscroll.getValue() * cwidth; + } + } + /** * DOCUMENT ME! * @@ -416,6 +433,37 @@ public class AlignmentPanel extends GAlignmentPanel repaint(); } + public void adjustAnnotationHeight() + { + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + while(alignFrame.getHeight()==0) + { + Thread.yield(); + } + + int height = annotationPanel.adjustPanelHeight(); + + if (height > alignFrame.getHeight() / 2) + { + height = alignFrame.getHeight() / 2; + } + + annotationScroller.setPreferredSize( + new Dimension(annotationScroller.getWidth(), + height)); + + annotationSpaceFillerHolder.setPreferredSize(new Dimension( + annotationSpaceFillerHolder.getWidth(), + height)); + + annotationPanel.repaint(); + } + }); + } + /** * DOCUMENT ME! * @@ -941,7 +989,6 @@ public class AlignmentPanel extends GAlignmentPanel { int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30; int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth); - if (idPanel.getWidth() == 0) { width += calculateIdWidth().getWidth() + 4; @@ -950,7 +997,15 @@ public class AlignmentPanel extends GAlignmentPanel if (av.getWrapAlignment()) { height = getWrappedHeight(); - width = seqPanel.getWidth() + idPanel.getWidth(); + if (System.getProperty("java.awt.headless") != null + && System.getProperty("java.awt.headless").equals("true")) + { + width = alignFrame.getWidth() - 22; + } + else + + width = seqPanel.getWidth() + idPanel.getWidth(); + } else if (av.getShowAnnotation()) { @@ -1123,9 +1178,9 @@ public class AlignmentPanel extends GAlignmentPanel if (features[f].getDescription() != null && !features[f].getType().equals(features[f].getDescription())) text.append(" " + features[f].getDescription()); - if (features[f].getStatus() != null && features[f].getStatus().length()>0) + if (features[f].getValue("status") != null ) { - text.append(" (" + features[f].getStatus() + ")"); + text.append(" (" + features[f].getValue("status") + ")"); } } } @@ -1153,9 +1208,19 @@ public class AlignmentPanel extends GAlignmentPanel int getWrappedHeight() { + int seqPanelWidth = seqPanel.seqCanvas.getWidth(); + + //If headless, seqPanel will have 0 width + if (System.getProperty("java.awt.headless") != null + && System.getProperty("java.awt.headless").equals("true")) + { + int idWidth = calculateIdWidth().width + 4; + seqPanelWidth = alignFrame.getWidth() - idWidth; + } int chunkWidth = seqPanel.seqCanvas.getWrappedCanvasWidth( - seqPanel.seqCanvas.getWidth()); + seqPanelWidth + ); int hgap = av.charHeight; if (av.scaleAboveWrapped)