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 protected int alwidth;
31 protected int alheight;
33 public OverviewDimensions(ViewportRanges ranges,
34 boolean showAnnotationPanel)
36 // scale the initial size of overviewpanel to shape of alignment
37 float initialScale = (float) ranges.getAbsoluteAlignmentWidth()
38 / (float) ranges.getAbsoluteAlignmentHeight();
40 if (!showAnnotationPanel)
45 if (ranges.getAbsoluteAlignmentWidth() > ranges
46 .getAbsoluteAlignmentHeight())
50 sequencesHeight = Math.round(MAX_WIDTH / initialScale);
51 if (sequencesHeight < MIN_SEQ_HEIGHT)
53 sequencesHeight = MIN_SEQ_HEIGHT;
59 width = Math.round(MAX_WIDTH * initialScale);
60 sequencesHeight = MAX_SEQ_HEIGHT;
62 if (width < MIN_WIDTH)
70 * Draw the overview panel's viewport box on a graphics object
73 * the graphics object to draw on
75 public void drawBox(Graphics g)
77 g.drawRect(boxX, boxY, boxWidth, boxHeight);
78 g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);
81 public int getScrollCol()
86 public int getScrollRow()
101 public int getBoxWidth()
106 public int getBoxHeight()
111 public int getWidth()
116 public int getHeight()
118 return sequencesHeight + graphHeight;
121 public int getSequencesHeight()
123 return sequencesHeight;
126 public int getGraphHeight()
131 public float getPixelsPerCol()
133 return (float) width / alwidth;
136 public float getPixelsPerSeq()
138 return (float) sequencesHeight / alheight;
141 public void setWidth(int w)
146 public void setHeight(int h)
148 sequencesHeight = h - graphHeight;
151 public abstract void updateViewportFromMouse(int mousex, int mousey,
152 HiddenSequences hiddenSeqs, ColumnSelection hiddenCols,
153 ViewportRanges ranges);
155 public abstract void setBoxPosition(HiddenSequences hiddenSeqs,
156 ColumnSelection hiddenCols, ViewportRanges ranges);
158 public abstract AlignmentColsCollectionI getColumns(
159 ViewportRanges ranges, ColumnSelection hiddenCols);
161 public abstract AlignmentRowsCollectionI getRows(
162 ViewportRanges ranges, AlignmentI al);