* @version $Revision: 1.161 $
*/
public class AlignmentPanel extends GAlignmentPanel implements
- AdjustmentListener, Printable, AlignmentViewPanel,
- ViewportListenerI
+ AdjustmentListener, Printable, AlignmentViewPanel, ViewportListenerI
{
public AlignViewport av;
// is initialised
if (av.getWrapAlignment())
{
- int widthInRes = getSeqPanel().seqCanvas
- .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
+ int widthInRes = getSeqPanel().seqCanvas.getWrappedCanvasWidth(
+ getSeqPanel().seqCanvas.getWidth());
vpRanges.setViewportWidth(widthInRes);
}
else
/ av.getCharWidth();
int heightInSeq = getSeqPanel().seqCanvas.getHeight()
/ av.getCharHeight();
-
+
vpRanges.setViewportWidth(widthInRes);
vpRanges.setViewportHeight(heightInSeq);
}
// to prevent drawing old image
FontMetrics fm = getFontMetrics(av.getFont());
- scalePanelHolder.setPreferredSize(new Dimension(10, av.getCharHeight()
- + fm.getDescent()));
- idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av
- .getCharHeight() + fm.getDescent()));
+ scalePanelHolder.setPreferredSize(
+ new Dimension(10, av.getCharHeight() + fm.getDescent()));
+ idSpaceFillerPanel1.setPreferredSize(
+ new Dimension(10, av.getCharHeight() + fm.getDescent()));
getIdPanel().getIdCanvas().gg = null;
getSeqPanel().seqCanvas.img = null;
{
Container c = new Container();
- FontMetrics fm = c.getFontMetrics(new Font(av.font.getName(),
- Font.ITALIC, av.font.getSize()));
+ FontMetrics fm = c.getFontMetrics(
+ new Font(av.font.getName(), Font.ITALIC, av.font.getSize()));
AlignmentI al = av.getAlignment();
int i = 0;
}
}
- return new Dimension(maxwidth < 0 ? idWidth : Math.min(maxwidth,
- idWidth), 12);
+ return new Dimension(
+ maxwidth < 0 ? idWidth : Math.min(maxwidth, idWidth), 12);
}
/**
/*
* Scroll down to make end of search results visible
*/
- setScrollValues(vpRanges.getStartRes(), starts + seqIndex - ends
- + 1);
+ setScrollValues(vpRanges.getStartRes(),
+ starts + seqIndex - ends + 1);
}
/*
* Else results are already visible - no need to scroll
*/
if (annotationHeight + alignmentHeight > availableHeight)
{
- annotationHeight = Math.min(annotationHeight, availableHeight - 2
- * rowHeight);
+ annotationHeight = Math.min(annotationHeight,
+ availableHeight - 2 * rowHeight);
}
}
else
}
hscroll.addNotify();
- annotationScroller.setPreferredSize(new Dimension(annotationScroller
- .getWidth(), annotationHeight));
+ annotationScroller.setPreferredSize(
+ new Dimension(annotationScroller.getWidth(), annotationHeight));
Dimension e = idPanel.getSize();
alabels.setSize(new Dimension(e.width, annotationHeight));
else
{
int widthInRes = (canvasWidth / av.getCharWidth()) - 1;
- int heightInSeq = (getSeqPanel().seqCanvas.getHeight() / av
- .getCharHeight()) - 1;
+ int heightInSeq = (getSeqPanel().seqCanvas.getHeight()
+ / av.getCharHeight()) - 1;
vpRanges.setViewportWidth(widthInRes);
vpRanges.setViewportHeight(heightInSeq);
repaint();
}
-
/**
* Adjust row/column scrollers to show a visible position in the alignment.
*
if (av.hasHiddenColumns())
{
// reset the width to exclude hidden columns
- width = av.getAlignment().getHiddenColumns().findColumnPosition(width);
+ width = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(width);
}
hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
{
return;
}
- else if (newY > -1)
+ if (newY > -1)
{
/*
* limit page up/down to one width's worth of positions
*/
int rowSize = vpRanges.getViewportWidth();
int newX = newY > oldY ? oldX + rowSize : oldX - rowSize;
- vpRanges.setViewportStartAndWidth(newX, rowSize);
+ vpRanges.setViewportStartAndWidth(Math.max(0, newX), rowSize);
}
}
else
{
@Override
public void run()
- {
+ {
// When updating scrolling to use ViewportChange events, this code
// could not be validated and it is not clear if it is now being
// called. Log warning here in case it is called and unforeseen
// problems occur
- Cache.log
- .warn("Unexpected path through code: Wrapped jar file opened with wrap alignment set in preferences");
+ Cache.log.warn(
+ "Unexpected path through code: Wrapped jar file opened with wrap alignment set in preferences");
// scroll to start of panel
vpRanges.setStartRes(0);
private void setScrollingForWrappedPanel(int topLeftColumn)
{
int scrollPosition = vpRanges.getWrappedScrollPosition(topLeftColumn);
- int maxScroll = vpRanges.getWrappedScrollPosition(vpRanges
- .getVisibleAlignmentWidth() - 1);
+ int maxScroll = vpRanges.getWrappedMaxScroll(topLeftColumn);
+ /*
+ * a scrollbar's value can be set to at most (maximum-extent)
+ * so we add extent (1) to the maxScroll value
+ */
vscroll.setUnitIncrement(1);
- vscroll.setValues(scrollPosition, 1, 0, maxScroll);
+ vscroll.setValues(scrollPosition, 1, 0, maxScroll + 1);
}
/**
* Get the horizontal offset to where we draw the sequences.
* This is idWidth if using a single Graphics context, else zero.
*/
- final int alignmentGraphicsOffset = idGraphics != alignmentGraphics ? 0 : idWidth;
+ final int alignmentGraphicsOffset = idGraphics != alignmentGraphics ? 0
+ : idWidth;
FontMetrics fm = getFontMetrics(av.getFont());
int charHeight = av.getCharHeight();
endSeq = alignmentHeight;
}
- int pagesHigh = ((alignmentHeight / totalSeq) + 1)
- * pageHeight;
+ int pagesHigh = ((alignmentHeight / totalSeq) + 1) * pageHeight;
if (av.isShowAnnotation())
{
{
return Printable.NO_SUCH_PAGE;
}
- final int alignmentDrawnHeight = (endSeq - startSeq) * charHeight
- + 3;
+ final int alignmentDrawnHeight = (endSeq - startSeq) * charHeight + 3;
/*
* draw the Scale at horizontal offset, then reset to top left (0, 0)
if (av.isRightAlignIds())
{
fm = idGraphics.getFontMetrics();
- xPos = idWidth
- - fm.stringWidth(displayId)
- - 4;
+ xPos = idWidth - fm.stringWidth(displayId) - 4;
}
idGraphics.drawString(displayId, xPos,
* draw the annotations starting at
* (idOffset, alignmentHeight) from (0, scaleHeight)
*/
- alignmentGraphics.translate(alignmentGraphicsOffset, alignmentDrawnHeight);
+ alignmentGraphics.translate(alignmentGraphicsOffset,
+ alignmentDrawnHeight);
getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,
alignmentGraphics, -1, startRes, endRes + 1);
}
.findColumnPosition(maxwidth) - 1;
}
- int resWidth = getSeqPanel().seqCanvas.getWrappedCanvasWidth(pwidth
- - idWidth);
+ int resWidth = getSeqPanel().seqCanvas
+ .getWrappedCanvasWidth(pwidth - idWidth);
int totalHeight = cHeight * (maxwidth / resWidth + 1);
}
if (labels != null)
{
- pg.translate(-3,
- ypos + (av.getAlignment().getHeight() * av.getCharHeight()));
+ pg.translate(-3, ypos
+ + (av.getAlignment().getHeight() * av.getCharHeight()));
pg.setFont(av.getFont());
labels.drawComponent(pg, idWidth);
- pg.translate(
- +3,
- -ypos
- - (av.getAlignment().getHeight() * av
- .getCharHeight()));
+ pg.translate(+3, -ypos
+ - (av.getAlignment().getHeight() * av.getCharHeight()));
}
ypos += cHeight;
return calculateIdWidth(-1).width + 4;
}
Integer idwidth = null;
- if (onscreen
- || (idwidth = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH")) == null)
+ if (onscreen || (idwidth = Cache
+ .getIntegerProperty("FIGURE_FIXEDIDWIDTH")) == null)
{
int w = getIdPanel().getWidth();
return (w > 0 ? w : calculateIdWidth().width + 4);
{
int boarderBottomOffset = 5;
long pSessionId = System.currentTimeMillis();
- headless = (System.getProperty("java.awt.headless") != null && System
- .getProperty("java.awt.headless").equals("true"));
+ headless = (System.getProperty("java.awt.headless") != null
+ && System.getProperty("java.awt.headless").equals("true"));
if (alignFrame != null && !headless)
{
if (file != null)
{
- alignFrame.setProgressBar(MessageManager.formatMessage(
- "status.saving_file", new Object[] { type.getLabel() }),
- pSessionId);
+ alignFrame.setProgressBar(MessageManager
+ .formatMessage("status.saving_file", new Object[]
+ { type.getLabel() }), pSessionId);
}
}
try
}
im = new jalview.util.ImageMaker(this, type, imageAction,
- aDimension.getWidth(), aDimension.getHeight()
- + boarderBottomOffset, file, imageTitle,
- alignFrame, pSessionId, headless);
+ aDimension.getWidth(),
+ aDimension.getHeight() + boarderBottomOffset, file,
+ imageTitle, alignFrame, pSessionId, headless);
Graphics graphics = im.getGraphics();
if (av.getWrapAlignment())
{
{
if (graphics != null)
{
- printUnwrapped(aDimension.getWidth(), aDimension.getHeight(),
- 0, graphics, graphics);
+ printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
+ graphics, graphics);
im.writeImage();
}
}
// this duplicates the calculation in getWrappedHeight but adjusts for
// offscreen idWith
width = alignFrame.getWidth() - vscroll.getPreferredSize().width
- - alignFrame.getInsets().left
- - alignFrame.getInsets().right - getVisibleIdWidth()
- + getVisibleIdWidth(false);
+ - alignFrame.getInsets().left - alignFrame.getInsets().right
+ - getVisibleIdWidth() + getVisibleIdWidth(false);
}
else
{
{
try
{
- int s, sSize = av.getAlignment().getHeight(), res, alwidth = av
- .getAlignment().getWidth(), g, gSize, f, fSize, sy;
+ int s, sSize = av.getAlignment().getHeight(), res,
+ alwidth = av.getAlignment().getWidth(), g, gSize, f, fSize,
+ sy;
PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
out.println(jalview.io.HTMLOutput.getImageMapHTML());
out.println("<img src=\"" + imageName
String triplet = null;
if (av.getAlignment().isNucleotide())
{
- triplet = ResidueProperties.nucleotideName.get(seq
- .getCharAt(res) + "");
+ triplet = ResidueProperties.nucleotideName
+ .get(seq.getCharAt(res) + "");
}
else
{
- triplet = ResidueProperties.aa2Triplet.get(seq.getCharAt(res)
- + "");
+ triplet = ResidueProperties.aa2Triplet
+ .get(seq.getCharAt(res) + "");
}
if (triplet == null)
{
text.append("<br>");
text.append(features[f].getType());
- if (features[f].getDescription() != null
- && !features[f].getType().equals(
- features[f].getDescription()))
+ if (features[f].getDescription() != null && !features[f]
+ .getType().equals(features[f].getDescription()))
{
text.append(" ").append(features[f].getDescription());
}
if (features[f].getValue("status") != null)
{
- text.append(" (").append(features[f].getValue("status"))
+ text.append(" (")
+ .append(features[f].getValue("status"))
.append(")");
}
}
@Override
/**
- * Property change event fired when a change is made to the viewport ranges
+ * Property change event fired when a change is made to the viewport ranges
* object associated with this alignment panel's viewport
*/
public void propertyChange(PropertyChangeEvent evt)