Package jmri.util
Class PhysicalLocation
- java.lang.Object
-
- javax.vecmath.Tuple3f
-
- javax.vecmath.Vector3f
-
- jmri.util.PhysicalLocation
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class PhysicalLocation extends javax.vecmath.Vector3f
PhysicalLocation Represents a physical location on the layout in 3D space. Dimension units are not specified, but should be kept consistent in all three dimensions for a given usage. Used by VSDecoder for spatially positioning sounds on the layout. Could also be used, for example, for velocity calculations between sensors, or for keying operations locations or panel icons to a physical map view of the layout.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NBPropertyKey
NBPropertyKey : Key name used when storing a PhysicalLocation as a NamedBean Propertystatic PhysicalLocation
Origin
Origin : constant representation of (0, 0, 0)
-
Constructor Summary
Constructors Constructor Description PhysicalLocation()
Default constructorPhysicalLocation(double x, double y, double z)
Constructor from X, Y, Z (double)PhysicalLocation(double x, double y, double z, boolean isTunnel)
Constructor from X, Y, Z (double)PhysicalLocation(float x, float y, float z)
Constructor from X, Y, Z (float)PhysicalLocation(float x, float y, float z, boolean isTunnel)
Constructor from X, Y, Z (float) + is_tunnel (boolean)PhysicalLocation(javax.vecmath.Vector3d v)
PhysicalLocation(javax.vecmath.Vector3f v)
Constructor from Vector3f.PhysicalLocation(PhysicalLocation p)
Copy Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static PhysicalLocation
getBeanPhysicalLocation(NamedBean b)
getBeanPhysicalLocation(NamedBean b) Extract the PhysicalLocation stored in NamedBean b, and return as a new PhysicalLocation object.static PhysicalLocationPanel
getPanel(java.lang.String title)
Get a panel component that can be used to view and/or edit a location.int
hashCode()
boolean
isTunnel()
static PhysicalLocation
parse(java.lang.String pos)
Parse a string representation (x,y,z) Returns a new PhysicalLocation object.static void
setBeanPhysicalLocation(PhysicalLocation p, NamedBean b)
setBeanPhysicalLocation(PhysicalLocation p, NamedBean b) Store PhysicalLocation p as a property in NamedBean b.void
setIsTunnel(boolean t)
java.lang.String
toString()
toString() Output a string representation (x,y,z)javax.vecmath.Vector3d
toVector3d()
void
translate(PhysicalLocation ref)
translate() Translate this PhysicalLocation's coordinates to be relative to point "ref".static PhysicalLocation
translate(PhysicalLocation loc, PhysicalLocation ref)
translate() Return a PhysicalLocation that represents the position of point "loc" relative to reference point "ref".-
Methods inherited from class javax.vecmath.Vector3f
angle, cross, dot, length, lengthSquared, normalize, normalize
-
Methods inherited from class javax.vecmath.Tuple3f
absolute, absolute, add, add, clamp, clamp, clampMax, clampMax, clampMin, clampMin, clone, epsilonEquals, equals, get, get, getX, getY, getZ, interpolate, interpolate, negate, negate, scale, scale, scaleAdd, scaleAdd, set, set, set, set, setX, setY, setZ, sub, sub
-
-
-
-
Field Detail
-
Origin
public static final PhysicalLocation Origin
Origin : constant representation of (0, 0, 0)
-
NBPropertyKey
public static final java.lang.String NBPropertyKey
NBPropertyKey : Key name used when storing a PhysicalLocation as a NamedBean Property- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PhysicalLocation
public PhysicalLocation()
Default constructor
-
PhysicalLocation
public PhysicalLocation(javax.vecmath.Vector3f v)
Constructor from Vector3f.- Parameters:
v
- the vector
-
PhysicalLocation
public PhysicalLocation(javax.vecmath.Vector3d v)
-
PhysicalLocation
public PhysicalLocation(float x, float y, float z, boolean isTunnel)
Constructor from X, Y, Z (float) + is_tunnel (boolean)- Parameters:
x
- location on X axisy
- location on Y axisz
- location on Z axisisTunnel
- true is location is in a tunnel
-
PhysicalLocation
public PhysicalLocation(float x, float y, float z)
Constructor from X, Y, Z (float)- Parameters:
x
- location on X axisy
- location on Y axisz
- location on Z axis
-
PhysicalLocation
public PhysicalLocation(double x, double y, double z)
Constructor from X, Y, Z (double)- Parameters:
x
- location on X axisy
- location on Y axisz
- location on Z axis
-
PhysicalLocation
public PhysicalLocation(double x, double y, double z, boolean isTunnel)
Constructor from X, Y, Z (double)- Parameters:
x
- location on X axisy
- location on Y axisz
- location on Z axisisTunnel
- true if location is in a tunnel
-
PhysicalLocation
public PhysicalLocation(PhysicalLocation p)
Copy Constructor- Parameters:
p
- the location to copy
-
-
Method Detail
-
translate
public static PhysicalLocation translate(PhysicalLocation loc, PhysicalLocation ref)
translate() Return a PhysicalLocation that represents the position of point "loc" relative to reference point "ref".- Parameters:
loc
- : PhysicalLocation to translateref
- : PhysicalLocation to use as new reference point (origin)- Returns:
- PhysicalLocation
-
getBeanPhysicalLocation
public static PhysicalLocation getBeanPhysicalLocation(NamedBean b)
getBeanPhysicalLocation(NamedBean b) Extract the PhysicalLocation stored in NamedBean b, and return as a new PhysicalLocation object. If the given NamedBean does not have a PhysicalLocation property returns Origin. (should probably return null instead, but...)- Parameters:
b
- : NamedBean- Returns:
- PhysicalLocation
-
setBeanPhysicalLocation
public static void setBeanPhysicalLocation(PhysicalLocation p, NamedBean b)
setBeanPhysicalLocation(PhysicalLocation p, NamedBean b) Store PhysicalLocation p as a property in NamedBean b.- Parameters:
p
- PhysicalLocationb
- NamedBean
-
getPanel
public static PhysicalLocationPanel getPanel(java.lang.String title)
Get a panel component that can be used to view and/or edit a location.- Parameters:
title
- the title of the component- Returns:
- a new component
-
parse
public static PhysicalLocation parse(java.lang.String pos)
Parse a string representation (x,y,z) Returns a new PhysicalLocation object.- Parameters:
pos
- : String "(X, Y, Z)"- Returns:
- PhysicalLocation
-
toString
public java.lang.String toString()
toString() Output a string representation (x,y,z)- Overrides:
toString
in classjavax.vecmath.Tuple3f
- Returns:
- String "(X, Y, Z)"
-
toVector3d
public javax.vecmath.Vector3d toVector3d()
-
isTunnel
public boolean isTunnel()
-
setIsTunnel
public void setIsTunnel(boolean t)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjavax.vecmath.Tuple3f
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjavax.vecmath.Tuple3f
-
translate
public void translate(PhysicalLocation ref)
translate() Translate this PhysicalLocation's coordinates to be relative to point "ref". NOTE: This is a "permanent" internal translation, and permanently changes this PhysicalLocation's value. If you want a new PhysicalLocation that represents the relative position, call the class method translate(loc, ref)- Parameters:
ref
- new reference (origin) point
-
-