net.sourceforge.jiu.gui.awt.dialogs

Class CropDialog

Implemented Interfaces:
ActionListener, KeyListener

public class CropDialog
extends Dialog
implements ActionListener, KeyListener

A dialog to enter the parameters for an image crop operation.
Author:
Marco Schmidt

Field Summary

private Button
cancel
private int
height
private Label
newHeight
private Label
newWidth
private Button
ok
private boolean
pressedOk
private int
width
private TextField
x1
private TextField
x2
private TextField
y1
private TextField
y2

Constructor Summary

CropDialog(Frame owner, Strings strings, int width, int height)

Method Summary

void
actionPerformed(ActionEvent e)
Hides (closes) this dialog if the OK button was source of the action event (e.g.
int
getHeight()
private int
getValue(TextComponent textField)
Attempts to convert the content of the argument text component to an int; if successful, returns that int, otherwise -1 is returned.
int
getWidth()
Returns the width of the to-be-cropped image as given by the current values in the text fields for left column and right column.
int
getX1()
int
getX2()
int
getY1()
int
getY2()
boolean
hasPressedOk()
void
keyPressed(KeyEvent e)
void
keyReleased(KeyEvent e)
void
keyTyped(KeyEvent e)
private void
updateLabels()
Computes width and height of new image and updates the corresponding labels.

Field Details

cancel

private Button cancel

height

private int height

newHeight

private Label newHeight

newWidth

private Label newWidth

ok

private Button ok

pressedOk

private boolean pressedOk

width

private int width

x1

private TextField x1

x2

private TextField x2

y1

private TextField y1

y2

private TextField y2

Constructor Details

CropDialog

public CropDialog(Frame owner,
                  Strings strings,
                  int width,
                  int height)
Parameters:
owner - the Frame this dialog will belong to
strings - Strings resource to be used for text messages
width - width of the original image, before cropping; this is used to determine the valid values for left and right column, from 0 to width - 1
height - height of the original image, before cropping; this is used to determine the valid values for top and bottom row, from 0 to height - 1

Method Details

actionPerformed

public void actionPerformed(ActionEvent e)
Hides (closes) this dialog if the OK button was source of the action event (e.g. if the button was pressed).

getHeight

public int getHeight()

getValue

private int getValue(TextComponent textField)
Attempts to convert the content of the argument text component to an int; if successful, returns that int, otherwise -1 is returned.
Parameters:
textField - the text component that is supposed to hold an int value
Returns:
int representation of the text component's data

getWidth

public int getWidth()
Returns the width of the to-be-cropped image as given by the current values in the text fields for left column and right column. Computes the width from those values and returns it or returns -1 if the data in the text fields is not valid for some reason.
Returns:
width of cropped image or -1 if information is invalid

getX1

public int getX1()

getX2

public int getX2()

getY1

public int getY1()

getY2

public int getY2()

hasPressedOk

public boolean hasPressedOk()

keyPressed

public void keyPressed(KeyEvent e)

keyReleased

public void keyReleased(KeyEvent e)

keyTyped

public void keyTyped(KeyEvent e)

updateLabels

private void updateLabels()
Computes width and height of new image and updates the corresponding labels. The labels will either display width and height or a single dash if the data in the text fields is invalid.