Class PieceSlot
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.Widget
VASSAL.build.widget.PieceSlot
- All Implemented Interfaces:
KeyListener
,MouseListener
,EventListener
,AutoConfigurable
,Buildable
,Configurable
,PropertyNameSource
,ComponentDescription
,ValidityChecker
,Translatable
,Auditable
,ImageSearchTarget
,SearchTarget
- Direct Known Subclasses:
CardSlot
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/interfaces inherited from class VASSAL.build.Widget
Widget.MyCellRenderer
Nested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
Modifier and TypeFieldDescriptionprotected GamePiece
protected GamePiece
protected static final Font
static final String
protected String
protected GpIdSupport
protected int
protected final JPanel
static final String
protected String
protected int
Fields inherited from class VASSAL.build.Widget
buildElement, description, DESCRIPTION, HEIGHT, NAME, parent, WIDTH
Fields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, name
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validator
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds all images used by this component AND any subcomponents to the collectionvoid
Adds this component to its parent.void
When building a PieceSlot, the text contents of the XML element are parsed into a String.void
protected void
protected void
protected void
Class<?>[]
The allowable Configurable components of a Widget determined by its parent's Child-Allowable method.String[]
Return an array of Strings describing the attributes of this object.String[]
Lists all the buildFile (XML) attribute names for this component.Class<?>[]
Return the Class for the attributes of this object.Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML elementgetBuildElement
(Document doc) ConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager
.static String
protected GamePiece
Return defined GamePiece with prototypes fully expanded.getGpId()
getName()
getPiece()
Return defined GamePiece with prototypes unexpanded.double
getScale()
boolean
isValid()
Has the PieceSlot been rendered for the first time yet?void
void
void
void
void
void
void
void
void
void
removeFrom
(Buildable parent) Remove this component from its parentvoid
setAttribute
(String name, Object value) Sets a buildFile (XML) attribute value for this component.void
void
void
protected void
void
Allocate a new gpid to this PieceSlot, plus to any PlaceMarker or Replace traits.void
Update the gpid for this PieceSlot, using the givenGpIdSupport
to generate the new id.void
updateGpId
(GamePiece piece) Allocate new gpids in the given GamePieceMethods inherited from class VASSAL.build.Widget
getChildAllowableConfigureComponents, getDescription, getParent, hasScalablePieces, hasScale, rebuild
Methods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getAttributeVisibility, getExpressionList, getFormattedStringList, getI18nPrefix, getMenuTextList, getNamedKeyStrokeList, getPropertyList, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getComponents, getComponentsOf, getNonFolderAncestor, getPropertyNames, setAncestor, validate
Methods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNames
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.script.expression.Auditable
getComponentName, getComponentTypeName
Methods inherited from interface VASSAL.build.Buildable
isMandatory, isMovable, isUnique
-
Field Details
-
GP_ID
- See Also:
-
PIECE_PALETTE_SCALE
- See Also:
-
c
-
expanded
-
pieceDefinition
-
FONT
-
panel
-
width
protected int width -
height
protected int height -
gpId
-
gpidSupport
-
-
Constructor Details
-
PieceSlot
public PieceSlot() -
PieceSlot
-
PieceSlot
-
PieceSlot
-
-
Method Details
-
getName
-
getPieceDefinition
-
getScale
-
copyFrom
-
isValid
public boolean isValid()Has the PieceSlot been rendered for the first time yet?- Returns:
- true if slot has been rendered
-
setPiece
-
getExpandedPiece
Return defined GamePiece with prototypes fully expanded. Do NOT cache the expanded piece unless Translation is complete, it may change under us.- Returns:
- expanded piece
-
clearExpandedPiece
protected void clearExpandedPiece() -
clearCache
public void clearCache() -
getPiece
Return defined GamePiece with prototypes unexpanded.- Returns:
- unexpanded piece
-
addImageNamesRecursively
Description copied from class:AbstractBuildable
Adds all images used by this component AND any subcomponents to the collection- Specified by:
addImageNamesRecursively
in interfaceImageSearchTarget
- Overrides:
addImageNamesRecursively
in classAbstractBuildable
- Parameters:
s
- Collection to add image names to
-
paint
-
getPreferredSize
-
startDrag
protected void startDrag() -
doPopup
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
keyPressed
- Specified by:
keyPressed
in interfaceKeyListener
-
keyTyped
- Specified by:
keyTyped
in interfaceKeyListener
-
keyReleased
- Specified by:
keyReleased
in interfaceKeyListener
-
getConfigureTypeName
-
getComponent
- Specified by:
getComponent
in 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 resultingCommand
should be an instance ofAddPiece
. The piece referred to in the Command becomes the piece contained in the PieceSlot -
addTo
Description copied from interface:Buildable
Adds this component to its parent. In order to make Buildable objects extensible, the child is responsible 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:
getBuildElement
in interfaceBuildable
- Overrides:
getBuildElement
in classWidget
- Parameters:
doc
- XML file- Returns:
- an XML element from which this component can be built
-
removeFrom
Description copied from interface:Configurable
Remove this component from its parent- Specified by:
removeFrom
in interfaceConfigurable
- Overrides:
removeFrom
in classWidget
-
getConfigureName
Description copied from class:AbstractConfigurable
ConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager
.- Specified by:
getConfigureName
in interfaceConfigurable
- Overrides:
getConfigureName
in classAbstractConfigurable
- Returns:
- The language-independent name of this component used for programmatic identification (including within Modules by e.g. Traits and module components)
-
getLocalizedConfigureName
- Overrides:
getLocalizedConfigureName
in classAbstractConfigurable
- Returns:
- The localized name for on-screen display
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Overrides:
getHelpFile
in classWidget
- Returns:
- a HelpFile describing how to use and configure * this component
-
getAttributeNames
Description copied from class:AbstractBuildable
Lists all the buildFile (XML) attribute names for this component. If this component is ALSO anAbstractConfigurable
, then this list of attributes determines the appropriate attribute order forAbstractConfigurable.getAttributeDescriptions()
andAbstractConfigurable.getAttributeTypes()
.- Specified by:
getAttributeNames
in interfaceAutoConfigurable
- Specified by:
getAttributeNames
in classAbstractBuildable
- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getAttributeDescriptions
Description copied from interface:AutoConfigurable
Return an array of Strings describing the attributes of this object. These strings are used as prompts in the Properties window for this object.- Specified by:
getAttributeDescriptions
in interfaceAutoConfigurable
- Specified by:
getAttributeDescriptions
in classAbstractConfigurable
- Returns:
- an array of Strings describing the buildFile (XML) attributes of this component. These strings are used as prompts in the
Properties window for this object, when the component is configured in the Editor. The order of descriptions should
be the same as the order of names in
AbstractBuildable.getAttributeNames()
-
getAttributeTypes
Description copied from interface:AutoConfigurable
Return the Class for the attributes of this object. Valid classes are: String, Integer, Double, Boolean, Image, File, Color, and KeyStroke- Specified by:
getAttributeTypes
in interfaceAutoConfigurable
- Specified by:
getAttributeTypes
in classAbstractConfigurable
- Returns:
- the Class for the buildFile (XML) attributes of this component. Valid classes include: String, Integer, Double, Boolean, Image,
Color, and KeyStroke, along with any class for which a Configurer exists in VASSAL.configure. The class determines, among other things,
which type of
AutoConfigurer
will be used to configure the attribute when the object is configured in the Editor. The order of classes should be the same as the order of names inAbstractBuildable.getAttributeNames()
-
setAttribute
Description copied from class:AbstractBuildable
Sets a buildFile (XML) attribute value for this component. Thekey
parameter will be one of those listed inAbstractBuildable.getAttributeNames()
. If thevalue
parameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
will be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
- Specified by:
setAttribute
in interfaceAutoConfigurable
- Specified by:
setAttribute
in interfaceTranslatable
- Specified by:
setAttribute
in classAbstractBuildable
- Parameters:
name
- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
value
- If thevalue
parameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
can also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
getConfigureComponents
- Specified by:
getConfigureComponents
in interfaceConfigurable
- Overrides:
getConfigureComponents
in classWidget
- Returns:
- an array of Configurer objects representing the Buildable children of this Configurable object
-
getAllowableConfigureComponents
Description copied from class:Widget
The allowable Configurable components of a Widget determined by its parent's Child-Allowable method.- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
- Overrides:
getAllowableConfigureComponents
in classWidget
- Returns:
- an array of Configurer objects representing all possible classes of Buildable children of this Configurable object
-
getAttributeValueString
Description copied from interface:AutoConfigurable
Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML element- Specified by:
getAttributeValueString
in interfaceAutoConfigurable
- Specified by:
getAttributeValueString
in interfaceTranslatable
- Specified by:
getAttributeValueString
in classAbstractBuildable
- Parameters:
attr
- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
- Returns:
- a String representation of the XML buildFile attribute with the given name. When initializing a module,
this String value will loaded from the XML and passed to
AbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
. It is also frequently used for checking the current value of an attribute.
-
getI18nData
- Specified by:
getI18nData
in interfaceTranslatable
- Overrides:
getI18nData
in classAbstractConfigurable
- Returns:
- the i18n data for this component
-
getConfigurer
Description copied from class:AbstractConfigurable
- Specified by:
getConfigurer
in interfaceConfigurable
- Overrides:
getConfigurer
in classAbstractConfigurable
- Returns:
- Configurer for this component
-
updateGpId
Update the gpid for this PieceSlot, using the givenGpIdSupport
to generate the new id. -
setGpidSupport
-
updateGpId
public void updateGpId()Allocate a new gpid to this PieceSlot, plus to any PlaceMarker or Replace traits. -
updateGpId
Allocate new gpids in the given GamePiece- Parameters:
piece
- GamePiece
-
getGpId
-
setGpId
-