Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.livingpaper.hansa
Class HansaWindow  view HansaWindow download HansaWindow.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended byorg.livingpaper.hansa.HansaWindow
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class HansaWindow
extends javax.swing.JFrame
implements java.awt.event.ActionListener

Hansa is the main class and main window of the Hansa application, the window that displays the map and handles player interaction with the game.


Nested Class Summary
 
Nested classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
(package private) static javax.swing.JMenu editMenu
           
(package private) static javax.swing.JMenu fileMenu
           
private static java.lang.String kVersionString
           
private  javax.swing.JTextField mAddressField
           
private  javax.swing.JLabel mAddressLabel
           
(package private) static javax.swing.JMenuBar mainMenuBar
           
private  javax.swing.JLabel mCityInfoLabel
           
private  javax.swing.JProgressBar mCityLaborBar
           
private  javax.swing.JPanel mCityPanel
           
private  javax.swing.JProgressBar mCityPopulationBar
           
private  javax.swing.JLabel mCityPortInfoLabel
           
private  javax.swing.JPanel mCityProductionBox
           
private  javax.swing.JProgressBar mCityUtilityBar
           
private  javax.swing.JButton mConnectButton
           
private  java.awt.BasicStroke mDefaultStroke
           
private  javax.swing.JButton mDisconnectButton
           
private  java.awt.Point mDragSource
           
private  javax.swing.JSlider mFishProductionSlider
           
private  GameTypeDialog mGameTypeDialog
           
private  java.awt.BasicStroke mHaloStroke
           
protected  javax.swing.JMenuItem miClear
           
protected  javax.swing.JMenuItem miClose
           
protected  javax.swing.JMenuItem miCopy
           
protected  javax.swing.JMenuItem miCut
           
protected  javax.swing.JMenuItem miNew
           
protected  javax.swing.JMenuItem miOpen
           
protected  javax.swing.JMenuItem miPaste
           
protected  javax.swing.JMenuItem miProductionWindow
           
protected  javax.swing.JMenuItem miQuit
           
private  javax.swing.JSlider mIronProductionSlider
           
protected  javax.swing.JMenuItem miSave
           
protected  javax.swing.JMenuItem miSaveAs
           
protected  javax.swing.JMenuItem miSelectAll
           
protected  javax.swing.JMenuItem miTradeWindow
           
protected  javax.swing.JMenuItem miUndo
           
private  java.awt.Point mLastDragPoint
           
private  MapView mMapView
           
private  int mMaxHeight
           
private  int mMaxWidth
           
private  javax.swing.JLabel mMessageLabel
           
private  GameModel mModel
           
private  NewLocalGameDialog mNewLocalGameDialog
           
private  javax.swing.JTextField mPortField
           
private  javax.swing.JLabel mPortLabel
           
private  int mScreenHeightPad
           
private  int mScreenWidthPad
           
private  javax.swing.JScrollPane mScrollPane
           
private  javax.swing.JSlider mSilkProductionSlider
           
private  javax.swing.JLabel mStatusField
           
private  javax.swing.JPanel mStatusPanel
           
private  javax.swing.JTabbedPane mTabbedPane
           
private  int mTabbedPaneWidth
           
private  javax.swing.JPanel mTradePanel
           
private  javax.swing.JButton mTurnButton
           
private  javax.swing.JSlider mWheatProductionSlider
           
private  int mWindowHeightPad
           
private  int mWindowWidthPad
           
(package private) static javax.swing.JMenu toolsMenu
           
 
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.Window
 
