From: kiramt Date: Fri, 21 Apr 2017 11:21:23 +0000 (+0100) Subject: JAL-2388 Tidies X-Git-Tag: Release_2_10_2~3^2~92^2~16 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=fb8c1854eae188200a5815dd097484cc6beaa434;p=jalview.git JAL-2388 Tidies --- diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java index e4c2056..5005f4e 100644 --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@ -31,7 +31,6 @@ import java.awt.image.BufferedImage; import javax.swing.JComponent; - public class OverviewCanvas extends JComponent { private static final Color TRANS_GREY = new Color(100, 100, 100, 25); @@ -52,9 +51,9 @@ public class OverviewCanvas extends JComponent private jalview.renderer.seqfeatures.FeatureRenderer fr; - OverviewDimensions od; + private OverviewDimensions od; - AlignViewportI av; + private AlignViewportI av; public OverviewCanvas(OverviewDimensions overviewDims, AlignViewportI alignvp) @@ -68,14 +67,20 @@ public class OverviewCanvas extends JComponent fr = new jalview.renderer.seqfeatures.FeatureRenderer(av); } + /** + * Update the overview dimensions object used by the canvas (e.g. if we change + * from showing hidden columns to hiding them or vice versa) + * + * @param overviewDims + */ public void resetOviewDims(OverviewDimensions overviewDims) { od = overviewDims; } - /* - * Signals to drawing code that the associated alignment viewport - * has changed and a redraw will be required + /** + * Signals to drawing code that the associated alignment viewport has changed + * and a redraw will be required */ public boolean restartDraw() { @@ -93,6 +98,16 @@ public class OverviewCanvas extends JComponent } } + /** + * Draw the overview sequences + * + * @param showSequenceFeatures + * true if sequence features are to be shown + * @param showAnnotation + * true if the annotation is to be shown + * @param transferRenderer + * the renderer to transfer feature colouring from + */ public void draw(boolean showSequenceFeatures, boolean showAnnotation, FeatureRenderer transferRenderer) { diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 8a416bd..ca09331 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -158,13 +158,16 @@ public class OverviewPanel extends JPanel implements Runnable toggleHiddenColumns(); } }; - JMenuItem item; - popup.add(item = new JMenuItem(MessageManager - .getString("label.togglehidden"))); + JMenuItem item = new JMenuItem( + MessageManager.getString("label.togglehidden")); + popup.add(item); item.addActionListener(menuListener); popup.show(this, e.getX(), e.getY()); } + /* + * Toggle overview display between showing hidden columns and hiding hidden columns + */ private void toggleHiddenColumns() { if (showHidden) diff --git a/src/jalview/gui/OverviewRenderer.java b/src/jalview/gui/OverviewRenderer.java index 566846a..62b8601 100644 --- a/src/jalview/gui/OverviewRenderer.java +++ b/src/jalview/gui/OverviewRenderer.java @@ -119,13 +119,13 @@ public class OverviewRenderer * Find the colour of a sequence at a specified column position */ private int getColumnColourFromSequence(jalview.datamodel.SequenceI seq, - boolean isHidden, int lastcol, FeatureColourFinder finder) + boolean isHidden, int lastcol, FeatureColourFinder fcfinder) { Color color = Color.white; if ((seq != null) && (seq.getLength() > lastcol)) { - color = sr.getResidueColour(seq, lastcol, finder); + color = sr.getResidueColour(seq, lastcol, fcfinder); } if (isHidden) @@ -136,45 +136,64 @@ public class OverviewRenderer return color.getRGB(); } - public void drawGraph(Graphics g, AlignmentAnnotation _aa, int charWidth, + /** + * Draw the alignment annotation in the overview panel + * + * @param g + * the graphics object to draw on + * @param anno + * alignment annotation information + * @param charWidth + * alignment character width value + * @param y + * y-position for the annotation graph + * @param cols + * the collection of columns used in the overview panel + */ + public void drawGraph(Graphics g, AlignmentAnnotation anno, int charWidth, int y, AlignmentColsCollectionI cols) { - Annotation[] aa_annotations = _aa.annotations; + Annotation[] annotations = anno.annotations; g.setColor(Color.white); g.fillRect(0, 0, miniMe.getWidth(), y); - // g.setColor(new Color(0, 0, 180)); int height; - int colIndex = 0; int pixelCol = 0; for (int alignmentCol : cols) { - int endCol = Math.min(Math.round((colIndex + 1) * pixelsPerCol) - 1, - miniMe.getWidth() - 1); - - if (alignmentCol < aa_annotations.length - && aa_annotations[alignmentCol] != null) + if (alignmentCol >= annotations.length) { - if (aa_annotations[alignmentCol].colour == null) - { - g.setColor(Color.black); - } - else - { - g.setColor(aa_annotations[alignmentCol].colour); - } + break; // no more annotations to draw here + } + else + { + int endCol = Math.min( + Math.round((colIndex + 1) * pixelsPerCol) - 1, + miniMe.getWidth() - 1); - height = (int) ((aa_annotations[alignmentCol].value / _aa.graphMax) * y); - if (height > y) + if (annotations[alignmentCol] != null) { - height = y; - } + if (annotations[alignmentCol].colour == null) + { + g.setColor(Color.black); + } + else + { + g.setColor(annotations[alignmentCol].colour); + } - g.fillRect(pixelCol, y - height, endCol - pixelCol + 1, height); + height = (int) ((annotations[alignmentCol].value / anno.graphMax) * y); + if (height > y) + { + height = y; + } + + g.fillRect(pixelCol, y - height, endCol - pixelCol + 1, height); + } + pixelCol = endCol + 1; + colIndex++; } - pixelCol = endCol + 1; - colIndex++; } } } diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index 7c4ba9e..9a1e398 100644 --- a/src/jalview/viewmodel/OverviewDimensions.java +++ b/src/jalview/viewmodel/OverviewDimensions.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.viewmodel; import jalview.api.AlignmentColsCollectionI; @@ -10,12 +30,13 @@ import java.awt.Graphics; public abstract class OverviewDimensions { - - private static final int DEFAULT_GRAPH_HEIGHT = 20; protected static final int MAX_WIDTH = 400; protected static final int MIN_WIDTH = 120; protected static final int MIN_SEQ_HEIGHT = 40; protected static final int MAX_SEQ_HEIGHT = 300; + + private static final int DEFAULT_GRAPH_HEIGHT = 20; + protected int width; protected int sequencesHeight; protected int graphHeight = DEFAULT_GRAPH_HEIGHT; @@ -25,9 +46,7 @@ public abstract class OverviewDimensions protected int boxHeight = -1; protected int scrollCol = -1; protected int scrollRow = -1; - protected int alwidth; - protected int alheight; public OverviewDimensions(ViewportRanges ranges, @@ -148,16 +167,58 @@ public abstract class OverviewDimensions sequencesHeight = h - graphHeight; } + /** + * Update the viewport location from a mouse click in the overview panel + * + * @param mousex + * x location of mouse + * @param mousey + * y location of mouse + * @param hiddenSeqs + * the alignment's hidden sequences + * @param hiddenCols + * the alignment's hidden columns + * @param ranges + * the alignment's width and height ranges + */ public abstract void updateViewportFromMouse(int mousex, int mousey, HiddenSequences hiddenSeqs, ColumnSelection hiddenCols, ViewportRanges ranges); + /** + * Set the overview panel's box position to match the viewport + * + * @param hiddenSeqs + * the alignment's hidden sequences + * @param hiddenCols + * the alignment's hidden columns + * @param ranges + * the alignment's width and height ranges + */ public abstract void setBoxPosition(HiddenSequences hiddenSeqs, ColumnSelection hiddenCols, ViewportRanges ranges); + /** + * Get the collection of columns used by this overview dimensions object + * + * @param ranges + * the alignment's width and height ranges + * @param hiddenCols + * the alignment's hidden columns + * @return a column collection + */ public abstract AlignmentColsCollectionI getColumns( ViewportRanges ranges, ColumnSelection hiddenCols); + /** + * Get the collection of rows used by this overview dimensions object + * + * @param ranges + * the alignment's width and height ranges + * @param al + * the alignment + * @return a row collection + */ public abstract AlignmentRowsCollectionI getRows( ViewportRanges ranges, AlignmentI al); } \ No newline at end of file diff --git a/src/jalview/viewmodel/OverviewDimensionsAllVisible.java b/src/jalview/viewmodel/OverviewDimensionsAllVisible.java index 7e5c412..b30cc78 100644 --- a/src/jalview/viewmodel/OverviewDimensionsAllVisible.java +++ b/src/jalview/viewmodel/OverviewDimensionsAllVisible.java @@ -3,10 +3,10 @@ package jalview.viewmodel; import jalview.api.AlignmentColsCollectionI; import jalview.api.AlignmentRowsCollectionI; import jalview.datamodel.AlignmentI; -import jalview.datamodel.AllColsCollection; -import jalview.datamodel.AllRowsCollection; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenSequences; +import jalview.datamodel.VisibleColsCollection; +import jalview.datamodel.VisibleRowsCollection; public class OverviewDimensionsAllVisible extends OverviewDimensions { @@ -134,7 +134,7 @@ public class OverviewDimensionsAllVisible extends OverviewDimensions public AlignmentColsCollectionI getColumns(ViewportRanges ranges, ColumnSelection hiddenCols) { - return new AllColsCollection(0, + return new VisibleColsCollection(0, ranges.getVisibleAlignmentWidth() - 1, hiddenCols); } @@ -142,7 +142,7 @@ public class OverviewDimensionsAllVisible extends OverviewDimensions public AlignmentRowsCollectionI getRows(ViewportRanges ranges, AlignmentI al) { - return new AllRowsCollection(0, + return new VisibleRowsCollection(0, ranges.getVisibleAlignmentHeight() - 1, al); } }