Color getNoColour();
/**
- * Answers true if the feature has a single colour
+ * Answers true if the feature has a single colour, i.e. if isColourByLabel()
+ * and isGraduatedColour() both answer false; else answers false
*
- * @return true iff not (isColourByLabel() || isGraduatedColour())
+ * @return
*/
boolean isSimpleColour();
/**
* Data structure to hold and manipulate a multiple sequence alignment
- */
-/**
- * @author JimP
*
+ * @author JimP
*/
public class Alignment implements AlignmentI
{
+ private static final SequenceGroup[] NO_GROUPS = new SequenceGroup[0];
+
private Alignment dataset;
private List<SequenceI> sequences;
private List<AlignedCodonFrame> codonFrameList;
- private static final SequenceGroup[] noGroups = new SequenceGroup[0];
-
/*
* persistent object to hold result of findAllGroups(SequenceI)
*/
int gSize = groups.size();
if (gSize == 0)
{
- return noGroups;
+ return NO_GROUPS;
}
groupsForSequence.clear();
for (int i = 0; i < gSize; i++)
public class AllColsCollection implements AlignmentColsCollectionI
{
- int start;
+ final int start;
- int end;
+ final int end;
HiddenColumns hidden;
private BitSet hiddenBitSet;
+ /**
+ * Returns a BitSet with a set bit for each hidden column (0, 1, ...). This is
+ * valid at the time of calling, but will not reflect any changes made
+ * afterwards.
+ *
+ * @return
+ */
public BitSet getBitset()
{
if (hiddenBitSet == null)
int imgHeight = 0;
- boolean fastPaint = false;
+ private boolean fastPaint = false;
List<SequenceI> searchResults;
@Override
public void propertyChange(PropertyChangeEvent evt)
{
- // BH just clarifying logic
String propertyName = evt.getPropertyName();
- switch (propertyName) {
+ switch (propertyName)
+ {
case ViewportRanges.STARTSEQ:
fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
- return;
+ break;
case ViewportRanges.STARTRES:
if (av.getWrapAlignment())
{
fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
}
- return;
+ break;
case ViewportRanges.STARTRESANDSEQ:
fastPaint(((int[]) evt.getNewValue())[1]
- ((int[]) evt.getOldValue())[1]);
- return;
+ break;
case ViewportRanges.MOVE_VIEWPORT:
repaint();
- return;
- case ViewportRanges.ENDRES:
- case ViewportRanges.ENDSEQ:
- // ignore ??
- return;
+ break;
+ default:
}
-// BH 2019.07.27 was:
-// if (propertyName.equals(ViewportRanges.STARTSEQ)
-// || (av.getWrapAlignment()
-// && propertyName.equals(ViewportRanges.STARTRES)))
-// {
-// fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
-// }
-// else if (propertyName.equals(ViewportRanges.STARTRESANDSEQ))
-// {
-// fastPaint(((int[]) evt.getNewValue())[1]
-// - ((int[]) evt.getOldValue())[1]);
-// }
-// else if (propertyName.equals(ViewportRanges.MOVE_VIEWPORT))
-// {
-// repaint();
- // }
+ }
+
+ /**
+ * Clears the flag that allows a 'fast paint' on the next repaint, so
+ * requiring a full repaint
+ */
+ public void setNoFastPaint()
+ {
+ fastPaint = false;
}
}
// Can set different properties in this seqCanvas than
// main visible SeqCanvas
- private SequenceRenderer sr;
+ private final SequenceRenderer sr;
- private jalview.renderer.seqfeatures.FeatureRenderer fr;
+ private final jalview.renderer.seqfeatures.FeatureRenderer fr;
private OverviewDimensions od;
private OverviewRenderer or = null;
- private AlignViewportI av;
+ private final AlignViewportI av;
- private OverviewResColourFinder cf;
+ private final OverviewResColourFinder cf;
- private ProgressPanel progressPanel;
+ private final ProgressPanel progressPanel;
private boolean showSequenceFeatures;
private jalview.api.FeatureRenderer featureRenderer;
- private OverviewPanel panel;
+ private final OverviewPanel panel;
- private boolean showProgress;
+ private final boolean showProgress;
public OverviewCanvas(OverviewPanel panel,
OverviewDimensions overviewDims,
synchronized void finalizeDraw(BufferedImage miniMe)
{
-
if (showProgress && or != null)
{
or.removePropertyChangeListener(progressPanel);
av.getRanges().addPropertyChangeListener(this);
- // without this the overview window does not size to fit the overview canvas
- // BH - no,no! - This does not include the progressPanel!
- // BH the problem was that OverviewCanvas.setPreferredSize() had not been set.
- // setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
-
addComponentListener(new ComponentAdapter()
{
@Override
{
resizePanel();
}
-
});
addMouseMotionListener(new MouseMotionAdapter()
Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
}
}
-
});
addMouseListener(new MouseAdapter()
@Override
public void mousePressed(MouseEvent evt)
{
-
if (Platform.isWinRightButton(evt))
{
showPopupMenu(evt);
{
draggingBox = false;
}
-
});
-
- // /*
- // * Javascript does not call componentResized on initial display,
- // * so do the update here
- // */
- // if (Platform.isJS())
- // {
- // updateOverviewImage();
- // }
}
protected void resizePanel()
od.setHeight(h - ph);
updateOverviewImage();
}
- // BH 2019.07.29 this is unnecessary -- it is what layout managers are
- // for:
- // setPreferredSize(new Dimension(od.getWidth(), od.getHeight() +
- // ph));
}
}
}
- /*
+ /**
* Displays the popup menu and acts on user input
*/
protected void showPopupMenu(MouseEvent e)
popup.show(this, e.getX(), e.getY());
}
- /*
- * Toggle overview display between showing hidden columns and hiding hidden columns
+ /**
+ * Toggle overview display between showing hidden columns and hiding hidden
+ * columns
*/
protected void toggleHiddenColumns()
{
{
// BH 2019.04.22 fixes JS problem of repaint() consolidation
// that occurs in JavaScript but not Java [JAL-3226]
- ((IdCanvas) comp).fastPaint = false;
+ ((IdCanvas) comp).setNoFastPaint();
}
else if (comp instanceof SeqCanvas)
{
// BH 2019.04.22 fixes JS problem of repaint() consolidation
// that occurs in JavaScript but not Java [JAL-3226]
- ((SeqCanvas) comp).fastPaint = false;
+ ((SeqCanvas) comp).setNoFastPaint();
}
comp.repaint();
}
@Override
public void paintComponent(Graphics g)
{
-
- // super.paintComponent(g); // BH 2019
-
/*
* shouldn't get called in wrapped mode as the scale above is
* drawn instead by SeqCanvas.drawNorthScale
private final SequenceRenderer seqRdr;
- boolean fastPaint = false;
+ private boolean fastPaint = false;
private boolean fastpainting = false;
availWidth -= (availWidth % charWidth);
availHeight -= (availHeight % charHeight);
- // BH 2019 can't possibly fastPaint if either width or height is 0
-
if (availWidth == 0 || availHeight == 0)
{
return;
int endRes = ranges.getEndRes();
int endSeq = ranges.getEndSeq();
- // [JAL-3226] problem that JavaScript (or Java) may consolidate multiple
- // repaint() requests in unpredictable ways. In this case, the issue was
- // that in response to a CTRL-C/CTRL-V paste request, in Java a fast
- // repaint request preceded two full requests, thus resulting
- // in a full request for paint. In constrast, in JavaScript, the three
- // requests were bundled together into one, so the fastPaint flag was
- // still present for the second and third request.
- //
- // This resulted in incomplete painting.
- //
- // The solution was to set seqCanvas.fastPaint and idCanvas.fastPaint false
- // in PaintRefresher when the target to be painted is one of those two
- // components.
- //
- // BH 2019.04.22
- //
- // An initial idea; can be removed once we determine this issue is closed:
- // if (av.isFastPaintDisabled())
- // {
- // fastPaint = false;
- // }
-
Rectangle vis, clip;
if (img != null
&& (fastPaint
/**
* Using the current font, determine fields labelWidthEast and labelWidthWest,
- * and return the number of residues that can fill the remaining width.
+ * and return the number of residues that can fill the remaining width
*
* @param width
* the width in pixels (possibly including scales)
// typically scroll, but possibly just the end changed
fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
return;
- case ViewportRanges.ENDRES:
- case ViewportRanges.ENDSEQ:
- // meaning second event along with "START" -- ENDONLY,NOTSTART
- // TODO: ignore??
- return;
case ViewportRanges.STARTRES:
// meaning STARTOREND
scrollX = (int) evt.getNewValue() - (int) evt.getOldValue();
}
break;
+ default:
+ return;
}
ViewportRanges vpRanges = av.getRanges();
return labelWidthWest;
}
+ /**
+ * Clears the flag that allows a 'fast paint' on the next repaint, so
+ * requiring a full repaint
+ */
+ public void setNoFastPaint()
+ {
+ fastPaint = false;
+ }
+
}
public class OverviewRenderer
{
// transparency of hidden cols/seqs overlay
- private final float TRANSPARENCY = 0.5f;
+ private static final float TRANSPARENCY = 0.5f;
public static final String UPDATE = "OverviewUpdate";
private Timer timer;
- private boolean isJS = Platform.isJS();
-
- private int delay = (isJS ? 1 : 0);
+ private int delay = (Platform.isJS() ? 1 : 0);
private int seqIndex;
sendProgressUpdate(1, 1, 0, 0);
}
}
+
panel.overviewDone(miniMe);
}
int icol)
{
return (seq == null || icol >= seq.getLength()
- ? resColFinder.GAP_COLOUR
- : resColFinder.getResidueColourInt(true, shader, allGroups, seq,
- icol, finder));
+ ? resColFinder.gapColourInt
+ : resColFinder.getResidueColourInt(true, shader, allGroups, seq,
+ icol, finder));
}
/**
public static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray
.darker();
- final int GAP_COLOUR; // default colour to use at gaps
+ final Color gapColour; // colour to use for gaps
- final int RESIDUE_COLOUR; // default colour to use at residues
+ final int gapColourInt;
- final Color HIDDEN_COLOUR; // colour for hidden regions
+ final Color residueColour; // colour to use for uncoloured residues
+
+ final int residueColourInt;
+
+ final Color hiddenColour; // colour for hidden regions
boolean useLegacy = false;
{
if (useLegacyColouring)
{
- GAP_COLOUR = Color.white.getRGB();
- RESIDUE_COLOUR = Color.lightGray.getRGB();
+ gapColour = Color.white;
+ residueColour = Color.lightGray;
}
else
{
- GAP_COLOUR = gapCol.getRGB();
- RESIDUE_COLOUR = Color.white.getRGB();
+ gapColour = gapCol;
+ residueColour = Color.WHITE;
}
- HIDDEN_COLOUR = hiddenCol;
+ gapColourInt = gapColour.getRGB();
+ residueColourInt = residueColour.getRGB();
+ hiddenColour = hiddenCol;
}
@Override
- /**
- * for Test suite only.
- */
public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
{
return new Color(getBoxColourInt(shader, seq, i));
boolean isGap = Comparison.isGap(currentChar);
if (shader.getColourScheme() == null)
{
- return (isGap ? GAP_COLOUR : RESIDUE_COLOUR);
+ return (isGap ? gapColourInt : residueColourInt);
}
- return (isGap && !shader.getColourScheme().hasGapColour() ? GAP_COLOUR
+ return (isGap && !shader.getColourScheme().hasGapColour() ? gapColourInt
: shader.findColourInt(currentChar, i, seq));
}
- /**
- * For test suite only.
- */
@Override
public Color getResidueColour(boolean showBoxes, ResidueShaderI shader,
SequenceGroup[] allGroups, final SequenceI seq, int i,
FeatureColourFinder finder)
{
- return new Color(getResidueColourInt(showBoxes, shader, allGroups, seq,
- i, finder));
+ Color col = getResidueBoxColour(showBoxes, shader, allGroups, seq, i);
+
+ // if there's a FeatureColourFinder we might override the residue colour
+ // here with feature colouring
+ col = finder == null || finder.noFeaturesDisplayed() ? col
+ : finder.findFeatureColour(col, seq, i);
+ return col;
}
return seq.setColor(i, col);
}
- /**
- * For test suite only.
- */
@Override
protected Color getResidueBoxColour(boolean showBoxes,
ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
*/
protected Color getHiddenColour()
{
- return HIDDEN_COLOUR;
+ return hiddenColour;
}
}
return; // BH 2019.07.27 standard check for no changes
}
- // listeners include:
-
- // jalview.gui.SeqCanvas[,0,0,568x90,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
- // STARTRES, STARTRESANDSEQ
- // jalview.gui.IdCanvas[,0,0,112x90,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=112,height=0]]
- // jalview.gui.ScalePanel[,0,0,594x17,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
- // jalview.gui.AnnotationPanel[,0,0,0x162,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=1,height=162]]
- // jalview.gui.AlignmentPanel[,0,0,706x133,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777225,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=220,height=166]]
- // jalview.gui.OverviewPanel[,0,0,543x135,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=543,height=135]]
-
-
// "STARTRES" is a misnomer here -- really "STARTORENDRES"
// note that this could be "no change" if the range is just being expanded
changeSupport.firePropertyChange(STARTRES, oldstartres, startRes);
*/
public void setStartResAndSeq(int res, int seq)
{
- // from Overview only
int width = getViewportWidth();
int[] oldresvalues = updateStartEndRes(res, res + width - 1);
{
vpstart = visHeight - h;
}
- // System.out.println("ViewportRanges setviewportStartAndHeight " + vpstart
- // + " " + start + " " + h + " " + getVisibleAlignmentHeight());
setStartEndSeq(vpstart, vpstart + h - 1);
}
}
/**
- * Set the viewport location so that a position is visible. From
- * SeqPanel.scrollToVisible(true) only, from AlignFrame keyboard actions
- * SeqPanel.scrollCursor[Row(VK_S)/Column(VK_C)/RowAndColumn(VK_ENTER,COMMA)/Position(VK_P)]
- *
+ * Set the viewport location so that a position is visible
*
* @param x
* column to be visible: absolute position in alignment
fr.findAllFeatures(true);
av.setShowSequenceFeatures(true);
fr.setColour("Pfam", new FeatureColour(Color.yellow));
+ seq1.resetColors();
assertEquals(or.getColumnColourFromSequence(null, seq1, 0),
Color.yellow.getRGB());
// don't show sequence features
av.setShowSequenceFeatures(false);
+ seq1.resetColors();
assertEquals(or.getColumnColourFromSequence(null, seq1, 0),
Color.magenta.getRGB());
}
av.getResidueShading(), null, seq, 3, null));
}
- @Test
+ @Test(groups = "Functional")
public void testGetResidueBoxColour_group()
{
SequenceI seq = new Sequence("name", "MA--TVLGSPRAPAFF");
av.getResidueShading(), groups, seq, 2, null));
}
- @Test
+ @Test(groups = "Functional")
public void testGetBoxColour()
{
SequenceI seq = new Sequence("name", "MAT--GSPRAPAFF"); // FER1_MAIZE... + a