Package jmri.jmrit.timetable
Class Layout
- java.lang.Object
-
- jmri.jmrit.timetable.Layout
-
- All Implemented Interfaces:
java.beans.VetoableChangeListener
,java.util.EventListener
public class Layout extends java.lang.Object implements java.beans.VetoableChangeListener
Define the content of a Layout record.The fast clock, scale and metric values affect the scale mile / scale km. When these are changed, the stop times for all of the trains have to be re-calculated. Depending on the schedule limits, this can result in calculation errors. When this occurs, exceptions occur which trigger rolling back the changes.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) TimeTableDataManager
_dm
static java.lang.String
SCALE_RATIO
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Layout
getCopy()
Make a copy of the layout.int
getFastClock()
int
getLayoutId()
java.lang.String
getLayoutName()
boolean
getMetric()
double
getRatio()
Scale
getScale()
double
getScaleMK()
int
getThrottles()
void
setFastClock(int newClock)
Set a new fast clock speed, update smile/skm.void
setLayoutName(java.lang.String newName)
void
setMetric(boolean newMetric)
Set metric flag, update smile/skm.void
setScale(Scale newScale)
void
setScaleMK()
Calculate the length of a scale mile or scale kilometer.void
setThrottles(int newThrottles)
Set the new value for throttles.java.lang.String
toString()
void
vetoableChange(java.beans.PropertyChangeEvent evt)
Listen for ratio changes to my current scale.
-
-
-
Field Detail
-
SCALE_RATIO
public static final java.lang.String SCALE_RATIO
- See Also:
- Constant Field Values
-
-
Method Detail
-
setScaleMK
public void setScaleMK()
Calculate the length of a scale mile or scale kilometer. The values are adjusted for scale and fast clock ratio. The resulting value is the real feet or meters. The final step is to re-calculate the train times.- Throws:
java.lang.IllegalArgumentException
- The calculate can throw an exception which will get re-thrown.
-
getScaleMK
public double getScaleMK()
-
getLayoutId
public int getLayoutId()
-
getLayoutName
public java.lang.String getLayoutName()
-
setLayoutName
public void setLayoutName(java.lang.String newName)
-
getRatio
public double getRatio()
-
getFastClock
public int getFastClock()
-
setFastClock
public void setFastClock(int newClock)
Set a new fast clock speed, update smile/skm.- Parameters:
newClock
- The value to be used.- Throws:
java.lang.IllegalArgumentException
- (CLOCK_LT_1) if the value is less than 1. will also re-throw a recalc error.
-
getThrottles
public int getThrottles()
-
setThrottles
public void setThrottles(int newThrottles)
Set the new value for throttles.- Parameters:
newThrottles
- The new throttle count.- Throws:
java.lang.IllegalArgumentException
- (THROTTLES_USED, THROTTLES_LT_0) when the new count is less than train references or a negative number was passed.
-
getMetric
public boolean getMetric()
-
setMetric
public void setMetric(boolean newMetric)
Set metric flag, update smile/skm.- Parameters:
newMetric
- True for metric units.- Throws:
java.lang.IllegalArgumentException
- if there was a recalc error.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
vetoableChange
public void vetoableChange(java.beans.PropertyChangeEvent evt) throws java.beans.PropertyVetoException
Listen for ratio changes to my current scale. Verify that the new ratio is neither too small nor too large. Too large can cause train times to move outside of the schedule window. If the new ratio is invalid, the change will be vetoed.- Specified by:
vetoableChange
in interfacejava.beans.VetoableChangeListener
- Parameters:
evt
- The scale ratio property change event.- Throws:
java.beans.PropertyVetoException
- The message will depend on the actual error.
-
-