|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.kolls.railworld.Distance
public class Distance
The Distance class maintains the current scale and zoom information globally, as well as managing individual distance conversion (feet to pixels). Distances should be created as feet and then rendered as pixels; the pixel value will change according to the scale and the zoom. As the user may alter the zoom at any time, the pixel values should not be cached.
To help with the display issues, we provide static point and line scaling routines.
| Nested Class Summary | |
|---|---|
static class |
Distance.Measure
The numeric value of each distance may be stored as either pixels or feet. |
| Field Summary | |
|---|---|
static double |
feetPerPixels
This value must be changed prior to constructing any segments, as the segments convert pixels into feet, depending on a correct scale. |
| Constructor Summary | |
|---|---|
Distance(double val,
Distance.Measure measure)
Create a new distance measurement based on either feet or pixels. |
|
| Method Summary | |
|---|---|
double |
feet()
The feet length of this distance. |
static double |
getDefaultZoom()
The default zoom for new maps or partial displays not subject to user zooming. |
int |
iPixels()
The length, in pixels. |
double |
pixels()
Compute the pixel length. |
static double |
toFeet(double pixels)
Convert a given length in pixels into feet/ |
static double |
toPixels(double feet)
Convert a given length in feet into pixels. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static double feetPerPixels
| Constructor Detail |
|---|
public Distance(double val,
Distance.Measure measure)
val - The length.measure - The unit of the length, as given in Distance.Measure.| Method Detail |
|---|
public static double getDefaultZoom()
feetPerPixels.public double pixels()
double indicating the length in pixels. For integer values, do not round this one, as it may come to zero.
Use iPixels instead.public double feet()
double indicating the length in feet.public int iPixels()
int, containing the pixel length.public static double toPixels(double feet)
feet - The length in feet
feetPerPixelspublic static double toFeet(double pixels)
pixels - The length in pixels
feetPerPixels
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||