VASSAL.build.widget
Class PieceSlot
java.lang.Object
|
+--VASSAL.build.AbstractBuildable
|
+--VASSAL.build.AbstractConfigurable
|
+--VASSAL.build.Widget
|
+--VASSAL.build.widget.PieceSlot
- All Implemented Interfaces:
- AutoConfigurable, Buildable, Configurable, java.util.EventListener, java.awt.event.KeyListener, java.awt.event.MouseListener
- Direct Known Subclasses:
- CardSlot
- public class PieceSlot
- extends Widget
- implements java.awt.event.MouseListener, java.awt.event.KeyListener
A Component that displays a GamePiece.
Can be added to any Widget but cannot contain any children
Keyboard input on a PieceSlot is forwarded to the GamePiece.keyEvent(javax.swing.KeyStroke)
method for the PieceSlot's GamePiece. Clicking on a PieceSlot
initiates a drag
|
Field Summary |
protected static java.awt.Font |
FONT
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FONT
protected static java.awt.Font FONT
PieceSlot
public PieceSlot()
PieceSlot
public PieceSlot(GamePiece p)
setPiece
public void setPiece(GamePiece p)
getPiece
public GamePiece getPiece()
paint
public void paint(java.awt.Graphics g)
getPreferredSize
public java.awt.Dimension getPreferredSize()
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressed in interface java.awt.event.MouseListener
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleased in interface java.awt.event.MouseListener
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClicked in interface java.awt.event.MouseListener
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEntered in interface java.awt.event.MouseListener
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExited in interface java.awt.event.MouseListener
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
- 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
getConfigureTypeName
public static java.lang.String getConfigureTypeName()
getComponent
public java.awt.Component getComponent()
- Overrides:
getComponent in class Widget
- Following copied from class:
VASSAL.build.Widget
- Returns:
- the Component for this widget. For efficiency, the
Component may be initialized lazily instead of being created
in the
Buildable.build(org.w3c.dom.Element) method
build
public void build(org.w3c.dom.Element e)
- When building a PieceSlot, the text contents of the XML element
are parsed into a String. The String is decoded using
GameModule.decode(java.lang.String). The resulting Command
should be an instance of AddPiece. The piece referred to
in the Command becomes the piece contained in the PieceSlot
- Overrides:
build in class Widget
- Following copied from interface:
VASSAL.build.Buildable
- Parameters:
e - the XML element containing the object data
addTo
public void addTo(Buildable parent)
- Description copied from interface:
Buildable
- Adds this component to its parent.
In order to make Buildable objects extensible, the child
is reponsible for adding itself to the parent. That way,
Buildable subcomponents can be defined in an extension package
without needing to modify the containing class.
- Overrides:
addTo in class Widget
getBuildElement
public org.w3c.dom.Element getBuildElement(org.w3c.dom.Document doc)
- Overrides:
getBuildElement in class Widget
- Following copied from interface:
VASSAL.build.Buildable
- Returns:
- an XML element from which
this component can be built
removeFrom
public void removeFrom(Buildable parent)
- Description copied from interface:
Configurable
- Remove this component from its parent
- Overrides:
removeFrom in class Widget
getConfigureName
public java.lang.String getConfigureName()
- Description copied from interface:
Configurable
- The name of this Configurable Object
- Overrides:
getConfigureName in class AbstractConfigurable
getHelpFile
public HelpFile getHelpFile()
- Overrides:
getHelpFile in class Widget
- Following copied from interface:
VASSAL.build.Configurable
- Returns:
- a HelpFilte describing how to use and configure
this component
getAttributeNames
public java.lang.String[] getAttributeNames()
- Overrides:
getAttributeNames in class AbstractBuildable
- Following copied from interface:
VASSAL.build.AutoConfigurable
- Returns:
- an array of Strings giving all attributes of this Buildable
component that will be written to/read from an XML element
getAttributeDescriptions
public java.lang.String[] getAttributeDescriptions()
- Description copied from class:
AbstractConfigurable
- Return an array of Strings describing the attributes
of this object. These strings are used as prompts in
the Properties window for this object. The order of
descriptions should be the same as the order of names
in
AbstractBuildable.getAttributeNames()
- Overrides:
getAttributeDescriptions in class AbstractConfigurable
getAttributeTypes
public java.lang.Class[] getAttributeTypes()
- Description copied from class:
AbstractConfigurable
- Return the Class for the attributes of this object.
Valid classes are: String, Integer, Double, Boolean, Image,
Color, and KeyStroke
The order of classes should be the same as the order of names
in
AbstractBuildable.getAttributeNames()
- Overrides:
getAttributeTypes in class AbstractConfigurable
setAttribute
public void setAttribute(java.lang.String name,
java.lang.Object value)
- Description copied from interface:
AutoConfigurable
- Called by the
Buildable.build(org.w3c.dom.Element) method, where value is the
String value read by the XML attribute.
Can also be called with Object value to set the attribute.
- Overrides:
setAttribute in class AbstractBuildable
- Following copied from class:
VASSAL.build.AbstractBuildable
- Parameters:
key - the name of the attribute. Will be one of those
listed in AbstractBuildable.getAttributeNames()
getAttributeValueString
public java.lang.String getAttributeValueString(java.lang.String name)
- Description copied from interface:
AutoConfigurable
- Called by the
Buildable.getBuildElement(org.w3c.dom.Document) method to write the
attributes into an XML element
- Overrides:
getAttributeValueString in class AbstractBuildable
- Following copied from class:
VASSAL.build.AbstractBuildable
- Parameters:
key - the name of the attribute. Will be one of those
listed in AbstractBuildable.getAttributeNames()
getAttributeConfigurers
public Configurer[] getAttributeConfigurers()
- Returns:
- an array of Configurer objects representing
the attributes of this Configurable object
getConfigureComponents
public Configurable[] getConfigureComponents()
- Overrides:
getConfigureComponents in class Widget
- Returns:
- an array of Configurer objects representing
the Buildable children of this Configurable object
getAllowableConfigureComponents
public java.lang.Class[] getAllowableConfigureComponents()
- Description copied from class:
Widget
- The allowable Configurable components of a Widget are the same
as its parent
- Overrides:
getAllowableConfigureComponents in class Widget
- Returns:
- an array of Configurer objects representing
all possible classes of Buildable children of this Configurable object
getConfigurer
public Configurer getConfigurer()
- Description copied from class:
AbstractConfigurable
- The default
Configurer of an AbstractConfigurable class is an instance of AutoConfigurer
- Overrides:
getConfigurer in class AbstractConfigurable