void showFrameRate(Graphics g) {
   frames++;
   if (System.currentTimeMillis() > firstFrame + 1000) {
     firstFrame = System.currentTimeMillis();
     fps = frames;
     frames = 0;
   }
   g.setColor(Color.white);
   g.fillRect(10, 12, 50, 15);
   g.setColor(Color.black);
   g.drawString((int) (fps + 0.5) + " fps", 10, 25);
 }
 public void paint(Graphics g) {
   if (histogram != null) {
     if (os == null) {
       os = createImage(WIDTH, HEIGHT);
       osg = os.getGraphics();
       osg.setColor(Color.white);
       osg.fillRect(0, 0, WIDTH, HEIGHT);
       osg.setColor(Color.gray);
       for (int i = 0; i < WIDTH; i++) {
         if (hColors != null) osg.setColor(hColors[i]);
         osg.drawLine(i, HEIGHT, i, HEIGHT - ((int) (HEIGHT * histogram[i]) / hmax) - 4);
       }
       osg.dispose();
     }
     g.drawImage(os, 0, 0, this);
   } else {
     g.setColor(Color.white);
     g.fillRect(0, 0, WIDTH, HEIGHT);
   }
   g.setColor(Color.black);
   g.drawLine(0, HEIGHT - 4, 256, HEIGHT - 4);
   g.drawRect(0, 0, WIDTH, HEIGHT);
   g.drawRect((int) minHue, 1, (int) (maxHue - minHue), HEIGHT - 5);
 }
 void drawZoomIndicator(Graphics g) {
   int x1 = 10;
   int y1 = 10;
   double aspectRatio = (double) imageHeight / imageWidth;
   int w1 = 64;
   if (aspectRatio > 1.0) w1 = (int) (w1 / aspectRatio);
   int h1 = (int) (w1 * aspectRatio);
   if (w1 < 4) w1 = 4;
   if (h1 < 4) h1 = 4;
   int w2 = (int) (w1 * ((double) srcRect.width / imageWidth));
   int h2 = (int) (h1 * ((double) srcRect.height / imageHeight));
   if (w2 < 1) w2 = 1;
   if (h2 < 1) h2 = 1;
   int x2 = (int) (w1 * ((double) srcRect.x / imageWidth));
   int y2 = (int) (h1 * ((double) srcRect.y / imageHeight));
   if (zoomIndicatorColor == null) zoomIndicatorColor = new Color(128, 128, 255);
   g.setColor(zoomIndicatorColor);
   ((Graphics2D) g).setStroke(Roi.onePixelWide);
   g.drawRect(x1, y1, w1, h1);
   if (w2 * h2 <= 200 || w2 < 10 || h2 < 10) g.fillRect(x1 + x2, y1 + y2, w2, h2);
   else g.drawRect(x1 + x2, y1 + y2, w2, h2);
 }