X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FRotatableCanvas.java;h=370de5f9cdbc95c8fb2b7021fa67e671520cfa1e;hb=99f3f01792321efb671ac7ad946efffc3a3319a4;hp=9fa7491cfa4e9daf6314bbbca93bd4425e7a20b2;hpb=8c2ee75d86492f03e4c01404855f9ad2dd305719;p=jalview.git diff --git a/src/jalview/appletgui/RotatableCanvas.java b/src/jalview/appletgui/RotatableCanvas.java index 9fa7491..370de5f 100755 --- a/src/jalview/appletgui/RotatableCanvas.java +++ b/src/jalview/appletgui/RotatableCanvas.java @@ -36,6 +36,8 @@ public class RotatableCanvas RotatableMatrix idmat = new RotatableMatrix(3, 3); RotatableMatrix objmat = new RotatableMatrix(3, 3); RotatableMatrix rotmat = new RotatableMatrix(3, 3); + String tooltip; + int toolx, tooly; //RubberbandRectangle rubberband; @@ -80,17 +82,23 @@ public class RotatableCanvas float scalefactor = 1; AlignViewport av; + boolean showLabels = false; public RotatableCanvas(AlignViewport av) { this.av = av; } + public void showLabels(boolean b) + { + showLabels = b; + repaint(); + } + public void setPoints(Vector points, int npoint) { this.points = points; this.npoint = npoint; - this.av = av; PaintRefresher.Register(this, av.alignment); prefsize = getPreferredSize(); @@ -285,6 +293,10 @@ public class RotatableCanvas return getPreferredSize(); } + public void update(Graphics g) + { + paint(g); + } public void paint(Graphics g) { if (points == null) @@ -317,6 +329,12 @@ public class RotatableCanvas drawAxes(ig); } + if(tooltip!=null) + { + ig.setColor(Color.red); + ig.drawString(tooltip, toolx, tooly); + } + g.drawImage(img, 0, 0, this); } } @@ -341,7 +359,7 @@ public class RotatableCanvas public void drawScene(Graphics g) { - boolean darker = false; + //boolean darker = false; int halfwidth = getSize().width / 2; int halfheight = getSize().height / 2; @@ -376,14 +394,14 @@ public class RotatableCanvas } g.fillRect(x - 3, y - 3, 6, 6); - g.setColor(Color.red); + if (showLabels) + { + g.setColor(Color.red); + g.drawString( ( (SequencePoint) points.elementAt(i)).sequence. + getName(), + x - 3, y - 4); + } } -// //Now the rectangle -// if (rectx2 != -1 && recty2 != -1) { -// g.setColor(Color.white); -// -// g.drawRect(rectx1,recty1,rectx2-rectx1,recty2-recty1); -// } } public Dimension minimumsize() @@ -404,7 +422,6 @@ public class RotatableCanvas public void keyPressed(KeyEvent evt) { - requestFocus(); if (evt.getKeyCode() == KeyEvent.VK_UP) { scalefactor = (float) (scalefactor * 1.1); @@ -494,27 +511,26 @@ public class RotatableCanvas repaint(); } - // private void fireSequenceSelectionEvent(Selection sel) { - // controller.handleSequenceSelectionEvent(new SequenceSelectionEvent(this,sel)); - //} public void mouseMoved(MouseEvent evt) { - // SequenceI found = findPoint(evt.getX(), evt.getY()); + SequenceI found = findPoint(evt.getX(), evt.getY()); + if(found==null) + tooltip = null; + else + { + tooltip = found.getName(); + toolx = evt.getX(); + tooly = evt.getY(); + } + repaint(); } public void mouseDragged(MouseEvent evt) { mx = evt.getX(); my = evt.getY(); - //Check if this is a rectangle drawing drag - if ( (evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) - { -// rectx2 = evt.getX(); -// recty2 = evt.getY(); - } - else - { + rotmat.setIdentity(); rotmat.rotate( (float) (my - omy), 'x'); @@ -544,13 +560,11 @@ public class RotatableCanvas omy = my; paint(this.getGraphics()); - } - } public void rectSelect(int x1, int y1, int x2, int y2) { - boolean changedSel = false; + //boolean changedSel = false; for (int i = 0; i < npoint; i++) { SequencePoint sp = (SequencePoint) points.elementAt(i); @@ -601,26 +615,5 @@ public class RotatableCanvas return null; } } - /* public boolean handleRubberbandEvent(RubberbandEvent evt) { - System.out.println("Rubberband handler called in RotatableCanvas with " + - evt.getBounds()); - - Rubberband rb = (Rubberband)evt.getSource(); - - // Clear the current selection (instance variable) - //if ((rb.getModifiers() & Event.SHIFT_MASK) == 0) { - // clearSelection(); - //} - - if (rb.getComponent() == this) { - Rectangle bounds = evt.getBounds(); - rectSelect(bounds.x,bounds.y,bounds.x+bounds.width,bounds.y+bounds.height); - } - - redrawneeded = true; - paint(this.getGraphics()); - - return true; - }*/ }