Class PictureExplorer

java.lang.Object
  extended by PictureExplorer
All Implemented Interfaces:
ActionListener, MouseListener, MouseMotionListener, EventListener

public class PictureExplorer
extends Object
implements MouseMotionListener, ActionListener, 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

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

Constructor Summary
PictureExplorer(DigitalPicture picture)
          Public constructor
 
Method Summary
 void actionPerformed(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
 JPanel createLocationPanel(Font labelFont)
          Create the pixel location panel
 void displayPixelInformation(String xString, 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(String[] args)
          Test Main.
 void mouseClicked(MouseEvent e)
          Method called when the mouse is clicked
 void mouseDragged(MouseEvent e)
          Called when the mouse is dragged (button held down and moved)
 void mouseEntered(MouseEvent e)
          Method called when the component is entered (mouse moves over it)
 void mouseExited(MouseEvent e)
          Method called when the mouse moves over the component
 void mouseMoved(MouseEvent e)
          Method called when the mouse is moved with no buttons down
 void mousePressed(MouseEvent e)
          Method called when the mouse button is pushed down
 void mouseReleased(MouseEvent e)
          Method called when the mouse button is released
 void repaint()
          Repaints the image on the scrollpane.
 void setTitle(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(String title)
Set the title of the frame

Parameters:
title - the title to use in the JFrame

createLocationPanel

public JPanel createLocationPanel(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(MouseEvent e)
Called when the mouse is dragged (button held down and moved)

Specified by:
mouseDragged in interface MouseMotionListener
Parameters:
e - MouseEvent to track

displayPixelInformation

public void displayPixelInformation(String xString,
                                    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(MouseEvent e)
Method called when the mouse is moved with no buttons down

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

mouseClicked

public void mouseClicked(MouseEvent e)
Method called when the mouse is clicked

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

mousePressed

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

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

mouseReleased

public void mouseReleased(MouseEvent e)
Method called when the mouse button is released

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

mouseEntered

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

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

mouseExited

public void mouseExited(MouseEvent e)
Method called when the mouse moves over the component

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

actionPerformed

public void actionPerformed(ActionEvent a)
Controls the zoom menu bar

Specified by:
actionPerformed in interface ActionListener
Parameters:
a - ActionEvent to track

main

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