Example #1
0
 /**
  * Set the image that this panel should show.
  *
  * @param image The image to be displayed.
  */
 public void setImage(OFImage image) {
   if (image != null) {
     width = image.getWidth();
     height = image.getHeight();
     panelImage = image;
     repaint();
   }
 }
 /**
  * Apply this filter to an image.
  *
  * @param image The image to be changed by this filter.
  */
 public void apply(OFImage image) {
   int height = image.getHeight();
   int width = image.getWidth();
   for (int y = 0; y < height; y++) {
     for (int x = 0; x < width / 2; x++) {
       Color left = image.getPixel(x, y);
       image.setPixel(x, y, image.getPixel(width - 1 - x, y));
       image.setPixel(width - 1 - x, y, left);
     }
   }
 }
Example #3
0
 /** Clear the image on this panel. */
 public void clearImage() {
   Graphics imageGraphics = panelImage.getGraphics();
   imageGraphics.setColor(Color.LIGHT_GRAY);
   imageGraphics.fillRect(0, 0, width, height);
   repaint();
 }