Example #1
0
  public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE && gamerunner.running) {

      Graphics gr = this.getGraphics();
      gr.setFont(new Font("TimesRoman", Font.PLAIN, 40));
      gr.drawString("PAUSE", (int) this.getWidth() / 2, this.getHeight() / 2);
      if (!online) {
        gamerunner.running = false;
      }
      if (soundan) {} // end of if
      Menu menu = new Menu(this);
      // volume.setValue(vol);
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
      gamerunner.running = true;
      if (soundan) {} // end of if
    } // end of if-else
    else if (e.getKeyCode() == KeyEvent.VK_R && !online) {
      restartGame();
    } else if (e.getKeyCode() == KeyEvent.VK_F11) {
      dispose();
      setUndecorated(true);
      String[] arguments = {"fullscreen"};
      new JavaGame(arguments);
    } else if (e.getKeyCode() == KeyEvent.VK_ENTER && online) {
      String message =
          JOptionPane.showInputDialog(null, "Chat", "Nachricht", JOptionPane.PLAIN_MESSAGE);
      try {
        if (!message.isEmpty()) {
          client.sendNewChatMessage(player[client.id].name, message);
        }
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    }
  }
Example #2
0
 /** Dessine l'icone de la grille */
 protected static void drawGrid(Graphics g, int x, int y, Color c) {
   g.setColor(c);
   for (int i = 0; i < TX.length; i++)
     g.drawLine(TX[i][0] + x, TX[i][2] + y, TX[i][1] + x, TX[i][2] + y);
   for (int i = 0; i < TY.length; i++)
     g.drawLine(TY[i][2] + x, TY[i][0] + y, TY[i][2] + x, TY[i][1] + y);
 }
 private void scaleImage() {
   Image img =
       back.getScaledInstance(scx(back.getWidth()), scy(back.getHeight()), Image.SCALE_SMOOTH);
   back =
       new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
   Graphics g = back.getGraphics();
   g.drawImage(img, 0, 0, null);
   g.dispose();
 }
 @Override
 public void paintComponent(Graphics g) {
   if (selected) {
     g.setColor(selColor);
     g.fillRoundRect(0, 0, getWidth(), getHeight(), getWidth() / 10, getHeight() / 10);
     label.setForeground(Color.YELLOW);
   } else label.setForeground(Color.WHITE);
   super.paintComponent(g);
 }
