courses.dsv2pvt.client
Class IconEditor

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended bycourses.dsv2pvt.client.IconEditor
All Implemented Interfaces:
Accessible, EventListener, ImageObserver, MenuContainer, RootPaneContainer, Serializable, WindowConstants, WindowListener

public class IconEditor
extends JFrame
implements WindowListener

The main window of the IconEditor component. Creates and opens pen and color palette windows. Contains the basic requirements of an IconEditor such as saving, loading and painting.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  JMenu AboutMenu
          The About menu component with About | Bogus items.
protected  JMenuItem AboutMenuItem
          The About->About menu item component
protected  JPanel backPane
          The panel containing all icon components
protected  JRadioButtonMenuItem BogusMenuItem
          The About->Bogus menu item component that does nothing
protected  courses.dsv2pvt.client.ColorAdapter colorAdapter
          Adapter connecting the currentColor panel and the color palette
protected  JLabel colorLabel
          The label containing the text Color
protected  ColPalWin colPalWin
          Window containing the color palette
protected  JPanel currentColor
          The panel showing the current color
protected  JMenu FileMenu
          The File menu component with New | Open | Save | Save as | Quit items.
protected  GridLayout iconEditorGridLayout
          The GridLayout instance used to manage the position of any subcomponents that the IconEditor may have
protected  JMenuBar IconEditorMenu
          The menu component with File and About menus.
protected  IconPanel iconPanel
          The icon panel containing all icon editing functions
protected  JPanel iconPanelHolder
          The panel containing the icon panel
protected  GridLayout iconPanelHolderGridLayout
          The GridLayout instance used to manage the position of the iconPanel inside the iconPanelHolder
protected  IconPreviewPanel iconPreview
          The panel previewing the icon in scale 1:1
protected  JMenuItem NewMenuItem
          The File->New menu item component
protected  JMenuItem OpenMenuItem
          The File->Open menu item component
protected  PenPalWin penPalWin
          Window containing the pen palette
protected  JLabel previewLabel
          The label containing the text Preview
protected  JMenuItem QuitMenuItem
          The File->Quit menu item component
protected  JMenuItem SaveAsMenuItem
          The File->Save as menu item component
protected  JMenuItem SaveMenuItem
          The File->Save menu item component
protected  courses.dsv2pvt.client.UpdateAdapter updateAdapter
          Adapter connecting the preview, the icon panel and the main window
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
IconEditor()
          Creates a new IconEditor, palettes, palette windows, creates adapters and connects them.
 
Method Summary
 void aboutEditor(ActionEvent e)
          Invoked upon selection of the About->About menu item.
 Icon getIcon()
          Retrieves the currently edited icon
 boolean loadIcon(File file)
          Loads an icon and sets it as the current icon
static void main(String[] args)
          Creates an instance of the IconEditor class and displays its windows
 void newIcon(ActionEvent e)
          Invoked upon selection of the File->New menu item.
 void openIcon(ActionEvent e)
          Invoked upon selection of the File->Open menu item.
 void quitEditor(ActionEvent e)
          Invoked upon selection of the File->Quit menu item.
 void saveIcon(ActionEvent e)
          Invoked upon selection of the File->Save menu item.
 boolean saveIcon(File file)
          Saves the current icon in the specified file
 void saveIconAs(ActionEvent e)
          Invoked upon selection of the File->Save as menu item.
 void setIcon(Icon icon)
          Sets the icon that is to be edited.
 void start()
          Sets sizes and displays the windows.
 void windowActivated(WindowEvent e)
          Ignored.
 void windowClosed(WindowEvent e)
          Exits the editor.
 void windowClosing(WindowEvent e)
          Hides the palette windows.
 void windowDeactivated(WindowEvent e)
          Ignored.
 void windowDeiconified(WindowEvent e)
          Shows the palette windows.
 void windowIconified(WindowEvent e)
          Hides the palette windows.
 void windowOpened(WindowEvent e)
          Shows the palette windows.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

IconEditorMenu

protected JMenuBar IconEditorMenu
The menu component with File and About menus.


FileMenu

protected JMenu FileMenu
The File menu component with New | Open | Save | Save as | Quit items.


NewMenuItem

protected JMenuItem NewMenuItem
The File->New menu item component


SaveMenuItem

protected JMenuItem SaveMenuItem
The File->Save menu item component


SaveAsMenuItem

protected JMenuItem SaveAsMenuItem
The File->Save as menu item component


QuitMenuItem

protected JMenuItem QuitMenuItem
The File->Quit menu item component


OpenMenuItem

protected JMenuItem OpenMenuItem
The File->Open menu item component


AboutMenu

protected JMenu AboutMenu
The About menu component with About | Bogus items.


AboutMenuItem

protected JMenuItem AboutMenuItem
The About->About menu item component


BogusMenuItem

protected JRadioButtonMenuItem BogusMenuItem
The About->Bogus menu item component that does nothing


iconEditorGridLayout

protected GridLayout iconEditorGridLayout
The GridLayout instance used to manage the position of any subcomponents that the IconEditor may have


