public void draw(Graphics2D g2, int zoomFactor) {
    float dash1[] = {4.0f};
    Stroke oldStroke=g2.getStroke();
    BasicStroke bs = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
                                     BasicStroke.JOIN_MITER, 3.0f, dash1, 0.0f);

    if (type == TYPE_RECT) {
      int x=(int)rect.getX()*zoomFactor, y=(int)rect.getY()*zoomFactor;
      int w=(int)rect.getWidth()*zoomFactor, h=(int)rect.getHeight()*zoomFactor;

      g2.setColor(Color.black);
      g2.drawRect(x, y, w, h);
      g2.setStroke(bs);
      g2.setColor(Color.white);
      g2.drawRect(x, y, w, h);

      g2.setStroke(oldStroke);
      g2.setColor(Color.black);
      g2.fillRect(x-2, y-2, 4, 4);
      g2.fillRect(x+w-2, y-2, 4, 4);
      g2.fillRect(x+w-2, y+h-2, 4, 4);
      g2.fillRect(x-2, y+h-2, 4, 4);
      g2.setColor(Color.white);
      g2.drawRect(x-2, y-2, 4, 4);
      g2.drawRect(x+w-2, y-2, 4, 4);
      g2.drawRect(x+w-2, y+h-2, 4, 4);
      g2.drawRect(x-2, y+h-2, 4, 4);
    } else if (type == TYPE_CIRCLE) {
      int x=(int)circle_center.getX()*zoomFactor;
      int y=(int)circle_center.getY()*zoomFactor;
      int r=circle_r*zoomFactor;

      g2.setColor(Color.black);
      g2.drawOval(x-r,y-r,r*2,r*2);
      g2.setStroke(bs);
      g2.setColor(Color.white);
      g2.drawOval(x-r,y-r,r*2,r*2);

      g2.setStroke(oldStroke);
      g2.setColor(Color.black);
      g2.fillRect(x+r-2,y-2, 4, 4);
      g2.setColor(Color.white);
      g2.drawRect(x+r-2,y-2, 4, 4);

    } else if (type == TYPE_POLY) {
      Polygon pg=poly;
      if (zoomFactor!=1) {
        pg=new Polygon();
        for (int i=0; i<poly.npoints; i++)
            pg.addPoint(poly.xpoints[i]*zoomFactor, poly.ypoints[i]*zoomFactor);
      }
      g2.setColor(Color.black);
      g2.drawPolygon(pg);
      g2.setStroke(bs);
      g2.setColor(Color.white);
      g2.drawPolygon(pg);

      g2.setStroke(oldStroke);
      g2.setColor(Color.black);
      for (int i=0; i<poly.npoints; i++)
        g2.fillRect(poly.xpoints[i]*zoomFactor-2, poly.ypoints[i]*zoomFactor-2, 4, 4);
      g2.setColor(Color.white);
      for (int i=0; i<poly.npoints; i++)
        g2.drawRect(poly.xpoints[i]*zoomFactor-2, poly.ypoints[i]*zoomFactor-2, 4, 4);
    }
  }