예제 #1
0
 public void paint(Graphics g) {
   if (loadflag && (!runflag)) {
     g.clearRect(0, 0, 530, 330);
     Graphics2D g2D = (Graphics2D) g;
     g2D.translate(0, 50); // 设置图像左上角为当前点
     g.drawImage(iImage, 0, 0, null); // 画输入图        	
   }
 }
예제 #2
0
  public void init() {
    Graphics g = getGraphics();
    Rectangle b = getBounds();
    g.clearRect(0, 0, b.width, b.height);
    // last_data_pos = ((NslVariable)variable_list.elementAt(0)).last_data_pos;
    // data = ((NslVariable)variable_list.elementAt(0)).data;
    paint(g);
    // draw_time = -1;

  }
예제 #3
0
 /** Clear all contents */
 public void clear() {
   if (gr == null) return;
   gr.clearRect(0, 0, getSize().width, getSize().height);
   repaint();
   if (state != null) {
     synchronized (state) {
       state.clear();
     }
   }
 }
예제 #4
0
  public void paint(Graphics g) {
    System.out.println("paint");
    Graphics2D g2d = (Graphics2D) g;

    Point1 p1, p2;

    n = paintInfo.size();

    if (toolFlag == 2) g2d.clearRect(0, 0, getSize().width - 100, getSize().height - 100); // 清除

    for (int i = 0; i < n - 1; i++) {
      p1 = (Point1) paintInfo.elementAt(i);
      p2 = (Point1) paintInfo.elementAt(i + 1);
      size = new BasicStroke(p1.boarder, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);

      g2d.setColor(p1.col);
      g2d.setStroke(size);

      if (p1.tool == p2.tool) {
        switch (p1.tool) {
          case 0: // 画笔
            Line2D line1 = new Line2D.Double(p1.x, p1.y, p2.x, p2.y);
            g2d.draw(line1);
            break;

          case 1: // 橡皮
            g.clearRect(p1.x, p1.y, p1.boarder, p1.boarder);
            break;

          case 3: // 画直线
            Line2D line2 = new Line2D.Double(p1.x, p1.y, p2.x, p2.y);
            g2d.draw(line2);
            break;

          case 4: // 画圆
            Ellipse2D ellipse =
                new Ellipse2D.Double(p1.x, p1.y, Math.abs(p2.x - p1.x), Math.abs(p2.y - p1.y));
            g2d.draw(ellipse);
            break;

          case 5: // 画矩形
            Rectangle2D rect =
                new Rectangle2D.Double(p1.x, p1.y, Math.abs(p2.x - p1.x), Math.abs(p2.y - p1.y));
            g2d.draw(rect);
            break;

          case 6: // 截断,跳过
            i = i + 1;
            break;

          default:
        } // end switch
      } // end if
    } // end for
  }
예제 #5
0
 public void paintComponent(Graphics g) { // display
   if (isFirst) {
     myWidth = getWidth();
     myHeight = getHeight();
     define();
     isFirst = false;
   }
   g.clearRect(0, 0, getWidth(), getHeight());
   room.draw(g); // draw map
   store.draw(g); // draw sidebar
   // b.draw(g);
   theMinion.draw(g);
   if (to != null) { // tower selected movement
     to.draw(g, xval, yval, to);
   }
   for (Tower i : tplace) {
     i.draw(g, i);
   }
 }
예제 #6
0
파일: LJ3MDApp.java 프로젝트: eskilj/mvp
 public void update(Graphics g) {
   if (img == null) g.clearRect(0, 0, getSize().width, getSize().height);
   paintComponent(g);
 }