Example #5
0
 /**
  * Turn a (possibly) translucent or indexed image into a display-compatible bitmask image using
  * the given alpha threshold and render-to-background colour, or display-compatible translucent
  * image. The alpha values in the image are set to either 0 (below threshold) or 255 (above
  * threshold). The render-to-background colour bg_col is used to determine how the pixels
  * overlapping transparent pixels should be rendered. The fast algorithm just sets the colour
  * behind the transparent pixels in the image (for bitmask source images); the slow algorithm
  * actually renders the image to a background of bg_col (for translucent sources).
  *
  * @param thresh alpha threshold between 0 and 255
  * @param fast use fast algorithm (only set bg_col behind transp. pixels)
  * @param bitmask true=use bitmask, false=use translucent
  */
 public JGImage toDisplayCompatible(int thresh, JGColor bg_col, boolean fast, boolean bitmask) {
   Color bgcol = new Color(bg_col.r, bg_col.g, bg_col.b);
   int bgcol_rgb = (bgcol.getRed() << 16) | (bgcol.getGreen() << 8) | bgcol.getBlue();
   JGPoint size = getSize();
   int[] buffer = getPixels();
   // render image to bg depending on bgcol
   BufferedImage img_bg;
   if (bitmask) {
     img_bg = createCompatibleImage(size.x, size.y, Transparency.BITMASK);
   } else {
     img_bg = createCompatibleImage(size.x, size.y, Transparency.TRANSLUCENT);
   }
   int[] bg_buf;
   if (!fast) {
     Graphics g = img_bg.getGraphics();
     g.setColor(bgcol);
     // the docs say I could use bgcol in the drawImage as an
     // equivalent to the following two lines, but this
     // doesn't handle translucency properly and is _slower_
     g.fillRect(0, 0, size.x, size.y);
     g.drawImage(img, 0, 0, null);
     bg_buf = new JREImage(img_bg).getPixels();
   } else {
     bg_buf = buffer;
   }
   // g.dispose();
   // ColorModel rgb_bitmask = ColorModel.getRGBdefault();
   // rgb_bitmask = new PackedColorModel(
   //		rgb_bitmask.getColorSpace(),25,0xff0000,0x00ff00,0x0000ff,
   //		0x1000000, false, Transparency.BITMASK, DataBuffer.TYPE_INT);
   //		ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean
   // isAlphaPremultiplied, int trans, int transferType)
   int[] thrsbuf = new int[size.x * size.y];
   for (int y = 0; y < size.y; y++) {
     for (int x = 0; x < size.x; x++) {
       if (((buffer[y * size.x + x] >> 24) & 0xff) >= thresh) {
         thrsbuf[y * size.x + x] = bg_buf[y * size.x + x] | (0xff << 24);
       } else {
         // explicitly set the colour of the transparent pixel.
         // This makes a difference when scaling!
         // thrsbuf[y*size.x+x]=bg_buf[y*size.x+x]&~(0xff<<24);
         thrsbuf[y * size.x + x] = bgcol_rgb;
       }
     }
   }
   return new JREImage(
       output_comp.createImage(
           new MemoryImageSource(
               size.x,
               size.y,
               // rgb_bitmask,
               img_bg.getColorModel(), // display compatible bitmask
               bitmask ? thrsbuf : bg_buf,
               0,
               size.x)));
 }
Example #6
0
 public void paint(Graphics g) {
   if (comp != null) {
     width = comp.getWidth() / 6;
     height = comp.getHeight() * 2 / 3;
   }
   g.setColor(bgColor);
   g.fillRect(x, y, width, height);
   g.setColor(fgColor);
   g.setFont(font);
   g.drawString(strTray, x / 2 + width / 2, y + height + 10);
   super.paint(g);
 }
    public void paint(Graphics g) {
      g.setColor(getBackground());
      g.fillRect(0, 0, getWidth(), getHeight());

      for (int i = 0; i < numImages; i++) {
        if (x[i] > 3 * i) {
          nudge(i);
          squish(g, icon[i], xh[i], yh[i], scale[i]);
        } else {
          x[i] += .05;
          y[i] += .05;
        }
      }
    }
Example #8
0
File: set.java Project: wcyuan/Set
  public void paint(Graphics g) {
    Message("Copyright Feb, 2000 Weicon Conan Yuan.", "All Rights Reserved", 7);
    for (int i = 0; i < NUM_LOCATIONS; i++) {
      locs[i].draw(g, this);
      g.setColor(txtcolor);
      if (locs[i].ToDraw()) {
        g.drawString("" + i, locs[i].GetX(), locs[i].GetY() + 10);
      }
    }

    g.setColor(Color.red);
    g.drawRect(400, 200, 30, 30);
    g.fillRect(400, 200, 30, 30);
    Message("Cheat", 4);
  }
