X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fappletgui%2FRotatableCanvas.java;h=615edbd9a15b2f4482047084747702632750c560;hb=65d6d09cd08743d481d39521bb0298ea683888f8;hp=86d06d99a11c58144779fe40ca73cfdb56012ddb;hpb=21c29b20790ac555b2e2a124a034f6c6b4486270;p=jalview.git
diff --git a/src/jalview/appletgui/RotatableCanvas.java b/src/jalview/appletgui/RotatableCanvas.java
index 86d06d9..615edbd 100755
--- a/src/jalview/appletgui/RotatableCanvas.java
+++ b/src/jalview/appletgui/RotatableCanvas.java
@@ -1,31 +1,47 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
- * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.appletgui;
-import java.util.*;
-
-import java.awt.*;
-import java.awt.event.*;
-
import jalview.api.RotatableCanvasI;
-import jalview.datamodel.*;
-import jalview.math.*;
-import jalview.util.*;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.datamodel.SequencePoint;
+import jalview.math.RotatableMatrix;
+import jalview.util.ColorUtils;
+import jalview.util.Format;
+import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Panel;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.util.Vector;
public class RotatableCanvas extends Panel implements MouseListener,
MouseMotionListener, KeyListener, RotatableCanvasI
@@ -96,11 +112,11 @@ public class RotatableCanvas extends Panel implements MouseListener,
float scalefactor = 1;
- AlignViewport av;
+ AlignmentViewport av;
boolean showLabels = false;
- public RotatableCanvas(AlignViewport av)
+ public RotatableCanvas(AlignmentViewport av)
{
this.av = av;
}
@@ -111,6 +127,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
repaint();
}
+ @Override
public void setPoints(Vector points, int npoint)
{
this.points = points;
@@ -272,7 +289,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
dim = height;
}
- return (float) (dim * scalefactor / (2 * maxwidth));
+ return dim * scalefactor / (2 * maxwidth);
}
public void findCentre()
@@ -289,6 +306,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
// System.out.println("Centre z " + centre[2]);
}
+ @Override
public Dimension getPreferredSize()
{
if (prefsize != null)
@@ -301,22 +319,26 @@ public class RotatableCanvas extends Panel implements MouseListener,
}
}
+ @Override
public Dimension getMinimumSize()
{
return getPreferredSize();
}
+ @Override
public void update(Graphics g)
{
paint(g);
}
+ @Override
public void paint(Graphics g)
{
if (points == null)
{
g.setFont(new Font("Verdana", Font.PLAIN, 18));
- g.drawString(MessageManager.getString("label.calculating_pca") + "....", 20, getSize().height / 2);
+ g.drawString(MessageManager.getString("label.calculating_pca")
+ + "....", 20, getSize().height / 2);
}
else
{
@@ -381,8 +403,8 @@ public class RotatableCanvas extends Panel implements MouseListener,
for (int i = 0; i < npoint; i++)
{
SequencePoint sp = (SequencePoint) points.elementAt(i);
- int x = (int) ((float) (sp.coord[0] - centre[0]) * scale) + halfwidth;
- int y = (int) ((float) (sp.coord[1] - centre[1]) * scale)
+ int x = (int) ((sp.coord[0] - centre[0]) * scale) + halfwidth;
+ int y = (int) ((sp.coord[1] - centre[1]) * scale)
+ halfheight;
float z = sp.coord[1] - centre[2];
@@ -392,7 +414,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
}
else
{
- g.setColor(av.getSequenceColour(sp.sequence));
+ g.setColor(ColorUtils.getColor(av.getSequenceColour(sp.sequence)));
}
if (av.getSelectionGroup() != null)
@@ -429,14 +451,17 @@ public class RotatableCanvas extends Panel implements MouseListener,
return prefsize;
}
+ @Override
public void keyTyped(KeyEvent evt)
{
}
+ @Override
public void keyReleased(KeyEvent evt)
{
}
+ @Override
public void keyPressed(KeyEvent evt)
{
if (evt.getKeyCode() == KeyEvent.VK_UP)
@@ -475,22 +500,27 @@ public class RotatableCanvas extends Panel implements MouseListener,
}
}
+ @Override
public void mouseClicked(MouseEvent evt)
{
}
+ @Override
public void mouseEntered(MouseEvent evt)
{
}
+ @Override
public void mouseExited(MouseEvent evt)
{
}
+ @Override
public void mouseReleased(MouseEvent evt)
{
}
+ @Override
public void mousePressed(MouseEvent evt)
{
int x = evt.getX();
@@ -535,6 +565,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
repaint();
}
+ @Override
public void mouseMoved(MouseEvent evt)
{
SequenceI found = findPoint(evt.getX(), evt.getY());
@@ -551,6 +582,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
repaint();
}
+ @Override
public void mouseDragged(MouseEvent evt)
{
mx = evt.getX();
@@ -558,8 +590,8 @@ public class RotatableCanvas extends Panel implements MouseListener,
rotmat.setIdentity();
- rotmat.rotate((float) (my - omy), 'x');
- rotmat.rotate((float) (mx - omx), 'y');
+ rotmat.rotate(my - omy, 'x');
+ rotmat.rotate(mx - omx, 'y');
for (int i = 0; i < npoint; i++)
{
@@ -593,8 +625,8 @@ public class RotatableCanvas extends Panel implements MouseListener,
for (int i = 0; i < npoint; i++)
{
SequencePoint sp = (SequencePoint) points.elementAt(i);
- int tmp1 = (int) ((sp.coord[0] - centre[0]) * scale + (float) getSize().width / 2.0);
- int tmp2 = (int) ((sp.coord[1] - centre[1]) * scale + (float) getSize().height / 2.0);
+ int tmp1 = (int) ((sp.coord[0] - centre[0]) * scale + getSize().width / 2.0);
+ int tmp2 = (int) ((sp.coord[1] - centre[1]) * scale + getSize().height / 2.0);
if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2)
{
@@ -622,9 +654,9 @@ public class RotatableCanvas extends Panel implements MouseListener,
{
SequencePoint sp = (SequencePoint) points.elementAt(i);
- int px = (int) ((float) (sp.coord[0] - centre[0]) * scale)
+ int px = (int) ((sp.coord[0] - centre[0]) * scale)
+ halfwidth;
- int py = (int) ((float) (sp.coord[1] - centre[1]) * scale)
+ int py = (int) ((sp.coord[1] - centre[1]) * scale)
+ halfheight;
if (Math.abs(px - x) < 3 && Math.abs(py - y) < 3)