com.realtime.crossfire.jxclient.skin.skin
Class DefaultJXCSkin

java.lang.Object
  extended by com.realtime.crossfire.jxclient.skin.skin.DefaultJXCSkin
All Implemented Interfaces:
JXCSkin, java.lang.Iterable<Gui>

public class DefaultJXCSkin
extends java.lang.Object
implements JXCSkin

Default JXCSkin implementation.


Field Summary
private  int currentScreenHeight
          The current screen height.
private  int currentScreenWidth
          The current screen width.
private static int DEFAULT_NUM_LOOK_OBJECTS
          The default number of ground view objects.
private  KeyBindings defaultKeyBindings
          The default key bindings.
private  JXCSkinCache<CommandList> definedCommandLists
          All defined command lists.
private  Dialogs dialogs
          All defined dialogs.
private  java.util.Collection<GUIItemList> floorLists
          The GUIItemLists that display floor items.
private  java.util.Collection<GUIElement> guiElements
          All GUI elements.
private  java.util.Collection<CommandList> initEvents
          All "event init" commands in execution order.
private  java.util.Collection<GUIMap> maps
          The GUIMaps that display maps.
private  Resolution maxResolution
          The maximal resolution.
private  Resolution minResolution
          The minimal resolution.
private  int numLookObjects
          The maximum number of ground view objects.
private  OptionManager optionManager
          The OptionManager to use.
private  java.util.Collection<java.lang.String> optionNames
          The defined option names.
private  java.util.Collection<SkinEvent> skinEvents
          All SkinEvents attached to this instance.
private  java.lang.String skinName
          The skin name.
private  AbstractLabel tooltipLabel
          The tooltip label or null.
private  TooltipManager tooltipManager
          The TooltipManager currently attached to or null if not attached.
 
Constructor Summary
DefaultJXCSkin(KeyBindings defaultKeyBindings, OptionManager optionManager, Dialogs dialogs)
          Creates a new instance.
 
Method Summary
 void addCommandList(java.lang.String commandListName, CommandListType commandListType)
          Defines a new command list.
 void addDialog(java.lang.String dialogName)
          Defines a new dialog.
 void addFloorList(GUIItemList floorList)
          Adds a GUIItemList element that displays floor items.
 void addInitEvent(CommandList commandList)
          Adds a command list to be executed on "init" events.
 void addMap(GUIMap map)
          Adds a GUIMap element that displays a map.
 void addOption(java.lang.String optionName, java.lang.String documentation, Option commandCheckBoxOption)
          Add a new option.
 void addSkinEvent(SkinEvent skinEvent)
          Records a SkinEvent attached to this instance.
 void attach(TooltipManager tooltipManager)
          Attaches this skin to a gui manager.
 void detach()
          Frees all allocated resources.
 CommandList getCommandList(java.lang.String name)
          Returns a named command list.
 KeyBindings getDefaultKeyBindings()
          Returns the default key bindings for this skin.
 Gui getDialog(java.lang.String name)
          Returns a dialog by name.
 Gui getDialogBook(int bookNo)
          Returns the popup dialog for readables.
 Gui getDialogConnect()
          Returns the "connection in progress" dialog.
 Gui getDialogDisconnect()
          Returns the "disconnect from server?" dialog.
 Gui getDialogKeyBind()
          Returns the key bindings dialog.
 Gui getDialogQuery()
          Returns the dialog for query text input.
 Gui getDialogQuit()
          Returns the "really quit?" dialog.
 java.lang.String getDialogToLoad()
          Returns one dialog pending loading.
 Gui getMainInterface()
          Returns the main window.
 java.awt.Dimension getMapSize()
          Returns the map size in squares.
 Resolution getMaxResolution()
          Returns the maximal resolution of this skin.
 Gui getMetaInterface()
          Returns the server selection window.
 Resolution getMinResolution()
          Returns the minimal resolution of this skin.
 int getNumLookObjects()
          The number of ground view objects to request from the server.
 java.lang.String getSkinName()
          Returns a short name for the skin.
 Gui getStartInterface()
          Returns the start window.
 AbstractLabel getTooltipLabel()
          Returns the AbstractLabel that is used to display tooltips.
 boolean hasChangedDialog()
          Returns whether the dialog state should be saved.
 void insertGuiElement(GUIElement guiElement)
          Adds a new GUIElement to this skin.
 java.util.Iterator<Gui> iterator()
          Returns all gui instances of this skin.
 void setNumLookObjects(int numLookObjects)
          Sets the maximum number of ground view objects.
 void setScreenSize(int screenWidth, int screenHeight)
          Updates the skin's gui elements to a screen size.
 void setSkinName(java.lang.String skinName, Resolution minResolution, Resolution maxResolution)
          Sets the skin name.
 void setTooltipLabel(AbstractLabel tooltipLabel)
          Sets the AbstractLabel that is used to display tooltips.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentScreenHeight

private int currentScreenHeight
The current screen height.


currentScreenWidth

private int currentScreenWidth
The current screen width.


