X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FRotatableCanvas.java;h=458d971171eca664caf1b3662ab23ca35855e834;hb=df9eac352d5fc1252e6377fec7cfc29fd841c932;hp=3fcfd3d61c2fe73ffef7745534b23c59dbf11774;hpb=8c2ee75d86492f03e4c01404855f9ad2dd305719;p=jalview.git diff --git a/src/jalview/gui/RotatableCanvas.java b/src/jalview/gui/RotatableCanvas.java index 3fcfd3d..458d971 100755 --- a/src/jalview/gui/RotatableCanvas.java +++ b/src/jalview/gui/RotatableCanvas.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -22,8 +22,6 @@ import jalview.datamodel.*; import jalview.math.*; -import jalview.util.*; - import java.awt.*; import java.awt.event.*; @@ -74,6 +72,8 @@ public class RotatableCanvas extends JPanel implements MouseListener, int recty2; float scalefactor = 1; AlignViewport av; + boolean showLabels = false; + Color bgColour = Color.black; // Controller controller; public RotatableCanvas(AlignViewport av) @@ -81,6 +81,12 @@ public class RotatableCanvas extends JPanel implements MouseListener, this.av = av; } + public void showLabels(boolean b) + { + showLabels = b; + repaint(); + } + public void setPoints(Vector points, int npoint) { this.points = points; @@ -88,7 +94,7 @@ public class RotatableCanvas extends JPanel implements MouseListener, ToolTipManager.sharedInstance().registerComponent(this); ToolTipManager.sharedInstance().setInitialDelay(0); ToolTipManager.sharedInstance().setDismissDelay(10000); - PaintRefresher.Register(this, av.alignment); + PaintRefresher.Register(this, av.getSequenceSetId()); prefsize = getPreferredSize(); orig = new float[npoint][3]; @@ -132,7 +138,6 @@ public class RotatableCanvas extends JPanel implements MouseListener, scale = findScale(); addMouseListener(this); - addKeyListener(this); addMouseMotionListener(this); @@ -295,8 +300,13 @@ public class RotatableCanvas extends JPanel implements MouseListener, * * @param g DOCUMENT ME! */ - public void paintComponent(Graphics g) + public void paintComponent(Graphics g1) { + + Graphics2D g = (Graphics2D) g1; + + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); if(points==null) { g.setFont(new Font("Verdana", Font.PLAIN, 18)); @@ -318,7 +328,8 @@ public class RotatableCanvas extends JPanel implements MouseListener, ig = img.getGraphics(); } - drawBackground(ig, Color.black); + + drawBackground(ig, bgColour); drawScene(ig); if (drawAxes == true) @@ -337,6 +348,7 @@ public class RotatableCanvas extends JPanel implements MouseListener, */ public void drawAxes(Graphics g) { + g.setColor(Color.yellow); for (int i = 0; i < 3; i++) @@ -364,9 +376,14 @@ public class RotatableCanvas extends JPanel implements MouseListener, * * @param g DOCUMENT ME! */ - public void drawScene(Graphics g) + public void drawScene(Graphics g1) { - boolean darker = false; + + Graphics2D g = (Graphics2D) g1; + + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + int halfwidth = getWidth() / 2; int halfheight = getHeight() / 2; @@ -391,7 +408,7 @@ public class RotatableCanvas extends JPanel implements MouseListener, if (av.getSelectionGroup() != null) { - if (av.getSelectionGroup().sequences.contains( + if (av.getSelectionGroup().getSequences(false).contains( ((SequencePoint) points.elementAt(i)).sequence)) { g.setColor(Color.gray); @@ -404,7 +421,13 @@ public class RotatableCanvas extends JPanel implements MouseListener, } 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 @@ -460,8 +483,6 @@ public class RotatableCanvas extends JPanel implements MouseListener, */ public void keyPressed(KeyEvent evt) { - requestFocus(); - if (evt.getKeyCode() == KeyEvent.VK_UP) { scalefactor = (float) (scalefactor * 1.1); @@ -485,24 +506,6 @@ public class RotatableCanvas extends JPanel implements MouseListener, repaint(); } - /** - * DOCUMENT ME! - */ - public void printPoints() - { - for (int i = 0; i < npoint; i++) - { - SequencePoint sp = (SequencePoint) points.elementAt(i); - Format.print(System.out, "%5d ", i); - - for (int j = 0; j < 3; j++) - { - Format.print(System.out, "%13.3f ", sp.coord[j]); - } - - System.out.println(); - } - } /** * DOCUMENT ME! @@ -572,7 +575,7 @@ public class RotatableCanvas extends JPanel implements MouseListener, if (av.getSelectionGroup() != null) { av.getSelectionGroup().addOrRemove(found, true); - PaintRefresher.Refresh(this, av.alignment); + PaintRefresher.Refresh(this, av.getSequenceSetId()); } else { @@ -663,8 +666,6 @@ public class RotatableCanvas extends JPanel implements MouseListener, */ public void rectSelect(int x1, int y1, int x2, int y2) { - boolean changedSel = false; - for (int i = 0; i < npoint; i++) { SequencePoint sp = (SequencePoint) points.elementAt(i); @@ -677,9 +678,8 @@ public class RotatableCanvas extends JPanel implements MouseListener, { if (av != null) { - if (!av.getSelectionGroup().sequences.contains(sp.sequence)) + if (!av.getSelectionGroup().getSequences(false).contains(sp.sequence)) { - changedSel = true; av.getSelectionGroup().addSequence(sp.sequence, true); } }