package jalview.viewmodel; import jalview.datamodel.AlignmentColsCollection; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentRowsCollection; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenSequences; 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; protected int width; protected int sequencesHeight; protected int graphHeight = DEFAULT_GRAPH_HEIGHT; protected int boxX = -1; protected int boxY = -1; protected int boxWidth = -1; protected int boxHeight = -1; protected int scrollCol = -1; protected int scrollRow = -1; public OverviewDimensions(ViewportRanges ranges, boolean showAnnotationPanel) { // scale the initial size of overviewpanel to shape of alignment float initialScale = (float) ranges.getAbsoluteAlignmentWidth() / (float) ranges.getAbsoluteAlignmentHeight(); if (!showAnnotationPanel) { graphHeight = 0; } if (ranges.getAbsoluteAlignmentWidth() > ranges .getAbsoluteAlignmentHeight()) { // wider width = MAX_WIDTH; sequencesHeight = Math.round(MAX_WIDTH / initialScale); if (sequencesHeight < MIN_SEQ_HEIGHT) { sequencesHeight = MIN_SEQ_HEIGHT; } } else { // taller width = Math.round(MAX_WIDTH * initialScale); sequencesHeight = MAX_SEQ_HEIGHT; if (width < MIN_WIDTH) { width = MIN_WIDTH; } } } /** * Draw the overview panel's viewport box on a graphics object * * @param g * the graphics object to draw on */ public void drawBox(Graphics g) { g.drawRect(boxX, boxY, boxWidth, boxHeight); g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); } public int getScrollCol() { return scrollCol; } public int getScrollRow() { return scrollRow; } public int getBoxX() { return boxX; } public int getBoxY() { return boxY; } public int getBoxWidth() { return boxWidth; } public int getBoxHeight() { return boxHeight; } public void setWidth(int w) { width = w; } public void setHeight(int h) { sequencesHeight = h - graphHeight; } public int getWidth() { return width; } public int getHeight() { return sequencesHeight + graphHeight; } public int getSequencesHeight() { return sequencesHeight; } public int getGraphHeight() { return graphHeight; } public abstract void updateViewportFromMouse(int mousex, int mousey, HiddenSequences hiddenSeqs, ColumnSelection hiddenCols, ViewportRanges ranges); public abstract void setBoxPosition(HiddenSequences hiddenSeqs, ColumnSelection hiddenCols, ViewportRanges ranges); public abstract AlignmentColsCollection getColumns( ViewportRanges ranges, ColumnSelection hiddenCols); public abstract AlignmentRowsCollection getRows( ViewportRanges ranges, AlignmentI al); public abstract float getPixelsPerCol(); public abstract float getPixelsPerSeq(); }