import java.util.Hashtable;
import java.util.Vector;
+import jalview.api.AlignmentViewPanel;
import jalview.datamodel.*;
+import jalview.structure.StructureSelectionManager;
-public class AlignmentPanel extends Panel implements AdjustmentListener
+public class AlignmentPanel extends Panel implements AdjustmentListener, AlignmentViewPanel
{
public AlignViewport av;
// this value is set false when selection area being dragged
boolean fastPaint = true;
-
+
+ public void finalize() {
+ alignFrame=null;
+ av=null;
+ seqPanel=null;
+ seqPanelHolder=null;
+ sequenceHolderPanel=null;
+ scalePanel=null;
+ scalePanelHolder=null;
+ annotationPanel=null;
+ annotationPanelHolder=null;
+ annotationSpaceFillerHolder=null;
+ }
public AlignmentPanel(AlignFrame af, final AlignViewport av)
{
try
public void componentResized(ComponentEvent evt)
{
setScrollValues(av.getStartRes(), av.getStartSeq());
+ if (getSize().height>0 && annotationPanelHolder.getSize().height>0) {
+ validateAnnotationDimensions(false);
+ }
repaint();
}
+
});
Dimension d = calculateIdWidth();
return false;
}
SequenceI seq = av.alignment.getSequenceAt(seqIndex);
- int[] r = results.getResults(seq, seq.getStart(), seq.getEnd());
+ int[] r = results.getResults(seq, 0,av.alignment.getWidth());
if (r == null)
{
if (av.applet.debug) {// DEBUG
}
if (av.applet.debug) {
// DEBUG
- System.out.println("DEBUG: scroll didn't happen: start=" + r[0]
+ System.out.println("DEBUG: scroll: start=" + r[0]
+ " av.getStartRes()=" + av.getStartRes() + " end=" + r[1]
+ " seq.end=" + seq.getEnd() + " av.getEndRes()="
+ av.getEndRes() + " hextent=" + hextent);
{
return false;
}
- if (av.hasHiddenColumns)
+ return scrollTo(start, end, seqIndex, false, redrawOverview);
+ }
+ return true;
+ }
+ public boolean scrollTo(int ostart, int end, int seqIndex, boolean scrollToNearest, boolean redrawOverview)
+ {
+ int start=-1;
+ if (av.hasHiddenColumns)
+ {
+ start = av.getColumnSelection().findColumnPosition(ostart);
+ end = av.getColumnSelection().findColumnPosition(end);
+ if (start == end)
{
- start = av.getColumnSelection().findColumnPosition(start);
- end = av.getColumnSelection().findColumnPosition(end);
- if (start == end)
+ if (!scrollToNearest && !av.colSel.isVisible(ostart))
{
- if (!av.colSel.isVisible(r[0]))
- {
- // don't scroll - position isn't visible
- return false;
- }
+ // don't scroll - position isn't visible
+ return false;
+ }
}
}
if (!av.wrapAlignment)
{
scrollToWrappedVisible(start);
}
- }
if (redrawOverview && overviewPanel != null)
{
overviewPanel.setBoxPosition();
validate();
repaint();
}
-
+
+ /**
+ * automatically adjust annotation panel height for new annotation whilst
+ * ensuring the alignment is still visible.
+ */
+ public void adjustAnnotationHeight()
+ {
+ // TODO: display vertical annotation scrollbar if necessary
+ // this is called after loading new annotation onto alignment
+ if (alignFrame.getSize().height == 0)
+ {
+ System.out.println("NEEDS FIXING");
+ }
+ fontChanged();
+ validateAnnotationDimensions(true);
+ apvscroll.addNotify();
+ hscroll.addNotify();
+ validate();
+ repaint();
+ }
+ /**
+ * calculate the annotation dimensions and refresh slider values accordingly.
+ * need to do repaints/notifys afterwards.
+ */
+ protected void validateAnnotationDimensions(boolean adjustPanelHeight) {
+ boolean modified=false;
+ int height = annotationPanel.calcPanelHeight();
+ int minsize=0;
+ if (hscroll.isVisible())
+ {
+ height += (minsize=hscroll.getPreferredSize().height);
+ }
+ if (apvscroll.isVisible()) {
+ minsize+=apvscroll.getPreferredSize().height;
+ }
+ int mheight = height;
+ Dimension d=sequenceHolderPanel.getSize(),e=idPanel.getSize();
+ int seqandannot=d.height-scalePanelHolder.getSize().height;
+ // sets initial preferred height
+ if ((height+40) > seqandannot / 2)
+ {
+ height = seqandannot / 2;
+ }
+ if (!adjustPanelHeight)
+ {
+ // maintain same window layout whilst updating sliders
+ height=annotationPanelHolder.getSize().height;
+ }
+
+ if (seqandannot-height<5)
+ {
+ height = seqandannot;
+ }
+ annotationPanel.setSize(new Dimension(d.width,height));
+ alabels.setSize(new Dimension(e.width,height));
+ annotationSpaceFillerHolder.setSize(new Dimension(e.width, height));
+ annotationPanelHolder.setSize(new Dimension(d.width, height));
+ seqPanelHolder.setSize(d.width,seqandannot-height);
+ int s=apvscroll.getValue();
+ if (s>mheight-height)
+ {
+ s = 0;
+ }
+ apvscroll.setValues(s, height, 0, mheight);
+ annotationPanel.setScrollOffset(apvscroll.getValue());
+ alabels.setScrollOffset(apvscroll.getValue());
+ }
+
public void setWrapAlignment(boolean wrap)
{
av.startSeq = 0;
{
overviewPanel.setBoxPosition();
}
+ sendViewPosition();
+
}
annotationPanel.fastPaint(av.getStartRes() - oldX);
}
}
+ sendViewPosition();
}
+ private void sendViewPosition()
+ {
+ StructureSelectionManager.getStructureSelectionManager(av.applet).sendViewPosition(this, av.startRes, av.endRes, av.startSeq, av.endSeq);
+ }
public void paintAlignment(boolean updateOverview)
{
if (updateOverview)
{
jalview.structure.StructureSelectionManager
- .getStructureSelectionManager().sequenceColoursChanged(this);
+ .getStructureSelectionManager(av.applet).sequenceColoursChanged(this);
if (overviewPanel != null)
{
adjustAnnotationHeight();
}
- /**
- * automatically adjust annotation panel height for new annotation whilst
- * ensuring the alignment is still visible.
- */
- public void adjustAnnotationHeight()
+ @Override
+ public AlignmentI getAlignment()
{
- // TODO: display vertical annotation scrollbar if necessary
- // this is called after loading new annotation onto alignment
- if (alignFrame.getSize().height == 0)
- {
- System.out.println("NEEDS FIXING");
- }
- fontChanged();
- validateAnnotationDimensions(true);
- apvscroll.addNotify();
- hscroll.addNotify();
- validate();
- addNotify();
- repaint();
+ return av.alignment;
}
- /**
- * calculate the annotation dimensions and refresh slider values accordingly.
- * need to do repaints/notifys afterwards.
- */
- protected void validateAnnotationDimensions(boolean adjustPanelHeight) {
- int height = annotationPanel.calcPanelHeight();
- if (hscroll.isVisible())
- {
- height += hscroll.getPreferredSize().height;
- }
- int mheight = height;
- // sets initial preferred height
- if ((height+40) > getSize().height / 2)
- {
- height = getSize().height / 2;
- }
- if (!adjustPanelHeight)
- {
- // maintain same window layout whilst updating sliders
- height=seqPanelHolder.getSize().height;
- }
- Dimension d=seqPanelHolder.getSize(),e=idPanel.getSize();
- annotationPanel.setSize(new Dimension(d.width,height));
- alabels.setSize(e.width,height);
- annotationSpaceFillerHolder.setSize(new Dimension(e.width, height));
- annotationPanelHolder.setSize(new Dimension(d.width, height));
- seqPanelHolder.setSize(d.width,d.height-height);
- int s=apvscroll.getValue();
- if (s>mheight-height)
- {
- s = 0;
- }
- apvscroll.setValues(apvscroll.getValue(), height, 0, mheight);
- annotationPanel.setScrollOffset(apvscroll.getValue());
- alabels.setScrollOffset(apvscroll.getValue());
+ @Override
+ public StructureSelectionManager getStructureSelectionManager()
+ {
+ return StructureSelectionManager.getStructureSelectionManager(av.applet);
}
}