es.prodevelop.gvsig.mobile.gui.mainframe
Class MainWindow

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byes.prodevelop.gvsig.mobile.gui.mainframe.MainWindow
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.awt.event.ComponentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable

public class MainWindow
extends java.awt.Frame
implements java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.ComponentListener

This is the application main window. It is instantiated by the GvsigMobileApp class and it owns the MapControl and all the graphic components (menu items, status bar, toos and tool bars, etc) It acts as the mouse listener that starts actions when a new tool is selected (not when the tool is used, this is done by the MapToolListener). When it is sezied (due also to new settings in the screen - horizontal/vertical) all the compoenents are notified and repainted.

Author:
jldominguez
See Also:
MapControl, MapToolListener, TBButton, Serialized Form

Field Summary
 Animator animator
           
 TBMenu dropMenu
           
 StatusBar statusBar
           
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MainWindow(java.awt.Frame spl_dlg, java.util.Timer spl_timer)
          Creates a new instance of the MainWindow given a splash screen and a timer
MainWindow(java.awt.Frame spl_dlg, java.util.Timer spl_timer, int _width, int _height)
          Creates a new instance of the MainWindow given a splash screen, a timer and dimensions of the screen
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
           
 void addEcwLayer(boolean repaint)
          Starts the process to add a new ECW layer to the view (first of all, shows a file chooser to choose a file.)
 void addShpLayer(boolean repaint)
          Starts the process to add a new SHP layer to the view (first of all, shows a file chooser to choose a file.)
 void addToolBar(ToolBar _newbar)
          Adds a ToolBar to the array of ToolBars in MainWindow
 void addWkrLayer(boolean repaint)
          Starts the process to add a new WKR layer to the view (first of all, shows a file chooser to choose a file.)
 void addWmsLayer(boolean repaint)
          This method is called when the user clicks on the "add WMS" button.
 void closeAll()
          Closes all datasources associated to the layers.
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
 void componentShown(java.awt.event.ComponentEvent e)
           
 void doAddWmsLayer(WMSDialog dlg, java.lang.String wms_version, java.lang.String path_symbol, boolean repaint)
          This is the method that truly adds a WMS layer, called by the WMS dialog.
 MapControl getMapControl()
          Returns the Window's MapControl
 ToolBar getSelectedToolBar()
          Gets the currently selected tool bar (its button is at the top of the left-most vertical button bar.)
 boolean getTool(TBButton tb)
          Searches for the existence of a tool in the ToolBars
 void keyPressed(java.awt.event.KeyEvent e)
          The main window also listens to key events: left arrow cursor: pan to the west, 1/2 of the width of the view.
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent arg0)
          This method is triggered every time a new tool button is selected, or when any of the available dialogs has to be opened (project/app/GPS settings, etc.)
 void mouseEntered(java.awt.event.MouseEvent arg0)
           
 void mouseExited(java.awt.event.MouseEvent arg0)
           
 void mousePressed(java.awt.event.MouseEvent arg0)
           
 void mouseReleased(java.awt.event.MouseEvent arg0)
           
 void setAllToolsVisible(boolean visibility)
          Sets all the buttons of all tool bars to visible/invisible
 void setStatusBarIcon(int id, java.lang.String dir, java.lang.String filename)
          Sets a new icon in the status bar.
 void setStatusBarSubIcon(int id, java.lang.String dir, java.lang.String filename)
          Sets a new sub icon in the status bar.
 void setStatusBarText(int id, java.lang.String txt)
          Sets a new text in the status bar.
 void unselectAllButtons()
          Unselects all the buttons of all tool bars.
 void winDeactivated()
          This method is called when the main window changes its graphical status in a way that makes it sensible to stop using the GPS tracking (iconified)
 
Methods inherited from class java.awt.Frame
addNotify, getAccessibleContext, 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, 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, remove, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, 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, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

statusBar

public StatusBar statusBar

animator

public Animator animator

dropMenu

public TBMenu dropMenu
Constructor Detail

MainWindow

public MainWindow(java.awt.Frame spl_dlg,
                  java.util.Timer spl_timer)
Creates a new instance of the MainWindow given a splash screen and a timer

Parameters:
spl_dlg - splash dialog to show
spl_timer - timer. Can be null

MainWindow

public MainWindow(java.awt.Frame spl_dlg,
                  java.util.Timer spl_timer,
                  int _width,
                  int _height)
Creates a new instance of the MainWindow given a splash screen, a timer and dimensions of the screen

Parameters:
spl_dlg - splash dialog to show
spl_timer - timer. Can be null
_width - screen width in pixels
_height - screen height in pixels
Method Detail

