@Override
  protected void updateExample(final ReadOnlyTimer timer) {
    if (allowClicks && zoom) {
      if (index > COUNT - 1) {
        index = COUNT - 1;
      } else if (index < 0) {
        index = 0;
      }
      final int currentTile = MathUtils.floor(index);
      final float fract = index - currentTile;

      if (firstTile != currentTile - 1) {
        // update the textures on the tiles
        firstTile = MathUtils.floor(index - 1);

        for (int i = 0; i < views.length; i++) {
          if (firstTile + i >= 0 && firstTile + i < COUNT) {
            views[i].removeAllComponents();
            views[i].add(srcs[firstTile + i]);
            views[i].updateMinimumSizeFromContents();
            views[i].layout();
            views[i].setVisible(true);
          } else {
            views[i].setVisible(false);
          }
        }
      }

      // update the positions of the tiles.
      final int y = (_canvas.getCanvasRenderer().getCamera().getHeight() / 2) - (hside / 2);
      for (int i = 0; i < views.length; i++) {
        final float x = (i - fract) * (wside + padding);
        views[i].setHudXY(Math.round(x), y);
      }

      // check for and apply movement
      index += timer.getTimePerFrame() * speed;
    }

    // update hud input
    hud.updateGeometricState(timer.getTimePerFrame());
  }
  @Override
  protected void initExample() {
    _canvas.setTitle("Generating textures... please wait");

    final Camera cam = _canvas.getCanvasRenderer().getCamera();
    wside = cam.getWidth() / SPAN;
    hside = wside;
    padding = wside / 10;

    // Set up hud
    hud = new UIHud();
    hud.setupInput(_canvas, _physicalLayer, _logicalLayer);

    // Set up the frames
    for (int i = 0; i < views.length; i++) {
      views[i] = new UIPanel();
      views[i].setLocalComponentSize(wside, hside);
      views[i].layout();
      hud.add(views[i]);
    }

    // Set up the panels
    for (int i = 0; i < COUNT; i++) {
      srcs[i] =
          new UIPanel(null) {
            @Override
            public boolean mousePressed(
                final com.ardor3d.input.MouseButton button,
                final com.ardor3d.input.InputState state) {
              if (zoom || this == zoomed) {
                toggleZoom(this);
              }
              return true;
            };
          };
      srcs[i].setTooltipPopTime(25);
    }

    // set up our different textures...

    int index = 0;

    // check
    setCheck(srcs[index++]);

    // mandelbrot
    setMandelbrot(srcs[index++]);

    // voronoi
    setVoronoi(srcs[index++]);

    // *** 'Planet' example:
    final Function3D terrain = Functions.scaleInput(Functions.simplexNoise(), 2, 2, 1);
    terrainColors = new ReadOnlyColorRGBA[256];
    terrainColors[0] = new ColorRGBA(0, 0, .5f, 1);
    terrainColors[95] = new ColorRGBA(0, 0, 1, 1);
    terrainColors[127] = new ColorRGBA(0, .5f, 1, 1);
    terrainColors[137] = new ColorRGBA(240 / 255f, 240 / 255f, 64 / 255f, 1);
    terrainColors[143] = new ColorRGBA(32 / 255f, 160 / 255f, 0, 1);
    terrainColors[175] = new ColorRGBA(224 / 255f, 224 / 255f, 0, 1);
    terrainColors[223] = new ColorRGBA(128 / 255f, 128 / 255f, 128 / 255f, 1);
    terrainColors[255] = ColorRGBA.WHITE;
    GeneratedImageFactory.fillInColorTable(terrainColors);

    // simplex - luminance
    setTerrain(srcs[index], terrain, false, false);
    srcs[index++].setTooltipText("Simplex noise.");

    // simplex + FBM - luminance
    setTerrain(srcs[index], terrain, true, false);
    srcs[index++].setTooltipText("Simplex noise + Fractional Brownian Motion (fBm).");

    // color ramp
    setColors(srcs[index++]);

    // simplex + FBM - color
    setTerrain(srcs[index], terrain, true, true);
    srcs[index++].setTooltipText("Noise + Colormap == Something that looks like a map. :)");

    // *** A few textures derived from samples in the libnoise project.
    // *** Perhaps we can get an some better ones from the community :)
    // A simple wood grain
    setWoodGrain(srcs[index++]);

    // Jade
    setJade(srcs[index++]);

    // Slime
    setSlime(srcs[index++]);
    _canvas.setTitle("Generated Textures Example - Ardor3D");
  }
 @Override
 protected void updateLogicalLayer(final ReadOnlyTimer timer) {
   hud.getLogicalLayer().checkTriggers(timer.getTimePerFrame());
 }