jfreerails.client.top
Class GUIComponentFactoryImpl

java.lang.Object
  extended by jfreerails.client.top.GUIComponentFactoryImpl
All Implemented Interfaces:
GUIComponentFactory, WorldListListener, WorldMapListener

public class GUIComponentFactoryImpl
extends java.lang.Object
implements GUIComponentFactory, WorldMapListener, WorldListListener

Creates and wires up the GUI components.

Author:
Luke

Field Summary
private  ActionRoot actionRoot
           
private  javax.swing.JMenu brokerMenu
           
private  BuildMenu buildMenu
           
private  javax.swing.JMenuItem callBrokerJMenuItem
           
private  CashJLabel cashjLabel
           
private static boolean CHEAT
          Whether to show certain 'cheat' menus used for testing.
private  ClientJFrame clientJFrame
           
private  DateJLabel datejLabel
           
private  DialogueBoxController dialogueBoxController
           
private  javax.swing.JMenu displayMenu
           
private  javax.swing.JMenu helpMenu
           
private  boolean isSetup
           
private  javax.swing.JMenuItem leaderBoardJMenuItem
           
private static java.util.logging.Logger logger
           
private  DetailMapRenderer mainMap
           
private  javax.swing.JScrollPane mainMapScrollPane1
           
private  MapViewJComponentConcrete mapViewJComponent
           
private  ModelRootImpl modelRoot
           
private  javax.swing.JMenuItem networthGraphJMenuItem
           
private  MapRenderer overviewMap
           
private  javax.swing.JPanel overviewMapContainer
           
private  java.awt.Rectangle r
           
private  RenderersRoot renderers
           
private  javax.swing.JMenu reportsMenu
           
private  ServerControlModel sc
           
private  ActionAdapter speedActions
           
private  javax.swing.JMenuItem stationInfoJMenuItem
           
private  StationTypesPopup stationTypesPopup
           
private  javax.swing.JMenuItem trainListJMenuItem
           
private  javax.swing.JMenuItem trainOrdersJMenuItem
           
private  RHSJTabPane trainsJTabPane
          This is the panel at the bottom right of the screen.
private  UserInputOnMapController userInputOnMapController
           
private  UserMessageGenerator userMessageGenerator
           
private  ReadOnlyWorld world
           
 
Constructor Summary
GUIComponentFactoryImpl(ModelRootImpl mr, ActionRoot ar)
           
 
Method Summary
private  void countStations()
           
private  void countTrains()
           
 javax.swing.JMenu createBrokerMenu()
           
 javax.swing.JMenu createBuildMenu()
           
 javax.swing.JLabel createCashJLabel()
           
 javax.swing.JFrame createClientJFrame(java.lang.String title)
           
 javax.swing.JLabel createDateJLabel()
           
 javax.swing.JMenu createDisplayMenu()
           
 javax.swing.JMenu createGameMenu()
           
 javax.swing.JMenu createHelpMenu()
           
 javax.swing.JScrollPane createMainMap()
           
 javax.swing.JPanel createOverviewMap()
           
 javax.swing.JMenu createReportsMenu()
           
 javax.swing.JTabbedPane createTrainsJTabPane()
           
 BuildTrackController getBuildTrackController()
           
 boolean isSetup()
           
 void itemAdded(KEY key, int index, FreerailsPrincipal principal)
           
 void itemRemoved(KEY key, int index, FreerailsPrincipal principal)
           
 void listUpdated(KEY key, int index, FreerailsPrincipal principal)
           
 void setup(RenderersRoot vl, ReadOnlyWorld w)
          Called when a new game is started or a game is loaded.
 void tilesChanged(java.awt.Rectangle tilesChanged)
          Listens for changes on the map, for instance when track is built, and refreshes the map views.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHEAT

private static final boolean CHEAT
Whether to show certain 'cheat' menus used for testing.


logger

private static final java.util.logging.Logger logger

actionRoot

private final ActionRoot actionRoot

buildMenu

private final BuildMenu buildMenu

cashjLabel

private final CashJLabel cashjLabel

clientJFrame

private final ClientJFrame clientJFrame

datejLabel

private final DateJLabel datejLabel

dialogueBoxController

private final DialogueBoxController dialogueBoxController

displayMenu

private javax.swing.JMenu displayMenu

helpMenu

private javax.swing.JMenu helpMenu

brokerMenu

private javax.swing.JMenu brokerMenu

isSetup

private boolean isSetup

leaderBoardJMenuItem

private javax.swing.JMenuItem leaderBoardJMenuItem

