Class PictureExplorer

java.lang.Object
  extended byPictureExplorer
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

public class PictureExplorer
extends java.lang.Object
implements java.awt.event.MouseMotionListener, java.awt.event.ActionListener, java.awt.event.MouseListener

Displays a picture and lets you explore the picture by displaying the x, y, red, green, and blue values of the pixel at the cursor when you click a mouse button or press and hold a mouse button while moving the cursor. It also lets you zoom in or out. You can also type in a x and y value to see the color at that location. Originally created for the Jython Environment for Students (JES). Modified to work with DrJava by Barbara Ericson Copyright Georgia Institute of Technology 2004

Author:
Keith McDermottt, gte047w@cc.gatech.edu, Barb Ericson ericson@cc.gatech.edu

Constructor Summary
PictureExplorer(DigitalPicture picture)
          Public constructor
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent a)
          Controls the zoom menu bar
 void changeToBaseOne()
          Changes the number system to start at one
 void checkScroll()
          Method to check that the current position is in the viewing area and if not scroll to center the current position if possible
 javax.swing.JPanel createLocationPanel(java.awt.Font labelFont)
          Create the pixel location panel
 void displayPixelInformation(java.lang.String xString, java.lang.String yString)
          Method to display the pixel information from the passed x and y but also converts x and y from strings
static void main(java.lang.String[] args)
          Test Main.
 void mouseClicked(java.awt.event.MouseEvent e)
          Method called when the mouse is clicked
 void mouseDragged(java.awt.event.MouseEvent e)
          Called when the mouse is dragged (button held down and moved)
 void mouseEntered(java.awt.event.MouseEvent e)
          Method called when the component is entered (mouse moves over it)
 void mouseExited(java.awt.event.MouseEvent e)
          Method called when the mouse moves over the component
 void mouseMoved(java.awt.event.MouseEvent e)
          Method called when the mouse is moved with no buttons down
 void mousePressed(java.awt.event.MouseEvent e)
          Method called when the mouse button is pushed down
 void mouseReleased(java.awt.event.MouseEvent e)
          Method called when the mouse button is released
 void repaint()
          Repaints the image on the scrollpane.
 void setTitle(java.lang.String title)
          Set the title of the frame
 void zoom(double factor)
          Zooms in the on picture by scaling the image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PictureExplorer

public PictureExplorer(DigitalPicture picture)
Public constructor

Parameters:
picture - the picture to explore
Method Detail

changeToBaseOne

public void changeToBaseOne()
Changes the number system to start at one


setTitle

public void setTitle(java.lang.String title)
Set the title of the frame

Parameters:
title - the title to use in the JFrame

createLocationPanel

public javax.swing.JPanel createLocationPanel(java.awt.Font labelFont)
Create the pixel location panel

Parameters:
labelFont - the font for the labels
Returns:
the location panel

checkScroll

public void checkScroll()
Method to check that the current position is in the viewing area and if not scroll to center the current position if possible


zoom

public void zoom(double factor)
Zooms in the on picture by scaling the image. It is extremely memory intensive.

Parameters:
factor - the amount to zoom by

repaint

public void repaint()
Repaints the image on the scrollpane.


mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Called when the mouse is dragged (button held down and moved)

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - the mouse event

displayPixelInformation

public void displayPixelInformation(java.lang.String xString,
                                    java.lang.String yString)
Method to display the pixel information from the passed x and y but also converts x and y from strings

Parameters:
xString - the x value as a string from the user
yString - the y value as a string from the user

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Method called when the mouse is moved with no buttons down

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e - the mouse event

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Method called when the mouse is clicked

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Method called when the mouse button is pushed down

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Method called when the mouse button is released

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Method called when the component is entered (mouse moves over it)

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Method called when the mouse moves over the component

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent a)
Controls the zoom menu bar

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
a - the ActionEvent

main

public static void main(java.lang.String[] args)
Test Main. It will ask you to pick a file and then show it