Ejemplo n.º 1
0
  /**
   * This method renders all debug text in the canvas. Doing is useful in a graphical application
   * because it's tricky stopping the debugger while rendering, so using this technique we can view
   * variable data in the app while it is running.
   *
   * @param g2 The graphics context for this canvas.
   */
  private void renderDebugText(Graphics2D g2) {
    // AND FINALLY, THE DEBUG TEXT, IF THE OPTION IS TURNED ON
    AnimatedSpriteEditor singleton = AnimatedSpriteEditor.getEditor();
    if (singleton.isDebugTextEnabled()) {
      // SET THE CORRECT FONT AND COLOR
      g2.setFont(DEBUG_TEXT_FONT);
      g2.setColor(DEBUG_TEXT_COLOR);

      // GET EACH ITEM ONE AT A TIME
      Iterator<String> debugTextIt = singleton.getDebugTextIterator();
      int x = DEBUG_TEXT_START_X;
      int y = DEBUG_TEXT_START_Y;
      while (debugTextIt.hasNext()) {
        String text = debugTextIt.next();
        g2.drawString(text, x, y);
        y += DEBUG_TEXT_LINE_SPACING;
      }
      singleton.clearDebugText();
    }
  }