public class PictureExplorer
extends java.lang.Object
implements java.awt.event.MouseMotionListener, java.awt.event.ActionListener, java.awt.event.MouseListener
Modifier and Type | Class and Description |
---|---|
private class |
PictureExplorer.PictureExplorerFocusTraversalPolicy
Class for establishing the focus for the textfields
|
Modifier and Type | Field and Description |
---|---|
private javax.swing.JLabel |
bValue
blue value label
|
private int |
colIndex
column index
|
private javax.swing.JLabel |
colLabel
column label
|
private javax.swing.JButton |
colNextButton
column next button
|
private javax.swing.JLabel |
colorLabel
color swatch label
|
private javax.swing.JPanel |
colorPanel
panel to show the color swatch
|
private javax.swing.JButton |
colPrevButton
column previous button
|
private javax.swing.JTextField |
colValue
text field to show column index
|
private javax.swing.JMenuItem |
fifty
50% zoom level
|
private javax.swing.JMenuItem |
fiveHundred
500% zoom level
|
private javax.swing.JLabel |
gValue
green value label
|
private javax.swing.JMenuItem |
hundred
100% zoom level
|
private javax.swing.JMenuItem |
hundredFifty
150% zoom level
|
private ImageDisplay |
imageDisplay
The image display
|
private javax.swing.JMenuBar |
menuBar
menu bar
|
private int |
numberBase
the number system to use, 0 means starting at 0, 1 means starting at 1
|
private DigitalPicture |
picture
The picture being explored
|
private javax.swing.JFrame |
pictureFrame
window to hold GUI
|
private int |
rowIndex
row index
|
private javax.swing.JLabel |
rowLabel
row label
|
private javax.swing.JButton |
rowNextButton
row next button
|
private javax.swing.JButton |
rowPrevButton
row previous button
|
private javax.swing.JTextField |
rowValue
text field to show row index
|
private javax.swing.JLabel |
rValue
red value label
|
private javax.swing.ImageIcon |
scrollImageIcon
The image icon used to display the picture
|
private javax.swing.JScrollPane |
scrollPane
window that allows the user to scroll to see a large picture
|
private javax.swing.JMenuItem |
seventyFive
75% zoom level
|
private javax.swing.JMenuItem |
twentyFive
25% zoom level
|
private javax.swing.JMenuItem |
twoHundred
200% zoom level
|
private double |
zoomFactor
the zoom factor (amount to zoom)
|
private javax.swing.JMenu |
zoomMenu
zoom menu
|
Constructor and Description |
---|
PictureExplorer(DigitalPicture picture)
Public constructor
|
Modifier and Type | Method and Description |
---|---|
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
|
private void |
clearInformation()
Method to clear the labels and current color and reset the
current index to -1
|
private void |
createAndInitPictureFrame()
Method to create and initialize the picture frame
|
private void |
createAndInitScrollingImage()
Create and initialize the scrolling image
|
private javax.swing.JPanel |
createColorInfoPanel(java.awt.Font labelFont)
Create the color information panel
|
private void |
createInfoPanel()
Creates the North JPanel with all the pixel location
and color information
|
javax.swing.JPanel |
createLocationPanel(java.awt.Font labelFont)
Create the pixel location panel
|
private void |
createWindow()
Creates the JFrame and sets everything up
|
private void |
displayPixelInformation(int pictureX,
int pictureY)
Method to display pixel information for the passed x and y
|
private void |
displayPixelInformation(java.awt.event.MouseEvent e)
Method to display pixel information based on a mouse event
|
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
|
private void |
enableZoomItems()
Method to enable all menu commands
|
private boolean |
isLocationInPicture(int column,
int row)
Method to check if the given x and y are in the picture
|
static void |
main(java.lang.String[] args)
Main method for testing the Picture.java class
|
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
|
private void |
setUpMenuBar()
Method to create the menu bar, menus, and menu items
|
private void |
setUpNextAndPreviousButtons()
Method to set up the next and previous buttons for the
pixel location information
|
void |
zoom(double factor)
Zooms in the on picture by scaling the image.
|
private int rowIndex
private int colIndex
private javax.swing.JFrame pictureFrame
private javax.swing.JScrollPane scrollPane
private javax.swing.JLabel colLabel
private javax.swing.JButton colPrevButton
private javax.swing.JButton rowPrevButton
private javax.swing.JButton colNextButton
private javax.swing.JButton rowNextButton
private javax.swing.JLabel rowLabel
private javax.swing.JTextField colValue
private javax.swing.JTextField rowValue
private javax.swing.JLabel rValue
private javax.swing.JLabel gValue
private javax.swing.JLabel bValue
private javax.swing.JLabel colorLabel
private javax.swing.JPanel colorPanel
private javax.swing.JMenuBar menuBar
private javax.swing.JMenu zoomMenu
private javax.swing.JMenuItem twentyFive
private javax.swing.JMenuItem fifty
private javax.swing.JMenuItem seventyFive
private javax.swing.JMenuItem hundred
private javax.swing.JMenuItem hundredFifty
private javax.swing.JMenuItem twoHundred
private javax.swing.JMenuItem fiveHundred
private DigitalPicture picture
private javax.swing.ImageIcon scrollImageIcon
private ImageDisplay imageDisplay
private double zoomFactor
private int numberBase
public PictureExplorer(DigitalPicture picture)
picture
- the picture to explorepublic void changeToBaseOne()
public void setTitle(java.lang.String title)
title
- the title to use in the JFrameprivate void createAndInitPictureFrame()
private void setUpMenuBar()
private void createAndInitScrollingImage()
private void createWindow()
private void setUpNextAndPreviousButtons()
public javax.swing.JPanel createLocationPanel(java.awt.Font labelFont)
labelFont
- the font for the labelsprivate javax.swing.JPanel createColorInfoPanel(java.awt.Font labelFont)
labelFont
- the font to use for labelsprivate void createInfoPanel()
public void checkScroll()
public void zoom(double factor)
factor
- the amount to zoom bypublic void repaint()
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
e
- the mouse eventprivate boolean isLocationInPicture(int column, int row)
column
- the horizontal valuerow
- the vertical valuepublic void displayPixelInformation(java.lang.String xString, java.lang.String yString)
xString
- the x value as a string from the useryString
- the y value as a string from the userprivate void displayPixelInformation(int pictureX, int pictureY)
pictureX
- the x value in the picturepictureY
- the y value in the pictureprivate void displayPixelInformation(java.awt.event.MouseEvent e)
e
- a mouse eventprivate void clearInformation()
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
e
- the mouse eventpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
e
- the mouse eventpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
e
- the mouse eventpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
e
- the mouse eventpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
e
- the mouse eventpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
e
- the mouse eventprivate void enableZoomItems()
public void actionPerformed(java.awt.event.ActionEvent a)
actionPerformed
in interface java.awt.event.ActionListener
a
- the ActionEventpublic static void main(java.lang.String[] args)
args
- the array of arguments sent to the main method