From: Jim Procter Date: Mon, 2 Feb 2015 11:54:50 +0000 (+0000) Subject: JAL-1640 updates to use get/setter on viewportI: efficiencies - temp variables create... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3cdecbd752fe2d2d8c7b48ba36343c5188f30c40;p=jalview.git JAL-1640 updates to use get/setter on viewportI: efficiencies - temp variables created for redraw loops and temp fields created where redraw involves multiple methods (methods made private where possible to avoid temp field being out of sync) --- diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index c58fc5b..e688177 100644 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -715,8 +715,7 @@ public class APopupMenu extends java.awt.PopupMenu implements // TODO consider using getSequenceSelection instead here cap.setText(new jalview.io.AppletFormatAdapter().formatSequences( - e.getActionCommand(), - ap.av.showJVSuffix, ap.av, true)); + e.getActionCommand(), ap.av.getShowJVSuffix(), ap.av, true)); } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 1f32da0..334ee5d 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -157,7 +157,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, viewport.updateConservation(alignPanel); viewport.updateConsensus(alignPanel); - annotationPanelMenuItem.setState(viewport.showAnnotation); + annotationPanelMenuItem.setState(viewport.isShowAnnotation()); displayNonconservedMenuItem.setState(viewport.getShowUnconserved()); followMouseOverFlag.setState(viewport.getFollowHighlight()); showGroupConsensus.setState(viewport.isShowGroupConsensus()); @@ -167,7 +167,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, normSequenceLogo.setState(viewport.isNormaliseSequenceLogo()); applyToAllGroups.setState(viewport.getColourAppliesToAllGroups()); - seqLimits.setState(viewport.showJVSuffix); + seqLimits.setState(viewport.getShowJVSuffix()); if (applet != null) { @@ -498,7 +498,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } case KeyEvent.VK_PAGE_UP: - if (viewport.wrapAlignment) + if (viewport.getWrapAlignment()) { alignPanel.scrollUp(true); } @@ -510,7 +510,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, break; case KeyEvent.VK_PAGE_DOWN: - if (viewport.wrapAlignment) + if (viewport.getWrapAlignment()) { alignPanel.scrollUp(false); } @@ -1185,7 +1185,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { e.getActionCommand() }), 600, 500); cap.setText(new AppletFormatAdapter().formatSequences( e.getActionCommand(), viewport.getAlignment(), - viewport.showJVSuffix)); + viewport.getShowJVSuffix())); } public void loadAnnotations() @@ -2349,7 +2349,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, protected void displayNonconservedMenuItem_actionPerformed() { - viewport.setShowunconserved(displayNonconservedMenuItem.getState()); + viewport.setShowUnconserved(displayNonconservedMenuItem.getState()); alignPanel.paintAlignment(true); } diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index 5308a42..05d4948 100644 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -100,7 +100,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, sequenceHolderPanel.add(annotationPanelHolder, BorderLayout.SOUTH); alabels = new AnnotationLabels(this); - setAnnotationVisible(av.showAnnotation); + setAnnotationVisible(av.isShowAnnotation()); idPanelHolder.add(idPanel, BorderLayout.CENTER); idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER); @@ -190,8 +190,9 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, idPanel.idCanvas.image = null; FontMetrics fm = getFontMetrics(av.getFont()); - scalePanel.setSize(new Dimension(10, av.charHeight + fm.getDescent())); - idwidthAdjuster.setSize(new Dimension(10, av.charHeight + scalePanel.setSize(new Dimension(10, av.getCharHeight() + + fm.getDescent())); + idwidthAdjuster.setSize(new Dimension(10, av.getCharHeight() + fm.getDescent())); av.updateSequenceIdColours(); annotationPanel.image = null; @@ -375,7 +376,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, { start = ostart; } - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { /* * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv = @@ -449,7 +450,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, public void setAnnotationVisible(boolean b) { - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { annotationSpaceFillerHolder.setVisible(b); annotationPanelHolder.setVisible(b); @@ -566,7 +567,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, annotationPanelHolder.setVisible(false); annotationSpaceFillerHolder.setVisible(false); } - else if (av.showAnnotation) + else if (av.isShowAnnotation()) { annotationPanelHolder.setVisible(true); annotationSpaceFillerHolder.setVisible(true); @@ -648,8 +649,8 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, } ; - hextent = seqPanel.seqCanvas.getSize().width / av.charWidth; - vextent = seqPanel.seqCanvas.getSize().height / av.charHeight; + hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth(); + vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight(); if (hextent > width) { @@ -694,7 +695,8 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, av.setEndSeq(endSeq); av.setStartRes(x); - av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av.charWidth)) - 1); + av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av + .getCharWidth())) - 1); hscroll.setValues(x, hextent, 0, width); vscroll.setValues(y, vextent, 0, height); @@ -776,7 +778,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, seqPanel.seqCanvas.fastPaint(scrollX, scrollY); scalePanel.repaint(); - if (av.getShowAnnotation()) + if (av.isShowAnnotation()) { annotationPanel.fastPaint(av.getStartRes() - oldX); } @@ -847,9 +849,9 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, seqPanel.seqCanvas.repaint(); idPanel.idCanvas.repaint(); - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { - if (av.showAnnotation) + if (av.isShowAnnotation()) { alabels.repaint(); annotationPanel.repaint(); diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index 6aaa033..566be33 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -311,8 +311,8 @@ public class AnnotationLabels extends Panel implements ActionListener, .getSize(), f = ap.seqPanelHolder.getSize(); int dif = evt.getY() - oldY; - dif /= ap.av.charHeight; - dif *= ap.av.charHeight; + dif /= ap.av.getCharHeight(); + dif *= ap.av.getCharHeight(); if ((d.height - dif) > 20 && (f.height + dif) > 20) { @@ -495,7 +495,7 @@ public class AnnotationLabels extends Panel implements ActionListener, } else { - ap.av.setIgnoreGapsConsensus(cbmi.getState()); + ap.av.setIgnoreGapsConsensus(cbmi.getState(), ap); } ap.paintAlignment(true); } @@ -813,7 +813,7 @@ public class AnnotationLabels extends Panel implements ActionListener, dragEvent.getY()); } - if (!av.wrapAlignment && ((aa == null) || (aa.length < 1))) + if (!av.getWrapAlignment() && ((aa == null) || (aa.length < 1))) { g.setColor(Color.black); g.drawString(MessageManager.getString("label.right_click"), 2, 8); diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index 22996f7..167dd09 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -574,13 +574,13 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, return; } - gg.copyArea(0, 0, imgWidth, getSize().height, -horizontal - * av.charWidth, 0); + gg.copyArea(0, 0, imgWidth, getSize().height, + -horizontal * av.getCharWidth(), 0); int sr = av.startRes, er = av.endRes + 1, transX = 0; if (horizontal > 0) // scrollbar pulled right, image to the left { - transX = (er - sr - horizontal) * av.charWidth; + transX = (er - sr - horizontal) * av.getCharWidth(); sr = er - horizontal; } else if (horizontal < 0) @@ -614,7 +614,8 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, g.setFont(ofont); g.setColor(Color.white); - g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getSize().height); + g.fillRect(0, 0, (endRes - startRes) * av.getCharWidth(), + getSize().height); if (fm == null) { diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index 0ac4e55..83b69eb 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -84,7 +84,7 @@ public class IdCanvas extends Panel ((i - starty) * charHeight) + ypos + charHeight - (charHeight / 5)); - if (av.hasHiddenRows() && av.showHiddenMarkers) + if (av.hasHiddenRows() && av.getShowHiddenMarkers()) { drawMarker(i, starty, ypos); } @@ -99,8 +99,8 @@ public class IdCanvas extends Panel return; } - gg.copyArea(0, 0, getSize().width, imgHeight, 0, -vertical - * av.charHeight); + gg.copyArea(0, 0, getSize().width, imgHeight, 0, + -vertical * av.getCharHeight()); int ss = av.startSeq, es = av.endSeq, transY = 0; if (vertical > 0) // scroll down @@ -112,7 +112,7 @@ public class IdCanvas extends Panel } else { - transY = imgHeight - vertical * av.charHeight; + transY = imgHeight - vertical * av.getCharHeight(); } } else if (vertical < 0) @@ -153,7 +153,7 @@ public class IdCanvas extends Panel } imgHeight = getSize().height; - imgHeight -= imgHeight % av.charHeight; + imgHeight -= imgHeight % av.getCharHeight(); if (imgHeight < 1) { @@ -178,10 +178,17 @@ public class IdCanvas extends Panel g.drawImage(image, 0, 0, this); } + /** + * local copy of av.getCharHeight set at top of drawIds + */ + private int avcharHeight; void drawIds(int starty, int endy) { + // hardwired italic IDs in applet currently Font italic = new Font(av.getFont().getName(), Font.ITALIC, av .getFont().getSize()); + // temp variable for speed + avcharHeight = av.getCharHeight(); gg.setFont(italic); @@ -201,20 +208,19 @@ public class IdCanvas extends Panel int annotationHeight = 0; AnnotationLabels labels = null; - if (av.showAnnotation) + if (av.isShowAnnotation()) { AnnotationPanel ap = new AnnotationPanel(av); annotationHeight = ap.adjustPanelHeight(); labels = new AnnotationLabels(av); } - - int hgap = av.charHeight; - if (av.scaleAboveWrapped) + int hgap = avcharHeight; + if (av.getScaleAboveWrapped()) { - hgap += av.charHeight; + hgap += avcharHeight; } - int cHeight = alheight * av.charHeight + hgap + annotationHeight; + int cHeight = alheight * avcharHeight + hgap + annotationHeight; int rowSize = av.getEndRes() - av.getStartRes(); @@ -236,9 +242,9 @@ public class IdCanvas extends Panel if (labels != null) { - gg.translate(0, ypos + (alheight * av.charHeight)); + gg.translate(0, ypos + (alheight * avcharHeight)); labels.drawComponent(gg, getSize().width); - gg.translate(0, -ypos - (alheight * av.charHeight)); + gg.translate(0, -ypos - (alheight * avcharHeight)); } } @@ -284,15 +290,15 @@ public class IdCanvas extends Panel gg.setColor(currentColor); // TODO: isrep could be used to highlight the representative in a // different way - gg.fillRect(0, (i - starty) * av.charHeight, getSize().width, - av.charHeight); + gg.fillRect(0, (i - starty) * avcharHeight, getSize().width, + avcharHeight); gg.setColor(currentTextColor); gg.drawString(seq.getDisplayId(av.getShowJVSuffix()), 0, - (((i - starty) * av.charHeight) + av.charHeight) - - (av.charHeight / 5)); + (((i - starty) * avcharHeight) + avcharHeight) + - (avcharHeight / 5)); - if (av.hasHiddenRows() && av.showHiddenMarkers) + if (av.hasHiddenRows() && av.getShowHiddenMarkers()) { drawMarker(i, starty, 0); } @@ -343,20 +349,20 @@ public class IdCanvas extends Panel if (below) { gg.fillPolygon(new int[] - { getSize().width - av.charHeight, getSize().width - av.charHeight, + { getSize().width - avcharHeight, getSize().width - avcharHeight, getSize().width }, new int[] - { (i - starty) * av.charHeight + yoffset, - (i - starty) * av.charHeight + yoffset + av.charHeight / 4, - (i - starty) * av.charHeight + yoffset }, 3); + { (i - starty) * avcharHeight + yoffset, + (i - starty) * avcharHeight + yoffset + avcharHeight / 4, + (i - starty) * avcharHeight + yoffset }, 3); } if (above) { gg.fillPolygon(new int[] - { getSize().width - av.charHeight, getSize().width - av.charHeight, + { getSize().width - avcharHeight, getSize().width - avcharHeight, getSize().width }, new int[] - { (i - starty + 1) * av.charHeight + yoffset, - (i - starty + 1) * av.charHeight + yoffset - av.charHeight / 4, - (i - starty + 1) * av.charHeight + yoffset }, 3); + { (i - starty + 1) * avcharHeight + yoffset, + (i - starty + 1) * avcharHeight + yoffset - avcharHeight / 4, + (i - starty + 1) * avcharHeight + yoffset }, 3); } } diff --git a/src/jalview/appletgui/IdPanel.java b/src/jalview/appletgui/IdPanel.java index 7981634..547a4f9 100755 --- a/src/jalview/appletgui/IdPanel.java +++ b/src/jalview/appletgui/IdPanel.java @@ -303,7 +303,7 @@ public class IdPanel extends Panel implements MouseListener, int y = e.getY(); if (av.getWrapAlignment()) { - y -= 2 * av.charHeight; + y -= 2 * av.getCharHeight(); } int seq = alignPanel.seqPanel.findSeq(e); diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index 2b6f37a..a8090a1 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -371,7 +371,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, // Fill the selected columns ColumnSelection cs = av.getColumnSelection(); gg.setColor(new Color(220, 0, 0)); - + int avcharWidth = av.getCharWidth(), avcharHeight = av.getCharHeight(); for (int i = 0; i < cs.size(); i++) { int sel = cs.columnAt(i); @@ -382,7 +382,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, if ((sel >= startx) && (sel <= endx)) { - gg.fillRect((sel - startx) * av.charWidth, 0, av.charWidth, + gg.fillRect((sel - startx) * avcharWidth, 0, avcharWidth, getSize().height); } } @@ -393,7 +393,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, int scalestartx = (startx / 10) * 10; FontMetrics fm = gg.getFontMetrics(av.getFont()); - int y = av.charHeight - fm.getDescent(); + int y = avcharHeight - fm.getDescent(); if ((scalestartx % 10) == 0) { @@ -409,25 +409,26 @@ public class ScalePanel extends Panel implements MouseMotionListener, { string = String.valueOf(av.getColumnSelection() .adjustForHiddenColumns(i)); - if ((i - startx - 1) * av.charWidth > maxX) + if ((i - startx - 1) * avcharWidth > maxX) { - gg.drawString(string, (i - startx - 1) * av.charWidth, y); - maxX = (i - startx + 1) * av.charWidth + fm.stringWidth(string); + gg.drawString(string, (i - startx - 1) * avcharWidth, y); + maxX = (i - startx + 1) * avcharWidth + fm.stringWidth(string); } gg.drawLine( - ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), +((i - startx - 1) * avcharWidth) + (avcharWidth / 2), y + 2, - ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), + ((i - startx - 1) * avcharWidth) + (avcharWidth / 2), y + (fm.getDescent() * 2)); } else { gg.drawLine( - ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), +((i - startx - 1) * avcharWidth) + (avcharWidth / 2), y + fm.getDescent(), - ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), + ((i - startx - 1) * avcharWidth) + + (avcharWidth / 2), y + (fm.getDescent() * 2)); } } @@ -451,10 +452,10 @@ public class ScalePanel extends Panel implements MouseMotionListener, } gg.fillPolygon(new int[] - { res * av.charWidth - av.charHeight / 4, - res * av.charWidth + av.charHeight / 4, res * av.charWidth }, + { res * avcharWidth - avcharHeight / 4, + res * avcharWidth + avcharHeight / 4, res * avcharWidth }, new int[] - { y - av.charHeight / 2, y - av.charHeight / 2, y + 8 }, + { y - avcharHeight / 2, y - avcharHeight / 2, y + 8 }, 3); } @@ -463,7 +464,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, if (reveal != null && reveal[0] > startx && reveal[0] < endx) { gg.drawString(MessageManager.getString("label.reveal_columns"), - reveal[0] * av.charWidth, 0); + reveal[0] * avcharWidth, 0); } } diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 3d1f7e2..ec94c6f 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -61,6 +61,15 @@ public class SeqCanvas extends Panel fr = new FeatureRenderer(av); sr = new SequenceRenderer(av); PaintRefresher.Register(this, av.getSequenceSetId()); + updateViewport(); + } + + int avcharHeight = 0, avcharWidth = 0; + + private void updateViewport() + { + avcharHeight = av.getCharHeight(); + avcharWidth = av.getCharWidth(); } public AlignViewport getViewport() @@ -78,7 +87,7 @@ public class SeqCanvas extends Panel return sr; } - void drawNorthScale(Graphics g, int startx, int endx, int ypos) + private void drawNorthScale(Graphics g, int startx, int endx, int ypos) { int scalestartx = startx - startx % 10 + 10; @@ -93,20 +102,20 @@ public class SeqCanvas extends Panel value = av.getColumnSelection().adjustForHiddenColumns(value); } - g.drawString(String.valueOf(value), (i - startx - 1) * av.charWidth, - ypos - (av.charHeight / 2)); + g.drawString(String.valueOf(value), (i - startx - 1) * avcharWidth, + ypos - (avcharHeight / 2)); - g.drawLine(((i - startx - 1) * av.charWidth) + (av.charWidth / 2), - (ypos + 2) - (av.charHeight / 2), - ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), + g.drawLine(((i - startx - 1) * avcharWidth) + (avcharWidth / 2), + (ypos + 2) - (avcharHeight / 2), + ((i - startx - 1) * avcharWidth) + (avcharWidth / 2), ypos - 2); } } - void drawWestScale(Graphics g, int startx, int endx, int ypos) + private void drawWestScale(Graphics g, int startx, int endx, int ypos) { FontMetrics fm = getFontMetrics(av.getFont()); - ypos += av.charHeight; + ypos += avcharHeight; if (av.hasHiddenColumns()) { startx = av.getColumnSelection().adjustForHiddenColumns(startx); @@ -143,16 +152,16 @@ public class SeqCanvas extends Panel if (value != -1) { int x = LABEL_WEST - fm.stringWidth(String.valueOf(value)) - - av.charWidth / 2; - g.drawString(value + "", x, (ypos + (i * av.charHeight)) - - (av.charHeight / 5)); + - avcharWidth / 2; + g.drawString(value + "", x, (ypos + (i * avcharHeight)) + - (avcharHeight / 5)); } } } - void drawEastScale(Graphics g, int startx, int endx, int ypos) + private void drawEastScale(Graphics g, int startx, int endx, int ypos) { - ypos += av.charHeight; + ypos += avcharHeight; if (av.hasHiddenColumns()) { @@ -183,8 +192,8 @@ public class SeqCanvas extends Panel if (value != -1) { - g.drawString(String.valueOf(value), 0, (ypos + (i * av.charHeight)) - - (av.charHeight / 5)); + g.drawString(String.valueOf(value), 0, (ypos + (i * avcharHeight)) + - (avcharHeight / 5)); } } } @@ -198,6 +207,8 @@ public class SeqCanvas extends Panel return; } + updateViewport(); + // Its possible on certain browsers that the call to fastpaint // is faster than it can paint, so this check here catches // this possibility @@ -209,16 +220,16 @@ public class SeqCanvas extends Panel lastsr = av.startRes; fastPaint = true; - gg.copyArea(horizontal * av.charWidth, vertical * av.charHeight, - imgWidth - horizontal * av.charWidth, imgHeight - vertical - * av.charHeight, -horizontal * av.charWidth, -vertical - * av.charHeight); + gg.copyArea(horizontal * avcharWidth, vertical * avcharHeight, imgWidth + - horizontal * avcharWidth, + imgHeight - vertical * avcharHeight, -horizontal * avcharWidth, + -vertical * avcharHeight); int sr = av.startRes, er = av.endRes, ss = av.startSeq, es = av.endSeq, transX = 0, transY = 0; if (horizontal > 0) // scrollbar pulled right, image to the left { - transX = (er - sr - horizontal) * av.charWidth; + transX = (er - sr - horizontal) * avcharWidth; sr = er - horizontal; } else if (horizontal < 0) @@ -235,7 +246,7 @@ public class SeqCanvas extends Panel } else { - transY = imgHeight - vertical * av.charHeight; + transY = imgHeight - vertical * avcharHeight; } } else if (vertical < 0) @@ -288,12 +299,13 @@ public class SeqCanvas extends Panel return; } + updateViewport(); // this draws the whole of the alignment imgWidth = this.getSize().width; imgHeight = this.getSize().height; - imgWidth -= imgWidth % av.charWidth; - imgHeight -= imgHeight % av.charHeight; + imgWidth -= imgWidth % avcharWidth; + imgHeight -= imgHeight % avcharHeight; if (imgWidth < 1 || imgHeight < 1) { @@ -328,24 +340,24 @@ public class SeqCanvas extends Panel public int getWrappedCanvasWidth(int cwidth) { - cwidth -= cwidth % av.charWidth; + cwidth -= cwidth % av.getCharWidth(); FontMetrics fm = getFontMetrics(av.getFont()); LABEL_EAST = 0; LABEL_WEST = 0; - if (av.scaleRightWrapped) + if (av.getScaleRightWrapped()) { LABEL_EAST = fm.stringWidth(getMask()); } - if (av.scaleLeftWrapped) + if (av.getScaleLeftWrapped()) { LABEL_WEST = fm.stringWidth(getMask()); } - return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth; + return (cwidth - LABEL_EAST - LABEL_WEST) / av.getCharWidth(); } /** @@ -375,31 +387,31 @@ public class SeqCanvas extends Panel return mask; } - public void drawWrappedPanel(Graphics g, int canvasWidth, + private void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, int startRes) { AlignmentI al = av.getAlignment(); FontMetrics fm = getFontMetrics(av.getFont()); - if (av.scaleRightWrapped) + if (av.getScaleRightWrapped()) { LABEL_EAST = fm.stringWidth(getMask()); } - if (av.scaleLeftWrapped) + if (av.getScaleLeftWrapped()) { LABEL_WEST = fm.stringWidth(getMask()); } - int hgap = av.charHeight; - if (av.scaleAboveWrapped) + int hgap = avcharHeight; + if (av.getScaleAboveWrapped()) { - hgap += av.charHeight; + hgap += avcharHeight; } - int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth; - int cHeight = av.getAlignment().getHeight() * av.charHeight; + int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / avcharWidth; + int cHeight = av.getAlignment().getHeight() * avcharHeight; av.setWrappedWidth(cWidth); @@ -426,12 +438,12 @@ public class SeqCanvas extends Panel g.setColor(Color.black); - if (av.scaleLeftWrapped) + if (av.getScaleLeftWrapped()) { drawWestScale(g, startRes, endx, ypos); } - if (av.scaleRightWrapped) + if (av.getScaleRightWrapped()) { g.translate(canvasWidth - LABEL_EAST, 0); drawEastScale(g, startRes, endx, ypos); @@ -440,11 +452,11 @@ public class SeqCanvas extends Panel g.translate(LABEL_WEST, 0); - if (av.scaleAboveWrapped) + if (av.getScaleAboveWrapped()) { drawNorthScale(g, startRes, endx, ypos); } - if (av.hasHiddenColumns() && av.showHiddenMarkers) + if (av.hasHiddenColumns() && av.getShowHiddenMarkers()) { g.setColor(Color.blue); int res; @@ -460,24 +472,24 @@ public class SeqCanvas extends Panel } gg.fillPolygon(new int[] - { res * av.charWidth - av.charHeight / 4, - res * av.charWidth + av.charHeight / 4, res * av.charWidth }, + { res * avcharWidth - avcharHeight / 4, + res * avcharWidth + avcharHeight / 4, res * avcharWidth }, new int[] - { ypos - (av.charHeight / 2), ypos - (av.charHeight / 2), - ypos - (av.charHeight / 2) + 8 }, 3); + { ypos - (avcharHeight / 2), ypos - (avcharHeight / 2), + ypos - (avcharHeight / 2) + 8 }, 3); } } if (g.getClip() == null) { - g.setClip(0, 0, cWidth * av.charWidth, canvasHeight); + g.setClip(0, 0, cWidth * avcharWidth, canvasHeight); } drawPanel(g, startRes, endx, 0, al.getHeight(), ypos); g.setClip(null); - if (av.showAnnotation) + if (av.isShowAnnotation()) { g.translate(0, cHeight + ypos + 4); if (annotations == null) @@ -501,7 +513,7 @@ public class SeqCanvas extends Panel int getAnnotationHeight() { - if (!av.showAnnotation) + if (!av.isShowAnnotation()) { return 0; } @@ -514,7 +526,8 @@ public class SeqCanvas extends Panel return annotations.adjustPanelHeight(); } - void drawPanel(Graphics g1, int startRes, int endRes, int startSeq, + private void drawPanel(Graphics g1, int startRes, int endRes, + int startSeq, int endSeq, int offset) { @@ -545,20 +558,20 @@ public class SeqCanvas extends Panel blockEnd = hideStart - 1; - g1.translate(screenY * av.charWidth, 0); + g1.translate(screenY * avcharWidth, 0); draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); if (av.getShowHiddenMarkers()) { g1.setColor(Color.blue); - g1.drawLine((blockEnd - blockStart + 1) * av.charWidth - 1, - 0 + offset, (blockEnd - blockStart + 1) * av.charWidth - - 1, (endSeq - startSeq) * av.charHeight + g1.drawLine((blockEnd - blockStart + 1) * avcharWidth - 1, + 0 + offset, (blockEnd - blockStart + 1) * avcharWidth + - 1, (endSeq - startSeq) * avcharHeight + offset); } - g1.translate(-screenY * av.charWidth, 0); + g1.translate(-screenY * avcharWidth, 0); screenY += blockEnd - blockStart + 1; blockStart = hideEnd + 1; } @@ -566,10 +579,10 @@ public class SeqCanvas extends Panel if (screenY <= (endRes - startRes)) { blockEnd = blockStart + (endRes - startRes) - screenY; - g1.translate(screenY * av.charWidth, 0); + g1.translate(screenY * avcharWidth, 0); draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); - g1.translate(-screenY * av.charWidth, 0); + g1.translate(-screenY * avcharWidth, 0); } } @@ -581,8 +594,8 @@ public class SeqCanvas extends Panel int offset) { g.setFont(av.getFont()); - sr.prepare(g, av.renderGaps); - + sr.prepare(g, av.isRenderGaps()); + updateViewport(); SequenceI nextSeq; // / First draw the sequences @@ -597,12 +610,12 @@ public class SeqCanvas extends Panel } sr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq), - startRes, endRes, offset + ((i - startSeq) * av.charHeight)); + startRes, endRes, offset + ((i - startSeq) * avcharHeight)); if (av.isShowSequenceFeatures()) { fr.drawSequence(g, nextSeq, startRes, endRes, offset - + ((i - startSeq) * av.charHeight)); + + ((i - startSeq) * avcharHeight)); } // / Highlight search Results once all sequences have been drawn @@ -617,8 +630,8 @@ public class SeqCanvas extends Panel { sr.drawHighlightedText(nextSeq, visibleResults[r], visibleResults[r + 1], (visibleResults[r] - startRes) - * av.charWidth, offset - + ((i - startSeq) * av.charHeight)); + * avcharWidth, offset + + ((i - startSeq) * avcharHeight)); } } } @@ -626,9 +639,8 @@ public class SeqCanvas extends Panel if (av.cursorMode && cursorY == i && cursorX >= startRes && cursorX <= endRes) { - sr.drawCursor(nextSeq, cursorX, - (cursorX - startRes) * av.charWidth, offset - + ((i - startSeq) * av.charHeight)); + sr.drawCursor(nextSeq, cursorX, (cursorX - startRes) * avcharWidth, + offset + ((i - startSeq) * avcharHeight)); } } @@ -640,7 +652,7 @@ public class SeqCanvas extends Panel } - void drawGroupsBoundaries(Graphics g, int startRes, int endRes, + private void drawGroupsBoundaries(Graphics g, int startRes, int endRes, int startSeq, int endSeq, int offset) { // @@ -673,16 +685,16 @@ public class SeqCanvas extends Panel for (i = startSeq; i < endSeq; i++) { - sx = (group.getStartRes() - startRes) * av.charWidth; - sy = offset + ((i - startSeq) * av.charHeight); - ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) - 1; + sx = (group.getStartRes() - startRes) * avcharWidth; + sy = offset + ((i - startSeq) * avcharHeight); + ex = (((group.getEndRes() + 1) - group.getStartRes()) * avcharWidth) - 1; if (sx + ex < 0 || sx > imgWidth) { continue; } - if ((sx <= (endRes - startRes) * av.charWidth) + if ((sx <= (endRes - startRes) * avcharWidth) && group.getSequences(null).contains( av.getAlignment().getSequenceAt(i))) { @@ -691,7 +703,7 @@ public class SeqCanvas extends Panel .contains( av.getAlignment().getSequenceAt(i + 1)))) { - bottom = sy + av.charHeight; + bottom = sy + avcharHeight; } if (!inGroup) @@ -741,9 +753,9 @@ public class SeqCanvas extends Panel ex = imgWidth; } - else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) + else if (sx + ex >= (endRes - startRes + 1) * avcharWidth) { - ex = (endRes - startRes + 1) * av.charWidth; + ex = (endRes - startRes + 1) * avcharWidth; } if (top != -1) @@ -765,7 +777,7 @@ public class SeqCanvas extends Panel if (inGroup) { - sy = offset + ((i - startSeq) * av.charHeight); + sy = offset + ((i - startSeq) * avcharHeight); if (sx >= 0 && sx < imgWidth) { g.drawLine(sx, oldY, sx, sy); @@ -786,9 +798,9 @@ public class SeqCanvas extends Panel { ex = imgWidth; } - else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) + else if (sx + ex >= (endRes - startRes + 1) * avcharWidth) { - ex = (endRes - startRes + 1) * av.charWidth; + ex = (endRes - startRes + 1) * avcharWidth; } if (top != -1) diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index a95dd27..9e0e237 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -212,7 +212,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, } endEditing(); - if (av.wrapAlignment) + if (av.getWrapAlignment()) { ap.scrollToWrappedVisible(seqCanvas.cursorX); } @@ -538,16 +538,17 @@ public class SeqPanel extends Panel implements MouseMotionListener, int res = 0; int x = evt.getX(); - if (av.wrapAlignment) + if (av.getWrapAlignment()) { - int hgap = av.charHeight; - if (av.scaleAboveWrapped) + int hgap = av.getCharHeight(); + if (av.getScaleAboveWrapped()) { - hgap += av.charHeight; + hgap += av.getCharHeight(); } - int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap + int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + + hgap + seqCanvas.getAnnotationHeight(); int y = evt.getY(); @@ -596,15 +597,16 @@ public class SeqPanel extends Panel implements MouseMotionListener, int seq = 0; int y = evt.getY(); - if (av.wrapAlignment) + if (av.getWrapAlignment()) { - int hgap = av.charHeight; - if (av.scaleAboveWrapped) + int hgap = av.getCharHeight(); + if (av.getScaleAboveWrapped()) { - hgap += av.charHeight; + hgap += av.getCharHeight(); } - int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap + int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + + hgap + seqCanvas.getAnnotationHeight(); y -= hgap; @@ -849,7 +851,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, { if (mouseWheelPressed) { - int oldWidth = av.charWidth; + int oldWidth = av.getCharWidth(); // Which is bigger, left-right or up-down? if (Math.abs(evt.getY() - lastMousePress.y) > Math.abs(evt.getX() @@ -857,7 +859,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, { int fontSize = av.font.getSize(); - if (evt.getY() < lastMousePress.y && av.charHeight > 1) + if (evt.getY() < lastMousePress.y && av.getCharHeight() > 1) { fontSize--; } @@ -872,29 +874,29 @@ public class SeqPanel extends Panel implements MouseMotionListener, } av.setFont(new Font(av.font.getName(), av.font.getStyle(), fontSize)); - av.charWidth = oldWidth; + av.setCharWidth(oldWidth); } else { - if (evt.getX() < lastMousePress.x && av.charWidth > 1) + if (evt.getX() < lastMousePress.x && av.getCharWidth() > 1) { - av.charWidth--; + av.setCharWidth(av.getCharWidth() - 1); } else if (evt.getX() > lastMousePress.x) { - av.charWidth++; + av.setCharWidth(av.getCharWidth() + 1); } - if (av.charWidth < 1) + if (av.getCharWidth() < 1) { - av.charWidth = 1; + av.setCharWidth(1); } } ap.fontChanged(); FontMetrics fm = getFontMetrics(av.getFont()); - av.validCharWidth = fm.charWidth('M') <= av.charWidth; + av.validCharWidth = fm.charWidth('M') <= av.getCharWidth(); lastMousePress = evt.getPoint(); diff --git a/src/jalview/appletgui/SequenceRenderer.java b/src/jalview/appletgui/SequenceRenderer.java index 9badf43..d9a0d2a 100755 --- a/src/jalview/appletgui/SequenceRenderer.java +++ b/src/jalview/appletgui/SequenceRenderer.java @@ -161,7 +161,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer int length = seq.getLength(); int curStart = -1; - int curWidth = av.charWidth; + int curWidth = av.getCharWidth(), avCharWidth = av.getCharWidth(), avCharHeight = av + .getCharHeight(); Color tempColour = null; while (i <= end) @@ -186,40 +187,41 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer { if (tempColour != null) { - graphics.fillRect(av.charWidth * (curStart - start), y1, - curWidth, av.charHeight); + graphics.fillRect(avCharWidth * (curStart - start), y1, curWidth, + avCharHeight); } graphics.setColor(resBoxColour); curStart = i; - curWidth = av.charWidth; + curWidth = avCharWidth; tempColour = resBoxColour; } else { - curWidth += av.charWidth; + curWidth += avCharWidth; } i++; } - graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth, - av.charHeight); + graphics.fillRect(avCharWidth * (curStart - start), y1, curWidth, + avCharHeight); } public void drawText(SequenceI seq, int start, int end, int y1) { + int avCharWidth = av.getCharWidth(), avCharHeight = av.getCharHeight(); Font boldFont = null; boolean bold = false; - if (av.upperCasebold) + if (av.isUpperCasebold()) { - boldFont = new Font(av.getFont().getName(), Font.BOLD, av.charHeight); + boldFont = new Font(av.getFont().getName(), Font.BOLD, avCharHeight); graphics.setFont(av.getFont()); } - y1 += av.charHeight - av.charHeight / 5; // height/5 replaces pady + y1 += avCharHeight - avCharHeight / 5; // height/5 replaces pady int charOffset = 0; @@ -286,7 +288,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } } - if (av.upperCasebold) + if (av.isUpperCasebold()) { fm = graphics.getFontMetrics(); if ('A' <= s && s <= 'Z') @@ -306,8 +308,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } - charOffset = (av.charWidth - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), charOffset + av.charWidth + charOffset = (avCharWidth - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), charOffset + avCharWidth * (i - start), y1); } @@ -350,11 +352,11 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer public void drawHighlightedText(SequenceI seq, int start, int end, int x1, int y1) { - int pady = av.charHeight / 5; + int avCharWidth = av.getCharWidth(), avCharHeight = av.getCharHeight(); + int pady = avCharHeight / 5; int charOffset = 0; graphics.setColor(Color.black); - graphics.fillRect(x1, y1, av.charWidth * (end - start + 1), - av.charHeight); + graphics.fillRect(x1, y1, avCharWidth * (end - start + 1), avCharHeight); graphics.setColor(Color.white); char s = '~'; @@ -368,19 +370,19 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer s = seq.getCharAt(i); } - charOffset = (av.charWidth - fm.charWidth(s)) / 2; + charOffset = (avCharWidth - fm.charWidth(s)) / 2; graphics.drawString(String.valueOf(s), charOffset + x1 - + av.charWidth * (i - start), y1 + av.charHeight - pady); + + avCharWidth * (i - start), y1 + avCharHeight - pady); } } } public void drawCursor(SequenceI seq, int res, int x1, int y1) { - int pady = av.charHeight / 5; + int pady = av.getCharHeight() / 5; int charOffset = 0; graphics.setColor(Color.black); - graphics.fillRect(x1, y1, av.charWidth, av.charHeight); + graphics.fillRect(x1, y1, av.getCharWidth(), av.getCharHeight()); graphics.setColor(Color.white); graphics.setColor(Color.white); @@ -389,9 +391,9 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer if (av.validCharWidth) { - charOffset = (av.charWidth - fm.charWidth(s)) / 2; + charOffset = (av.getCharWidth() - fm.charWidth(s)) / 2; graphics.drawString(String.valueOf(s), charOffset + x1, - (y1 + av.charHeight) - pady); + (y1 + av.getCharHeight()) - pady); } } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 6e3024d..974dbad 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -339,7 +339,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, buildSortByAnnotationScoresMenu(); buildTreeMenu(); - if (viewport.wrapAlignment) + if (viewport.getWrapAlignment()) { wrapMenuItem_actionPerformed(null); } @@ -542,7 +542,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, break; } case KeyEvent.VK_PAGE_UP: - if (viewport.wrapAlignment) + if (viewport.getWrapAlignment()) { alignPanel.scrollUp(true); } @@ -553,7 +553,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } break; case KeyEvent.VK_PAGE_DOWN: - if (viewport.wrapAlignment) + if (viewport.getWrapAlignment()) { alignPanel.scrollUp(false); } @@ -737,17 +737,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, void setMenusFromViewport(AlignViewport av) { padGapsMenuitem.setSelected(av.isPadGaps()); - colourTextMenuItem.setSelected(av.showColourText); + colourTextMenuItem.setSelected(av.isShowColourText()); abovePIDThreshold.setSelected(av.getAbovePIDThreshold()); conservationMenuItem.setSelected(av.getConservationSelected()); seqLimits.setSelected(av.getShowJVSuffix()); idRightAlign.setSelected(av.isRightAlignIds()); centreColumnLabelsMenuItem.setState(av.centreColumnLabels); - renderGapsMenuItem.setSelected(av.renderGaps); - wrapMenuItem.setSelected(av.wrapAlignment); - scaleAbove.setVisible(av.wrapAlignment); - scaleLeft.setVisible(av.wrapAlignment); - scaleRight.setVisible(av.wrapAlignment); + renderGapsMenuItem.setSelected(av.isRenderGaps()); + wrapMenuItem.setSelected(av.getWrapAlignment()); + scaleAbove.setVisible(av.getWrapAlignment()); + scaleLeft.setVisible(av.getWrapAlignment()); + scaleRight.setVisible(av.getWrapAlignment()); annotationPanelMenuItem.setState(av.isShowAnnotation()); /* * Show/hide annotations only enabled if annotation panel is shown @@ -756,8 +756,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, hideAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState()); showAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState()); hideAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState()); - viewBoxesMenuItem.setSelected(av.showBoxes); - viewTextMenuItem.setSelected(av.showText); + viewBoxesMenuItem.setSelected(av.getShowBoxes()); + viewTextMenuItem.setSelected(av.getShowText()); showNonconservedMenuItem.setSelected(av.getShowUnconserved()); showGroupConsensus.setSelected(av.isShowGroupConsensus()); showGroupConservation.setSelected(av.isShowGroupConservation()); @@ -769,7 +769,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, .getGlobalColourScheme())); showSeqFeatures.setSelected(av.isShowSequenceFeatures()); - hiddenMarkers.setState(av.showHiddenMarkers); + hiddenMarkers.setState(av.getShowHiddenMarkers()); applyToAllGroups.setState(av.getColourAppliesToAllGroups()); showNpFeatsMenuitem.setSelected(av.isShowNpFeats()); showDbRefsMenuitem.setSelected(av.isShowDbRefs()); diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 6517e70..0508f44 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -163,9 +163,10 @@ public class AlignmentPanel extends GAlignmentPanel implements // to prevent drawing old image FontMetrics fm = getFontMetrics(av.getFont()); - scalePanelHolder.setPreferredSize(new Dimension(10, av.charHeight + scalePanelHolder.setPreferredSize(new Dimension(10, av.getCharHeight() + fm.getDescent())); - idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av.charHeight + idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av + .getCharHeight() + fm.getDescent())); getIdPanel().getIdCanvas().gg = null; @@ -339,7 +340,7 @@ public class AlignmentPanel extends GAlignmentPanel implements } } } - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { if ((startv = av.getStartRes()) >= start) { @@ -412,7 +413,7 @@ public class AlignmentPanel extends GAlignmentPanel implements */ public void setAnnotationVisible(boolean b) { - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { annotationSpaceFillerHolder.setVisible(b); annotationScroller.setVisible(b); @@ -605,10 +606,11 @@ public class AlignmentPanel extends GAlignmentPanel implements width = av.getColumnSelection().findColumnPosition(width); } - av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av.charWidth)) - 1); + av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av + .getCharWidth())) - 1); - hextent = getSeqPanel().seqCanvas.getWidth() / av.charWidth; - vextent = getSeqPanel().seqCanvas.getHeight() / av.charHeight; + hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth(); + vextent = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight(); if (hextent > width) { @@ -859,7 +861,7 @@ public class AlignmentPanel extends GAlignmentPanel implements { int idWidth = getVisibleIdWidth(false); FontMetrics fm = getFontMetrics(av.getFont()); - int scaleHeight = av.charHeight + fm.getDescent(); + int scaleHeight = av.getCharHeight() + fm.getDescent(); pg.setColor(Color.white); pg.fillRect(0, 0, pwidth, pheight); @@ -949,7 +951,7 @@ public class AlignmentPanel extends GAlignmentPanel implements } pg.setColor(currentColor); - pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth, + pg.fillRect(0, (i - startSeq) * av.getCharHeight(), idWidth, av.getCharHeight()); pg.setColor(currentTextColor); @@ -966,7 +968,7 @@ public class AlignmentPanel extends GAlignmentPanel implements pg.drawString( seq.getDisplayId(av.getShowJVSuffix()), xPos, - (((i - startSeq) * av.charHeight) + av.getCharHeight()) + (((i - startSeq) * av.getCharHeight()) + av.getCharHeight()) - (av.getCharHeight() / 5)); } @@ -981,7 +983,8 @@ public class AlignmentPanel extends GAlignmentPanel implements // draw annotation - need to offset for current scroll position int offset = -getAlabels().getScrollOffset(); pg.translate(0, offset); - pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3); + pg.translate(-idWidth - 3, (endSeq - startSeq) * av.getCharHeight() + + 3); getAlabels().drawComponent(pg, idWidth); pg.translate(idWidth + 3, 0); getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av, @@ -1021,13 +1024,13 @@ public class AlignmentPanel extends GAlignmentPanel implements labels = new AnnotationLabels(av); } - int hgap = av.charHeight; - if (av.scaleAboveWrapped) + int hgap = av.getCharHeight(); + if (av.getScaleAboveWrapped()) { - hgap += av.charHeight; + hgap += av.getCharHeight(); } - int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap + int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + hgap + annotationHeight; int idWidth = getVisibleIdWidth(false); @@ -1071,18 +1074,19 @@ public class AlignmentPanel extends GAlignmentPanel implements xPos = idWidth - fm.stringWidth(string) - 4; } pg.drawString(string, xPos, - ((i * av.charHeight) + ypos + av.charHeight) - - (av.charHeight / 5)); + ((i * av.getCharHeight()) + ypos + av.getCharHeight()) + - (av.getCharHeight() / 5)); } if (labels != null) { pg.translate(-3, ypos - + (av.getAlignment().getHeight() * av.charHeight)); + + (av.getAlignment().getHeight() * av.getCharHeight())); pg.setFont(av.getFont()); labels.drawComponent(pg, idWidth); pg.translate(+3, -ypos - - (av.getAlignment().getHeight() * av.charHeight)); + - (av.getAlignment().getHeight() * av + .getCharHeight())); } ypos += cHeight; @@ -1225,9 +1229,9 @@ public class AlignmentPanel extends GAlignmentPanel implements maxwidth = av.getColumnSelection().findColumnPosition(maxwidth); } - int height = ((av.getAlignment().getHeight() + 1) * av.charHeight) + int height = ((av.getAlignment().getHeight() + 1) * av.getCharHeight()) + getScalePanel().getHeight(); - int width = getVisibleIdWidth(false) + (maxwidth * av.charWidth); + int width = getVisibleIdWidth(false) + (maxwidth * av.getCharWidth()); if (av.getWrapAlignment()) { @@ -1283,7 +1287,7 @@ public class AlignmentPanel extends GAlignmentPanel implements // //////////////////////////////////////////// int idWidth = getVisibleIdWidth(false); FontMetrics fm = getFontMetrics(av.getFont()); - int scaleHeight = av.charHeight + fm.getDescent(); + int scaleHeight = av.getCharHeight() + fm.getDescent(); // Gen image map // //////////////////////////////// @@ -1302,7 +1306,7 @@ public class AlignmentPanel extends GAlignmentPanel implements for (s = 0; s < sSize; s++) { - sy = s * av.charHeight + scaleHeight; + sy = s * av.getCharHeight() + scaleHeight; SequenceI seq = av.getAlignment().getSequenceAt(s); SequenceFeature[] features = seq.getDatasetSequence() @@ -1336,9 +1340,10 @@ public class AlignmentPanel extends GAlignmentPanel implements if (text.length() < 1) { text.append(" 20) { @@ -1122,7 +1122,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, dragEvent.getY() - getScrollOffset()); } - if (!av.wrapAlignment && ((aa == null) || (aa.length < 1))) + if (!av.getWrapAlignment() && ((aa == null) || (aa.length < 1))) { g.drawString(MessageManager.getString("label.right_click"), 2, 8); g.drawString(MessageManager.getString("label.to_add_annotation"), 2, diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 3a97f96..8733459 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -757,10 +757,10 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, public void drawCursor(Graphics graphics, SequenceI seq, int res, int x1, int y1) { - int pady = av.charHeight / 5; + int pady = av.getCharHeight() / 5; int charOffset = 0; graphics.setColor(Color.black); - graphics.fillRect(x1, y1, av.charWidth, av.charHeight); + graphics.fillRect(x1, y1, av.getCharWidth(), av.getCharHeight()); if (av.validCharWidth) { @@ -768,9 +768,9 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, char s = seq.getCharAt(res); - charOffset = (av.charWidth - fm.charWidth(s)) / 2; + charOffset = (av.getCharWidth() - fm.charWidth(s)) / 2; graphics.drawString(String.valueOf(s), charOffset + x1, - (y1 + av.charHeight) - pady); + (y1 + av.getCharHeight()) - pady); } } @@ -799,7 +799,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, return; } } - imgWidth = (av.endRes - av.startRes + 1) * av.charWidth; + imgWidth = (av.endRes - av.startRes + 1) * av.getCharWidth(); if (imgWidth < 1) { return; @@ -867,7 +867,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, return; } long stime = System.currentTimeMillis(); - gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.charWidth, 0); + gg.copyArea(0, 0, imgWidth, getHeight(), + -horizontal * av.getCharWidth(), 0); long mtime = System.currentTimeMillis(); int sr = av.startRes; int er = av.endRes + 1; @@ -875,7 +876,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (horizontal > 0) // scrollbar pulled right, image to the left { - transX = (er - sr - horizontal) * av.charWidth; + transX = (er - sr - horizontal) * av.getCharWidth(); sr = er - horizontal; } else if (horizontal < 0) @@ -960,7 +961,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } g.setColor(Color.white); - g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight()); + g.fillRect(0, 0, (endRes - startRes) * av.getCharWidth(), getHeight()); g.setFont(av.getFont()); if (fm == null) diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index 3bc3168..5801423 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -94,7 +94,7 @@ public class IdCanvas extends JPanel { int xPos = 0; int panelWidth = getWidth(); - int charHeight = av.charHeight; + int charHeight = av.getCharHeight(); if ((searchResults != null) && searchResults.contains(s)) { @@ -128,7 +128,7 @@ public class IdCanvas extends JPanel gg.drawString(s.getDisplayId(av.getShowJVSuffix()), xPos, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); - if (av.hasHiddenRows() && av.showHiddenMarkers) + if (av.hasHiddenRows() && av.getShowHiddenMarkers()) { drawMarker(i, starty, ypos); } @@ -150,7 +150,8 @@ public class IdCanvas extends JPanel return; } - gg.copyArea(0, 0, getWidth(), imgHeight, 0, -vertical * av.charHeight); + gg.copyArea(0, 0, getWidth(), imgHeight, 0, + -vertical * av.getCharHeight()); int ss = av.startSeq; int es = av.endSeq; @@ -166,7 +167,7 @@ public class IdCanvas extends JPanel } else { - transY = imgHeight - (vertical * av.charHeight); + transY = imgHeight - (vertical * av.getCharHeight()); } } else if (vertical < 0) @@ -211,7 +212,7 @@ public class IdCanvas extends JPanel int oldHeight = imgHeight; imgHeight = getHeight(); - imgHeight -= (imgHeight % av.charHeight); + imgHeight -= (imgHeight % av.getCharHeight()); if (imgHeight < 1) { @@ -245,7 +246,7 @@ public class IdCanvas extends JPanel */ void drawIds(int starty, int endy) { - if (av.seqNameItalics) + if (av.isSeqNameItalics()) { setIdfont(new Font(av.getFont().getName(), Font.ITALIC, av.getFont() .getSize())); @@ -293,13 +294,13 @@ public class IdCanvas extends JPanel } } - int hgap = av.charHeight; - if (av.scaleAboveWrapped) + int hgap = av.getCharHeight(); + if (av.getScaleAboveWrapped()) { - hgap += av.charHeight; + hgap += av.getCharHeight(); } - int cHeight = alheight * av.charHeight + hgap + annotationHeight; + int cHeight = alheight * av.getCharHeight() + hgap + annotationHeight; int rowSize = av.getEndRes() - av.getStartRes(); @@ -324,9 +325,9 @@ public class IdCanvas extends JPanel if (labels != null && av.isShowAnnotation()) { - gg.translate(0, ypos + (alheight * av.charHeight)); + gg.translate(0, ypos + (alheight * av.getCharHeight())); labels.drawComponent(gg, getWidth()); - gg.translate(0, -ypos - (alheight * av.charHeight)); + gg.translate(0, -ypos - (alheight * av.getCharHeight())); } } } @@ -376,8 +377,8 @@ public class IdCanvas extends JPanel gg.setColor(currentColor); - gg.fillRect(0, (i - starty) * av.charHeight, getWidth(), - av.charHeight); + gg.fillRect(0, (i - starty) * av.getCharHeight(), getWidth(), + av.getCharHeight()); gg.setColor(currentTextColor); @@ -389,10 +390,10 @@ public class IdCanvas extends JPanel } gg.drawString(string, xPos, - (((i - starty) * av.charHeight) + av.charHeight) - - (av.charHeight / 5)); + (((i - starty) * av.getCharHeight()) + av.getCharHeight()) + - (av.getCharHeight() / 5)); - if (av.hasHiddenRows() && av.showHiddenMarkers) + if (av.hasHiddenRows() && av.getShowHiddenMarkers()) { drawMarker(i, starty, 0); } @@ -441,24 +442,27 @@ public class IdCanvas extends JPanel { gg.fillPolygon( new int[] - { getWidth() - av.charHeight, getWidth() - av.charHeight, + { getWidth() - av.getCharHeight(), + getWidth() - av.getCharHeight(), getWidth() }, new int[] { - (i - starty) * av.charHeight + yoffset, - (i - starty) * av.charHeight + yoffset + av.charHeight - / 4, (i - starty) * av.charHeight + yoffset }, 3); + (i - starty) * av.getCharHeight() + yoffset, + (i - starty) * av.getCharHeight() + yoffset + + av.getCharHeight() / 4, + (i - starty) * av.getCharHeight() + yoffset }, 3); } if (above) { gg.fillPolygon( new int[] - { getWidth() - av.charHeight, getWidth() - av.charHeight, + { getWidth() - av.getCharHeight(), + getWidth() - av.getCharHeight(), getWidth() }, new int[] { - (i - starty + 1) * av.charHeight + yoffset, - (i - starty + 1) * av.charHeight + yoffset - - av.charHeight / 4, - (i - starty + 1) * av.charHeight + yoffset }, 3); + (i - starty + 1) * av.getCharHeight() + yoffset, + (i - starty + 1) * av.getCharHeight() + yoffset + - av.getCharHeight() / 4, + (i - starty + 1) * av.getCharHeight() + yoffset }, 3); } } diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index a2cd147..ce2dd81 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -1097,7 +1097,7 @@ public class Jalview2XML view.setFontName(av.font.getName()); view.setFontSize(av.font.getSize()); view.setFontStyle(av.font.getStyle()); - view.setRenderGaps(av.renderGaps); + view.setRenderGaps(av.isRenderGaps()); view.setShowAnnotation(av.isShowAnnotation()); view.setShowBoxes(av.getShowBoxes()); view.setShowColourText(av.getColourText()); @@ -1107,9 +1107,9 @@ public class Jalview2XML view.setShowText(av.getShowText()); view.setShowUnconserved(av.getShowUnconserved()); view.setWrapAlignment(av.getWrapAlignment()); - view.setTextCol1(av.textColour.getRGB()); - view.setTextCol2(av.textColour2.getRGB()); - view.setTextColThreshold(av.thresholdTextColour); + view.setTextCol1(av.getTextColour().getRGB()); + view.setTextCol2(av.getTextColour2().getRGB()); + view.setTextColThreshold(av.getThresholdTextColour()); view.setShowConsensusHistogram(av.isShowConsensusHistogram()); view.setShowSequenceLogo(av.isShowSequenceLogo()); view.setNormaliseSequenceLogo(av.isNormaliseSequenceLogo()); @@ -3695,9 +3695,9 @@ public class Jalview2XML af.viewport.setShowText(view.getShowText()); - af.viewport.textColour = new java.awt.Color(view.getTextCol1()); - af.viewport.textColour2 = new java.awt.Color(view.getTextCol2()); - af.viewport.thresholdTextColour = view.getTextColThreshold(); + af.viewport.setTextColour(new java.awt.Color(view.getTextCol1())); + af.viewport.setTextColour2(new java.awt.Color(view.getTextCol2())); + af.viewport.setThresholdTextColour(view.getTextColThreshold()); af.viewport.setShowUnconserved(view.hasShowUnconserved() ? view .isShowUnconserved() : false); af.viewport.setStartRes(view.getStartRes()); diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 5df60d2..c30fcd6 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -135,7 +135,7 @@ public class OverviewPanel extends JPanel implements Runnable @Override public void mouseDragged(MouseEvent evt) { - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { // TODO: feature: jv2.5 detect shift drag and update selection from // it. @@ -151,7 +151,7 @@ public class OverviewPanel extends JPanel implements Runnable @Override public void mousePressed(MouseEvent evt) { - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { boxX = evt.getX(); boxY = evt.getY(); diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 32773b9..21160ef 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -423,6 +423,8 @@ public class ScalePanel extends JPanel implements MouseMotionListener, // Fill the selected columns ColumnSelection cs = av.getColumnSelection(); + int avCharWidth = av.getCharWidth(), avCharHeight = av.getCharHeight(); + int s; if (cs != null) { @@ -445,7 +447,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, if ((sel >= startx) && (sel <= endx)) { - gg.fillRect((sel - startx) * av.charWidth, 0, av.charWidth, + gg.fillRect((sel - startx) * avCharWidth, 0, avCharWidth, getHeight()); } } @@ -456,7 +458,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, int scalestartx = (startx / 10) * 10; FontMetrics fm = gg.getFontMetrics(av.getFont()); - int y = av.charHeight - fm.getDescent(); + int y = avCharHeight - fm.getDescent(); if ((scalestartx % 10) == 0) { @@ -472,25 +474,26 @@ public class ScalePanel extends JPanel implements MouseMotionListener, { string = String.valueOf(av.getColumnSelection() .adjustForHiddenColumns(i)); - if ((i - startx - 1) * av.charWidth > maxX) + if ((i - startx - 1) * avCharWidth > maxX) { - gg.drawString(string, (i - startx - 1) * av.charWidth, y); - maxX = (i - startx + 1) * av.charWidth + fm.stringWidth(string); + gg.drawString(string, (i - startx - 1) * avCharWidth, y); + maxX = (i - startx + 1) * avCharWidth + fm.stringWidth(string); } gg.drawLine( - ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), +((i - startx - 1) * avCharWidth) + (avCharWidth / 2), y + 2, - ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), + ((i - startx - 1) * avCharWidth) + (avCharWidth / 2), y + (fm.getDescent() * 2)); } else { gg.drawLine( - ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), +((i - startx - 1) * avCharWidth) + (avCharWidth / 2), y + fm.getDescent(), - ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), + ((i - startx - 1) * avCharWidth) + + (avCharWidth / 2), y + (fm.getDescent() * 2)); } } @@ -515,10 +518,10 @@ public class ScalePanel extends JPanel implements MouseMotionListener, } gg.fillPolygon(new int[] - { res * av.charWidth - av.charHeight / 4, - res * av.charWidth + av.charHeight / 4, res * av.charWidth }, + { res * avCharWidth - avCharHeight / 4, + res * avCharWidth + avCharHeight / 4, res * avCharWidth }, new int[] - { y - av.charHeight / 2, y - av.charHeight / 2, y + 8 }, + { y - avCharHeight / 2, y - avCharHeight / 2, y + 8 }, 3); } @@ -527,7 +530,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, if (reveal != null && reveal[0] > startx && reveal[0] < endx) { gg.drawString(MessageManager.getString("label.reveal_columns"), - reveal[0] * av.charWidth, 0); + reveal[0] * avCharWidth, 0); } } diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 5032f69..6080cf5 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -81,6 +81,7 @@ public class SeqCanvas extends JComponent public SeqCanvas(AlignmentPanel ap) { this.av = ap.av; + updateViewport(); fr = new FeatureRenderer(ap); sr = new SequenceRenderer(av); setLayout(new BorderLayout()); @@ -98,6 +99,13 @@ public class SeqCanvas extends JComponent return fr; } + int charHeight = 0, charWidth = 0; + + private void updateViewport() + { + charHeight = av.getCharHeight(); + charWidth = av.getCharWidth(); + } /** * DOCUMENT ME! * @@ -110,12 +118,12 @@ public class SeqCanvas extends JComponent * @param ypos * DOCUMENT ME! */ - void drawNorthScale(Graphics g, int startx, int endx, int ypos) + private void drawNorthScale(Graphics g, int startx, int endx, int ypos) { + updateViewport(); int scalestartx = startx - (startx % 10) + 10; g.setColor(Color.black); - // NORTH SCALE for (int i = scalestartx; i < endx; i += 10) { @@ -125,12 +133,12 @@ public class SeqCanvas extends JComponent value = av.getColumnSelection().adjustForHiddenColumns(value); } - g.drawString(String.valueOf(value), (i - startx - 1) * av.charWidth, - ypos - (av.charHeight / 2)); + g.drawString(String.valueOf(value), (i - startx - 1) * charWidth, + ypos - (charHeight / 2)); - g.drawLine(((i - startx - 1) * av.charWidth) + (av.charWidth / 2), - (ypos + 2) - (av.charHeight / 2), - ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), + g.drawLine(((i - startx - 1) * charWidth) + (charWidth / 2), + (ypos + 2) - (charHeight / 2), ((i - startx - 1) * charWidth) + + (charWidth / 2), ypos - 2); } } @@ -150,7 +158,7 @@ public class SeqCanvas extends JComponent void drawWestScale(Graphics g, int startx, int endx, int ypos) { FontMetrics fm = getFontMetrics(av.getFont()); - ypos += av.charHeight; + ypos += charHeight; if (av.hasHiddenColumns()) { @@ -188,9 +196,9 @@ public class SeqCanvas extends JComponent if (value != -1) { int x = LABEL_WEST - fm.stringWidth(String.valueOf(value)) - - av.charWidth / 2; - g.drawString(value + "", x, (ypos + (i * av.charHeight)) - - (av.charHeight / 5)); + - charWidth / 2; + g.drawString(value + "", x, (ypos + (i * charHeight)) + - (charHeight / 5)); } } } @@ -209,7 +217,7 @@ public class SeqCanvas extends JComponent */ void drawEastScale(Graphics g, int startx, int endx, int ypos) { - ypos += av.charHeight; + ypos += charHeight; if (av.hasHiddenColumns()) { @@ -240,8 +248,8 @@ public class SeqCanvas extends JComponent if (value != -1) { - g.drawString(String.valueOf(value), 0, (ypos + (i * av.charHeight)) - - (av.charHeight / 5)); + g.drawString(String.valueOf(value), 0, (ypos + (i * charHeight)) + - (charHeight / 5)); } } } @@ -265,10 +273,9 @@ public class SeqCanvas extends JComponent } fastpainting = true; fastPaint = true; - - gg.copyArea(horizontal * av.charWidth, vertical * av.charHeight, - imgWidth, imgHeight, -horizontal * av.charWidth, -vertical - * av.charHeight); + updateViewport(); + gg.copyArea(horizontal * charWidth, vertical * charHeight, imgWidth, + imgHeight, -horizontal * charWidth, -vertical * charHeight); int sr = av.startRes; int er = av.endRes; @@ -280,7 +287,7 @@ public class SeqCanvas extends JComponent if (horizontal > 0) // scrollbar pulled right, image to the left { er++; - transX = (er - sr - horizontal) * av.charWidth; + transX = (er - sr - horizontal) * charWidth; sr = er - horizontal; } else if (horizontal < 0) @@ -297,7 +304,7 @@ public class SeqCanvas extends JComponent } else { - transY = imgHeight - (vertical * av.charHeight); + transY = imgHeight - (vertical * charHeight); } } else if (vertical < 0) @@ -330,6 +337,7 @@ public class SeqCanvas extends JComponent // Set this to false to force a full panel paint public void paintComponent(Graphics g) { + updateViewport(); BufferedImage lcimg = img; // take reference since other threads may null // img and call later. super.paintComponent(g); @@ -348,8 +356,8 @@ public class SeqCanvas extends JComponent imgWidth = getWidth(); imgHeight = getHeight(); - imgWidth -= (imgWidth % av.charWidth); - imgHeight -= (imgHeight % av.charHeight); + imgWidth -= (imgWidth % charWidth); + imgHeight -= (imgHeight % charHeight); if ((imgWidth < 1) || (imgHeight < 1)) { @@ -412,17 +420,17 @@ public class SeqCanvas extends JComponent LABEL_EAST = 0; LABEL_WEST = 0; - if (av.scaleRightWrapped) + if (av.getScaleRightWrapped()) { LABEL_EAST = fm.stringWidth(getMask()); } - if (av.scaleLeftWrapped) + if (av.getScaleLeftWrapped()) { LABEL_WEST = fm.stringWidth(getMask()); } - return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth; + return (cwidth - LABEL_EAST - LABEL_WEST) / charWidth; } /** @@ -466,28 +474,29 @@ public class SeqCanvas extends JComponent public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, int startRes) { + updateViewport(); AlignmentI al = av.getAlignment(); FontMetrics fm = getFontMetrics(av.getFont()); - if (av.scaleRightWrapped) + if (av.getScaleRightWrapped()) { LABEL_EAST = fm.stringWidth(getMask()); } - if (av.scaleLeftWrapped) + if (av.getScaleLeftWrapped()) { LABEL_WEST = fm.stringWidth(getMask()); } - int hgap = av.charHeight; - if (av.scaleAboveWrapped) + int hgap = charHeight; + if (av.getScaleAboveWrapped()) { - hgap += av.charHeight; + hgap += charHeight; } - int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth; - int cHeight = av.getAlignment().getHeight() * av.charHeight; + int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / charWidth; + int cHeight = av.getAlignment().getHeight() * charHeight; av.setWrappedWidth(cWidth); @@ -514,12 +523,12 @@ public class SeqCanvas extends JComponent g.setFont(av.getFont()); g.setColor(Color.black); - if (av.scaleLeftWrapped) + if (av.getScaleLeftWrapped()) { drawWestScale(g, startRes, endx, ypos); } - if (av.scaleRightWrapped) + if (av.getScaleRightWrapped()) { g.translate(canvasWidth - LABEL_EAST, 0); drawEastScale(g, startRes, endx, ypos); @@ -528,12 +537,12 @@ public class SeqCanvas extends JComponent g.translate(LABEL_WEST, 0); - if (av.scaleAboveWrapped) + if (av.getScaleAboveWrapped()) { drawNorthScale(g, startRes, endx, ypos); } - if (av.hasHiddenColumns() && av.showHiddenMarkers) + if (av.hasHiddenColumns() && av.getShowHiddenMarkers()) { g.setColor(Color.blue); int res; @@ -549,11 +558,11 @@ public class SeqCanvas extends JComponent } gg.fillPolygon(new int[] - { res * av.charWidth - av.charHeight / 4, - res * av.charWidth + av.charHeight / 4, res * av.charWidth }, + { res * charWidth - charHeight / 4, + res * charWidth + charHeight / 4, res * charWidth }, new int[] - { ypos - (av.charHeight / 2), ypos - (av.charHeight / 2), - ypos - (av.charHeight / 2) + 8 }, 3); + { ypos - (charHeight / 2), ypos - (charHeight / 2), + ypos - (charHeight / 2) + 8 }, 3); } } @@ -564,11 +573,11 @@ public class SeqCanvas extends JComponent if (clip == null) { - g.setClip(0, 0, cWidth * av.charWidth, canvasHeight); + g.setClip(0, 0, cWidth * charWidth, canvasHeight); } else { - g.setClip(0, (int) clip.getBounds().getY(), cWidth * av.charWidth, + g.setClip(0, (int) clip.getBounds().getY(), cWidth * charWidth, (int) clip.getBounds().getHeight()); } @@ -632,6 +641,7 @@ public class SeqCanvas extends JComponent int startSeq, int endSeq, int offset) { + updateViewport(); if (!av.hasHiddenColumns()) { draw(g1, startRes, endRes, startSeq, endSeq, offset); @@ -658,7 +668,7 @@ public class SeqCanvas extends JComponent blockEnd = hideStart - 1; - g1.translate(screenY * av.charWidth, 0); + g1.translate(screenY * charWidth, 0); draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); @@ -666,12 +676,12 @@ public class SeqCanvas extends JComponent { g1.setColor(Color.blue); - g1.drawLine((blockEnd - blockStart + 1) * av.charWidth - 1, - 0 + offset, (blockEnd - blockStart + 1) * av.charWidth - - 1, (endSeq - startSeq) * av.charHeight + offset); + g1.drawLine((blockEnd - blockStart + 1) * charWidth - 1, + 0 + offset, (blockEnd - blockStart + 1) * charWidth - 1, + (endSeq - startSeq) * charHeight + offset); } - g1.translate(-screenY * av.charWidth, 0); + g1.translate(-screenY * charWidth, 0); screenY += blockEnd - blockStart + 1; blockStart = hideEnd + 1; } @@ -679,10 +689,10 @@ public class SeqCanvas extends JComponent if (screenY <= (endRes - startRes)) { blockEnd = blockStart + (endRes - startRes) - screenY; - g1.translate(screenY * av.charWidth, 0); + g1.translate(screenY * charWidth, 0); draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); - g1.translate(-screenY * av.charWidth, 0); + g1.translate(-screenY * charWidth, 0); } } @@ -690,11 +700,12 @@ public class SeqCanvas extends JComponent // int startRes, int endRes, int startSeq, int endSeq, int x, int y, // int x1, int x2, int y1, int y2, int startx, int starty, - void draw(Graphics g, int startRes, int endRes, int startSeq, int endSeq, + private void draw(Graphics g, int startRes, int endRes, int startSeq, + int endSeq, int offset) { g.setFont(av.getFont()); - sr.prepare(g, av.renderGaps); + sr.prepare(g, av.isRenderGaps()); SequenceI nextSeq; @@ -710,12 +721,12 @@ public class SeqCanvas extends JComponent continue; } sr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq), - startRes, endRes, offset + ((i - startSeq) * av.charHeight)); + startRes, endRes, offset + ((i - startSeq) * charHeight)); if (av.isShowSequenceFeatures()) { fr.drawSequence(g, nextSeq, startRes, endRes, offset - + ((i - startSeq) * av.charHeight)); + + ((i - startSeq) * charHeight)); } // / Highlight search Results once all sequences have been drawn @@ -730,8 +741,8 @@ public class SeqCanvas extends JComponent { sr.drawHighlightedText(nextSeq, visibleResults[r], visibleResults[r + 1], (visibleResults[r] - startRes) - * av.charWidth, offset - + ((i - startSeq) * av.charHeight)); + * charWidth, offset + + ((i - startSeq) * charHeight)); } } } @@ -739,9 +750,8 @@ public class SeqCanvas extends JComponent if (av.cursorMode && cursorY == i && cursorX >= startRes && cursorX <= endRes) { - sr.drawCursor(nextSeq, cursorX, - (cursorX - startRes) * av.charWidth, offset - + ((i - startSeq) * av.charHeight)); + sr.drawCursor(nextSeq, cursorX, (cursorX - startRes) * charWidth, + offset + ((i - startSeq) * charHeight)); } } @@ -767,7 +777,7 @@ public class SeqCanvas extends JComponent int sy = -1; int ex = -1; int groupIndex = -1; - int visWidth = (endRes - startRes + 1) * av.charWidth; + int visWidth = (endRes - startRes + 1) * charWidth; if ((group == null) && (av.getAlignment().getGroups().size() > 0)) { @@ -787,16 +797,16 @@ public class SeqCanvas extends JComponent for (i = startSeq; i < endSeq; i++) { - sx = (group.getStartRes() - startRes) * av.charWidth; - sy = offset + ((i - startSeq) * av.charHeight); - ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) - 1; + sx = (group.getStartRes() - startRes) * charWidth; + sy = offset + ((i - startSeq) * charHeight); + ex = (((group.getEndRes() + 1) - group.getStartRes()) * charWidth) - 1; if (sx + ex < 0 || sx > visWidth) { continue; } - if ((sx <= (endRes - startRes) * av.charWidth) + if ((sx <= (endRes - startRes) * charWidth) && group.getSequences(null).contains( av.getAlignment().getSequenceAt(i))) { @@ -804,7 +814,7 @@ public class SeqCanvas extends JComponent && !group.getSequences(null).contains( av.getAlignment().getSequenceAt(i + 1))) { - bottom = sy + av.charHeight; + bottom = sy + charHeight; } if (!inGroup) @@ -858,9 +868,9 @@ public class SeqCanvas extends JComponent ex = visWidth; } - else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) + else if (sx + ex >= (endRes - startRes + 1) * charWidth) { - ex = (endRes - startRes + 1) * av.charWidth; + ex = (endRes - startRes + 1) * charWidth; } if (top != -1) @@ -882,7 +892,7 @@ public class SeqCanvas extends JComponent if (inGroup) { - sy = offset + ((i - startSeq) * av.charHeight); + sy = offset + ((i - startSeq) * charHeight); if (sx >= 0 && sx < visWidth) { g.drawLine(sx, oldY, sx, sy); @@ -903,9 +913,9 @@ public class SeqCanvas extends JComponent { ex = visWidth; } - else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) + else if (sx + ex >= (endRes - startRes + 1) * charWidth) { - ex = (endRes - startRes + 1) * av.charWidth; + ex = (endRes - startRes + 1) * charWidth; } if (top != -1) diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 7c6a202..4a43798 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -165,16 +165,17 @@ public class SeqPanel extends JPanel implements MouseListener, int res = 0; int x = evt.getX(); - if (av.wrapAlignment) + if (av.getWrapAlignment()) { - int hgap = av.charHeight; - if (av.scaleAboveWrapped) + int hgap = av.getCharHeight(); + if (av.getScaleAboveWrapped()) { - hgap += av.charHeight; + hgap += av.getCharHeight(); } - int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap + int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + + hgap + seqCanvas.getAnnotationHeight(); int y = evt.getY(); @@ -218,15 +219,16 @@ public class SeqPanel extends JPanel implements MouseListener, int seq = 0; int y = evt.getY(); - if (av.wrapAlignment) + if (av.getWrapAlignment()) { - int hgap = av.charHeight; - if (av.scaleAboveWrapped) + int hgap = av.getCharHeight(); + if (av.getScaleAboveWrapped()) { - hgap += av.charHeight; + hgap += av.getCharHeight(); } - int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap + int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + + hgap + seqCanvas.getAnnotationHeight(); y -= hgap; @@ -342,7 +344,7 @@ public class SeqPanel extends JPanel implements MouseListener, } endEditing(); - if (av.wrapAlignment) + if (av.getWrapAlignment()) { ap.scrollToWrappedVisible(seqCanvas.cursorX); } @@ -356,7 +358,7 @@ public class SeqPanel extends JPanel implements MouseListener, { ap.scrollUp(false); } - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { while (seqCanvas.cursorX < av.getColumnSelection() .adjustForHiddenColumns(av.startRes)) @@ -820,7 +822,7 @@ public class SeqPanel extends JPanel implements MouseListener, { if (mouseWheelPressed) { - int oldWidth = av.charWidth; + int oldWidth = av.getCharWidth(); // Which is bigger, left-right or up-down? if (Math.abs(evt.getY() - lastMousePress.getY()) > Math.abs(evt @@ -843,25 +845,25 @@ public class SeqPanel extends JPanel implements MouseListener, } av.setFont(new Font(av.font.getName(), av.font.getStyle(), fontSize)); - av.charWidth = oldWidth; + av.setCharWidth(oldWidth); ap.fontChanged(); } else { - if (evt.getX() < lastMousePress.getX() && av.charWidth > 1) + if (evt.getX() < lastMousePress.getX() && av.getCharWidth() > 1) { - av.charWidth--; + av.setCharWidth(av.getCharWidth() - 1); } else if (evt.getX() > lastMousePress.getX()) { - av.charWidth++; + av.setCharWidth(av.getCharWidth() + 1); } ap.paintAlignment(false); } FontMetrics fm = getFontMetrics(av.getFont()); - av.validCharWidth = fm.charWidth('M') <= av.charWidth; + av.validCharWidth = fm.charWidth('M') <= av.getCharWidth(); lastMousePress = evt.getPoint(); @@ -1416,7 +1418,7 @@ public class SeqPanel extends JPanel implements MouseListener, startWrapBlock = wrappedBlock; - if (av.wrapAlignment && seq > av.getAlignment().getHeight()) + if (av.getWrapAlignment() && seq > av.getAlignment().getHeight()) { JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager .getString("label.cannot_edit_annotations_in_wrapped_view"), diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index 438ef00..767858d 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -81,7 +81,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer // If EPS graphics, stringWidth will be a double, not an int double dwidth = fm.getStringBounds("M", g).getWidth(); - monospacedFont = (dwidth == fm.getStringBounds("|", g).getWidth() && av.charWidth == dwidth); + monospacedFont = (dwidth == fm.getStringBounds("|", g).getWidth() && av + .getCharWidth() == dwidth); this.renderGaps = renderGaps; } @@ -222,7 +223,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer int length = seq.getLength(); int curStart = -1; - int curWidth = av.charWidth; + int curWidth = av.getCharWidth(), avWidth = av.getCharWidth(), avHeight = av + .getCharHeight(); Color tempColour = null; @@ -250,26 +252,25 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer { if (tempColour != null) { - graphics.fillRect(av.charWidth * (curStart - start), y1, - curWidth, av.charHeight); + graphics.fillRect(avWidth * (curStart - start), y1, curWidth, + avHeight); } graphics.setColor(resBoxColour); curStart = i; - curWidth = av.charWidth; + curWidth = avWidth; tempColour = resBoxColour; } else { - curWidth += av.charWidth; + curWidth += avWidth; } i++; } - graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth, - av.charHeight); + graphics.fillRect(avWidth * (curStart - start), y1, curWidth, avHeight); } @@ -293,7 +294,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer */ public void drawText(SequenceI seq, int start, int end, int y1) { - y1 += av.charHeight - av.charHeight / 5; // height/5 replaces pady + y1 += av.getCharHeight() - av.getCharHeight() / 5; // height/5 replaces pady int charOffset = 0; char s; @@ -301,12 +302,12 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer { end = seq.getLength() - 1; } - graphics.setColor(av.textColour); + graphics.setColor(av.getTextColour()); - if (monospacedFont && av.showText && allGroups.length == 0 - && !av.getColourText() && av.thresholdTextColour == 0) + if (monospacedFont && av.getShowText() && allGroups.length == 0 + && !av.getColourText() && av.getThresholdTextColour() == 0) { - if (av.renderGaps) + if (av.isRenderGaps()) { graphics.drawString(seq.getSequenceAsString(start, end + 1), 0, y1); } @@ -323,7 +324,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer boolean getboxColour = false; for (int i = start; i <= end; i++) { - graphics.setColor(av.textColour); + graphics.setColor(av.getTextColour()); getboxColour = false; s = seq.getCharAt(i); if (!renderGaps && jalview.util.Comparison.isGap(s)) @@ -393,7 +394,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } } - if (av.thresholdTextColour > 0) + if (av.getThresholdTextColour() > 0) { if (!getboxColour) { @@ -401,9 +402,9 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } if (resBoxColour.getRed() + resBoxColour.getBlue() - + resBoxColour.getGreen() < av.thresholdTextColour) + + resBoxColour.getGreen() < av.getThresholdTextColour()) { - graphics.setColor(av.textColour2); + graphics.setColor(av.getTextColour2()); } } if (av.getShowUnconserved()) @@ -415,8 +416,9 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } - charOffset = (av.charWidth - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), charOffset + av.charWidth + charOffset = (av.getCharWidth() - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), + charOffset + av.getCharWidth() * (i - start), y1); } @@ -487,11 +489,11 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer public void drawHighlightedText(SequenceI seq, int start, int end, int x1, int y1) { - int pady = av.charHeight / 5; + int pady = av.getCharHeight() / 5; int charOffset = 0; graphics.setColor(Color.BLACK); - graphics.fillRect(x1, y1, av.charWidth * (end - start + 1), - av.charHeight); + graphics.fillRect(x1, y1, av.getCharWidth() * (end - start + 1), + av.getCharHeight()); graphics.setColor(Color.white); char s = '~'; @@ -506,19 +508,20 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer s = seq.getCharAt(i); } - charOffset = (av.charWidth - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), charOffset + x1 - + (av.charWidth * (i - start)), (y1 + av.charHeight) - pady); + charOffset = (av.getCharWidth() - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), + charOffset + x1 + (av.getCharWidth() * (i - start)), + (y1 + av.getCharHeight()) - pady); } } } public void drawCursor(SequenceI seq, int res, int x1, int y1) { - int pady = av.charHeight / 5; + int pady = av.getCharHeight() / 5; int charOffset = 0; graphics.setColor(Color.black); - graphics.fillRect(x1, y1, av.charWidth, av.charHeight); + graphics.fillRect(x1, y1, av.getCharWidth(), av.getCharHeight()); if (av.validCharWidth) { @@ -526,9 +529,9 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer char s = seq.getCharAt(res); - charOffset = (av.charWidth - fm.charWidth(s)) / 2; + charOffset = (av.getCharWidth() - fm.charWidth(s)) / 2; graphics.drawString(String.valueOf(s), charOffset + x1, - (y1 + av.charHeight) - pady); + (y1 + av.getCharHeight()) - pady); } } diff --git a/src/jalview/gui/TextColourChooser.java b/src/jalview/gui/TextColourChooser.java index 4315e0b..75b4c67 100644 --- a/src/jalview/gui/TextColourChooser.java +++ b/src/jalview/gui/TextColourChooser.java @@ -42,9 +42,9 @@ public class TextColourChooser int original1, original2, originalThreshold; if (sg == null) { - original1 = ap.av.textColour.getRGB(); - original2 = ap.av.textColour2.getRGB(); - originalThreshold = ap.av.thresholdTextColour; + original1 = ap.av.getTextColour().getRGB(); + original2 = ap.av.getTextColour2().getRGB(); + originalThreshold = ap.av.getThresholdTextColour(); } else { @@ -119,9 +119,9 @@ public class TextColourChooser { if (sg == null) { - ap.av.textColour = new Color(original1); - ap.av.textColour2 = new Color(original2); - ap.av.thresholdTextColour = originalThreshold; + ap.av.setTextColour(new Color(original1)); + ap.av.setTextColour2(new Color(original2)); + ap.av.setThresholdTextColour(originalThreshold); } else { @@ -136,7 +136,7 @@ public class TextColourChooser { if (sg == null) { - ap.av.textColour = col; + ap.av.setTextColour(col); if (ap.av.getColourAppliesToAllGroups()) { setGroupTextColour(); @@ -154,7 +154,7 @@ public class TextColourChooser { if (sg == null) { - ap.av.textColour2 = col; + ap.av.setTextColour2(col); if (ap.av.getColourAppliesToAllGroups()) { setGroupTextColour(); @@ -172,7 +172,7 @@ public class TextColourChooser { if (sg == null) { - ap.av.thresholdTextColour = value; + ap.av.setThresholdTextColour(value); if (ap.av.getColourAppliesToAllGroups()) { setGroupTextColour(); @@ -195,9 +195,9 @@ public class TextColourChooser for (SequenceGroup sg : ap.av.getAlignment().getGroups()) { - sg.textColour = ap.av.textColour; - sg.textColour2 = ap.av.textColour2; - sg.thresholdTextColour = ap.av.thresholdTextColour; + sg.textColour = ap.av.getTextColour(); + sg.textColour2 = ap.av.getTextColour2(); + sg.thresholdTextColour = ap.av.getThresholdTextColour(); } }