mainMap

private DetailMapRenderer mainMap

mainMapScrollPane1

private final javax.swing.JScrollPane mainMapScrollPane1

mapViewJComponent

private final MapViewJComponentConcrete mapViewJComponent

modelRoot

private final ModelRootImpl modelRoot

networthGraphJMenuItem

private javax.swing.JMenuItem networthGraphJMenuItem

overviewMap

private MapRenderer overviewMap

overviewMapContainer

private final javax.swing.JPanel overviewMapContainer

r

private final java.awt.Rectangle r

reportsMenu

private javax.swing.JMenu reportsMenu

sc

private ServerControlModel sc

speedActions

private ActionAdapter speedActions

stationInfoJMenuItem

private javax.swing.JMenuItem stationInfoJMenuItem

stationTypesPopup

private final StationTypesPopup stationTypesPopup

trainListJMenuItem

private javax.swing.JMenuItem trainListJMenuItem

trainOrdersJMenuItem

private javax.swing.JMenuItem trainOrdersJMenuItem

callBrokerJMenuItem

private javax.swing.JMenuItem callBrokerJMenuItem

trainsJTabPane

private final RHSJTabPane trainsJTabPane
This is the panel at the bottom right of the screen.


userInputOnMapController

private final UserInputOnMapController userInputOnMapController

userMessageGenerator

private UserMessageGenerator userMessageGenerator

renderers

private RenderersRoot renderers

world

private ReadOnlyWorld world
Constructor Detail

GUIComponentFactoryImpl

public GUIComponentFactoryImpl(ModelRootImpl mr,
                               ActionRoot ar)
Method Detail

countStations

private void countStations()

countTrains

private void countTrains()

createBuildMenu

public javax.swing.JMenu createBuildMenu()
Specified by:
createBuildMenu in interface GUIComponentFactory

createCashJLabel

public javax.swing.JLabel createCashJLabel()
Specified by:
createCashJLabel in interface GUIComponentFactory

createClientJFrame

public javax.swing.JFrame createClientJFrame(java.lang.String title)

createDateJLabel

public javax.swing.JLabel createDateJLabel()
Specified by:
createDateJLabel in interface GUIComponentFactory

createBrokerMenu

public javax.swing.JMenu createBrokerMenu()
Specified by:
createBrokerMenu in interface GUIComponentFactory

createDisplayMenu

public javax.swing.JMenu createDisplayMenu()
Specified by:
createDisplayMenu in interface GUIComponentFactory

createGameMenu

public javax.swing.JMenu createGameMenu()
Specified by:
createGameMenu in interface GUIComponentFactory

createHelpMenu

public javax.swing.JMenu createHelpMenu()
Specified by:
createHelpMenu in interface GUIComponentFactory

createMainMap

public javax.swing.JScrollPane createMainMap()
Specified by:
createMainMap in interface GUIComponentFactory

createOverviewMap

public javax.swing.JPanel createOverviewMap()
Specified by:
createOverviewMap in interface GUIComponentFactory

createReportsMenu

public javax.swing.JMenu createReportsMenu()
Specified by:
createReportsMenu in interface GUIComponentFactory

createTrainsJTabPane

public javax.swing.JTabbedPane createTrainsJTabPane()
Specified by:
createTrainsJTabPane in interface GUIComponentFactory

getBuildTrackController

public BuildTrackController getBuildTrackController()

isSetup

public boolean isSetup()

itemAdded

public void itemAdded(KEY key,
                      int index,
                      FreerailsPrincipal principal)
Specified by:
itemAdded in interface WorldListListener

itemRemoved

public void itemRemoved(KEY key,
                        int index,
                        FreerailsPrincipal principal)
Specified by:
itemRemoved in interface WorldListListener

listUpdated

public void listUpdated(KEY key,
                        int index,
                        FreerailsPrincipal principal)
Specified by:
listUpdated in interface WorldListListener

setup

public void setup(RenderersRoot vl,
                  ReadOnlyWorld w)
           throws java.io.IOException
Called when a new game is started or a game is loaded.

Be extremely careful with the references of objects allocated in this method to avoid memory leaks - see bug 967677 (OutOfMemoryError after starting several new games).

Throws:
java.io.IOException

tilesChanged

public void tilesChanged(java.awt.Rectangle tilesChanged)
Listens for changes on the map, for instance when track is built, and refreshes the map views.

Specified by:
tilesChanged in interface WorldMapListener
Parameters:
tilesChanged - rectangle containing the tiles that have change; all the points contained by the rectangle must be within the map's bounds.