public void paintUpdate(Graphics gra) {
      Graphics2D g = (Graphics2D)gra;
      g.setColor(lineColor);
      g.setStroke(stroke);
      switch(type) {
        case 0: {
          g.draw(new Line2D.Double(startX, startY, endX, endY));
          break;
        }
        case 1: {
          for(int i=0; i<index-1; i++) {
            g.draw(new Line2D.Double(dots[i], dots[i+1]));
          }
          break;
        }
        case 2: {
          g.draw(new Rectangle2D.Double(startX, startY, width, height));
          break;
        }
        case 3: {
          g.draw(new Ellipse2D.Double(startX, startY, width, height));
          break;
        }
        case 4: {
          g.drawPolygon(new int[]{startX, startX, endX}, new int[] {startY, endY, startY}, 3);
          break;
        }
      }
    }