DEFAULT_NUM_LOOK_OBJECTS

private static final int DEFAULT_NUM_LOOK_OBJECTS
The default number of ground view objects.

See Also:
Constant Field Values

defaultKeyBindings

@NotNull
private final KeyBindings defaultKeyBindings
The default key bindings.


definedCommandLists

@NotNull
private final JXCSkinCache<CommandList> definedCommandLists
All defined command lists.


dialogs

@NotNull
private final Dialogs dialogs
All defined dialogs.


floorLists

@NotNull
private final java.util.Collection<GUIItemList> floorLists
The GUIItemLists that display floor items.


guiElements

@NotNull
private final java.util.Collection<GUIElement> guiElements
All GUI elements.


initEvents

@NotNull
private final java.util.Collection<CommandList> initEvents
All "event init" commands in execution order.


maps

@NotNull
private final java.util.Collection<GUIMap> maps
The GUIMaps that display maps.


maxResolution

@NotNull
private Resolution maxResolution
The maximal resolution.


minResolution

@NotNull
private Resolution minResolution
The minimal resolution.


numLookObjects

private int numLookObjects
The maximum number of ground view objects.


optionManager

@NotNull
private final OptionManager optionManager
The OptionManager to use.


optionNames

@NotNull
private final java.util.Collection<java.lang.String> optionNames
The defined option names.


skinEvents

@NotNull
private final java.util.Collection<SkinEvent> skinEvents
All SkinEvents attached to this instance.


skinName

@NotNull
private java.lang.String skinName
The skin name.


tooltipLabel

@Nullable
private AbstractLabel tooltipLabel
The tooltip label or null.


tooltipManager

@Nullable
private TooltipManager tooltipManager
The TooltipManager currently attached to or null if not attached.

Constructor Detail

DefaultJXCSkin

public DefaultJXCSkin(@NotNull
                      KeyBindings defaultKeyBindings,
                      @NotNull
                      OptionManager optionManager,
                      @NotNull
                      Dialogs dialogs)
Creates a new instance.

Parameters:
defaultKeyBindings - the default key bindings
optionManager - the option manager to use
dialogs - the dialogs to use
Method Detail

addCommandList

public void addCommandList(@NotNull
                           java.lang.String commandListName,
                           @NotNull
                           CommandListType commandListType)
                    throws JXCSkinException
Defines a new command list.

Parameters:
commandListName - the command list's name
commandListType - the command list's type
Throws:
JXCSkinException - if the command list cannot be created

addDialog

public void addDialog(@NotNull
                      java.lang.String dialogName)
Defines a new dialog.

Parameters:
dialogName - the dialog's name

addFloorList

public void addFloorList(@NotNull
                         GUIItemList floorList)
Adds a GUIItemList element that displays floor items. These elements are used to calculate the number of floor objects to request from the Crossfire server.

Parameters:
floorList - the floor list element

addInitEvent

public void addInitEvent(@NotNull
                         CommandList commandList)
Adds a command list to be executed on "init" events.

Parameters:
commandList - the command list

addMap

public void addMap(@NotNull
                   GUIMap map)
Adds a GUIMap element that displays a map. These elements are used to calculate the size of the map view to request from the Crossfire server.

Parameters:
map - the map element

addOption

public void addOption(@NotNull
                      java.lang.String optionName,
                      @NotNull
                      java.lang.String documentation,
                      @NotNull
                      Option commandCheckBoxOption)
               throws JXCSkinException
Add a new option.

Parameters:
optionName - the option name to add
documentation - the documentation string for the settings
commandCheckBoxOption - the option instance to forward to
Throws:
JXCSkinException - if the option cannot be created

addSkinEvent

public void addSkinEvent(@NotNull
                         SkinEvent skinEvent)
Records a SkinEvent attached to this instance.

Parameters:
skinEvent - the skin event to add

attach

public void attach(@NotNull
                   TooltipManager tooltipManager)
Attaches this skin to a gui manager.

Specified by:
attach in interface JXCSkin
Parameters:
tooltipManager - the tooltip manager to attach to

detach

public void detach()
Frees all allocated resources.

Specified by:
detach in interface JXCSkin

getCommandList

@NotNull
public CommandList getCommandList(@NotNull
                                          java.lang.String name)
                           throws JXCSkinException
Returns a named command list.

Specified by:
getCommandList in interface JXCSkin
Parameters:
name - the name of the command list
Returns:
the command list
Throws:
JXCSkinException - if the command list does not exist

getDefaultKeyBindings

@NotNull
public KeyBindings getDefaultKeyBindings()
Returns the default key bindings for this skin.

Specified by:
getDefaultKeyBindings in interface JXCSkin
Returns:
the default key bindings

getDialog

@NotNull
public Gui getDialog(@NotNull
                             java.lang.String name)
              throws JXCSkinException
Returns a dialog by name.

Specified by:
getDialog in interface JXCSkin
Parameters:
name - the dialog's name
Returns:
the dialog
Throws:
JXCSkinException - if the dialog does not exist

