*/
package jalview.appletgui;
- import jalview.datamodel.AlignmentI;
+ import jalview.datamodel.SequenceI;
+import jalview.renderer.seqfeatures.FeatureColourFinder;
+ import jalview.viewmodel.OverviewDimensions;
import java.awt.Color;
import java.awt.Dimension;
}
}
- public void setBoxPosition()
+ /*
+ * Build the overview panel image
+ */
+ private void buildImage(float sampleRow, float sampleCol, Graphics mg)
{
- int fullsizeWidth = av.getAlignment().getWidth() * av.getCharWidth();
- int fullsizeHeight = (av.getAlignment().getHeight() + av.getAlignment()
- .getHiddenSequences().getSize())
- * av.getCharHeight();
-
- int startRes = av.getStartRes();
- int endRes = av.getEndRes();
+ int lastcol = 0;
+ int lastrow = 0;
+ int xstart = 0;
+ int ystart = 0;
+ Color color = Color.yellow;
+ int sameRow = 0;
+ int sameCol = 0;
- if (av.hasHiddenColumns())
- {
- startRes = av.getColumnSelection().adjustForHiddenColumns(startRes);
- endRes = av.getColumnSelection().adjustForHiddenColumns(endRes);
- }
+ SequenceI seq = null;
++ FeatureColourFinder finder = new FeatureColourFinder(fr);
- int startSeq = av.startSeq;
- int endSeq = av.endSeq;
+ final boolean hasHiddenCols = av.hasHiddenColumns();
+ boolean hiddenRow = false;
- if (av.hasHiddenRows())
+ for (int row = 0; row <= od.getSequencesHeight() && !resizeAgain; row++)
{
- startSeq = av.getAlignment().getHiddenSequences()
- .adjustForHiddenSeqs(startSeq);
-
- endSeq = av.getAlignment().getHiddenSequences()
- .adjustForHiddenSeqs(endSeq);
+ if ((int) (row * sampleRow) == lastrow)
+ {
+ sameRow++;
+ }
+ else
+ {
+ // get the sequence which would be at alignment index 'lastrow' if no
+ // columns were hidden, and determine whether it is hidden or not
+ hiddenRow = av.getAlignment().isHidden(lastrow);
+ seq = av.getAlignment().getSequenceAtAbsoluteIndex(lastrow);
+ for (int col = 0; col < od.getWidth(); col++)
+ {
+ if ((int) (col * sampleCol) == lastcol
+ && (int) (row * sampleRow) == lastrow)
+ {
+ sameCol++;
+ }
+ else
+ {
+ lastcol = (int) (col * sampleCol);
+
+ color = getColumnColourFromSequence(seq, hiddenRow,
- hasHiddenCols, lastcol);
++ hasHiddenCols, lastcol, finder);
+
+ mg.setColor(color);
+ if (sameCol == 1 && sameRow == 1)
+ {
+ mg.drawLine(xstart, ystart, xstart, ystart);
+ }
+ else
+ {
+ mg.fillRect(xstart, ystart, sameCol, sameRow);
+ }
+
+ xstart = col;
+ sameCol = 1;
+ }
+ }
+ lastrow = (int) (row * sampleRow);
+ ystart = row;
+ sameRow = 1;
+ }
}
+ }
- scalew = (float) width / (float) fullsizeWidth;
- scaleh = (float) sequencesHeight / (float) fullsizeHeight;
-
- boxX = (int) (startRes * av.getCharWidth() * scalew);
- boxY = (int) (startSeq * av.getCharHeight() * scaleh);
-
- if (av.hasHiddenColumns())
+ /*
+ * Find the colour of a sequence at a specified column position
+ */
+ private Color getColumnColourFromSequence(
+ jalview.datamodel.SequenceI seq, boolean hiddenRow,
- boolean hasHiddenCols, int lastcol)
++ boolean hasHiddenCols, int lastcol, FeatureColourFinder finder)
+ {
- Color color;
++ Color color = Color.white;
+ if (seq.getLength() > lastcol)
{
- boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
- color = sr.getResidueBoxColour(seq, lastcol);
-
- if (av.isShowSequenceFeatures())
- {
- color = fr.findFeatureColour(color, seq, lastcol);
- }
- }
- else
- {
- color = Color.white;
++ color = sr.getResidueColour(seq, lastcol, finder);
}
- else
+
+ if (hiddenRow
+ || (hasHiddenCols && !av.getColumnSelection()
+ .isVisible(lastcol)))
{
- boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
+ color = color.darker().darker();
}
+ return color;
+ }
- boxHeight = (int) ((endSeq - startSeq) * av.getCharHeight() * scaleh);
-
+ /**
+ * Update the overview panel box when the associated alignment panel is
+ * changed
+ *
+ */
+ public void setBoxPosition()
+ {
+ od.setBoxPosition(av.getAlignment()
+ .getHiddenSequences(), av.getColumnSelection(), av.getRanges());
repaint();
}
*/
package jalview.gui;
+ import jalview.datamodel.SequenceI;
import jalview.renderer.AnnotationRenderer;
+import jalview.renderer.seqfeatures.FeatureColourFinder;
+ import jalview.viewmodel.OverviewDimensions;
import java.awt.Color;
import java.awt.Dimension;
// Can set different properties in this seqCanvas than
// main visible SeqCanvas
- SequenceRenderer sr;
+ private SequenceRenderer sr;
- private jalview.renderer.seqfeatures.FeatureRenderer fr;
+ jalview.renderer.seqfeatures.FeatureRenderer fr;
/**
* Creates a new OverviewPanel object.
sr = new SequenceRenderer(av);
sr.renderGaps = false;
sr.forOverview = true;
- fr = new FeatureRenderer(alPanel);
+ fr = new FeatureRenderer(ap);
- // scale the initial size of overviewpanel to shape of alignment
- float initialScale = (float) av.getAlignment().getWidth()
- / (float) av.getAlignment().getHeight();
-
- if (av.getAlignmentConservationAnnotation() == null)
- {
- graphHeight = 0;
- }
-
- if (av.getAlignment().getWidth() > av.getAlignment().getHeight())
- {
- // wider
- width = 400;
- sequencesHeight = (int) (400f / initialScale);
- if (sequencesHeight < 40)
- {
- sequencesHeight = 40;
- }
- }
- else
- {
- // taller
- width = (int) (400f * initialScale);
- sequencesHeight = 300;
-
- if (width < 120)
- {
- width = 120;
- }
- }
+ od = new OverviewDimensions(av.getRanges(), av.isShowAnnotation());
addComponentListener(new ComponentAdapter()
{
setBoxPosition();
}
- /**
- * DOCUMENT ME!
+ /*
+ * Build the overview panel image
*/
- public void setBoxPosition()
+ private void buildImage(float sampleRow, float sampleCol)
{
- int fullsizeWidth = av.getAlignment().getWidth() * av.getCharWidth();
- int fullsizeHeight = (av.getAlignment().getHeight() + av.getAlignment()
- .getHiddenSequences().getSize())
- * av.getCharHeight();
+ int lastcol = -1;
+ int lastrow = -1;
- int color = Color.white.getRGB();
++ int rgbColour = Color.white.getRGB();
- int startRes = av.getStartRes();
- int endRes = av.getEndRes();
+ SequenceI seq = null;
++ FeatureColourFinder finder = new FeatureColourFinder(fr);
- if (av.hasHiddenColumns())
+ final boolean hasHiddenCols = av.hasHiddenColumns();
+ boolean hiddenRow = false;
+ // get hidden row and hidden column map once at beginning.
+ // clone featureRenderer settings to avoid race conditions... if state is
+ // updated just need to refresh again
+ for (int row = 0; row < od.getSequencesHeight() && !resizeAgain; row++)
{
- startRes = av.getColumnSelection().adjustForHiddenColumns(startRes);
- endRes = av.getColumnSelection().adjustForHiddenColumns(endRes);
- }
+ boolean doCopy = true;
+ int currentrow = (int) (row * sampleRow);
+ if (currentrow != lastrow)
+ {
+ doCopy = false;
- int startSeq = av.startSeq;
- int endSeq = av.endSeq;
+ lastrow = currentrow;
- if (av.hasHiddenRows())
- {
- startSeq = av.getAlignment().getHiddenSequences()
- .adjustForHiddenSeqs(startSeq);
+ // get the sequence which would be at alignment index 'lastrow' if no
+ // rows were hidden, and determine whether it is hidden or not
+ hiddenRow = av.getAlignment().isHidden(lastrow);
+ seq = av.getAlignment().getSequenceAtAbsoluteIndex(lastrow);
+ }
- endSeq = av.getAlignment().getHiddenSequences()
- .adjustForHiddenSeqs(endSeq);
+ for (int col = 0; col < od.getWidth() && !resizeAgain; col++)
+ {
+ if (doCopy)
+ {
- color = miniMe.getRGB(col, row - 1);
++ rgbColour = miniMe.getRGB(col, row - 1);
+ }
+ else if ((int) (col * sampleCol) != lastcol
+ || (int) (row * sampleRow) != lastrow)
+ {
+ lastcol = (int) (col * sampleCol);
- color = getColumnColourFromSequence(seq, hiddenRow, hasHiddenCols,
- lastcol);
++ rgbColour = getColumnColourFromSequence(seq, hiddenRow,
++ hasHiddenCols, lastcol, finder);
+ }
+ // else we just use the color we already have , so don't need to set it
- miniMe.setRGB(col, row, color);
++ miniMe.setRGB(col, row, rgbColour);
+ }
}
+ }
- scalew = (float) width / (float) fullsizeWidth;
- scaleh = (float) sequencesHeight / (float) fullsizeHeight;
-
- boxX = (int) (startRes * av.getCharWidth() * scalew);
- boxY = (int) (startSeq * av.getCharHeight() * scaleh);
+ /*
+ * Find the colour of a sequence at a specified column position
+ */
- private int getColumnColourFromSequence(jalview.datamodel.SequenceI seq,
- boolean hiddenRow, boolean hasHiddenCols, int lastcol)
++ private int getColumnColourFromSequence(
++ jalview.datamodel.SequenceI seq,
++ boolean hiddenRow, boolean hasHiddenCols, int lastcol,
++ FeatureColourFinder finder)
+ {
- int color;
++ Color color = Color.white;
- if (av.hasHiddenColumns())
- if (seq == null)
++ if ((seq != null) && (seq.getLength() > lastcol))
{
- boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
- color = Color.white.getRGB();
- }
- else if (seq.getLength() > lastcol)
- {
- color = sr.getResidueBoxColour(seq, lastcol).getRGB();
-
- if (av.isShowSequenceFeatures())
- {
- color = fr.findFeatureColour(color, seq, lastcol);
- }
- }
- else
- {
- color = Color.white.getRGB();
++ color = sr.getResidueColour(seq, lastcol, finder);
}
- else
+
+ if (hiddenRow
+ || (hasHiddenCols && !av.getColumnSelection()
+ .isVisible(lastcol)))
{
- boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
- color = new Color(color).darker().darker().getRGB();
++ color = color.darker().darker();
}
- boxHeight = (int) ((endSeq - startSeq) * av.getCharHeight() * scaleh);
-
- repaint();
- return color;
++ return color.getRGB();
}
- private BufferedImage lastMiniMe = null;
-
/**
- * DOCUMENT ME!
+ * Update the overview panel box when the associated alignment panel is
+ * changed
*
- * @param g
- * DOCUMENT ME!
*/
+ public void setBoxPosition()
+ {
+ od.setBoxPosition(av.getAlignment()
+ .getHiddenSequences(), av.getColumnSelection(), av.getRanges());
+ repaint();
+ }
+
+
@Override
public void paintComponent(Graphics g)
{