Example #9
0
  public void paint(Graphics g) {
    gRef = (Graphics2D) g;

    // change size of font
    gRef.setFont(gRef.getFont().deriveFont(9.0f));

    fmRef = g.getFontMetrics();

    // Clear background

    if (Preferences.monochrome) {
      gRef.setColor(Preferences.whiteColor);
    } else {
      gRef.setColor(Preferences.backgroundColor);
    }
    gRef.fillRect(0, 0, getWidth(), getHeight());

    // set colour to correct drawing colour
    if (Preferences.monochrome) {
      gRef.setColor(Preferences.blackColor);
    } else {
      gRef.setColor(Preferences.penColor);
    }

    gRef.translate(0, margin);

    // Call c code to draw tree
    gRef.scale(scale, scale);
    nativeDrawTree();
  }
 public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
   g.setColor(Color.white);
   g.fillRect(0, 0, c.getWidth(), c.getHeight());
   if (getImageObserver() == null) {
     g.drawImage(
         getImage(),
         c.getWidth() / 2 - getIconWidth() / 2,
         c.getHeight() / 2 - getIconHeight() / 2,
         c);
   } else {
     g.drawImage(
         getImage(),
         c.getWidth() / 2 - getIconWidth() / 2,
         c.getHeight() / 2 - getIconHeight() / 2,
         getImageObserver());
   }
 }
Example #11
0
 public void setClip(Graphics g) {
   if (g == null) return;
   int scaleHeight = mHeight;
   scaleHeight -= (mBottom + mTop);
   int scaleWidth = mWidth;
   scaleWidth -= (mLeft + mRight);
   g.setClip(mLeft, mTop, scaleWidth, scaleHeight);
 }
Example #12
0
    public void paintComponent(Graphics page) {
      super.paintComponent(page);

      Image icon = this.getToolkit().getImage("chess1.jpg");
      page.drawImage(icon, -40, 20, this);

      setOpaque(false);
    }
Example #13
0
 public void paint(Graphics g) {
   g.setColor(this.getBackground());
   g.fillRect(0, 0, this.width, this.height);
   g.setColor(this.getForeground());
   g.drawImage(this.imLogo, 10, 40, this);
   g.setFont(this.fontTitle);
   g.drawString(this.appName, 70, 65);
   g.setFont(this.fontText);
   int startY = 130;
   int l = 6;
   for (int i = 0; i < textLines.length; ++i) {
     g.drawString(this.textLines[i], 10, startY);
     startY += 20;
   }
   if (str != null) g.drawString(str, 10, startY);
   g.drawImage(this.imHelp, 50, startY + 30, this);
 }
  private synchronized void render(Graphics g) {
    if (level != null) {
      int xScroll = (int) (player.pos.x - screen.w / 2);
      int yScroll = (int) (player.pos.y - (screen.h - 24) / 2);
      soundPlayer.setListenerPosition((float) player.pos.x, (float) player.pos.y);
      level.render(screen, xScroll, yScroll);
    }
    if (!menuStack.isEmpty()) {
      menuStack.peek().render(screen);
    }

    Font.draw(screen, "FPS: " + fps, 10, 10);
    // for (int p = 0; p < players.length; p++) {
    // if (players[p] != null) {
    // String msg = "P" + (p + 1) + ": " + players[p].getScore();
    // Font.draw(screen, msg, 320, screen.h - 24 + p * 8);
    // }
    // }
    if (player != null && menuStack.size() == 0) {
      Font.draw(screen, player.health + " / 10", 340, screen.h - 19);
      Font.draw(screen, "" + player.score, 340, screen.h - 33);
    }

    g.setColor(Color.BLACK);

    g.fillRect(0, 0, getWidth(), getHeight());
    g.translate((getWidth() - GAME_WIDTH * SCALE) / 2, (getHeight() - GAME_HEIGHT * SCALE) / 2);
    g.clipRect(0, 0, GAME_WIDTH * SCALE, GAME_HEIGHT * SCALE);

    if (!menuStack.isEmpty() || level != null) {

      // render mouse
      renderMouse(screen, mouseButtons);

      g.drawImage(screen.image, 0, 0, GAME_WIDTH * SCALE, GAME_HEIGHT * SCALE, null);
    }

    // String msg = "FPS: " + fps;
    // g.setColor(Color.LIGHT_GRAY);
    // g.drawString(msg, 11, 11);
    // g.setColor(Color.WHITE);
    // g.drawString(msg, 10, 10);

  }
