2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.viewmodel;
23 import jalview.api.AlignmentColsCollectionI;
24 import jalview.api.AlignmentRowsCollectionI;
25 import jalview.datamodel.AlignmentI;
26 import jalview.datamodel.ColumnSelection;
27 import jalview.datamodel.HiddenSequences;
29 import java.awt.Graphics;
31 public abstract class OverviewDimensions
33 protected static final int MAX_WIDTH = 400;
34 protected static final int MIN_WIDTH = 120;
35 protected static final int MIN_SEQ_HEIGHT = 40;
36 protected static final int MAX_SEQ_HEIGHT = 300;
38 private static final int DEFAULT_GRAPH_HEIGHT = 20;
41 protected int sequencesHeight;
42 protected int graphHeight = DEFAULT_GRAPH_HEIGHT;
43 protected int boxX = -1;
44 protected int boxY = -1;
45 protected int boxWidth = -1;
46 protected int boxHeight = -1;
47 protected int scrollCol = -1;
48 protected int scrollRow = -1;
49 protected int alwidth;
50 protected int alheight;
52 public OverviewDimensions(ViewportRanges ranges,
53 boolean showAnnotationPanel)
55 // scale the initial size of overviewpanel to shape of alignment
56 float initialScale = (float) ranges.getAbsoluteAlignmentWidth()
57 / (float) ranges.getAbsoluteAlignmentHeight();
59 if (!showAnnotationPanel)
64 if (ranges.getAbsoluteAlignmentWidth() > ranges
65 .getAbsoluteAlignmentHeight())
69 sequencesHeight = Math.round(MAX_WIDTH / initialScale);
70 if (sequencesHeight < MIN_SEQ_HEIGHT)
72 sequencesHeight = MIN_SEQ_HEIGHT;
78 width = Math.round(MAX_WIDTH * initialScale);
79 sequencesHeight = MAX_SEQ_HEIGHT;
81 if (width < MIN_WIDTH)
89 * Draw the overview panel's viewport box on a graphics object
92 * the graphics object to draw on
94 public void drawBox(Graphics g)
96 g.drawRect(boxX, boxY, boxWidth, boxHeight);
97 g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);
100 public int getScrollCol()
105 public int getScrollRow()
120 public int getBoxWidth()
125 public int getBoxHeight()
130 public int getWidth()
135 public int getHeight()
137 return sequencesHeight + graphHeight;
140 public int getSequencesHeight()
142 return sequencesHeight;
145 public int getGraphHeight()
150 public float getPixelsPerCol()
152 return (float) width / alwidth;
155 public float getPixelsPerSeq()
157 return (float) sequencesHeight / alheight;
160 public void setWidth(int w)
165 public void setHeight(int h)
167 sequencesHeight = h - graphHeight;
171 * Update the viewport location from a mouse click in the overview panel
174 * x location of mouse
176 * y location of mouse
178 * the alignment's hidden sequences
180 * the alignment's hidden columns
182 * the alignment's width and height ranges
184 public abstract void updateViewportFromMouse(int mousex, int mousey,
185 HiddenSequences hiddenSeqs, ColumnSelection hiddenCols,
186 ViewportRanges ranges);
189 * Set the overview panel's box position to match the viewport
192 * the alignment's hidden sequences
194 * the alignment's hidden columns
196 * the alignment's width and height ranges
198 public abstract void setBoxPosition(HiddenSequences hiddenSeqs,
199 ColumnSelection hiddenCols, ViewportRanges ranges);
202 * Get the collection of columns used by this overview dimensions object
205 * the alignment's width and height ranges
207 * the alignment's hidden columns
208 * @return a column collection
210 public abstract AlignmentColsCollectionI getColumns(
211 ViewportRanges ranges, ColumnSelection hiddenCols);
214 * Get the collection of rows used by this overview dimensions object
217 * the alignment's width and height ranges
220 * @return a row collection
222 public abstract AlignmentRowsCollectionI getRows(
223 ViewportRanges ranges, AlignmentI al);