private int availHeight;
+ private boolean allowFastPaint;
// Don't do this! Graphics handles are supposed to be transient
// private Graphics2D gg;
int yPos = ypos + charHeight;
int startX = startx;
int endX = endx;
-
+
if (av.hasHiddenColumns())
{
HiddenColumns hiddenColumns = av.getAlignment().getHiddenColumns();
}
}
+
// System.err.println(">>> FastPaint to " + transX + " " + transY + " "
// + horizontal + " " + vertical + " " + startRes + " " + endRes
// + " " + startSeq + " " + endSeq);
gg.copyArea(horizontal * charWidth, vertical * charHeight,
img.getWidth(), img.getHeight(), -horizontal * charWidth,
-vertical * charHeight);
+
+
gg.translate(transX, transY);
drawPanel(gg, startRes, endRes, startSeq, endSeq, 0);
gg.translate(-transX, -transY);
// Call repaint on alignment panel so that repaints from other alignment
// panel components can be aggregated. Otherwise performance of the
// overview window and others may be adversely affected.
- // System.out.println("SeqCanvas fastPaint() repaint() request...");
av.getAlignPanel().repaint();
} finally
{
@Override
public void paintComponent(Graphics g)
{
- if (av.getAlignPanel().getHoldRepaint())
+ if (av==null || av.getAlignPanel()==null || av.getAlignPanel().getHoldRepaint())
{
return;
}
// }
Rectangle vis, clip;
- if (img != null
- && (fastPaint
- || (vis = getVisibleRect()).width != (clip = g
- .getClipBounds()).width
- || vis.height != clip.height))
+ if (allowFastPaint && img != null
+ && (fastPaint || (vis = getVisibleRect()).width != (clip = g.getClipBounds()).width
+ || vis.height != clip.height))
{
g.drawImage(img, 0, 0, this);
drawSelectionGroup((Graphics2D) g, startRes, endRes, startSeq,
}
else
{
+ allowFastPaint = true;
// img is a cached version of the last view we drew.
// If we have no img or the size has changed, make a new one.
//
drawCursor(g, startRes, endRes, startSeq, endSeq);
}
}
-
/**
* Draw an alignment panel for printing
*
}
/**
- * Using the current font, determine fields labelWidthEast and labelWidthWest,
- * and return the number of residues that can fill the remaining width
+ * Returns the visible width of the canvas in residues, after allowing for
+ * East or West scales (if shown)
*
- * @param w
+ * @param canvasWidth
* the width in pixels (possibly including scales)
*
- * @return the visible width in residues, after allowing for East or West
- * scales (if shown)
- *
+ * @return
*/
- public int getWrappedCanvasWidth(int w)
+ public int getWrappedCanvasWidth(int canvasWidth)
{
int charWidth = av.getCharWidth();
FontMetrics fm = getFontMetrics(av.getFont());
- int labelWidth = (av.getScaleRightWrapped() || av.getScaleLeftWrapped()
- ? getLabelWidth(fm)
- : 0);
+ int labelWidth = 0;
+
+ if (av.getScaleRightWrapped() || av.getScaleLeftWrapped())
+ {
+ labelWidth = getLabelWidth(fm);
+ }
labelWidthEast = av.getScaleRightWrapped() ? labelWidth : 0;
labelWidthWest = av.getScaleLeftWrapped() ? labelWidth : 0;
- return (w - labelWidthEast - labelWidthWest) / charWidth;
+ return (canvasWidth - labelWidthEast - labelWidthWest) / charWidth;
}
/**
final int startColumn)
{
int wrappedWidthInResidues = calculateWrappedGeometry();
+
av.setWrappedWidth(wrappedWidthInResidues);
+
ViewportRanges ranges = av.getRanges();
ranges.setViewportStartAndWidth(startColumn, wrappedWidthInResidues);
availWidth -= (availWidth % charWidth);
availHeight -= (availHeight % charHeight);
}
-
/**
* Calculates and saves values needed when rendering a wrapped alignment.
* These depend on many factors, including
*/
public int calculateWrappedGeometry(int canvasWidth, int canvasHeight)
{
-
int charHeight = av.getCharHeight();
/*
if (av.getScaleRightWrapped())
{
int x = labelWidthWest + viewportWidth * charWidth;
-
g.translate(x, 0);
drawVerticalScale(g, startCol, endColumn, ypos, false);
g.translate(-x, 0);
{ 5f, 3f }, 0f);
private final static BasicStroke basicStroke = new BasicStroke();
-
/*
* Draw a selection group over a wrapped alignment
*/
/ charWidth;
int startx = startRes;
int maxwidth = av.getAlignment().getVisibleWidth();
-
// JAL-3253-applet had this:
// // height gap above each panel
// int charHeight = av.getCharHeight();
}
g.translate(labelWidthWest, 0);
-
drawUnwrappedSelection(g, group, startx, endx, 0,
av.getAlignment().getHeight() - 1, ypos);
-
g.translate(-labelWidthWest, 0);
// update vertical offset
}
}
+
/**
* Draw a selection group over an unwrapped alignment
*
int startRes, int endRes, int startSeq, int endSeq, int offset)
{
int charWidth = av.getCharWidth();
-
if (!av.hasHiddenColumns())
{
drawPartialGroupOutline(g, group, startRes, endRes, startSeq, endSeq,
g.drawLine(sx + xwidth, oldY, sx + xwidth, sy);
}
}
-
/**
* Highlights search results in the visible region by rendering as white text
* on a black background. Any previous highlighting is removed. Answers true
return highlightSearchResults(results, false);
}
-
/**
* Highlights search results in the visible region by rendering as white text
* on a black background. Any previous highlighting is removed. Answers true
public void propertyChange(PropertyChangeEvent evt)
{
String eventName = evt.getPropertyName();
-
// BH 2019.07.27 removes dead code introduced in aad3650 and simplifies
// logic, emphasizing no check for ENDRES or ENDSEQ
- ((int[]) evt.getOldValue())[0];
scrollY = ((int[]) evt.getNewValue())[1]
- ((int[]) evt.getOldValue())[1];
-
- // System.out.println("SC dx dy " + scrollX + " " + scrollY);
-
if (scrollX != 0 && scrollY != 0)
{
// all sorts of problems in JavaScript if this is commented out.
try
{
-
Graphics gg = img.getGraphics();
-
calculateWrappedGeometry();
/*
drawWrappedDecorators(gg, ranges.getStartRes());
gg.dispose();
-
repaint();
} finally
{
}
Graphics gg = img.getGraphics();
-
ViewportRanges ranges = av.getRanges();
int viewportWidth = ranges.getViewportWidth();
int charWidth = av.getCharWidth();
/*
* white fill first to erase annotations
*/
-
gg.translate(xOffset, 0);
gg.setColor(Color.white);
gg.fillRect(labelWidthWest, ypos, (endRes - startRes + 1) * charWidth,
gg.translate(-xOffset, 0);
drawWrappedWidth(gg, ypos, startRes, endRes, canvasHeight);
-
}
/*
}
}
}
-
gg.dispose();
return matchFound;
*/
public void setNoFastPaint()
{
- fastPaint = false;
+ allowFastPaint = false;
}
}