Example #15
0
 public void paint(Graphics g) {
   Dimension d = getSize();
   int j = line_ascent + btnMarginHeight;
   for (int k = 0; k < num_lines; k++) {
     int i = (d.width - line_widths[k]) / 2;
     g.drawString(lines[k], i, j);
     j += line_height;
   }
   if (btnPlacement == 1 || btnPlacement == 2) setSize(d.width, max_height);
 }
 public void squish(Graphics g, ImageIcon icon, int x, int y, double scale) {
   if (isVisible()) {
     g.drawImage(
         icon.getImage(),
         x,
         y,
         (int) (icon.getIconWidth() * scale),
         (int) (icon.getIconHeight() * scale),
         this);
   }
 }
Example #17
0
  public static java.awt.image.BufferedImage loadBufferedImageFromResources(
      Component c, String filename) {

    try {
      Misc m = new Misc();
      java.awt.Image img = loadImageFromResources(filename);
      MediaTracker mt = new MediaTracker(c);
      mt.addImage(img, 0);
      mt.waitForID(0);
      int width = img.getWidth(null);
      int height = img.getHeight(null);
      BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
      Graphics gg = bi.getGraphics();
      gg.drawImage(img, 0, 0, null);
      gg.dispose();
      return bi;
    } catch (Exception ex) {
      System.out.println(ex.toString());
    }
    return null;
  }
  /** Paints the image on the window. */
  public void paint(Graphics g) {
    g.drawImage(image, 0, 0, this);

    // Notify method splash that the window has been painted.
    // Note: To improve performance we do not enter the synchronized block unless we have to.
    if (!paintCalled) {
      paintCalled = true;
      synchronized (this) {
        notifyAll();
      }
    }
  }
Example #19
0
  /** Affichage du logo */
  protected void drawLogo(Graphics g) {

    int x = 5;
    int y = 2;

    g.setColor(getBackground());
    g.fillRect(0, 0, W, H);

    // Remplissage
    fillBG(g, x, y, Color.white);

    // Dessin
    drawGrid(
        g,
        x,
        y,
        !isAvailable()
            ? Aladin.MYGRAY
            : isActive() ? Aladin.GREEN : isMouseIn() ? Color.blue : Color.black);

    // Label
    g.setColor(isAvailable() ? Color.black : Aladin.MYGRAY);
    g.setFont(Aladin.SPLAIN);
    g.drawString(LABEL, W / 2 - g.getFontMetrics().stringWidth(LABEL) / 2, H - 2);
  }
Example #20
0
  // draws the current snapshot
  public void paintComponent(Graphics g) {

    // System.out.println("In paint in draw");
    super.paintComponent(g);
    my_width = getSize().width;
    my_height = getSize().height;
    if (my_image != null) g.drawImage(my_image, 0, 0, my_width, my_height, this);

    setBackground(new Color(1.0f, 1.0f, 1.0f));
    //         g.setColor(Color.black);
    //         g.drawRect(0,0,my_width-1,my_height-1);

  }
Example #21
0
File: set.java Project: wcyuan/Set
    public void centerText(String s1, String s2, Graphics g, Color c, int x, int y, int w, int h) {
      // locs[0].centerText(s1, s2, this.getGraphics(),
      // Color.white, 400,0,200,50);
      // g.setXORMode(unselected_color);
      // centerText("pic" + im, null, g, Color.black, x, y, w, h);

      Font f = g.getFont();
      FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(f);
      int ascent = fm.getAscent();
      int height = fm.getHeight();
      int width1 = 0, width2 = 0, x0 = 0, x1 = 0, y0 = 0, y1 = 0;
      width1 = fm.stringWidth(s1);
      if (s2 != null) width2 = fm.stringWidth(s2);
      x0 = x + (w - width1) / 2;
      x0 = x + (w - width2) / 2;
      if (s2 == null) y0 = y + (h - height) / 2 + ascent;
      else {
        y0 = y + (h - (int) (height * 2.2)) / 2 + ascent;
        y1 = y0 + (int) (height * 1.2);
      }
      g.setColor(c);
      g.drawString(s1, x0, y0);
      if (s2 != null) g.drawString(s2, x1, y1);
    }