Fields inherited from class java.awt.Container
 
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
HansaWindow(GameModel model)
          The Hansa constructor creates and lays out the main window, and populates it with a map, cities, and the city and trade information panes.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent newEvent)
          Handles events in the main window, dispatching them to handlers according to their command types.
 void addEditMenuItems()
          Sets up the appllication's Edit menu items.
 void addFileMenuItems()
          Sets up the appplication's File menu.
 void addMenus()
          Adds the application's menus to its interface.
 void addToolsMenuItems()
          Sets up the application's Tools menu items.
 void adjustSize()
           
 void cityInfoMessage(java.lang.String message)
          Displays a message in the CIty Info panel.
 void cityLaborInfo(int labor)
          Displays a labor value in the city info panel
 void cityPopulationInfo(int pop)
          Displays a population value in the city info panel
 void cityPortInfoMessage(boolean hasport)
           
 void cityUtilityInfo(double utility)
          Displays a utility value in the city info panel
 void disableProductionControls()
           
 void doClear()
           
 void doClose()
           
 void doCopy()
           
 void doCut()
           
 void doEndTurn(java.awt.event.ActionEvent evt)
           
 void doNew()
           
 void doOpen()
           
 void doPaste()
           
 void doQuit()
           
 void doSave()
           
 void doSaveAs()
           
 void doSelectAll()
           
 void doUndo()
           
 void enableProductionControls()
           
 javax.swing.JLabel getCityPortInfoLabel()
           
 MapView getMapView()
           
 java.awt.Dimension getMaximumSize()
          Returns a Dimension representing the maximum allowed size of the main window.
 GameModel getModel()
           
 void hideTurnButton()
           
private  void initLayout()
          Initializes and lays out the interface of the game's main window.
 void paint(java.awt.Graphics g)
          Draws the Hansa window contents
 void setDragSource(java.awt.Point p)
           
 void setLastDragPoint(java.awt.Point p)
           
 void showTurnButton()
           
 void statusMessage(java.lang.String message)
          Displays a status message in the label at the bottom of the main window.
 void statusMessage(java.lang.String message, java.awt.Color color)
           
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getPreferredSize, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, 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
addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getGraphicsConfiguration, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMinimumSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, 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, 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, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

kVersionString

private static final java.lang.String kVersionString
See Also:
Constant Field Values

mScrollPane

private javax.swing.JScrollPane mScrollPane

mTabbedPane

private javax.swing.JTabbedPane mTabbedPane

mCityPanel

private javax.swing.JPanel mCityPanel

mTradePanel

private javax.swing.JPanel mTradePanel

mMapView

private MapView mMapView

mCityPortInfoLabel

private javax.swing.JLabel mCityPortInfoLabel

mCityInfoLabel

private javax.swing.JLabel mCityInfoLabel

mCityUtilityBar

private javax.swing.JProgressBar mCityUtilityBar

mCityPopulationBar

private javax.swing.JProgressBar mCityPopulationBar

mCityLaborBar

private javax.swing.JProgressBar mCityLaborBar

mCityProductionBox

private javax.swing.JPanel mCityProductionBox

mWheatProductionSlider

private javax.swing.JSlider mWheatProductionSlider

mFishProductionSlider

private javax.swing.JSlider mFishProductionSlider

mIronProductionSlider

private javax.swing.JSlider mIronProductionSlider

mSilkProductionSlider

private javax.swing.JSlider mSilkProductionSlider

mStatusPanel

private javax.swing.JPanel mStatusPanel

mMessageLabel

private javax.swing.JLabel mMessageLabel

mTurnButton

private javax.swing.JButton mTurnButton

mDefaultStroke

private java.awt.BasicStroke mDefaultStroke

mHaloStroke

private java.awt.BasicStroke mHaloStroke

mGameTypeDialog

private GameTypeDialog mGameTypeDialog

mNewLocalGameDialog

private NewLocalGameDialog mNewLocalGameDialog

mMaxWidth

private int mMaxWidth

mMaxHeight

private int mMaxHeight

mTabbedPaneWidth

private int mTabbedPaneWidth

mWindowWidthPad

private int mWindowWidthPad

mWindowHeightPad

private int mWindowHeightPad

mScreenWidthPad

private int mScreenWidthPad

mScreenHeightPad

private int mScreenHeightPad

mModel

private GameModel mModel

mDragSource

private java.awt.Point mDragSource

mLastDragPoint

private java.awt.Point mLastDragPoint

mainMenuBar

static final javax.swing.JMenuBar mainMenuBar

fileMenu

static final javax.swing.JMenu fileMenu

miNew

protected javax.swing.JMenuItem miNew

miOpen