getMapControl

public MapControl getMapControl()
Returns the Window's MapControl

Returns:
the property MapControl of this class

addToolBar

public void addToolBar(ToolBar _newbar)
Adds a ToolBar to the array of ToolBars in MainWindow

Parameters:
_newbar - New ToolBar to be added

getTool

public boolean getTool(TBButton tb)
Searches for the existence of a tool in the ToolBars

Parameters:
tb - TBActionButton button to be found
Returns:
boolean answer. true if found

setAllToolsVisible

public void setAllToolsVisible(boolean visibility)
Sets all the buttons of all tool bars to visible/invisible

Parameters:
visibility - true set all buttons to visible false set all buttons to invisible

unselectAllButtons

public void unselectAllButtons()
Unselects all the buttons of all tool bars. It doesn't change other widgets but TBButton's


closeAll

public void closeAll()
Closes all datasources associated to the layers. Asks user to save project if it was modified.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

addShpLayer

public void addShpLayer(boolean repaint)
Starts the process to add a new SHP layer to the view (first of all, shows a file chooser to choose a file.)

Parameters:
repaint - whether the view has to be repainted after the layer has been added. This is useful when the layer is added from the TOC. We don't want arefresh in that moment.

addEcwLayer

public void addEcwLayer(boolean repaint)
Starts the process to add a new ECW layer to the view (first of all, shows a file chooser to choose a file.)

Parameters:
repaint - whether the view has to be repainted after the layer has been added. This is useful when the layer is added from the TOC. We don't want arefresh in that moment.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent arg0)
This method is triggered every time a new tool button is selected, or when any of the available dialogs has to be opened (project/app/GPS settings, etc.)

Specified by:
mouseClicked in interface java.awt.event.MouseListener

winDeactivated

public void winDeactivated()
This method is called when the main window changes its graphical status in a way that makes it sensible to stop using the GPS tracking (iconified)


doAddWmsLayer

public void doAddWmsLayer(WMSDialog dlg,
                          java.lang.String wms_version,
                          java.lang.String path_symbol,
                          boolean repaint)
This is the method that truly adds a WMS layer, called by the WMS dialog.

Parameters:
dlg - the WMS dialog that has just been closed
wms_version - the WMS version of the server
path_symbol - The path separator to be ueed in requests
repaint - Whether the view has to be repainted after the new layer has been added (if added from TOC, this has to be false)

getSelectedToolBar

public ToolBar getSelectedToolBar()
Gets the currently selected tool bar (its button is at the top of the left-most vertical button bar.)

Returns:
the currently selected tool bar.

setStatusBarText

public void setStatusBarText(int id,
                             java.lang.String txt)
Sets a new text in the status bar.

Parameters:
id - The ID of the status bar to be updated.
txt - The text to be printed in the status bar.

setStatusBarIcon

public void setStatusBarIcon(int id,
                             java.lang.String dir,
                             java.lang.String filename)
Sets a new icon in the status bar.

Parameters:
id - The ID of the status bar to be updated.
dir - The path of the folder where the image is located
filename - The name of the image file.

setStatusBarSubIcon

public void setStatusBarSubIcon(int id,
                                java.lang.String dir,
                                java.lang.String filename)
Sets a new sub icon in the status bar.

Parameters:
id - The ID of the status bar to be updated.
dir - The path of the folder where the image is located
filename - The name of the image file.

mousePressed

public void mousePressed(java.awt.event.MouseEvent arg0)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent arg0)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent arg0)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent arg0)
Specified by:
mouseExited in interface java.awt.event.MouseListener

addWmsLayer

public void addWmsLayer(boolean repaint)
This method is called when the user clicks on the "add WMS" button. Is simply creates a new WMS dialog and makes it visible

Parameters:
repaint - whether the view has to be repainted after adding the new layer.
See Also:
WMSDialog

addWkrLayer

public void addWkrLayer(boolean repaint)
Starts the process to add a new WKR layer to the view (first of all, shows a file chooser to choose a file.) WKR (well known rasters) are PNG, JPG and GIF files.

Parameters:
repaint - whether the view has to be repainted after the layer has been added. This is useful when the layer is added from the TOC. We don't want arefresh in that moment.

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
The main window also listens to key events: left arrow cursor: pan to the west, 1/2 of the width of the view. right arrow cursor: pan to the west, 1/2 of the width of the view. up arrow cursor: pan to the west, 1/2 of the width of the view. down arrow cursor: pan to the west, 1/2 of the width of the view. central button: zoom in. The new scale will be 1/2 of the current scale.

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener