Package VASSAL.build.module.map
Class LOS_Thread
java.lang.Object
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.module.map.LOS_Thread
- All Implemented Interfaces:
MouseListener
,MouseMotionListener
,EventListener
,AutoConfigurable
,Buildable
,Configurable
,Drawable
,PropertyNameSource
,CommandEncoder
,ValidityChecker
,Translatable
,UniqueIdManager.Identifyable
public class LOS_Thread extends AbstractConfigurable 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 Classes Modifier and Type Class Description static class
LOS_Thread.GlobalOptions
static class
LOS_Thread.IconConfig
static class
LOS_Thread.LOSCommand
static class
LOS_Thread.PersistenceOptions
static class
LOS_Thread.ReportFormatConfig
static class
LOS_Thread.RoundingOptions
Nested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
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
Constructors Constructor Description LOS_Thread()
-
Method Summary
Modifier and Type Method Description void
addTo(Buildable b)
Expects to be added to aMap
.Command
decode(String command)
Translate a String into aCommand
void
draw(Graphics g, Map m)
boolean
drawAboveCounters()
void
drawRange(Graphics g, int range)
Writes text showing the rangeString
encode(Command c)
Translate aCommand
into a StringClass<?>[]
getAllowableConfigureComponents()
Return a list of valid sub-component Classes.protected Point
getAnchor()
protected Point
getArrow()
String[]
getAttributeDescriptions()
Return an array of Strings describing the attributes of this object.String[]
getAttributeNames()
The attributes of an LOS_Thread are:Class<?>[]
getAttributeTypes()
Return the Class for the buildFile (XML) attributes of this component.String
getAttributeValueString(String key)
Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML elementVisibilityCondition
getAttributeVisibility(String name)
By default, all attributes are visibleConfigurable[]
getConfigureComponents()
static String
getConfigureTypeName()
HelpFile
getHelpFile()
String
getId()
protected int
getLosCheckCount()
protected String
getLosCheckList()
String
getState()
With Global visibility, LOS_Thread now has a state that needs to be communicated to clients on other machinesprotected boolean
isMirroring()
protected boolean
isPersisting()
boolean
isVisible()
protected void
launch()
void
mouseClicked(MouseEvent e)
void
mouseDragged(MouseEvent e)
void
mouseEntered(MouseEvent e)
Since we register ourselves as a MouseListener usingMap.pushMouseListener(java.awt.event.MouseListener)
, these mouse events are received in map coordinatesvoid
mouseExited(MouseEvent e)
void
mouseMoved(MouseEvent e)
void
mousePressed(MouseEvent e)
void
mouseReleased(MouseEvent e)
void
removeFrom(Buildable b)
Remove this component from its parentvoid
setAttribute(String key, Object value)
Sets a buildFile (XML) attribute value for this component.protected void
setEndPoints(Point newAnchor, Point newArrow)
void
setId(String id)
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
setState(String state)
protected void
setTransparency(int h)
void
setup(boolean show)
void
setVisible(boolean state)
If true, draw the thread on the mapMethods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureName, getConfigurer, getI18nData, getI18nPrefix, getLocalizedConfigureName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
build, getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getPropertyNames, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.build.Buildable
add, build, getBuildElement
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:
- Constant Field Values
-
NAME
- 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
-
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
-
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 -
map
-
launch
-
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:
addTo
in interfaceBuildable
- See Also:
Map.pushMouseListener(java.awt.event.MouseListener)
-
removeFrom
Description copied from interface:Configurable
Remove this component from its parent- Specified by:
removeFrom
in interfaceConfigurable
-
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
- Specified by:
getAttributeNames
in classAbstractBuildable
- Returns:
- a list of all buildFile (XML) attribute names for this component
-
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:
key
- 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()
-
setTransparency
protected void setTransparency(int h) -
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:
key
- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
- Returns:
- a String representation of the attribute with the given name. When initializing a module, this String value will be passed to
AbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
.
-
setup
public void setup(boolean show) -
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
Writes text showing the range- Parameters:
range
- the range to display, in whatever units returned by theMapGrid
containing the thread
-
getConfigureTypeName
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Returns:
- a HelpFilte describing how to use and configure 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 class:AbstractConfigurable
Return 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 ofAutoConfigurer
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()
- Specified by:
getAttributeTypes
in interfaceAutoConfigurable
- Specified by:
getAttributeTypes
in classAbstractConfigurable
-
getAttributeVisibility
Description copied from class:AbstractConfigurable
By default, all attributes are visible- Specified by:
getAttributeVisibility
in interfaceAutoConfigurable
- Overrides:
getAttributeVisibility
in classAbstractConfigurable
- 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
Description copied from interface:Configurable
Return 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 Configuration Window.- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
-
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
-