import java.io.PrintWriter;
import java.util.List;
-import javax.swing.JScrollBar;
-
/**
* The main panel of an AlignFrame, containing holders for the IdPanel,
* SeqPanel, AnnotationLabels (a JPanel), and AnnotationPanel.
hscroll.addAdjustmentListener(this);
vscroll.addAdjustmentListener(this);
-
addComponentListener(new ComponentAdapter()
{
@Override
public void componentResized(ComponentEvent evt)
{
- System.out.println("AlignmentPanel resized " + evt);
// reset the viewport ranges when the alignment panel is resized
// in particular, this initialises the end residue value when Jalview
// is initialised
/ av.getCharHeight();
ranges.setViewportWidth(widthInRes);
- ViewportRanges.sTest += "AP.resize chht=" + av.getCharHeight()
- + "canvHt=" + getSeqPanel().seqCanvas.getHeight() + " "
- + heightInSeq + "\n";
ranges.setViewportHeight(heightInSeq);
}
}
}
@Override
- public void setBounds(int x, int y, int width, int height)
- {
- System.out.println("?AlignmentPanel.setBounds " + this.getX() + " "
- + this.getY() + " " + this.getWidth() + " " + getHeight() + " "
- + x + " " + y + " " + width + " " + height);
- // BH 2020.03.23 when the Desktop changes its progress bar it re-lays out
- // all
- // its
- // children, for unclear reasons. Maybe because they could be tiled?
- if (x == this.getX() && y == this.getY() && width == this.getWidth()
- && height == this.getHeight())
- {
- return;
- }
- System.out.println("!AlignmentPanel.setBounds " + this.getX() + " "
- + this.getY() + " " + this.getWidth() + " " + getHeight() + " "
- + x + " " + y + " " + width + " " + height);
- super.setBounds(x, y, width, height);
- }
-
- // @Override
- // public void reshape(int x, int y, int width, int height)
- // {
- // // BH 2020.03.23 when the Desktop changes its progress bar it relays out
- // all its
- // // children, for unclear reasons. Maybe because they could be tiled?
- // if (x == this.getX() && y == this.getY() && width == this.getWidth()
- // && height == this.getHeight())
- // {
- // return;
- // }
- //
- // System.out.println("AlignmentPanel.reshape " + this.getX() + " "
- // + this.getY() + " " + this.getWidth() + " " + getHeight() + " "
- // + x
- // + " " + y + " " + width + " " + height);
- // super.reshape(x, y, width, height);
- // }
-
- @Override
public AlignViewportI getAlignViewport()
{
return av;
* visible column to scroll to
* @param y
* visible row to scroll to
- *
- * @return true if scrollbars will fire property changes
*
*/
- public boolean setScrollValues(int xpos, int ypos)
+ public void setScrollValues(int xpos, int ypos)
{
int x = xpos;
int y = ypos;
if (av == null || av.getAlignment() == null)
{
- return false;
+ return;
}
if (av.getWrapAlignment())
{
- return setScrollingForWrappedPanel(x);
+ setScrollingForWrappedPanel(x);
}
- int width = av.getAlignment().getVisibleWidth();
- int height = av.getAlignment().getHeight();
-
- hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
- vextent = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight();
-
- if (hextent > width)
- {
- hextent = width;
- }
-
- if (vextent > height)
+ else
{
- vextent = height;
- }
+ int width = av.getAlignment().getVisibleWidth();
+ int height = av.getAlignment().getHeight();
- if ((hextent + x) > width)
- {
- x = width - hextent;
- }
+ hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
+ vextent = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight();
- if ((vextent + y) > height)
- {
- y = height - vextent;
- }
+ if (hextent > width)
+ {
+ hextent = width;
+ }
- if (y < 0)
- {
- y = 0;
- }
+ if (vextent > height)
+ {
+ vextent = height;
+ }
- if (x < 0)
- {
- x = 0;
- }
+ if ((hextent + x) > width)
+ {
+ x = width - hextent;
+ }
- // update the scroll values and return true if they changed
+ if ((vextent + y) > height)
+ {
+ y = height - vextent;
+ }
- return (setIfChanged(hscroll, x, hextent, 0, width)
- + setIfChanged(vscroll, y, vextent, 0, height) != 0);
+ if (y < 0)
+ {
+ y = 0;
+ }
- }
+ if (x < 0)
+ {
+ x = 0;
+ }
- /**
- * Update a horizontal or vertical scrollbar and indicate if it is actually changed
- * (and so will be firing an AdjustmentChangedEvent)
- * @param sb
- * @param val
- * @param extent
- * @param min
- * @praam max
- * @return 1 if JScrollBar is changed; 0 if not
- */
- private int setIfChanged(JScrollBar sb, int val, int extent, int min,
- int max)
- {
- if (sb.getValue() == val && sb.getModel().getExtent() == extent
- && sb.getMinimum() == min && sb.getMaximum() == max)
- {
- return 0;
+ // update the scroll values
+ hscroll.setValues(x, hextent, 0, width);
+ vscroll.setValues(y, vextent, 0, height);
}
- sb.setValues(val, extent, min, max);
- return 1;
}
/**
int y = vscroll.getValue();
int height = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight();
-
// if we're scrolling to the position we're already at, stop
// this prevents infinite recursion of events when the scroll/viewport
// ranges values are the same
{
return;
}
-
- ViewportRanges.sTest += "AP.adjvalChanged chht=" + av.getCharHeight()
- + "canvHt=" + getSeqPanel().seqCanvas.getHeight() + " newHt="
- + height + "\n";
-
ranges.setViewportStartAndHeight(y, height);
}
repaint();
}
}
- @Override
- public void invalidate()
- {
- System.out.println("AlignmentPanel invalidate");
- super.invalidate();
- }
-
- @Override
- public void validate()
- {
- System.out.println("AlignmentPanel validate");
- super.validate();
- }
-
/**
* DOCUMENT ME!
*
public void paintComponent(Graphics g)
{
- System.out.println("AlignmentPanel paintComponent");
-
invalidate(); // needed so that the id width adjuster works correctly
Dimension d = getIdPanel().getIdCanvas().getPreferredSize();
* though I still think this call should be elsewhere.
*/
ViewportRanges ranges = av.getRanges();
- if (!setScrollValues(ranges.getStartRes(), ranges.getStartSeq()))
- {
- // super.paintComponent(g);
- }
+ setScrollValues(ranges.getStartRes(), ranges.getStartSeq());
super.paintComponent(g);
}
* @param topLeftColumn
* the column position at top left (0..)
*/
- private boolean setScrollingForWrappedPanel(int topLeftColumn)
+ private void setScrollingForWrappedPanel(int topLeftColumn)
{
ViewportRanges ranges = av.getRanges();
int scrollPosition = ranges.getWrappedScrollPosition(topLeftColumn);
* so we add extent (1) to the maxScroll value
*/
vscroll.setUnitIncrement(1);
- return (setIfChanged(vscroll, scrollPosition, 1, 0,
- maxScroll + 1) != 0);
+ vscroll.setValues(scrollPosition, 1, 0, maxScroll + 1);
}
/**