Package VASSAL.build.widget
Class PieceSlot
java.lang.Object
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.Widget
VASSAL.build.widget.PieceSlot
- All Implemented Interfaces:
KeyListener,MouseListener,EventListener,AutoConfigurable,Buildable,Configurable,PropertyNameSource,ValidityChecker,Translatable
- Direct Known Subclasses:
CardSlot
public class PieceSlot extends Widget implements MouseListener, 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-
Nested Class Summary
Nested Classes Modifier and Type Class Description classPieceSlot.PanelNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util -
Field Summary
Fields Modifier and Type Field Description protected GamePiececprotected GamePieceexpandedprotected static FontFONTstatic StringGP_IDprotected StringgpIdprotected GpIdSupportgpidSupportprotected intheightprotected JPanelpanelprotected StringpieceDefinitionprotected intwidthFields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, name -
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidaddTo(Buildable par)Adds this component to its parent.voidbuild(Element e)When building a PieceSlot, the text contents of the XML element are parsed into a String.protected voidclearExpandedPiece()protected voidcopyFrom(PieceSlot piece)protected voiddoPopup(MouseEvent e)Class<?>[]getAllowableConfigureComponents()The allowable Configurable components of a Widget are the same as its parentString[]getAttributeDescriptions()Return an array of Strings describing the attributes of this object.String[]getAttributeNames()Class<?>[]getAttributeTypes()Return the Class for the attributes of this object.StringgetAttributeValueString(String attr)Return a String representation of the attribute with the given name.ElementgetBuildElement(Document doc)ComponentgetComponent()Configurable[]getConfigureComponents()StringgetConfigureName()The name of this Configurable ObjectConfigurergetConfigurer()static StringgetConfigureTypeName()protected GamePiecegetExpandedPiece()Return defined GamePiece with prototypes fully expanded.StringgetGpId()HelpFilegetHelpFile()ComponentI18nDatagetI18nData()Return the i18n data for this componentGamePiecegetPiece()Return defined GamePiece with prototypes unexpanded.DimensiongetPreferredSize()doublegetScale()voidkeyPressed(KeyEvent e)voidkeyReleased(KeyEvent e)voidkeyTyped(KeyEvent e)voidmouseClicked(MouseEvent e)voidmouseEntered(MouseEvent e)voidmouseExited(MouseEvent e)voidmousePressed(MouseEvent e)voidmouseReleased(MouseEvent e)voidpaint(Graphics g)voidremoveFrom(Buildable parent)Remove this component from its parentvoidsetAttribute(String name, Object value)Sets an attribute value for this component.voidsetGpId(String id)voidsetPiece(GamePiece p)protected voidstartDrag()voidupdateGpId()Allocate a new gpid to this PieceSlot, plus to any PlaceMarker or Replace traits.voidupdateGpId(GpIdSupport s)Update the gpid for this PieceSlot, using the givenGpIdSupportto generate the new id.voidupdateGpId(GamePiece piece)Allocate new gpid's in the given GamePieceMethods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getAttributeVisibility, getI18nPrefix, getLocalizedConfigureName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameMethods inherited from class VASSAL.build.AbstractBuildable
getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getComponents, getComponentsOf, getPropertyNames, validate
-
Field Details
-
GP_ID
- See Also:
- Constant Field Values
-
c
-
expanded
-
pieceDefinition
-
FONT
-
panel
-
width
protected int width -
height
protected int height -
gpId
-
gpidSupport
-
-
Constructor Details
-
Method Details
-
getScale
public double getScale() -
copyFrom
-
setPiece
-
getExpandedPiece
Return defined GamePiece with prototypes fully expanded.- Returns:
- expanded piece
-
clearExpandedPiece
protected void clearExpandedPiece() -
getPiece
Return defined GamePiece with prototypes unexpanded.- Returns:
- unexpanded piece
-
paint
-
getPreferredSize
-
startDrag
protected void startDrag() -
doPopup
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
keyPressed
- Specified by:
keyPressedin interfaceKeyListener
-
keyTyped
- Specified by:
keyTypedin interfaceKeyListener
-
keyReleased
- Specified by:
keyReleasedin interfaceKeyListener
-
getConfigureTypeName
-
getComponent
- Specified by:
getComponentin classWidget- 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
When building a PieceSlot, the text contents of the XML element are parsed into a String. The String is decoded usingGameModule.decode(java.lang.String). The resultingCommandshould be an instance ofAddPiece. The piece referred to in the Command becomes the piece contained in the PieceSlot -
addTo
Description copied from interface:BuildableAdds 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. -
getBuildElement
- Specified by:
getBuildElementin interfaceBuildable- Overrides:
getBuildElementin classWidget- Returns:
- an XML element from which this component can be built
-
removeFrom
Description copied from interface:ConfigurableRemove this component from its parent- Specified by:
removeFromin interfaceConfigurable- Overrides:
removeFromin classWidget
-
getConfigureName
Description copied from interface:ConfigurableThe name of this Configurable Object- Specified by:
getConfigureNamein interfaceConfigurable- Overrides:
getConfigureNamein classAbstractConfigurable
-
getHelpFile
- Specified by:
getHelpFilein interfaceConfigurable- Overrides:
getHelpFilein classWidget- Returns:
- a HelpFilte describing how to use and configure this component
-
getAttributeNames
- Specified by:
getAttributeNamesin interfaceAutoConfigurable- Specified by:
getAttributeNamesin classAbstractBuildable- Returns:
- a list of all attribute names for this component
-
getAttributeDescriptions
Description copied from class:AbstractConfigurableReturn 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 inAbstractBuildable.getAttributeNames()- Specified by:
getAttributeDescriptionsin interfaceAutoConfigurable- Specified by:
getAttributeDescriptionsin classAbstractConfigurable
-
getAttributeTypes
Description copied from class:AbstractConfigurableReturn 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 inAbstractBuildable.getAttributeNames()- Specified by:
getAttributeTypesin interfaceAutoConfigurable- Specified by:
getAttributeTypesin classAbstractConfigurable
-
setAttribute
Description copied from class:AbstractBuildableSets an attribute value for this component. Thekeyparameter will be one of those listed inAbstractBuildable.getAttributeNames(). If thevalueparameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluewill be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()- Specified by:
setAttributein interfaceAutoConfigurable- Specified by:
setAttributein interfaceTranslatable- Specified by:
setAttributein classAbstractBuildable- Parameters:
name- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
-
getConfigureComponents
- Specified by:
getConfigureComponentsin interfaceConfigurable- Overrides:
getConfigureComponentsin classWidget- Returns:
- an array of Configurer objects representing the Buildable children of this Configurable object
-
getAllowableConfigureComponents
Description copied from class:WidgetThe allowable Configurable components of a Widget are the same as its parent- Specified by:
getAllowableConfigureComponentsin interfaceConfigurable- Overrides:
getAllowableConfigureComponentsin classWidget- Returns:
- an array of Configurer objects representing all possible classes of Buildable children of this Configurable object
-
getAttributeValueString
Description copied from class:AbstractBuildableReturn a String representation of the attribute with the given name. When initializing a module, this String value will be passed toAbstractBuildable.setAttribute(java.lang.String, java.lang.Object).- Specified by:
getAttributeValueStringin interfaceAutoConfigurable- Specified by:
getAttributeValueStringin interfaceTranslatable- Specified by:
getAttributeValueStringin classAbstractBuildable- Parameters:
attr- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
-
getI18nData
Description copied from class:AbstractConfigurableReturn the i18n data for this component- Specified by:
getI18nDatain interfaceTranslatable- Overrides:
getI18nDatain classAbstractConfigurable
-
getConfigurer
Description copied from class:AbstractConfigurable- Specified by:
getConfigurerin interfaceConfigurable- Overrides:
getConfigurerin classAbstractConfigurable
-
updateGpId
Update the gpid for this PieceSlot, using the givenGpIdSupportto generate the new id. -
updateGpId
public void updateGpId()Allocate a new gpid to this PieceSlot, plus to any PlaceMarker or Replace traits. -
updateGpId
Allocate new gpid's in the given GamePiece- Parameters:
piece- GamePiece
-
getGpId
-
setGpId
-