Package VASSAL.build.module.map
Class LOS_Thread
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.AbstractToolbarItem
VASSAL.build.module.map.LOS_Thread
- All Implemented Interfaces:
MouseListener
,MouseMotionListener
,PropertyChangeListener
,EventListener
,AutoConfigurable
,Buildable
,Configurable
,GameComponent
,Drawable
,PropertyNameSource
,CommandEncoder
,ValidityChecker
,Translatable
,Auditable
,ImageSearchTarget
,SearchTarget
,UniqueIdManager.Identifyable
public class LOS_Thread
extends AbstractToolbarItem
implements MouseListener, MouseMotionListener, Drawable, Configurable, UniqueIdManager.Identifyable, CommandEncoder
A class that allows the user to draw a straight line on a Map (LOS
= Line Of Sight). No automatic detection of obstacles is
performed; the user must simply observe the thread against the
image of the map. However, if the user clicks on a board with a
Grid
, the thread may snap to the grid and report the
distance between endpoints of the line-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
Deprecated, for removal: This API element is subject to removal in a future version.static class
static class
static class
static class
Nested classes/interfaces inherited from class VASSAL.build.AbstractToolbarItem
AbstractToolbarItem.FormattedStringConfig
Nested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected Point
protected String
protected Point
static final String
static final String
static final String
protected boolean
static final String
static final String
protected boolean
protected String
static final String
protected String
static final String
static final String
static final String
protected boolean
protected int
protected KeyStroke
static final String
static final String
protected String
protected static final UniqueIdManager
protected boolean
static final String
protected Point
protected Point
protected String
protected String
protected Rectangle
protected long
protected LaunchButton
Deprecated, for removal: This API element is subject to removal in a future version.use launch from the superclassstatic final String
static final String
static final String
protected int
protected Map
protected boolean
static final String
static final String
protected String
static final String
static final String
protected String
protected boolean
static final String
static final String
static final Font
static final String
static final String
static final String
protected Color
protected Color
protected double
protected int
static final String
protected FormattedString
protected boolean
static final String
static final String
static final String
static final String
static final String
static final String
protected boolean
protected boolean
protected Color
protected String
static final String
static final String
protected boolean
static final String
Fields inherited from class VASSAL.build.AbstractToolbarItem
BUTTON_TEXT, CAN_DISABLE, canDisable, DISABLED_ICON, disabledIconConfig, HIDE_WHEN_DISABLED, hideWhenDisabled, ICON, property, PROPERTY_GATE, propertyGate, showDisabledOptions
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
In case reports use HTML and refer to any image filesvoid
Expects to be added to aMap
.Translate a String into aCommand
void
boolean
void
Writes text showing the rangeTranslate aCommand
into a StringClass<?>[]
protected Point
protected Point
getArrow()
String[]
This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.String[]
The attributes of an LOS_Thread are:Class<?>[]
This getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.getAttributeVisibility
(String name) By default, all attributes are visiblestatic String
getId()
protected int
protected String
getState()
With Global visibility, LOS_Thread now has a state that needs to be communicated to clients on other machinesprotected boolean
protected boolean
boolean
protected void
launch()
void
void
void
Since we register ourselves as a MouseListener usingMap.pushMouseListener(java.awt.event.MouseListener)
, these mouse events are received in map coordinatesvoid
void
void
void
void
Remove from our parentvoid
reset()
Reset the LOS Thread back to hidden, ready for next activationvoid
setAttribute
(String key, Object value) Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.protected void
setEndPoints
(Point newAnchor, Point newArrow) void
Commands controlling persistence are passed between players, so LOS Threads must have a unique ID.protected void
setMirroring
(boolean b) protected void
setPersisting
(boolean b) void
protected void
setTransparency
(int h) void
setup
(boolean show) Notify the GameComponent that a game has started/endedvoid
setVisible
(boolean state) If true, draw the thread on the mapMethods inherited from class VASSAL.build.AbstractToolbarItem
addPropertyGateListener, addPropertyGateListener, checkDisabled, disableIfTrue, getComponent, getLaunchButton, getMenuTextList, getNamedKeyStrokeList, getNameKey, getPropertyList, getRestoreCommand, isShowDisabledOptions, makeLaunchButton, propertyChange, removePropertyGateListener, setButtonTextKey, setHotKeyKey, setIconKey, setLaunchButton, setNameKey, setNamePrompt, setShowDisabledOptions, setTooltipKey
Methods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureName, getConfigurer, getExpressionList, getI18nData, getI18nPrefix, getLocalizedConfigureName, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, build, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, getPropertyNames, setAncestor, validate
Methods inherited from class VASSAL.search.AbstractImageFinder
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
add, build, getBuildElement, isMandatory, isMovable, isUnique
Methods inherited from interface VASSAL.build.Configurable
addPropertyChangeListener, getConfigureName, getConfigurer, remove
Methods inherited from interface VASSAL.i18n.Translatable
getI18nData
Methods inherited from interface VASSAL.tools.UniqueIdManager.Identifyable
getConfigureName
-
Field Details
-
LOS_THREAD_COMMAND
- See Also:
-
NAME
- See Also:
-
HOTKEY
- See Also:
-
TOOLTIP
- See Also:
-
ICON_NAME
- See Also:
-
LABEL
- See Also:
-
SNAP_LOS
- See Also:
-
SNAP_START
- See Also:
-
SNAP_END
- See Also:
-
REPORT
- See Also:
-
PERSISTENCE
- See Also:
-
PERSISTENT_ICON_NAME
- See Also:
-
GLOBAL
- See Also:
-
LOS_THICKNESS
- See Also:
-
LOS_COLOR
- See Also:
-
DRAW_RANGE
- See Also:
-
HIDE_COUNTERS
- See Also:
-
HIDE_OPACITY
- See Also:
-
RANGE_BACKGROUND
- See Also:
-
RANGE_FOREGROUND
- See Also:
-
RANGE_SCALE
- See Also:
-
RANGE_ROUNDING
- See Also:
-
ROUND_UP
- See Also:
-
ROUND_DOWN
- See Also:
-
ROUND_OFF
- See Also:
-
RANGE_FONT
-
DEFAULT_ICON
- See Also:
-
FROM_LOCATION
- See Also:
-
TO_LOCATION
- See Also:
-
CHECK_COUNT
- See Also:
-
CHECK_LIST
- See Also:
-
RANGE
- See Also:
-
NEVER
- See Also:
-
ALWAYS
- See Also:
-
CTRL_CLICK
- See Also:
-
WHEN_PERSISTENT
- See Also:
-
idMgr
-
retainAfterRelease
protected boolean retainAfterRelease -
lastRelease
protected long lastRelease -
launch
Deprecated, for removal: This API element is subject to removal in a future version.use launch from the superclass -
map
-
hotkey
-
anchor
-
arrow
-
visible
protected boolean visible -
drawRange
protected boolean drawRange -
rangeScale
protected int rangeScale -
rangeRounding
protected double rangeRounding -
hideCounters
protected boolean hideCounters -
losThickness
protected int losThickness -
hideOpacity
protected int hideOpacity -
fixedColor
-
threadColor
-
rangeFg
-
rangeBg
-
snapStart
protected boolean snapStart -
snapEnd
protected boolean snapEnd -
lastAnchor
-
lastArrow
-
lastRangeRect
-
anchorLocation
-
lastLocation
-
lastRange
-
reportFormat
-
checkList
-
persistence
-
persistentIconName
-
global
-
threadId
-
persisting
protected boolean persisting -
mirroring
protected boolean mirroring -
iconName
-
ctrlWhenClick
protected boolean ctrlWhenClick -
initializing
protected boolean initializing
-
-
Constructor Details
-
LOS_Thread
public LOS_Thread()
-
-
Method Details
-
isVisible
public boolean isVisible()- Returns:
- whether the thread should be drawn
-
setVisible
public void setVisible(boolean state) If true, draw the thread on the map -
addTo
Expects to be added to aMap
. Adds a button to the map window's toolbar. Pushing the button pushes a MouseListener onto the Map that draws the thread. Adds some entries to preferences- Specified by:
addTo
in interfaceBuildable
- Overrides:
addTo
in classAbstractToolbarItem
- Parameters:
b
- parent Buildable to add this component to as a subcomponent.- See Also:
-
removeFrom
Description copied from class:AbstractToolbarItem
Remove from our parent- Specified by:
removeFrom
in interfaceConfigurable
- Overrides:
removeFrom
in classAbstractToolbarItem
- Parameters:
b
- parent
-
setAttribute
Description copied from class:AbstractToolbarItem
Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.Sets a buildFile (XML) attribute value for this component. The
key
parameter will be one of those listed inAbstractToolbarItem.getAttributeNames()
. If thevalue
parameter is a String, it will be the value returned byAbstractToolbarItem.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
- Overrides:
setAttribute
in classAbstractToolbarItem
- Parameters:
key
- the name of the attribute. Will be one of those listed inAbstractToolbarItem.getAttributeNames()
value
- If thevalue
parameter is a String, it will be the value returned byAbstractToolbarItem.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()
-
setTransparency
protected void setTransparency(int h) -
getAttributeValueString
Description copied from class:AbstractToolbarItem
Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.- Specified by:
getAttributeValueString
in interfaceAutoConfigurable
- Specified by:
getAttributeValueString
in interfaceTranslatable
- Overrides:
getAttributeValueString
in classAbstractToolbarItem
- Parameters:
key
- the name of the attribute. Will be one of those listed inAbstractToolbarItem.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
AbstractToolbarItem.setAttribute(java.lang.String, java.lang.Object)
. It is also frequently used for checking the current value of an attribute.
-
setup
public void setup(boolean show) Description copied from interface:GameComponent
Notify the GameComponent that a game has started/ended- Specified by:
setup
in interfaceGameComponent
- Overrides:
setup
in classAbstractToolbarItem
- Parameters:
show
- if true, a game is starting. If false, then a game is ending
-
reset
public void reset()Reset the LOS Thread back to hidden, ready for next activation -
getState
With Global visibility, LOS_Thread now has a state that needs to be communicated to clients on other machines -
setState
-
draw
-
drawAboveCounters
public boolean drawAboveCounters()- Specified by:
drawAboveCounters
in interfaceDrawable
-
launch
protected void launch() -
setId
Commands controlling persistence are passed between players, so LOS Threads must have a unique ID.- Specified by:
setId
in interfaceUniqueIdManager.Identifyable
-
getId
- Specified by:
getId
in interfaceUniqueIdManager.Identifyable
-
mouseEntered
Since we register ourselves as a MouseListener usingMap.pushMouseListener(java.awt.event.MouseListener)
, these mouse events are received in map coordinates- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
setPersisting
protected void setPersisting(boolean b) -
isPersisting
protected boolean isPersisting() -
setMirroring
protected void setMirroring(boolean b) -
isMirroring
protected boolean isMirroring() -
getAnchor
-
setEndPoints
-
getArrow
-
getLosCheckCount
protected int getLosCheckCount() -
getLosCheckList
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
drawRange
-
getConfigureTypeName
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Returns:
- a HelpFile describing how to use and configure * this component
-
getAttributeNames
The attributes of an LOS_Thread are:NAME
: the name of the Preferences tabLABEL
: the label of the buttonHOTKEY
: the hotkey equivalent of the buttonDRAW_RANGE
: If true, draw the distance between endpoints of the threadRANGE_FOREGROUND
: the color of the text when drawing the distanceRANGE_BACKGROUND
: the color of the background rectangle when drawing the distanceHIDE_COUNTERS
: If true, hide allGamePiece
s on the map when drawing the thread- Specified by:
getAttributeNames
in interfaceAutoConfigurable
- Overrides:
getAttributeNames
in classAbstractToolbarItem
- Returns:
- an array of all buildFile (XML) attribute names for this component
-
getAttributeDescriptions
Description copied from class:AbstractToolbarItem
This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeDescriptions(), key1, ..., keyN), or supply their own order from scratch.- Specified by:
getAttributeDescriptions
in interfaceAutoConfigurable
- Overrides:
getAttributeDescriptions
in classAbstractToolbarItem
- 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 class:AbstractToolbarItem
This getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeTypes(), key1, ..., keyN), or supply their own order from scratch.- Specified by:
getAttributeTypes
in interfaceAutoConfigurable
- Overrides:
getAttributeTypes
in classAbstractToolbarItem
- 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 in
AbstractBuildable.getAttributeNames()
-
getAttributeVisibility
Description copied from class:AbstractConfigurable
By default, all attributes are visible- Specified by:
getAttributeVisibility
in interfaceAutoConfigurable
- Overrides:
getAttributeVisibility
in classAbstractToolbarItem
- Parameters:
name
- Name (key) of one of this component's attributes- Returns:
- a
VisibilityCondition
for this attribute, or null if attribute should always be visible.
-
getConfigureComponents
- Specified by:
getConfigureComponents
in interfaceConfigurable
- Overrides:
getConfigureComponents
in classAbstractConfigurable
- Returns:
- A list of all child components (i.e. subcomponents) of this component that are configurable.
-
getAllowableConfigureComponents
- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
- Returns:
- a list of valid sub-component Classes. If a Class
appears in this list, then instances of that class may be added
to this component from the Editor's
ConfigureTree
window by right-clicking on the component and selecting the appropriate "Add" option.
-
decode
Description copied from interface:CommandEncoder
Translate a String into aCommand
- Specified by:
decode
in interfaceCommandEncoder
-
encode
Description copied from interface:CommandEncoder
Translate aCommand
into a String- Specified by:
encode
in interfaceCommandEncoder
-
getFormattedStringList
- Specified by:
getFormattedStringList
in interfaceSearchTarget
- Overrides:
getFormattedStringList
in classAbstractConfigurable
- Returns:
- a list of any Message Format strings referenced in the Configurable, if any (for search)
-
addLocalImageNames
In case reports use HTML and refer to any image files- Specified by:
addLocalImageNames
in interfaceImageSearchTarget
- Overrides:
addLocalImageNames
in classAbstractToolbarItem
- Parameters:
s
- Collection to add image names to
-
AbstractToolbarItem.IconConfig
instead.