Class Layout

java.lang.Object
jmri.jmrit.timetable.Layout
All Implemented Interfaces:
VetoableChangeListener, EventListener

public class Layout extends Object implements 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 Details

  • Constructor Details

    • Layout

      public Layout()
      Create a new layout with default values.
    • Layout

      public Layout(int layoutId, String layoutName, Scale scale, int fastClock, int throttles, boolean metric)
  • Method Details

    • getCopy

      public Layout getCopy()
      Make a copy of the layout.
      Returns:
      a new layout instance.
    • 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:
      IllegalArgumentException - The calculate can throw an exception which will get re-thrown.
    • getScaleMK

      public double getScaleMK()
    • getLayoutId

      public int getLayoutId()
    • getLayoutName

    • setLayoutName

      public void setLayoutName(String newName)
    • getRatio

      public double getRatio()
    • getScale

      public Scale getScale()
    • setScale

      public void setScale(Scale newScale)
    • 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:
      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:
      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:
      IllegalArgumentException - if there was a recalc error.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • vetoableChange

      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 interface VetoableChangeListener
      Parameters:
      evt - The scale ratio property change event.
      Throws:
      PropertyVetoException - The message will depend on the actual error.