public void drawAxes(Graphics g) { g.setColor(Color.yellow); for (int i = 0; i < 3; i++) { g.drawLine( size().width / 2, size().height / 2, (int) (axes[i][0] * scale * max[0] + size().width / 2), (int) (axes[i][1] * scale * max[1] + size().height / 2)); } }
public void paint(Graphics g) { // Only create the image at the beginning - if ((img == null) || (prefsize.width != size().width) || (prefsize.height != size().height)) { prefsize.width = size().width; prefsize.height = size().height; scale = findScale(); // System.out.println("New scale = " + scale); img = createImage(size().width, size().height); ig = img.getGraphics(); redrawneeded = true; } if (redrawneeded == true) { drawBackground(ig, Color.black); drawScene(ig); if (drawAxes == true) { drawAxes(ig); } redrawneeded = false; } else { ig = img.getGraphics(); } g.drawImage(img, 0, 0, this); }
public void drawScene(Graphics g) { boolean darker = false; int halfwidth = size().width / 2; int halfheight = size().height / 2; 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) + halfheight; float z = sp.coord[1] - centre[2]; if (sp.sequence instanceof DrawableSequence) { if (((DrawableSequence) sp.sequence).color == Color.black) { g.setColor(Color.white); } else { g.setColor(((DrawableSequence) sp.sequence).color); } } else { g.setColor(Color.red); } if (av != null) { if (av.getSelection().contains(((SequencePoint) points.elementAt(i)).sequence)) { g.setColor(Color.gray); } } if (z < 0) { g.setColor(g.getColor().darker()); } g.fillRect(x - 3, y - 3, 6, 6); g.setColor(Color.red); } // //Now the rectangle // if (rectx2 != -1 && recty2 != -1) { // g.setColor(Color.white); // // g.drawRect(rectx1,recty1,rectx2-rectx1,recty2-recty1); // } }
public void drawBackground(Graphics g, Color col) { g.setColor(col); g.fillRect(0, 0, prefsize.width, prefsize.height); }