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,EventListener,AutoConfigurable,Buildable,Configurable,Drawable,PropertyNameSource,CommandEncoder,ValidityChecker,Translatable,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
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classDeprecated, for removal: This API element is subject to removal in a future version.static classstatic classstatic classstatic classNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Stringprotected Pointprotected Stringprotected Pointstatic Stringstatic Stringstatic Stringprotected booleanstatic Stringstatic Stringprotected booleanprotected Stringstatic Stringprotected Stringstatic Stringstatic Stringstatic Stringprotected booleanprotected intprotected KeyStrokestatic Stringstatic Stringprotected Stringprotected static UniqueIdManagerprotected booleanstatic Stringprotected Pointprotected Pointprotected Stringprotected Stringprotected Rectangleprotected longprotected LaunchButtonDeprecated, for removal: This API element is subject to removal in a future version.use launch from the superclassstatic Stringstatic Stringprotected Mapprotected booleanstatic Stringstatic Stringprotected Stringstatic Stringstatic Stringprotected Stringprotected booleanstatic Stringstatic Stringstatic Fontstatic Stringstatic Stringstatic Stringprotected Colorprotected Colorprotected doubleprotected intstatic Stringprotected FormattedStringprotected booleanstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringprotected booleanprotected booleanprotected Colorprotected Stringstatic Stringstatic Stringprotected booleanstatic StringFields inherited from class VASSAL.build.AbstractToolbarItem
BUTTON_TEXT, ICONFields 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 TypeMethodDescriptionvoidIn case reports use HTML and refer to any image filesvoidExpects to be added to aMap.Translate a String into aCommandvoidbooleanvoidWrites text showing the rangeTranslate aCommandinto a StringClass<?>[]protected Pointprotected PointgetArrow()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 StringgetId()protected intprotected StringgetState()With Global visibility, LOS_Thread now has a state that needs to be communicated to clients on other machinesprotected booleanprotected booleanbooleanprotected voidlaunch()voidvoidvoidSince we register ourselves as a MouseListener usingMap.pushMouseListener(java.awt.event.MouseListener), these mouse events are received in map coordinatesvoidvoidmouseMoved(MouseEvent e)voidvoidvoidremoveFrom(Buildable b)Default behavior assumes we are removing this from the module toolbarvoidreset()Reset the LOS Thread back to hidden, ready for next activationvoidsetAttribute(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 voidsetEndPoints(Point newAnchor, Point newArrow)voidCommands controlling persistence are passed between players, so LOS Threads must have a unique ID.protected voidsetMirroring(boolean b)protected voidsetPersisting(boolean b)voidprotected voidsetTransparency(int h)voidsetup(boolean show)voidsetVisible(boolean state)If true, draw the thread on the mapMethods inherited from class VASSAL.build.AbstractToolbarItem
getComponent, getLaunchButton, getMenuTextList, getNamedKeyStrokeList, makeLaunchButton, setButtonTextKey, setHotKeyKey, setIconKey, setLaunchButton, setNameKey, setTooltipKeyMethods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureName, getConfigurer, getExpressionList, getI18nData, getI18nPrefix, getLocalizedConfigureName, getPropertyList, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameMethods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, build, getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getPropertyNames, validateMethods inherited from class VASSAL.search.AbstractImageFinder
getAllImageNames, getLocalImageNamesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface VASSAL.build.Buildable
add, build, getBuildElementMethods inherited from interface VASSAL.build.Configurable
addPropertyChangeListener, getConfigureName, getConfigurer, removeMethods inherited from interface VASSAL.i18n.Translatable
getI18nDataMethods inherited from interface VASSAL.tools.UniqueIdManager.Identifyable
getConfigureName
-
Field Details
-
LOS_THREAD_COMMAND
- See Also:
- Constant Field Values
-
NAME
- See Also:
- Constant Field Values
-
HOTKEY
- See Also:
- Constant Field Values
-
TOOLTIP
- See Also:
- Constant Field Values
-
ICON_NAME
- See Also:
- Constant Field Values
-
LABEL
- See Also:
- Constant Field Values
-
SNAP_LOS
- See Also:
- Constant Field Values
-
SNAP_START
- See Also:
- Constant Field Values
-
SNAP_END
- See Also:
- Constant Field Values
-
REPORT
- See Also:
- Constant Field Values
-
PERSISTENCE
- See Also:
- Constant Field Values
-
PERSISTENT_ICON_NAME
- See Also:
- Constant Field Values
-
GLOBAL
- See Also:
- Constant Field Values
-
LOS_COLOR
- See Also:
- Constant Field Values
-
DRAW_RANGE
- See Also:
- Constant Field Values
-
HIDE_COUNTERS
- See Also:
- Constant Field Values
-
HIDE_OPACITY
- See Also:
- Constant Field Values
-
RANGE_BACKGROUND
- See Also:
- Constant Field Values
-
RANGE_FOREGROUND
- See Also:
- Constant Field Values
-
RANGE_SCALE
- See Also:
- Constant Field Values
-
RANGE_ROUNDING
- See Also:
- Constant Field Values
-
ROUND_UP
- See Also:
- Constant Field Values
-
ROUND_DOWN
- See Also:
- Constant Field Values
-
ROUND_OFF
- See Also:
- Constant Field Values
-
RANGE_FONT
-
DEFAULT_ICON
- See Also:
- Constant Field Values
-
FROM_LOCATION
- See Also:
- Constant Field Values
-
TO_LOCATION
- See Also:
- Constant Field Values
-
CHECK_COUNT
- See Also:
- Constant Field Values
-
CHECK_LIST
- See Also:
- Constant Field Values
-
RANGE
- See Also:
- Constant Field Values
-
NEVER
- See Also:
- Constant Field Values
-
ALWAYS
- See Also:
- Constant Field Values
-
CTRL_CLICK
- See Also:
- Constant Field Values
-
WHEN_PERSISTENT
- See Also:
- Constant Field Values
-
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 -
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:
addToin interfaceBuildable- Overrides:
addToin classAbstractToolbarItem- Parameters:
b- parent Buildable to add this component to as a subcomponent.- See Also:
Map.pushMouseListener(java.awt.event.MouseListener)
-
removeFrom
Description copied from class:AbstractToolbarItemDefault behavior assumes we are removing this from the module toolbar- Specified by:
removeFromin interfaceConfigurable- Overrides:
removeFromin classAbstractToolbarItem- Parameters:
b- parent
-
setAttribute
Description copied from class:AbstractToolbarItemClasses 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. Thekeyparameter will be one of those listed inAbstractToolbarItem.getAttributeNames(). If thevalueparameter is a String, it will be the value returned byAbstractToolbarItem.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- Overrides:
setAttributein classAbstractToolbarItem- Parameters:
key- the name of the attribute. Will be one of those listed inAbstractToolbarItem.getAttributeNames()value- If thevalueparameter is a String, it will be the value returned byAbstractToolbarItem.getAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluecan also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
setTransparency
protected void setTransparency(int h) -
getAttributeValueString
Description copied from class:AbstractToolbarItemClasses 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:
getAttributeValueStringin interfaceAutoConfigurable- Specified by:
getAttributeValueStringin interfaceTranslatable- Overrides:
getAttributeValueStringin 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) -
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:
drawAboveCountersin interfaceDrawable
-
launch
protected void launch() -
setId
Commands controlling persistence are passed between players, so LOS Threads must have a unique ID.- Specified by:
setIdin interfaceUniqueIdManager.Identifyable
-
getId
- Specified by:
getIdin 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:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin 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:
mouseMovedin interfaceMouseMotionListener
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
drawRange
Writes text showing the range- Parameters:
range- the range to display, in whatever units returned by theMapGridcontaining the thread
-
getConfigureTypeName
-
getHelpFile
- Specified by:
getHelpFilein 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 allGamePieces on the map when drawing the thread- Specified by:
getAttributeNamesin interfaceAutoConfigurable- Overrides:
getAttributeNamesin classAbstractToolbarItem- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getAttributeDescriptions
Description copied from class:AbstractToolbarItemThis 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:
getAttributeDescriptionsin interfaceAutoConfigurable- Overrides:
getAttributeDescriptionsin 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:AbstractToolbarItemThis 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:
getAttributeTypesin interfaceAutoConfigurable- Overrides:
getAttributeTypesin 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
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 in
AbstractBuildable.getAttributeNames()
-
getAttributeVisibility
Description copied from class:AbstractConfigurableBy default, all attributes are visible- Specified by:
getAttributeVisibilityin interfaceAutoConfigurable- Overrides:
getAttributeVisibilityin classAbstractConfigurable- Parameters:
name- Name (key) of one of this component's attributes- Returns:
- a
VisibilityConditionfor this attribute, or null if attribute should always be visible.
-
getConfigureComponents
- Specified by:
getConfigureComponentsin interfaceConfigurable- Overrides:
getConfigureComponentsin classAbstractConfigurable- Returns:
- A list of all child components (i.e. subcomponents) of this component that are configurable.
-
getAllowableConfigureComponents
- Specified by:
getAllowableConfigureComponentsin 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
ConfigureTreewindow by right-clicking on the component and selecting the appropriate "Add" option.
-
decode
Description copied from interface:CommandEncoderTranslate a String into aCommand- Specified by:
decodein interfaceCommandEncoder
-
encode
Description copied from interface:CommandEncoderTranslate aCommandinto a String- Specified by:
encodein interfaceCommandEncoder
-
getFormattedStringList
- Specified by:
getFormattedStringListin interfaceSearchTarget- Overrides:
getFormattedStringListin 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:
addLocalImageNamesin interfaceImageSearchTarget- Overrides:
addLocalImageNamesin classAbstractToolbarItem- Parameters:
s- Collection to add image names to
-