Example #22
0
File: set.java Project: wcyuan/Set
    public void draw(Graphics g, ImageObserver ob) {
      if (!todraw) {
        g.setColor(bgcolor);
        g.drawRect(x, y, w + 2 * border, h + 2 * border);
        g.fillRect(x, y, w + 2 * border, h + 2 * border);
        return;
      }

      if (selected) g.setColor(selected_color);
      else g.setColor(unselected_color);

      g.drawRect(x, y, w + 2 * border, h + 2 * border);
      g.fillRect(x, y, w + 2 * border, h + 2 * border);
      g.drawImage(image[im], x + border, y + border, ob);

      // g.setColor(Color.black);
      // g.drawString("" + im,x+5,y+5);
    }
Example #23
0
 @Override
 public void paintIcon(Component c, Graphics g, int x, int y) {
   Graphics2D g2 = (Graphics2D) g.create();
   g2.setPaint(Objects.nonNull(c) ? c.getBackground() : Color.WHITE);
   g2.fillRect(x, y, getIconWidth(), getIconHeight());
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   g2.setColor(ELLIPSE_COLOR);
   g2.translate(x, y);
   int size = list.size();
   for (int i = 0; i < size; i++) {
     float alpha = isRunning ? (i + 1) / (float) size : .5f;
     g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
     g2.fill(list.get(i));
   }
   // g2.translate(-x, -y);
   g2.dispose();
 }
Example #24
0
File: set.java Project: wcyuan/Set
  public void Message(String s1, String s2, int i) {
    Graphics g = getGraphics();

    if (s1 == null || s2 == null) {
      g.setColor(bgcolor);
      g.drawRect(400, 50 * i - 10, 200, 20);
      g.fillRect(400, 50 * i - 10, 200, 20);
      return;
    }
    /*
      g.setColor(Color.blue);
      g.drawRect(400,50 * i - 10,200,20);
      g.fillRect(400,50 * i - 10,200,20);
    */
    g.setColor(txtcolor);
    g.drawString(s1, 400, 50 * i);
    g.drawString(s2, 400, 50 * i + 10);
  }
  /** Paint it. */
  public void paint(Graphics g) {
    Dimension d = getSize();
    g.setColor(Color.black);
    int xoff = d.width / 3;
    int yoff = d.height / 3;
    g.drawLine(xoff, 0, xoff, d.height);
    g.drawLine(2 * xoff, 0, 2 * xoff, d.height);
    g.drawLine(0, yoff, d.width, yoff);
    g.drawLine(0, 2 * yoff, d.width, 2 * yoff);

    int i = 0;
    for (int r = 0; r < 3; r++) {
      for (int c = 0; c < 3; c++, i++) {
        if ((white & (1 << i)) != 0) {
          g.drawImage(notImage, c * xoff + 1, r * yoff + 1, this);
        } else if ((black & (1 << i)) != 0) {
          g.drawImage(crossImage, c * xoff + 1, r * yoff + 1, this);
        }
      }
    }
  }
 @Override
 public void paintComponent(Graphics g) {
   g.drawImage(back, 0, 0, null);
   super.paintComponent(g);
 }
 public final void paint(Graphics g) {
   all = true;
   if (inner != null) inner.paint(g);
   if (forcems) g.drawImage(fms, 0, 0, this);
 }
 private final void showpercent(String s, int i, int j) {
   Graphics g = getGraphics();
   Font font = new Font("Helvetica", 1, 13);
   FontMetrics fontmetrics = getFontMetrics(font);
   Font font1 = new Font("Helvetica", 0, 13);
   FontMetrics fontmetrics1 = getFontMetrics(font1);
   if (all || !img && mt.checkAll(true)) {
     all = false;
     if (img || mt.checkAll(true)) {
       g.drawImage(loading, 0, 0, this);
       img = true;
     } else {
       g.setColor(Color.black);
       g.fillRect(0, 0, 512, 344);
     }
     g.setColor(Color.white);
     g.setFont(font);
     String s1 = "RuneScape has been updated!";
     g.drawString(s1, 256 - fontmetrics.stringWidth(s1) / 2, 125);
     s1 = "Please wait - Fetching new files...";
     g.drawString(s1, 256 - fontmetrics.stringWidth(s1) / 2, 140);
     g.setFont(font1);
     s1 = "This may take a few minutes, but only";
     g.drawString(s1, 256 - fontmetrics1.stringWidth(s1) / 2, 165);
     s1 = "needs to be done when the game is updated.";
     g.drawString(s1, 256 - fontmetrics1.stringWidth(s1) / 2, 180);
   }
   Color color = new Color(140, 17, 17);
   g.setColor(color);
   g.drawRect(104, 190, 304, 34);
   g.fillRect(106, 192, j * 3, 30);
   g.setColor(Color.black);
   g.fillRect(106 + j * 3, 192, 300 - j * 3, 30);
   String s2 = "Loading " + s + " - " + i + "%";
   g.setFont(font);
   g.setColor(Color.white);
   g.drawString(s2, 256 - fontmetrics.stringWidth(s2) / 2, 212);
 }