protected javax.swing.JMenuItem miOpen

miClose

protected javax.swing.JMenuItem miClose

miSave

protected javax.swing.JMenuItem miSave

miSaveAs

protected javax.swing.JMenuItem miSaveAs

miQuit

protected javax.swing.JMenuItem miQuit

editMenu

static final javax.swing.JMenu editMenu

miUndo

protected javax.swing.JMenuItem miUndo

miCut

protected javax.swing.JMenuItem miCut

miCopy

protected javax.swing.JMenuItem miCopy

miPaste

protected javax.swing.JMenuItem miPaste

miClear

protected javax.swing.JMenuItem miClear

miSelectAll

protected javax.swing.JMenuItem miSelectAll

mAddressLabel

private javax.swing.JLabel mAddressLabel

mPortLabel

private javax.swing.JLabel mPortLabel

mAddressField

private javax.swing.JTextField mAddressField

mPortField

private javax.swing.JTextField mPortField

mConnectButton

private javax.swing.JButton mConnectButton

mStatusField

private javax.swing.JLabel mStatusField

mDisconnectButton

private javax.swing.JButton mDisconnectButton

toolsMenu

static final javax.swing.JMenu toolsMenu

miProductionWindow

protected javax.swing.JMenuItem miProductionWindow

miTradeWindow

protected javax.swing.JMenuItem miTradeWindow
Constructor Detail

HansaWindow

public HansaWindow(GameModel model)
The Hansa constructor creates and lays out the main window, and populates it with a map, cities, and the city and trade information panes. It also sets up event handlers in the map view that enable players to interact with the map.

Method Detail

addFileMenuItems

public void addFileMenuItems()
Sets up the appplication's File menu.


addEditMenuItems

public void addEditMenuItems()
Sets up the appllication's Edit menu items.


addToolsMenuItems

public void addToolsMenuItems()
Sets up the application's Tools menu items.


addMenus

public void addMenus()
Adds the application's menus to its interface.


paint

public void paint(java.awt.Graphics g)
Draws the Hansa window contents


getModel

public GameModel getModel()

getMapView

public MapView getMapView()

getCityPortInfoLabel

public javax.swing.JLabel getCityPortInfoLabel()

statusMessage

public void statusMessage(java.lang.String message)
Displays a status message in the label at the bottom of the main window.


statusMessage

public void statusMessage(java.lang.String message,
                          java.awt.Color color)

cityInfoMessage

public void cityInfoMessage(java.lang.String message)
Displays a message in the CIty Info panel. Most commonly used to display the name of the currently-selected city.


cityPortInfoMessage

public void cityPortInfoMessage(boolean hasport)

cityUtilityInfo

public void cityUtilityInfo(double utility)
Displays a utility value in the city info panel


cityPopulationInfo

public void cityPopulationInfo(int pop)
Displays a population value in the city info panel


cityLaborInfo

public void cityLaborInfo(int labor)
Displays a labor value in the city info panel


setDragSource

public void setDragSource(java.awt.Point p)

setLastDragPoint

public void setLastDragPoint(java.awt.Point p)

getMaximumSize

public java.awt.Dimension getMaximumSize()
Returns a Dimension representing the maximum allowed size of the main window. The resize control will not grow the window larger than this size.


adjustSize

public void adjustSize()

initLayout

private void initLayout()
Initializes and lays out the interface of the game's main window.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent newEvent)
Handles events in the main window, dispatching them to handlers according to their command types.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

doNew

public void doNew()

doOpen

public void doOpen()

doClose

public void doClose()

doSave

public void doSave()

doSaveAs

public void doSaveAs()

doQuit

public void doQuit()

doUndo

public void doUndo()

doCut

public void doCut()

doCopy

public void doCopy()

doPaste

public void doPaste()

doClear

public void doClear()

doSelectAll

public void doSelectAll()

doEndTurn

public void doEndTurn(java.awt.event.ActionEvent evt)

hideTurnButton

public void hideTurnButton()

showTurnButton

public void showTurnButton()

enableProductionControls

public void enableProductionControls()

disableProductionControls

public void disableProductionControls()