net.sourceforge.jiu.gui.awt

Class JiuAwtFrame

Implemented Interfaces:
ActionListener, ComponentListener, JiuInfo, ProgressListener

public class JiuAwtFrame
extends Frame
implements ActionListener, ComponentListener, JiuInfo, ProgressListener

The frame class for the AWT demo program jiuawt.
Author:
Marco Schmidt
Since:
0.8.0

Field Summary

static String
APP_NAME
The name of this application, jiuawt, plus the version number taken from JiuInfo.
private ImageCanvas
canvas
private EditorState
editor
private AwtMenuWrapper
menuWrapper
private AwtOperationProcessor
processor
private ScrollPane
scrollPane
(package private) static long
serialVersionUID
private Label
statusBar

Fields inherited from interface net.sourceforge.jiu.apps.JiuInfo

JIU_FEEDBACK_ADDRESS, JIU_HOMEPAGE, JIU_NUMERICAL_VERSION, JIU_VERSION

Constructor Summary

JiuAwtFrame(EditorState editorState)
Create an object of this class, using the argument editor state.

Method Summary

void
actionPerformed(ActionEvent e)
Processes event objects that get created when menu items are picked.
void
componentHidden(ComponentEvent e)
void
componentMoved(ComponentEvent e)
void
componentResized(ComponentEvent e)
void
componentShown(ComponentEvent e)
void
maximize()
Maximize the frame on the desktop.
void
setDefaultCursor()
Sets the current cursor to be java.awt.Cursor.DEFAULT_CURSOR.
void
setOriginalSize()
If an image is currently loaded,
void
setProgress(float progress)
Set a new progress status.
void
setProgress(int zeroBasedIndex, int totalItems)
Sets a new progress level.
void
setStatusBar(String text)
void
setWaitCursor()
void
showError(String text)
Displays the argument text in a message box with error in the title bar.
void
showInfo(String title, String text)
Shows a modal dialog with given title bar and message text.
void
updateCanvas()
If there is an image loaded, forces a canvas redraw by calling repaint.
void
updateImage()
Removes the current canvas from the frame (if there is an image loaded) and creates a new canvas for the current image.
void
updateStatusBar()
Creates a description string for the current image and sets the status bar to that text.
void
updateTitle()
Sets the frame's title bar to the application name, plus the file name of the currently loaded image file, plus the current zoom factor, plus an optional asterisk in case the image was modified but not yet saved.
void
zoomIn()
If an image is currently displayed, zoom in one level.
void
zoomOut()
If an image is currently displayed, zoom out one level.

Field Details

APP_NAME

public static final String APP_NAME
The name of this application, jiuawt, plus the version number taken from JiuInfo. Example: jiuawt 0.8.0. Will be displayed in the title bar of this frame.

canvas

private ImageCanvas canvas

editor

private EditorState editor

menuWrapper

private AwtMenuWrapper menuWrapper

processor

private AwtOperationProcessor processor

scrollPane

private ScrollPane scrollPane

serialVersionUID

(package private) static final long serialVersionUID
Field Value:
2592450425245L

statusBar

private Label statusBar

Constructor Details

JiuAwtFrame

public JiuAwtFrame(EditorState editorState)
Create an object of this class, using the argument editor state. String resources to initialize the menu etc. will be taken from the EditorState object's Strings variable
Parameters:
editorState - EditorState object used by this frame

Method Details

actionPerformed

public void actionPerformed(ActionEvent e)
Processes event objects that get created when menu items are picked. Determines the MenuIndexConstants value for a given event object and calls the internal AwtOperationProcessor object's process method with the menu value. The operation will then be performed.
Parameters:
e - the ActionEvent object

componentHidden

public void componentHidden(ComponentEvent e)

componentMoved

public void componentMoved(ComponentEvent e)

componentResized

public void componentResized(ComponentEvent e)

componentShown

public void componentShown(ComponentEvent e)

maximize

public void maximize()
Maximize the frame on the desktop. There is no such function in the 1.1 AWT (was added in 1.4), so this class determines the screen size and sets the frame to be a little smaller than that (to make up for task bars etc.). So this is just a heuristical approach.

setDefaultCursor

public void setDefaultCursor()
Sets the current cursor to be java.awt.Cursor.DEFAULT_CURSOR.

setOriginalSize

public void setOriginalSize()
If an image is currently loaded,

setProgress

public void setProgress(float progress)
Set a new progress status.
Specified by:
setProgress in interface ProgressListener
Parameters:
progress - float from 0.0f to 1.0f, indicating the progress between 0 and 100 percent

setProgress

public void setProgress(int zeroBasedIndex,
                        int totalItems)
Specified by:
setProgress in interface ProgressListener
Parameters:
zeroBasedIndex - the index of the step that was just completed
totalItems - the number of steps in this operation

setStatusBar

public void setStatusBar(String text)

setWaitCursor

public void setWaitCursor()

showError

public void showError(String text)
Displays the argument text in a message box with error in the title bar.
Parameters:
text - the error message to be displayed

showInfo

public void showInfo(String title,
                     String text)
Shows a modal dialog with given title bar and message text.
Parameters:
title - will be displayed in the dialog's title bar
text - will be displayed in the dialog's center part

updateCanvas

public void updateCanvas()
If there is an image loaded, forces a canvas redraw by calling repaint.

updateImage

public void updateImage()
Removes the current canvas from the frame (if there is an image loaded) and creates a new canvas for the current image.

updateStatusBar

public void updateStatusBar()
Creates a description string for the current image and sets the status bar to that text.

updateTitle

public void updateTitle()
Sets the frame's title bar to the application name, plus the file name of the currently loaded image file, plus the current zoom factor, plus an optional asterisk in case the image was modified but not yet saved.

zoomIn

public void zoomIn()
If an image is currently displayed, zoom in one level.

zoomOut

public void zoomOut()
If an image is currently displayed, zoom out one level.