iconPanelHolderGridLayout

protected GridLayout iconPanelHolderGridLayout
The GridLayout instance used to manage the position of the iconPanel inside the iconPanelHolder


backPane

protected JPanel backPane
The panel containing all icon components


iconPanelHolder

protected JPanel iconPanelHolder
The panel containing the icon panel


iconPanel

protected IconPanel iconPanel
The icon panel containing all icon editing functions


currentColor

protected JPanel currentColor
The panel showing the current color


iconPreview

protected IconPreviewPanel iconPreview
The panel previewing the icon in scale 1:1


colorLabel

protected JLabel colorLabel
The label containing the text Color


previewLabel

protected JLabel previewLabel
The label containing the text Preview


updateAdapter

protected courses.dsv2pvt.client.UpdateAdapter updateAdapter
Adapter connecting the preview, the icon panel and the main window


colorAdapter

protected courses.dsv2pvt.client.ColorAdapter colorAdapter
Adapter connecting the currentColor panel and the color palette


penPalWin

protected PenPalWin penPalWin
Window containing the pen palette


colPalWin

protected ColPalWin colPalWin
Window containing the color palette

Constructor Detail

IconEditor

public IconEditor()
Creates a new IconEditor, palettes, palette windows, creates adapters and connects them. Adds pens to the pen palette.

Method Detail

start

public void start()
Sets sizes and displays the windows.


setIcon

public void setIcon(Icon icon)
Sets the icon that is to be edited.


getIcon

public Icon getIcon()
Retrieves the currently edited icon

Returns:
the currently edited icon

saveIcon

public boolean saveIcon(File file)
Saves the current icon in the specified file

Parameters:
file - the file that the icon should be saved to
Returns:
true if icon was saved, else false

loadIcon

public boolean loadIcon(File file)
Loads an icon and sets it as the current icon

Parameters:
file - the file containing the icon to be loaded
Returns:
true if icon was loaded, else false

main

public static void main(String[] args)
Creates an instance of the IconEditor class and displays its windows

Parameters:
args - argument vector, ignored by program

newIcon

public void newIcon(ActionEvent e)
Invoked upon selection of the File->New menu item. If there are unsaved changes, the user is prompted to save or to discard them. Creates a new white icon.

Parameters:
e - the system generated action event, ignored by this method

openIcon

public void openIcon(ActionEvent e)
Invoked upon selection of the File->Open menu item. If there are unsaved changes, the user is prompted to save or to discard them. If an existing file containing an icon is selected, the icon is deserialised and shown.

Parameters:
e - the system generated action event, ignored by this method

saveIcon

public void saveIcon(ActionEvent e)
Invoked upon selection of the File->Save menu item. If the icon has been saved before, the old file name is used, else the user is prompted by the saveAs dialog and must first choose a file name.

Parameters:
e - the system generated action event, ignored by this method

saveIconAs

public void saveIconAs(ActionEvent e)
Invoked upon selection of the File->Save as menu item. The user is prompted by the saveAs dialog and must first choose a file name. If the selected file name is available or can be overwritten, the Icon is serialised to that file.

Parameters:
e - the system generated action event, ignored by this method

quitEditor

public void quitEditor(ActionEvent e)
Invoked upon selection of the File->Quit menu item. If there are unsaved changes, the user is prompted to save or to discard them. Closes all windows and exits the icon editor.

Parameters:
e - the system generated action event, ignored by this method

aboutEditor

public void aboutEditor(ActionEvent e)
Invoked upon selection of the About->About menu item. Displays the about dialog.

Parameters:
e - the system generated action event, ignored by this method

windowOpened

public void windowOpened(WindowEvent e)
Shows the palette windows. Is invoked when the main window is opened.

Specified by:
windowOpened in interface WindowListener
Parameters:
e - an ignored window event

windowClosing

public void windowClosing(WindowEvent e)
Hides the palette windows. Is invoked when the main window is closing.

Specified by:
windowClosing in interface WindowListener
Parameters:
e - an ignored window event

windowClosed

public void windowClosed(WindowEvent e)
Exits the editor. Is invoked when the main window is closed.

Specified by:
windowClosed in interface WindowListener
Parameters:
e - an ignored window event

windowIconified

public void windowIconified(WindowEvent e)
Hides the palette windows. Is invoked when the main window is minimized.

Specified by:
windowIconified in interface WindowListener
Parameters:
e - an ignored window event

windowDeiconified

public void windowDeiconified(WindowEvent e)
Shows the palette windows. Is invoked when the main window is deminimized.

Specified by:
windowDeiconified in interface WindowListener

windowActivated

public void windowActivated(WindowEvent e)
Ignored. Required by WindowListener.

Specified by:
windowActivated in interface WindowListener
Parameters:
e - an ignored window event

windowDeactivated

public void windowDeactivated(WindowEvent e)
Ignored. Required by WindowListener.

Specified by:
windowDeactivated in interface WindowListener
Parameters:
e - an ignored window event