import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
// this value is set false when selection area being dragged
boolean fastPaint = true;
- int hextent = 0;
+ private int hextent = 0;
- int vextent = 0;
+ private int vextent = 0;
/*
* Flag set while scrolling to follow complementary cDNA/protein scroll. When
* Highlight the given results on the alignment.
*
*/
- public void highlightSearchResults(SearchResults results)
+ public void highlightSearchResults(SearchResultsI results)
{
scrollToPosition(results);
getSeqPanel().seqCanvas.highlightSearchResults(results);
*
* @param results
*/
- public boolean scrollToPosition(SearchResults results)
+ public boolean scrollToPosition(SearchResultsI results)
{
return scrollToPosition(results, 0, true, false);
}
* @param redrawOverview
* @return
*/
- public boolean scrollToPosition(SearchResults searchResults,
+ public boolean scrollToPosition(SearchResultsI searchResults,
boolean redrawOverview)
{
return scrollToPosition(searchResults, 0, redrawOverview, false);
* if true, try to centre the search results horizontally in the view
* @return false if results were not found
*/
- public boolean scrollToPosition(SearchResults results,
+ public boolean scrollToPosition(SearchResultsI results,
int verticalOffset, boolean redrawOverview, boolean centre)
{
int startv, endv, starts, ends;
if (res < av.getStartRes() || res >= (av.getStartRes() + cwidth))
{
vscroll.setValue((res / cwidth));
- av.startRes = vscroll.getValue() * cwidth;
+ av.setStartRes(vscroll.getValue() * cwidth);
}
}
fontChanged();
setAnnotationVisible(av.isShowAnnotation());
boolean wrap = av.getWrapAlignment();
- av.startSeq = 0;
+ av.setStartSeq(0);
scalePanelHolder.setVisible(!wrap);
hscroll.setVisible(!wrap);
idwidthAdjuster.setVisible(!wrap);
*/
public void setScrollValues(int x, int y)
{
- // System.err.println("Scroll " + this.av.viewName + " to " + x + "," + y);
if (av == null || av.getAlignment() == null)
{
return;
if (av.hasHiddenColumns())
{
+ // reset the width to exclude hidden columns
width = av.getColumnSelection().findColumnPosition(width);
}
- av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av
- .getCharWidth())) - 1);
-
hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
vextent = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight();
x = 0;
}
+ // update endRes after x has (possibly) been adjusted
+ av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av
+ .getCharWidth())) - 1);
+
/*
* each scroll adjustment triggers adjustmentValueChanged, which resets the
* 'do not scroll complement' flag; ensure it is the same for both
overviewPanel.setBoxPosition();
}
- int scrollX = av.startRes - oldX;
- int scrollY = av.startSeq - oldY;
+ int scrollX = av.getStartRes() - oldX;
+ int scrollY = av.getStartSeq() - oldY;
if (av.getWrapAlignment() || !fastPaint)
{
{
// Make sure we're not trying to draw a panel
// larger than the visible window
- if (scrollX > av.endRes - av.startRes)
+ if (scrollX > av.getEndRes() - av.getStartRes())
{
- scrollX = av.endRes - av.startRes;
+ scrollX = av.getEndRes() - av.getStartRes();
}
- else if (scrollX < av.startRes - av.endRes)
+ else if (scrollX < av.getStartRes() - av.getEndRes())
{
- scrollX = av.startRes - av.endRes;
+ scrollX = av.getStartRes() - av.getEndRes();
}
if (scrollX != 0 || scrollY != 0)
+ 3;
/*
- * draw the Scale at horizontal offset, then reset to origin
+ * draw the Scale at horizontal offset, then reset to top left (0, 0)
*/
alignmentGraphics.translate(alignmentGraphicsOffset, 0);
getScalePanel().drawScale(alignmentGraphics, startRes, endRes,
/*
* Draw the sequence ids, offset for scale height,
- * then reset to origin
+ * then reset to top left (0, 0)
*/
idGraphics.translate(0, scaleHeight);
idGraphics.setFont(getIdPanel().getIdCanvas().getIdfont());
/*
* draw the sequences, offset for scale height, and id width (if using a
- * single graphics context), then reset to origin + scale height
+ * single graphics context), then reset to (0, scale height)
*/
alignmentGraphics.translate(alignmentGraphicsOffset, scaleHeight);
getSeqPanel().seqCanvas.drawPanel(alignmentGraphics, startRes, endRes,
if (av.isShowAnnotation() && (endSeq == alignmentHeight))
{
/*
- * draw annotation labels, offset for current scroll position
- * then reset to origin + scale height
+ * draw annotation labels; drawComponent() translates by
+ * getScrollOffset(), so compensate for that first;
+ * then reset to (0, scale height)
*/
- int offset = -getAlabels().getScrollOffset();
- idGraphics.translate(0, offset + alignmentDrawnHeight);
+ int offset = getAlabels().getScrollOffset();
+ idGraphics.translate(0, -offset);
+ idGraphics.translate(0, alignmentDrawnHeight);
getAlabels().drawComponent(idGraphics, idWidth);
- idGraphics.translate(0, -offset - alignmentDrawnHeight);
+ idGraphics.translate(0, -alignmentDrawnHeight);
/*
- * draw the annotations
+ * draw the annotations starting at
+ * (idOffset, alignmentHeight) from (0, scaleHeight)
*/
alignmentGraphics.translate(alignmentGraphicsOffset, alignmentDrawnHeight);
getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,
if (onscreen
|| (idwidth = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH")) == null)
{
- return (getIdPanel().getWidth() > 0 ? getIdPanel().getWidth()
- : calculateIdWidth().width + 4);
+ int w = getIdPanel().getWidth();
+ return (w > 0 ? w : calculateIdWidth().width + 4);
}
return idwidth.intValue() + 4;
}
public void makePNGImageMap(File imgMapFile, String imageName)
{
- // /////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS
+ // /////ONLY WORKS WITH NON WRAPPED ALIGNMENTS
// ////////////////////////////////////////////
int idWidth = getVisibleIdWidth(false);
FontMetrics fm = getFontMetrics(av.getFont());
{
int s, sSize = av.getAlignment().getHeight(), res, alwidth = av
.getAlignment().getWidth(), g, gSize, f, fSize, sy;
- StringBuffer text = new StringBuffer();
PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
out.println(jalview.io.HTMLOutput.getImageMapHTML());
out.println("<img src=\"" + imageName
SequenceGroup[] groups = av.getAlignment().findAllGroups(seq);
for (res = 0; res < alwidth; res++)
{
- text = new StringBuffer();
+ StringBuilder text = new StringBuilder();
String triplet = null;
if (av.getAlignment().isNucleotide())
{
{
if (text.length() < 1)
{
- text.append("<area shape=\"rect\" coords=\""
- + (idWidth + res * av.getCharWidth()) + "," + sy
- + "," + (idWidth + (res + 1) * av.getCharWidth())
- + "," + (av.getCharHeight() + sy) + "\""
- + " onMouseOver=\"toolTip('" + alIndex + " "
- + triplet);
+ text.append("<area shape=\"rect\" coords=\"")
+ .append((idWidth + res * av.getCharWidth()))
+ .append(",").append(sy).append(",")
+ .append((idWidth + (res + 1) * av.getCharWidth()))
+ .append(",").append((av.getCharHeight() + sy))
+ .append("\"").append(" onMouseOver=\"toolTip('")
+ .append(alIndex).append(" ").append(triplet);
}
if (groups[g].getStartRes() < res
&& groups[g].getEndRes() > res)
{
- text.append("<br><em>" + groups[g].getName() + "</em>");
+ text.append("<br><em>").append(groups[g].getName())
+ .append("</em>");
}
}
{
if (text.length() < 1)
{
- text.append("<area shape=\"rect\" coords=\""
- + (idWidth + res * av.getCharWidth()) + "," + sy
- + "," + (idWidth + (res + 1) * av.getCharWidth())
- + "," + (av.getCharHeight() + sy) + "\""
- + " onMouseOver=\"toolTip('" + alIndex + " "
- + triplet);
+ text.append("<area shape=\"rect\" coords=\"")
+ .append((idWidth + res * av.getCharWidth()))
+ .append(",").append(sy).append(",")
+ .append((idWidth + (res + 1) * av.getCharWidth()))
+ .append(",").append((av.getCharHeight() + sy))
+ .append("\"").append(" onMouseOver=\"toolTip('")
+ .append(alIndex).append(" ").append(triplet);
}
fSize = features.length;
for (f = 0; f < fSize; f++)
if ((features[f].getBegin() <= seq.findPosition(res))
&& (features[f].getEnd() >= seq.findPosition(res)))
{
- if (features[f].getType().equals("disulfide bond"))
+ if (features[f].isContactFeature())
{
if (features[f].getBegin() == seq.findPosition(res)
|| features[f].getEnd() == seq
.findPosition(res))
{
- text.append("<br>disulfide bond "
- + features[f].getBegin() + ":"
- + features[f].getEnd());
+ text.append("<br>").append(features[f].getType())
+ .append(" ").append(features[f].getBegin())
+ .append(":").append(features[f].getEnd());
}
}
else
&& !features[f].getType().equals(
features[f].getDescription()))
{
- text.append(" " + features[f].getDescription());
+ text.append(" ").append(features[f].getDescription());
}
if (features[f].getValue("status") != null)
{
- text.append(" (" + features[f].getValue("status")
- + ")");
+ text.append(" (").append(features[f].getValue("status"))
+ .append(")");
}
}
}
* @param verticalOffset
* the number of visible sequences to show above the mapped region
*/
- public void scrollToCentre(SearchResults sr, int verticalOffset)
+ public void scrollToCentre(SearchResultsI sr, int verticalOffset)
{
/*
* To avoid jumpy vertical scrolling (if some sequences are gapped or not
* mapped), we can make the scroll-to location a sequence above the one
* actually mapped.
*/
- SequenceI mappedTo = sr.getResultSequence(0);
+ SequenceI mappedTo = sr.getResults().get(0).getSequence();
List<SequenceI> seqs = av.getAlignment().getSequences();
/*