1 package jalview.viewmodel;
3 import jalview.api.AlignmentColsCollectionI;
4 import jalview.api.AlignmentRowsCollectionI;
5 import jalview.datamodel.AlignmentI;
6 import jalview.datamodel.ColumnSelection;
7 import jalview.datamodel.HiddenSequences;
9 import java.awt.Graphics;
11 public abstract class OverviewDimensions
14 private static final int DEFAULT_GRAPH_HEIGHT = 20;
15 protected static final int MAX_WIDTH = 400;
16 protected static final int MIN_WIDTH = 120;
17 protected static final int MIN_SEQ_HEIGHT = 40;
18 protected static final int MAX_SEQ_HEIGHT = 300;
20 protected int sequencesHeight;
21 protected int graphHeight = DEFAULT_GRAPH_HEIGHT;
22 protected int boxX = -1;
23 protected int boxY = -1;
24 protected int boxWidth = -1;
25 protected int boxHeight = -1;
26 protected int scrollCol = -1;
27 protected int scrollRow = -1;
29 public OverviewDimensions(ViewportRanges ranges,
30 boolean showAnnotationPanel)
32 // scale the initial size of overviewpanel to shape of alignment
33 float initialScale = (float) ranges.getAbsoluteAlignmentWidth()
34 / (float) ranges.getAbsoluteAlignmentHeight();
36 if (!showAnnotationPanel)
41 if (ranges.getAbsoluteAlignmentWidth() > ranges
42 .getAbsoluteAlignmentHeight())
46 sequencesHeight = Math.round(MAX_WIDTH / initialScale);
47 if (sequencesHeight < MIN_SEQ_HEIGHT)
49 sequencesHeight = MIN_SEQ_HEIGHT;
55 width = Math.round(MAX_WIDTH * initialScale);
56 sequencesHeight = MAX_SEQ_HEIGHT;
58 if (width < MIN_WIDTH)
66 * Draw the overview panel's viewport box on a graphics object
69 * the graphics object to draw on
71 public void drawBox(Graphics g)
73 g.drawRect(boxX, boxY, boxWidth, boxHeight);
74 g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);
77 public int getScrollCol()
82 public int getScrollRow()
97 public int getBoxWidth()
102 public int getBoxHeight()
107 public void setWidth(int w)
112 public void setHeight(int h)
114 sequencesHeight = h - graphHeight;
117 public int getWidth()
122 public int getHeight()
124 return sequencesHeight + graphHeight;
127 public int getSequencesHeight()
129 return sequencesHeight;
132 public int getGraphHeight()
137 public abstract void updateViewportFromMouse(int mousex, int mousey,
138 HiddenSequences hiddenSeqs, ColumnSelection hiddenCols,
139 ViewportRanges ranges);
141 public abstract void setBoxPosition(HiddenSequences hiddenSeqs,
142 ColumnSelection hiddenCols, ViewportRanges ranges);
144 public abstract AlignmentColsCollectionI getColumns(
145 ViewportRanges ranges, ColumnSelection hiddenCols);
147 public abstract AlignmentRowsCollectionI getRows(
148 ViewportRanges ranges, AlignmentI al);
150 public abstract float getPixelsPerCol();
152 public abstract float getPixelsPerSeq();