Example #29
0
  // ------------------------------------------------------------------
  // initialize the canvas contents or judge the user's mouse events and respond
  public void paint(Graphics g) {

    // if forceNumber < 0 and !mUp: do nothing until mUp

    // if forceNumber < 0 and mUp (click): start the forces
    if (forceNumber < 0 && mUp) {
      fInit = true;
      mDown = false;
      // next line added 4/17/08 (correction for case of zero force true answer)
      mUp = false;
      forceNumber = 0;
      forceName = forceNames[forceNumber];
      userPosX = tailPosX;
      userPosY = tailPosY;
      numTries = 0;
      messageCanvas.notifyMouseClick(blinkerStrings[forceNumber]);
      // create the force equation and vector objects
      canvasEquation = new CanvasEquation(g);
      canvasVector = new CanvasVector(g);
    }

    // if mouseDown and all forces finished: do end game
    if (mDown && (forceNumber == maxForceNumber + 1)) {
      endGame("OK", cgiScript, problemNo, mouseUpsString);
    }

    // if mouseDown or mouseDrag and really a force:
    //     erase user's old vector & eqn, update position
    if ((mDown || mDrag) && (forceNumber >= 0) && (forceNumber <= maxForceNumber)) {
      messageCanvas.notifyMouseDown(blinkerStrings[forceNumber]);
      eraseUserStuff(g, forceX[0], forceY[0], 0);
      if (numEquations == 2) {
        eraseUserStuff(g, forceX[1], forceY[1], 1);
      }
      userPosX = newUserPosX;
      userPosY = newUserPosY;
    }

    // if browserPaint or forceInit or mouseDown or mouseDrag and really a force:
    //     plot fixed & user's new stuff
    if ((ifBrowserPaint || fInit || mDown || mDrag)
        && (forceNumber >= 0)
        && (forceNumber <= maxForceNumber)) {

      // redraw the userCanvas bounding box and the apparatus
      g.setColor(Color.black);
      g.drawRect(0, 0, userFrameX, userFrameY);
      problemSelector.drawUserApparatus(g);

      // draw the user's previously-done correct vectors
      if (forceNumber > 0) {
        drawDoneVectors(forceNumber - 1, g);
      }

      // draw the user's new vector and equation
      canvasVector.plotVector(tailPosX, tailPosY, userPosX, userPosY, g);
      forceX[0] = p2fX(userPosX, userPosY);
      forceY[0] = p2fY(userPosX, userPosY);
      canvasEquation.plotEquation(g, forceName, units, forceX[0], forceY[0], 0);
      if (numEquations == 2) {
        forceX[1] = (int) Math.round(cost * forceX[0] - sint * forceY[0]);
        forceY[1] = (int) Math.round(sint * forceX[0] + cost * forceY[0]);
        canvasEquation.plotEquation(g, forceName, units, forceX[1], forceY[1], 1);
      }

      // get ready up for new input
      fInit = mDown = mDrag = false;
      if (ifBrowserPaint) {
        ifBrowserPaint = false;
      }
    }

    // if mouseUp, evaluate the user's answer
    if (mUp && (forceNumber >= 0) && (forceNumber < numForces)) {

      // keep track of the mouse ups
      String leftStr = "";
      String rightStr = "";
      String midStr = mouseUpsString.substring(forceNumber, forceNumber + 1);
      if (forceNumber > 0) {
        leftStr = mouseUpsString.substring(0, forceNumber);
      }
      if (forceNumber < numForces - 1) {
        rightStr = mouseUpsString.substring(forceNumber + 1, numForces);
      }
      int numTries = Integer.parseInt(midStr);
      numTries++;
      if (numTries <= 9) {
        midStr = Integer.toString(numTries);
      } else {
        midStr = "9";
      }
      mouseUpsString = leftStr + midStr + rightStr;

      // if correct, cycle to the next force or to the trailer message
      int matchIndex = matchForceComps[forceNumber] - 1;

      int depX = Math.abs(forceX[matchIndex] - truAnsX[forceNumber][matchIndex]);
      int depY = Math.abs(forceY[matchIndex] - truAnsY[forceNumber][matchIndex]);
      if ((depX <= forceTolerance) && (depY <= forceTolerance)) {

        // erase the user's stuff
        for (int n = 0; n <= numEquations - 1; n++) {
          eraseUserStuff(g, forceX[n], forceY[n], n);
        }

        // draw the apparatus
        problemSelector.drawUserApparatus(g);

        // draw the set of correctly done vectors
        drawDoneVectors(forceNumber, g);

        // notify the resultsCanvas of the user's correctly drawn force
        boolean ifResultsDone = false;
        if (forceNumber == maxForceNumber) {
          ifResultsDone = true;
        }
        resultsCanvas.notifyMouseUpOk(
            ifResultsDone,
            forceNumber,
            forceNames,
            units,
            truAnsX,
            truAnsY,
            resultsSpacingStrings,
            numEquations,
            numForces);

        // cycle the force or do the end game
        if (forceNumber < maxForceNumber) {
          forceNumber++;
          numTries = 0;
          forceName = forceNames[forceNumber];
          userPosX = tailPosX;
          userPosY = tailPosY;
          forceX[0] = forceY[0] = forceX[1] = forceY[1] = 0;
          // draw the equation and message for the *next* force
          for (int n = 0; n <= numEquations - 1; n++) {
            canvasEquation.plotEquation(g, forceName, units, forceX[n], forceY[n], n);
          }
          // notify the messageCanvas that there is a new force
          messageCanvas.notifyMouseUpOk(blinkerStrings[forceNumber]);
        } else {
          g.setColor(userTrailerColor);
          g.drawString(userTrailer, userTrailerPosX, userTrailerPosY);
          // notify the messageCanvas that we are all done
          messageCanvas.notifyMouseUpOk("done");
          forceNumber++;
        }
      }
      // if not correct and mode > 1, check # of tries
      else {
        if (problemMode > 1 && numTries >= maxTriesEachForce) {
          endGame("notOK", cgiScript, problemNo, mouseUpsString);
        }
      }
      fInit = mUp = mDown = false;
    }
  }
 public void paint(Graphics g) {
   if (image != null) {
     g.drawImage(image, 0, 0, getSize().width, getSize().height, this);
   }
 }