import javax.swing.JComponent;
-
public class OverviewCanvas extends JComponent
{
private static final Color TRANS_GREY = new Color(100, 100, 100, 25);
private jalview.renderer.seqfeatures.FeatureRenderer fr;
- OverviewDimensions od;
+ private OverviewDimensions od;
- AlignViewportI av;
+ private AlignViewportI av;
public OverviewCanvas(OverviewDimensions overviewDims,
AlignViewportI alignvp)
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()
{
}
}
+ /**
+ * 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)
{
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)
* 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)
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++;
}
}
}
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.viewmodel;
import jalview.api.AlignmentColsCollectionI;
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;
protected int boxHeight = -1;
protected int scrollCol = -1;
protected int scrollRow = -1;
-
protected int alwidth;
-
protected int alheight;
public OverviewDimensions(ViewportRanges ranges,
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
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
{
public AlignmentColsCollectionI getColumns(ViewportRanges ranges,
ColumnSelection hiddenCols)
{
- return new AllColsCollection(0,
+ return new VisibleColsCollection(0,
ranges.getVisibleAlignmentWidth() - 1, hiddenCols);
}
public AlignmentRowsCollectionI getRows(ViewportRanges ranges,
AlignmentI al)
{
- return new AllRowsCollection(0,
+ return new VisibleRowsCollection(0,
ranges.getVisibleAlignmentHeight() - 1, al);
}
}