jmri.jmrit.display.layoutEditor
Class LayoutTurntable

Show UML class diagram
java.lang.Object
  extended by jmri.jmrit.display.layoutEditor.LayoutTurntable

public class LayoutTurntable
extends Object

A LayoutTurntable is a representation used by LayoutEditor to display a turntable.

A LayoutTurntable has a variable number of connection points, called RayTracks, each radiating from the center of the turntable. Each of these points should be connected to a TrackSegment.

Each radiating segment (RayTrack) gets its Block information from its connected track segment.

Each radiating segment (RayTrack) has a unique connection index. The connection index is set when the RayTrack is created, and cannot be changed. This connection index is used to maintain the identity of the radiating segment to its connected Track Segment as ray tracks are added and deleted by the user.

The radius of the turntable circle is variable by the user.

Each radiating segment (RayTrack) connecting point is a fixed distance from the center of the turntable. The user may vary the angle of the radiating segment. Angles are measured from the vertical (12 o'clock) position in a clockwise manner. For example, 30 degrees is 1 o'clock, 60 degrees is 2 o'clock, 90 degrees is 3 o'clock, etc.

Each radiating segment is drawn from its connection point to the turntable circle in the direction of the turntable center.


Nested Class Summary
(package private)  class LayoutTurntable.RayTrack
           
 
Field Summary
(package private)  boolean active
           
(package private)  JButton addRayTrack
           
(package private)  JTextField angleField
           
(package private)  JCheckBox dccControlled
           
(package private)  JButton deleteRayTrack
           
(package private)  boolean editOpen
           
(package private)  JmriJFrame editTurntableFrame
           
(package private) static org.slf4j.Logger log
           
(package private)  boolean needsRedraw
           
(package private)  String oldRadius
           
(package private)  JPopupMenu popup
           
(package private)  JTextField radiusField
           
(package private)  JPanel rayPanel
           
(package private)  JPopupMenu rayPopup
           
(package private)  ResourceBundle rb
           
(package private)  JButton turntableEditCancel
           
(package private)  JButton turntableEditDone
           
 
Constructor Summary
LayoutTurntable(String id, Point2D c, LayoutEditor myPanel)
          constructor method
 
Method Summary
protected  LayoutTurntable.RayTrack addRay(double angle)
           
 void addRayTrack(double angle, int index, String name)
           
(package private)  void deleteRay(LayoutTurntable.RayTrack closest)
           
(package private)  void deleteRayTrackPressed(ActionEvent a)
           
 double diffAngle(double a, double b)
           
(package private)  void dispose()
          Clean up when this object is no longer needed.
protected  void editTurntable(LayoutTurntable x)
          Edit a Turntable
 Point2D getCoordsCenter()
           
 String getID()
          Accessor methods
 int getNumberRays()
           
 int getPosition()
           
 double getRadius()
           
 double getRayAngle(int i)
           
 TrackSegment getRayConnectIndexed(int index)
           
 TrackSegment getRayConnectOrdered(int i)
           
 Point2D getRayCoordsIndexed(int index)
           
 Point2D getRayCoordsOrdered(int i)
           
 int getRayIndex(int i)
           
 String getRayTurnoutName(int i)
           
 int getRayTurnoutState(int i)
           
 boolean isActive()
          "active" means that the object is still displayed, and should be stored.
 boolean isMainlineIndexed(int index)
          Methods to test if ray is a mainline track or not Returns true if connecting track segment is mainline Defaults to not mainline if connecting track segment is missing
 boolean isMainlineOrdered(int i)
           
 boolean isTurnoutControlled()
           
 double normalizeAngle(double a)
           
(package private)  void remove()
          Removes this object from display and persistance
(package private)  double round(double x)
           
 void scaleCoords(float xFactor, float yFactor)
           
 void setCoordsCenter(Point2D p)
          Modify coordinates methods
 void setObjects(LayoutEditor p)
          Initialization method The name of each track segment connected to a ray track is initialized by by LayoutTurntableXml, then the following method is called after the entire LayoutEditor is loaded to set the specific TrackSegment objects.
 void setPosition(int index)
           
 void setRadius(double r)
           
 void setRayConnect(TrackSegment tr, int index)
           
 void setRayCoordsIndexed(double x, double y, int index)
           
 void setRayTurnout(int index, String turnoutName, int state)
           
 void setTurnoutControlled(boolean boo)
           
protected  void showPopUp(MouseEvent e)
          Display popup menu for information and editing
protected  void showRayPopUp(MouseEvent e, int index)
           
(package private)  void turntableEditCancelPressed(ActionEvent a)
           
(package private)  void turntableEditDonePressed(ActionEvent a)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rb

ResourceBundle rb

popup

JPopupMenu popup

rayPopup

JPopupMenu rayPopup

editTurntableFrame

JmriJFrame editTurntableFrame

radiusField

JTextField radiusField

angleField

JTextField angleField

turntableEditDone

JButton turntableEditDone

turntableEditCancel

JButton turntableEditCancel

addRayTrack

JButton addRayTrack

deleteRayTrack

JButton deleteRayTrack

dccControlled

JCheckBox dccControlled

oldRadius

String oldRadius

rayPanel

JPanel rayPanel

editOpen

boolean editOpen

needsRedraw

boolean needsRedraw

active

boolean active

log

static org.slf4j.Logger log
Constructor Detail

LayoutTurntable

public LayoutTurntable(String id,
                       Point2D c,
                       LayoutEditor myPanel)
constructor method

Method Detail

getID

public String getID()
Accessor methods


getCoordsCenter

public Point2D getCoordsCenter()

getRadius

public double getRadius()

setRadius

public void setRadius(double r)

addRay

protected LayoutTurntable.RayTrack addRay(double angle)

addRayTrack

public void addRayTrack(double angle,
                        int index,
                        String name)

getRayConnectIndexed

public TrackSegment getRayConnectIndexed(int index)

getRayConnectOrdered

public TrackSegment getRayConnectOrdered(int i)

setRayConnect

public void setRayConnect(TrackSegment tr,
                          int index)

getNumberRays

public int getNumberRays()

getRayIndex

public int getRayIndex(int i)

getRayAngle

public double getRayAngle(int i)

setRayTurnout

public void setRayTurnout(int index,
                          String turnoutName,
                          int state)

getRayTurnoutName

public String getRayTurnoutName(int i)

getRayTurnoutState

public int getRayTurnoutState(int i)

getRayCoordsIndexed

public Point2D getRayCoordsIndexed(int index)

getRayCoordsOrdered

public Point2D getRayCoordsOrdered(int i)

setRayCoordsIndexed

public void setRayCoordsIndexed(double x,
                                double y,
                                int index)

isMainlineIndexed

public boolean isMainlineIndexed(int index)
Methods to test if ray is a mainline track or not Returns true if connecting track segment is mainline Defaults to not mainline if connecting track segment is missing


isMainlineOrdered

public boolean isMainlineOrdered(int i)

setCoordsCenter

public void setCoordsCenter(Point2D p)
Modify coordinates methods


scaleCoords

public void scaleCoords(float xFactor,
                        float yFactor)

round

double round(double x)

setObjects

public void setObjects(LayoutEditor p)
Initialization method The name of each track segment connected to a ray track is initialized by by LayoutTurntableXml, then the following method is called after the entire LayoutEditor is loaded to set the specific TrackSegment objects.


isTurnoutControlled

public boolean isTurnoutControlled()

setTurnoutControlled

public void setTurnoutControlled(boolean boo)

showPopUp

protected void showPopUp(MouseEvent e)
Display popup menu for information and editing


showRayPopUp

protected void showRayPopUp(MouseEvent e,
                            int index)

setPosition

public void setPosition(int index)

getPosition

public int getPosition()

editTurntable

protected void editTurntable(LayoutTurntable x)
Edit a Turntable


deleteRayTrackPressed

void deleteRayTrackPressed(ActionEvent a)

deleteRay

void deleteRay(LayoutTurntable.RayTrack closest)

turntableEditDonePressed

void turntableEditDonePressed(ActionEvent a)

turntableEditCancelPressed

void turntableEditCancelPressed(ActionEvent a)

dispose

void dispose()
Clean up when this object is no longer needed. Should not be called while the object is still displayed; see remove()


remove

void remove()
Removes this object from display and persistance


isActive

public boolean isActive()
"active" means that the object is still displayed, and should be stored.


normalizeAngle

public double normalizeAngle(double a)

diffAngle

public double diffAngle(double a,
                        double b)


Copyright © 1997-2013 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads