import jalview.datamodel.SequencePoint;
import jalview.math.RotatableMatrix;
import jalview.math.RotatableMatrix.Axis;
+import jalview.util.ColorUtils;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
}
- public void showLabels(boolean b)
+ /**
+ * Refreshes the display with labels shown (or not)
+ *
+ * @param show
+ */
+ public void showLabels(boolean show)
{
- showLabels = b;
+ showLabels = show;
repaint();
}
* Resets axes to the initial state: x-axis to the right, y-axis up, z-axis to
* back (so obscured in a 2-D display)
*/
- public void resetAxes()
+ protected void resetAxes()
{
axisEndPoints[0] = new Point(1f, 0f, 0f);
axisEndPoints[1] = new Point(0f, 1f, 0f);
* sequence point, and also the min-max range (width) for each dimension, and
* the maximum width for all dimensions
*/
- public void findWidth()
+ protected void findWidth()
{
max = new float[DIMS];
min = new float[DIMS];
*
* @return DOCUMENT ME!
*/
- public float findScale()
+ protected float findScale()
{
int dim;
int w;
/**
* Computes and saves the position of the centre of the view
*/
- public void findCentre()
+ protected void findCentre()
{
findWidth();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- int halfwidth = getWidth() / 2;
- int halfheight = getHeight() / 2;
-
for (int i = 0; i < npoint; i++)
{
+ /*
+ * sequence point colour as sequence id, but
+ * gray if sequence is currently selected
+ */
SequencePoint sp = points.elementAt(i);
- int x = (int) ((sp.coord.x - centre.x) * scale) + halfwidth;
- int y = (int) ((sp.coord.y - centre.y) * scale)
- + halfheight;
- float z = sp.coord.y - centre.z; // todo sp.coord.z JAL-2963
-
- SequenceI sequence = sp.getSequence();
- if (av.getSequenceColour(sequence) == Color.black)
- {
- g.setColor(Color.white);
- }
- else
- {
- g.setColor(av.getSequenceColour(sequence));
- }
-
- if (av.getSelectionGroup() != null)
- {
- if (av.getSelectionGroup().getSequences(null)
- .contains(sequence))
- {
- g.setColor(Color.gray);
- }
- }
-
- if (z < 0)
- {
- g.setColor(g.getColor().darker());
- }
+ Color sequenceColour = getSequencePointColour(sp);
+ g.setColor(sequenceColour);
+ int halfwidth = getWidth() / 2;
+ int halfheight = getHeight() / 2;
+ int x = (int) ((sp.coord.x - centre.x) * scale) + halfwidth;
+ int y = (int) ((sp.coord.y - centre.y) * scale) + halfheight;
g.fillRect(x - 3, y - 3, 6, 6);
+
if (showLabels)
{
g.setColor(Color.red);
- g.drawString(sequence.getName(), x - 3, y - 4);
+ g.drawString(sp.getSequence().getName(), x - 3, y - 4);
}
}
// }
}
+ /**
+ * Determines the colour to use when drawing a sequence point. The colour is
+ * taken from the sequence id, with black converted to white, and then
+ * graduated from darker (at the back) to brighter (at the front) based on the
+ * z-axis coordinate of the point.
+ *
+ * @param sp
+ * @return
+ */
+ protected Color getSequencePointColour(SequencePoint sp)
+ {
+ SequenceI sequence = sp.getSequence();
+ Color sequenceColour = av.getSequenceColour(sequence);
+ if (sequenceColour == Color.black)
+ {
+ sequenceColour = Color.white;
+ }
+ if (av.getSelectionGroup() != null)
+ {
+ if (av.getSelectionGroup().getSequences(null).contains(sequence))
+ {
+ sequenceColour = Color.gray;
+ }
+ }
+
+ /*
+ * graduate from front (brighter) to back (darker)
+ */
+ sequenceColour = ColorUtils.getGraduatedColour(sp.coord.z, min[2],
+ max[2], sequenceColour);
+
+ return sequenceColour;
+ }
+
@Override
public void keyTyped(KeyEvent evt)
{
* @param x2
* @param y2
*/
- public void rectSelect(int x1, int y1, int x2, int y2)
+ protected void rectSelect(int x1, int y1, int x2, int y2)
{
for (int i = 0; i < npoint; i++)
{
*
* @return
*/
- public SequenceI findSequenceAtPoint(int x, int y)
+ protected SequenceI findSequenceAtPoint(int x, int y)
{
int halfwidth = getWidth() / 2;
int halfheight = getHeight() / 2;