getDialogBook

@NotNull
public Gui getDialogBook(int bookNo)
Returns the popup dialog for readables.

Specified by:
getDialogBook in interface JXCSkin
Parameters:
bookNo - the book ID
Returns:
the dialog

getDialogConnect

@Nullable
public Gui getDialogConnect()
Returns the "connection in progress" dialog. It is opened while the connection establishment is in progress.

Specified by:
getDialogConnect in interface JXCSkin
Returns:
the dialog or null if the dialog does not exist

getDialogDisconnect

@Nullable
public Gui getDialogDisconnect()
Returns the "disconnect from server?" dialog. It is opened when the user presses ESCAPE.

Specified by:
getDialogDisconnect in interface JXCSkin
Returns:
the dialog or null if the dialog does not exist

getDialogKeyBind

@NotNull
public Gui getDialogKeyBind()
Returns the key bindings dialog.

Specified by:
getDialogKeyBind in interface JXCSkin
Returns:
the dialog

getDialogQuery

@NotNull
public Gui getDialogQuery()
Returns the dialog for query text input.

Specified by:
getDialogQuery in interface JXCSkin
Returns:
the dialog

getDialogQuit

@Nullable
public Gui getDialogQuit()
Returns the "really quit?" dialog. It is opened when the user presses ESCAPE.

Specified by:
getDialogQuit in interface JXCSkin
Returns:
the dialog or null if the dialog does not exist

getDialogToLoad

@Nullable
public java.lang.String getDialogToLoad()
Returns one dialog pending loading. Each dialog is returned only once.

Returns:
a dialog pending loading or null

getMainInterface

@NotNull
public Gui getMainInterface()
Returns the main window.

Specified by:
getMainInterface in interface JXCSkin
Returns:
the dialog

getMapSize

@NotNull
public java.awt.Dimension getMapSize()
Returns the map size in squares.

Specified by:
getMapSize in interface JXCSkin
Returns:
the map size

getMaxResolution

@NotNull
public Resolution getMaxResolution()
Returns the maximal resolution of this skin.

Specified by:
getMaxResolution in interface JXCSkin
Returns:
the maximal resolution

getMetaInterface

@NotNull
public Gui getMetaInterface()
Returns the server selection window.

Specified by:
getMetaInterface in interface JXCSkin
Returns:
the dialog

getMinResolution

@NotNull
public Resolution getMinResolution()
Returns the minimal resolution of this skin.

Specified by:
getMinResolution in interface JXCSkin
Returns:
the minimal resolution

getNumLookObjects

public int getNumLookObjects()
The number of ground view objects to request from the server.

Specified by:
getNumLookObjects in interface JXCSkin
Returns:
the number of ground view objects

getSkinName

@NotNull
public java.lang.String getSkinName()
Returns a short name for the skin. It is used to construct path or file names.

Specified by:
getSkinName in interface JXCSkin
Returns:
the skin name

getStartInterface

@NotNull
public Gui getStartInterface()
Returns the start window.

Specified by:
getStartInterface in interface JXCSkin
Returns:
the dialog

getTooltipLabel

@Nullable
public AbstractLabel getTooltipLabel()
Returns the AbstractLabel that is used to display tooltips.

Specified by:
getTooltipLabel in interface JXCSkin
Returns:
the label or null if tooltips are disabled

hasChangedDialog

public boolean hasChangedDialog()
Returns whether the dialog state should be saved.

Specified by:
hasChangedDialog in interface JXCSkin
Returns:
whether the dialog state should be saved

insertGuiElement

public void insertGuiElement(@NotNull
                             GUIElement guiElement)
Adds a new GUIElement to this skin.

Parameters:
guiElement - the GUI element

iterator

@NotNull
public java.util.Iterator<Gui> iterator()
Returns all gui instances of this skin. The instances has no defined order.

Specified by:
iterator in interface JXCSkin
Specified by:
iterator in interface java.lang.Iterable<Gui>
Returns:
an iterator returning all gui instances

setNumLookObjects

public void setNumLookObjects(int numLookObjects)
Sets the maximum number of ground view objects.

Parameters:
numLookObjects - the number of objects

setScreenSize

public void setScreenSize(int screenWidth,
                          int screenHeight)
Updates the skin's gui elements to a screen size.

Specified by:
setScreenSize in interface JXCSkin
Parameters:
screenWidth - the new screen width
screenHeight - the new screen height

setSkinName

public void setSkinName(@NotNull
                        java.lang.String skinName,
                        @NotNull
                        Resolution minResolution,
                        @NotNull
                        Resolution maxResolution)
Sets the skin name.

Parameters:
skinName - the skin name
minResolution - the minimal supported resolution
maxResolution - the maximal supported resolution

setTooltipLabel

public void setTooltipLabel(@Nullable
                            AbstractLabel tooltipLabel)
Sets the AbstractLabel that is used to display tooltips.

Parameters:
tooltipLabel - the label or null to disable tooltips