예제 #1
0
  public void paint(Graphics gg) {
    int faceSize = Math.min(getWidth() - 4, getHeight() - 4);
    if (face == null)
      face =
          new PADFaceMapped(
              Math.max(2, (getWidth() - faceSize) / 2),
              Math.max(2, (getHeight() - faceSize) / 2),
              faceSize);
    if (buffer == null) {
      im = this.createImage(getWidth(), getHeight());
      buffer = im.getGraphics();
    }
    super.paint(buffer);

    buffer.setColor(new Color(255, 255, 255, 0));
    buffer.fillRect(0, 0, im.getWidth(null), im.getHeight(null));

    face.setDimensions(
        Math.max(2, (getWidth() - faceSize) / 2),
        Math.max(2, (getHeight() - faceSize) / 2),
        faceSize);
    face.paint(buffer);

    // draw buffer to screen
    gg.drawImage(im, 0, 0, null, null);
  }
예제 #2
0
 public void showState(int mousex, int mousey) {
   p = ((double) mousex - (double) getWidth() / (double) 2) / ((double) (getWidth() + 1) / 2.0);
   d = -((double) mousey - (double) getHeight() / (double) 2) / ((double) (getHeight() + 1) / 2.0);
   setXY(p, d);
   face.setEmotion(p, a, d, mousex, mousey);
   paint();
   this.getGraphics().drawLine(mousex - 3, mousey, mousex + 3, mousey);
   this.getGraphics().drawLine(mousex, mousey - 3, mousex, mousey + 3);
 }
예제 #3
0
 public void mouseMoved(MouseEvent e) {
   if (isEnabled()) {
     setXY(
         ((double) e.getX() - (double) getWidth() / (double) 2)
             / ((double) (getWidth() + 1) / 2.0),
         -((double) e.getY() - (double) getHeight() / (double) 2)
             / ((double) (getHeight() + 1) / 2.0));
     face.setEmotion(p, a, d, e.getX(), e.getY());
   }
   paint();
 }
예제 #4
0
 public void reset() {
   p = 0;
   a = 0;
   d = 0;
   face.setEmotion(p, a, d);
 }