Package VASSAL.build.widget
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 ClassesNested classes/interfaces inherited from class VASSAL.build.Widget
Widget.MyCellRendererNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GamePieceprotected GamePieceprotected static final Fontstatic final Stringprotected Stringprotected GpIdSupportprotected intprotected final JPanelstatic final Stringprotected Stringprotected intFields inherited from class VASSAL.build.Widget
buildElement, description, DESCRIPTION, HEIGHT, NAME, parent, WIDTHFields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, nameFields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validatorFields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds all images used by this component AND any subcomponents to the collectionvoidAdds this component to its parent.voidWhen building a PieceSlot, the text contents of the XML element are parsed into a String.voidprotected voidprotected voidprotected voidClass<?>[]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 Stringprotected GamePieceReturn defined GamePiece with prototypes fully expanded.getGpId()getName()getPiece()Return defined GamePiece with prototypes unexpanded.doublegetScale()booleanisValid()Has the PieceSlot been rendered for the first time yet?voidvoidvoidvoidvoidvoidvoidvoidvoidvoidremoveFrom(Buildable parent) Remove this component from its parentvoidsetAttribute(String name, Object value) Sets a buildFile (XML) attribute value for this component.voidvoidvoidprotected voidvoidAllocate a new gpid to this PieceSlot, plus to any PlaceMarker or Replace traits.voidUpdate the gpid for this PieceSlot, using the givenGpIdSupportto generate the new id.voidupdateGpId(GamePiece piece) Allocate new gpids in the given GamePieceMethods inherited from class VASSAL.build.Widget
getChildAllowableConfigureComponents, getDescription, getParent, hasScalablePieces, hasScale, rebuildMethods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getAttributeVisibility, getExpressionList, getFormattedStringList, getI18nPrefix, getMenuTextList, getNamedKeyStrokeList, getPropertyList, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameMethods inherited from class VASSAL.build.AbstractBuildable
buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getComponents, getComponentsOf, getNonFolderAncestor, getPropertyNames, setAncestor, validateMethods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNamesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface VASSAL.script.expression.Auditable
getComponentName, getComponentTypeNameMethods 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:AbstractBuildableAdds all images used by this component AND any subcomponents to the collection- Specified by:
addImageNamesRecursivelyin interfaceImageSearchTarget- Overrides:
addImageNamesRecursivelyin classAbstractBuildable- Parameters:
s- Collection to add image names to
-
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 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:
getBuildElementin interfaceBuildable- Overrides:
getBuildElementin classWidget- Parameters:
doc- XML file- 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 class:AbstractConfigurableConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager.- Specified by:
getConfigureNamein interfaceConfigurable- Overrides:
getConfigureNamein 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:
getLocalizedConfigureNamein classAbstractConfigurable- Returns:
- The localized name for on-screen display
-
getHelpFile
- Specified by:
getHelpFilein interfaceConfigurable- Overrides:
getHelpFilein classWidget- Returns:
- a HelpFile describing how to use and configure * this component
-
getAttributeNames
Description copied from class:AbstractBuildableLists 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:
getAttributeNamesin interfaceAutoConfigurable- Specified by:
getAttributeNamesin classAbstractBuildable- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getAttributeDescriptions
Description copied from interface:AutoConfigurableReturn 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:
getAttributeDescriptionsin interfaceAutoConfigurable- Specified by:
getAttributeDescriptionsin 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:AutoConfigurableReturn the Class for the attributes of this object. Valid classes are: String, Integer, Double, Boolean, Image, File, Color, and KeyStroke- Specified by:
getAttributeTypesin interfaceAutoConfigurable- Specified by:
getAttributeTypesin 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
AutoConfigurerwill 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:AbstractBuildableSets a buildFile (XML) 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()value- If thevalueparameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluecan also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
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 determined by its parent's Child-Allowable method.- 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 interface:AutoConfigurableCalled by theBuildable.getBuildElement(org.w3c.dom.Document)method to write the attributes into an XML element- 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()- 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:
getI18nDatain interfaceTranslatable- Overrides:
getI18nDatain classAbstractConfigurable- Returns:
- the i18n data for this component
-
getConfigurer
Description copied from class:AbstractConfigurable- Specified by:
getConfigurerin interfaceConfigurable- Overrides:
getConfigurerin classAbstractConfigurable- Returns:
- Configurer for this component
-
updateGpId
Update the gpid for this PieceSlot, using the givenGpIdSupportto 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
-