From: amwaterhouse Date: Fri, 23 Sep 2005 16:18:02 +0000 (+0000) Subject: Draw labels, anti alias X-Git-Tag: Release_2_06~12 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=fb1ff6c555915bb15fd546c569faf59fdc2a1ff1;p=jalview.git Draw labels, anti alias --- diff --git a/src/jalview/gui/RotatableCanvas.java b/src/jalview/gui/RotatableCanvas.java index 3fcfd3d..92abbf6 100755 --- a/src/jalview/gui/RotatableCanvas.java +++ b/src/jalview/gui/RotatableCanvas.java @@ -74,6 +74,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 +83,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; @@ -297,6 +305,7 @@ public class RotatableCanvas extends JPanel implements MouseListener, */ public void paintComponent(Graphics g) { + if(points==null) { g.setFont(new Font("Verdana", Font.PLAIN, 18)); @@ -318,7 +327,8 @@ public class RotatableCanvas extends JPanel implements MouseListener, ig = img.getGraphics(); } - drawBackground(ig, Color.black); + + drawBackground(ig, bgColour); drawScene(ig); if (drawAxes == true) @@ -335,8 +345,13 @@ public class RotatableCanvas extends JPanel implements MouseListener, * * @param g DOCUMENT ME! */ - public void drawAxes(Graphics g) + public void drawAxes(Graphics g1) { + Graphics2D g = (Graphics2D) g1; + + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g.setColor(Color.yellow); for (int i = 0; i < 3; i++) @@ -364,9 +379,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; @@ -404,7 +424,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