*/
package jalview.appletgui;
+import jalview.datamodel.SequenceI;
import jalview.viewmodel.OverviewDimensions;
import java.awt.Color;
private Frame nullFrame;
- public OverviewPanel(AlignmentPanel ap)
+ public OverviewPanel(AlignmentPanel alPanel)
{
- this.av = ap.av;
- this.ap = ap;
+ this.av = alPanel.av;
+ this.ap = alPanel;
setLayout(null);
nullFrame = new Frame();
nullFrame.addNotify();
sr.forOverview = true;
fr = new FeatureRenderer(av);
- boolean showAnnotation = true;
- // TODO: in applet this was getSequenceConsensusHash()
- // check if it makes any functional difference: hconsensus or conservation
- if (av.getAlignmentConservationAnnotation() == null)
- {
- showAnnotation = false;
- }
-
- od = new OverviewDimensions(av.getPosProps(), showAnnotation);
+ od = new OverviewDimensions(av.getPosProps(), av.isShowAnnotation());
setSize(new Dimension(od.getWidth(), od.getHeight()));
addComponentListener(new ComponentAdapter()
}
/**
- * DOCUMENT ME!
+ * Updates the overview image when the related alignment panel is updated
*/
public void updateOverviewImage()
{
if ((getWidth() > 0) && (getHeight() > 0))
{
- od.setWidth(getWidth()); // width = getWidth();
- od.setHeight(getHeight()); // sequencesHeight = getHeight() - graphHeight;
+ od.setWidth(getWidth());
+ od.setHeight(getHeight());
}
setSize(new Dimension(od.getWidth(), od.getHeight()));
Graphics mg = miniMe.getGraphics();
- // od.updateScales();
-
int alwidth = av.getAlignment().getWidth();
int alheight = av.getAlignment().getAbsoluteHeight();
float sampleCol = alwidth / (float) od.getWidth();
buildImage(sampleRow, sampleCol, mg);
- if (av.getAlignmentConservationAnnotation() != null)
+ if (av.isShowAnnotation())
{
for (int col = 0; col < od.getWidth() && !resizeAgain; col++)
{
}
}
+ /*
+ * Build the overview panel image
+ */
private void buildImage(float sampleRow, float sampleCol, Graphics mg)
{
int lastcol = 0;
int sameRow = 0;
int sameCol = 0;
- jalview.datamodel.SequenceI seq = null;
+ SequenceI seq = null;
final boolean hasHiddenCols = av.hasHiddenColumns();
boolean hiddenRow = false;
sameRow = 1;
}
}
-
}
/*
}
else
{
- color = Color.white; // White
+ color = Color.white;
}
if (hiddenRow
*/
package jalview.gui;
+import jalview.datamodel.SequenceI;
import jalview.renderer.AnnotationRenderer;
import jalview.viewmodel.OverviewDimensions;
sr.forOverview = true;
fr = new FeatureRenderer(alPanel);
- boolean showAnnotation = true;
- // TODO: in applet this was getSequenceConsensusHash()
- // check if it makes any functional difference: hconsensus or conservation
- if (av.getAlignmentConservationAnnotation() == null)
- {
- showAnnotation = false;
- }
- od = new OverviewDimensions(av.getPosProps(), showAnnotation);
+ od = new OverviewDimensions(av.getPosProps(), av.isShowAnnotation());
addComponentListener(new ComponentAdapter()
{
{
if (!av.getWrapAlignment())
{
- // TODO: feature: jv2.5 detect shift drag and update selection from
- // it.
od.updateViewportFromMouse(evt.getX(), evt.getY(), av
.getAlignment().getHiddenSequences(), av
.getColumnSelection(), av.getPosProps());
if ((getWidth() > 0) && (getHeight() > 0))
{
- od.setWidth(getWidth()); // width = getWidth();
- od.setHeight(getHeight()); // sequencesHeight = getHeight() - graphHeight;
+ od.setWidth(getWidth());
+ od.setHeight(getHeight());
}
setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
buildImage(sampleRow, sampleCol);
- if (av.getAlignmentConservationAnnotation() != null)
+ if (av.isShowAnnotation())
{
renderer.updateFromAlignViewport(av);
for (int col = 0; col < od.getWidth() && !resizeAgain; col++)
setBoxPosition();
}
+ /*
+ * Build the overview panel image
+ */
private void buildImage(float sampleRow, float sampleCol)
{
int lastcol = -1;
int lastrow = -1;
int color = Color.white.getRGB();
- jalview.datamodel.SequenceI seq = null;
+ SequenceI seq = null;
final boolean hasHiddenCols = av.hasHiddenColumns();
boolean hiddenRow = false;
seq = av.getAlignment().getSequenceAtAbsoluteIndex(lastrow);
}
- if (seq == null)
- {
- System.out.println(lastrow + " null");
- continue;
- }
-
for (int col = 0; col < od.getWidth() && !resizeAgain; col++)
{
if (doCopy)
color = getColumnColourFromSequence(seq, hiddenRow, hasHiddenCols,
lastcol);
}
- // else if ((int) (col * sampleCol) == lastcol && (int) (row *
- // sampleRow) == lastrow))
- // we just use the color we already have , so don't need to set it
+ // else we just use the color we already have , so don't need to set it
miniMe.setRGB(col, row, color);
}
{
int color;
- if (seq.getLength() > lastcol)
+ if (seq == null)
+ {
+ color = Color.white.getRGB();
+ }
+ else if (seq.getLength() > lastcol)
{
color = sr.getResidueBoxColour(seq, lastcol).getRGB();
}
else
{
- color = Color.white.getRGB(); // White
+ color = Color.white.getRGB();
}
if (hiddenRow
g.fillRect(0, 0, getWidth(), getHeight());
}
}
- // TODO: render selected regions
+
g.setColor(Color.red);
od.drawBox(g);
}
ViewportPositionProps props = new ViewportPositionProps(al1);
OverviewDimensions od = new OverviewDimensions(props, true);
- int scaledHeight = 266;
+ int scaledHeight = 267;
assertEquals(od.getGraphHeight(), defaultGraphHeight);
assertEquals(od.getSequencesHeight(), scaledHeight);
assertEquals(od.getWidth(), maxWidth);
// overly large boxX value reset to width-boxWidth
mouseClick(od, 100, 6);
- assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1);
+ assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
assertEquals(od.getBoxY(), 6);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
assertEquals(od.getBoxHeight(), boxHeight);
assertEquals(od.getScrollCol(),
Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+
+ // here (float) od.getBoxY() * alheight / od.getSequencesHeight() = 507.5
+ // and round rounds to 508; however we get 507 working with row values
+ // hence the subtraction of 1
assertEquals(od.getScrollRow(),
Math.round((float) od.getBoxY() * alheight
- / od.getSequencesHeight()));
+ / od.getSequencesHeight()) - 1);
// click past end of alignment, as above
mouseClick(od, 3000, 5);
- assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1);
+ assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
assertEquals(od.getScrollCol(),
assertEquals(od.getBoxHeight(), boxHeight);
// try to click in hidden cols, check box does not move
- // this test currently fails as the overview box does not behave like this!
int xpos = 10;
mouseClick(od, xpos, 0);
assertEquals(
// overly large boxX value reset to width-boxWidth
xpos = 100;
mouseClick(od, xpos, 5);
- assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1);
+ assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
assertEquals(od.getBoxY(), 5);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
// boxX, scrollCol adjusted back, box width normal
xpos = 3000;
mouseClick(od, xpos, 5);
- assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1);
+ assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
assertEquals(od.getBoxY(), 5);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
xpos = Math.round((float) 145 * od.getWidth() / alwidth) - boxWidth;
mouseClick(od, xpos, 0);
assertEquals(od.getBoxX(),
- Math.round((firstHidden - 1) * od.getWidth() / alwidth)
- - boxWidth);
+ Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth)
+ - boxWidth + 1);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
assertEquals(od.getScrollCol(),
- Math.round(od.getBoxX() * alwidth / od.getWidth()));
+ Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
assertEquals(od.getScrollRow(), 0);
// click in hidden cols
// boxX and scrollCol adjusted for hidden cols, width normal
- // TODO breaks as above test
- /*xpos = 115;
- assertEquals(
- od.getBoxX(),
- Math.round((firstHidden - 1) * scalew * av.getCharWidth())
- - od.getBoxWidth());
+ xpos = 115;
+ assertEquals(od.getBoxX(),
+ Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth)
+ - boxWidth + 1);
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(od.getBoxHeight(), boxHeight);
assertEquals(od.getScrollCol(),
- Math.round(od.getBoxX() * alwidth / od.getWidth()));
- assertEquals(od.getScrollRow(), 0);*/
+ Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+ assertEquals(od.getScrollRow(), 0);
// click off end of alignment
// boxX and scrollCol adjusted for hidden cols, width normal
- // TODO breaks as above test
- /* xpos = 3000;
- assertEquals(
- od.getBoxX(),
- Math.round((firstHidden - 1) * scalew * av.getCharWidth())
- - od.getBoxWidth());
- assertEquals(od.getBoxY(), 0);
- assertEquals(od.getBoxWidth(), boxWidth);
- assertEquals(od.getBoxHeight(), boxHeight);
- assertEquals(od.getScrollCol(),
- Math.round(od.getBoxX() * alwidth / od.getWidth()));
- assertEquals(od.getScrollRow(), 0);*/
+ xpos = 3000;
+ assertEquals(od.getBoxX(),
+ Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth)
+ - boxWidth + 1);
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(od.getBoxWidth(), boxWidth);
+ assertEquals(od.getBoxHeight(), boxHeight);
+ assertEquals(od.getScrollCol(),
+ Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+ assertEquals(od.getScrollRow(), 0);
}
/**
Math.round((float) 102 * od.getWidth() / alwidth));
assertEquals(od.getBoxY(), 0);
assertEquals(od.getBoxWidth(), boxWidth
- + Math.round((float) (lastHidden - firstHidden)
+ + Math.round((float) (lastHidden - firstHidden + 1)
* od.getWidth() / alwidth));
assertEquals(od.getBoxHeight(), boxHeight);
}
// hide rows in middle and check updated box position is correct
// no changes
int firstHiddenRow = 50;
- int lastHiddenRow = 60;
+ int lastHiddenRow = 54;
hideSequences(firstHiddenRow, lastHiddenRow);
od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
assertEquals(od.getBoxHeight(), boxHeight);
// click above hidden rows, so that box overlaps
- int ypos = 40;
- // TODO test fails because box does not change height - dealt with by scroll
- // values
- /* mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight()));
- assertEquals(od.getBoxX(), 0);
- assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()),
- 1.5);
- assertEquals(od.getBoxWidth(), boxWidth);
- assertEquals(
- od.getBoxHeight(),
- boxHeight
- + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
- .getCharHeight()));
- */
+ int ypos = 35; // column value in residues
+ mouseClick(od, 0,
+ Math.round((float) ypos * od.getSequencesHeight() / alheight));
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(),
+ Math.round((float) ypos * od.getSequencesHeight() / alheight));
+ assertEquals(od.getBoxWidth(), boxWidth);
+ assertEquals(
+ od.getBoxHeight(),
+ boxHeight
+ + Math.round((float) (lastHiddenRow - firstHiddenRow + 1)
+ * od.getSequencesHeight() / alheight));
+
// click so that box straddles hidden rows
- ypos = 48;
- // TODO test fails because box does not change height - dealt with by scroll
- // values
- /*mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight()));
+ ypos = 44; // column value in residues
+ mouseClick(od, 0,
+ Math.round((float) ypos * od.getSequencesHeight() / alheight));
assertEquals(od.getBoxX(), 0);
- assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()),
- 1.5);
+ assertEquals(od.getBoxY(),
+ Math.round((float) ypos * od.getSequencesHeight() / alheight));
assertEquals(od.getBoxWidth(), boxWidth);
assertEquals(
od.getBoxHeight(),
boxHeight
- + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
- .getCharHeight()));*/
+ + Math.round((float) (lastHiddenRow - firstHiddenRow + 1)
+ * od.getSequencesHeight() / alheight));
}
/**
// click above hidden rows so box overlaps
// boxY moved upwards, boxHeight remains same
- // TODO fails with boxY located at row 497 - correction done by
- // setScrollValues
- /* ypos = 497; // row 497
- mouseClick(od, 0, Math.round (ypos * scaleh * av.getCharHeight()));
- assertEquals(od.getBoxX(), 0);
- assertEquals(
- od.getBoxY(),
- Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()),
- 1.5);
- assertEquals(od.getBoxWidth(), boxWidth);
- assertEquals(od.getBoxHeight(), boxHeight);*/
+ ypos = 497; // row 497
+ mouseClick(od, 0,
+ Math.round((float) ypos * od.getSequencesHeight() / alheight));
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(
+ od.getBoxY(),
+ Math.round((float) (firstHidden - viewHeight)
+ * od.getSequencesHeight() / alheight));
+ assertEquals(od.getBoxWidth(), boxWidth);
+ assertEquals(od.getBoxHeight(), boxHeight);
// click within hidden rows
ypos = 505;
- // TODO: fails with wrong boxHeight - correction done by setScrollValues(?)
- /*mouseClick(od, 0, Math.round (ypos * scaleh * av.getCharHeight()));
+ mouseClick(od, 0,
+ Math.round((float) ypos * od.getSequencesHeight() / alheight));
assertEquals(od.getBoxX(), 0);
assertEquals(
od.getBoxY(),
- Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()),
- 1.5);
+ Math.round((firstHidden - viewHeight) * od.getSequencesHeight()
+ / alheight));
assertEquals(od.getBoxWidth(), boxWidth);
- assertEquals(od.getBoxHeight(), boxHeight);*/
+ assertEquals(od.getBoxHeight(), boxHeight);
}
/*