|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.kolls.railworld.RailSegment
net.kolls.railworld.segment.Switch
public class Switch
Provides a Y connector which can be toggled by the user to route trains.
| Field Summary | |
|---|---|
boolean |
flipped
Indicates if the switch is in the default or flipped orientation. |
static int |
POINT_BEGIN
The origin (base) segment |
static int |
POINT_END1
The default straight destination segment |
static int |
POINT_END2
The alternate turn-out destination segment |
| Fields inherited from class net.kolls.railworld.RailSegment |
|---|
dests, ec, MOUSE_NEAR, pts, RAIL_BED_WIDTH, RAIL_WIDTH, trains |
| Constructor Summary | |
|---|---|
Switch(RailSegment bg,
RailSegment en1,
RailSegment en2,
java.awt.geom.Point2D pos)
Create a switch. |
|
| Method Summary | |
|---|---|
boolean |
canErase()
Can this segment be erased? In some cases, other segments must be erased first. |
boolean |
click(java.awt.geom.Point2D pos,
RailCanvas rc)
Whenever a user clicks on the canvas, all dynamic segments receive this event. |
SegmentEditPoint |
createSEP(int ptIdx,
RailSegment anchor)
Given a point index in the pts array and possibly a railsegment to attach, return a segmenteditpoint if such attachment is possible. |
RailSegment |
dest(RailSegment src)
Each rail segment must at the very least tell us where it comes from and where it goes, currently. |
void |
draw(int z,
java.awt.Graphics2D gc)
Draw the segment. |
javax.swing.JPanel |
editPanel()
You are guaranteed that the variable RailSegment.ec will be set prior to this call. |
void |
enter(Train t)
When a train enters this segment, the switch will automatically flip, if necessary, to align itself with the direction the train is coming from. |
java.awt.geom.Point2D |
getPoint(RailSegment s,
double pos)
|
boolean |
isDynamic()
Dynamic segments receive additional events while the game is running; non-dynamic segments are only asked to draw z levels 1 and 2 at draw static time. |
Distance |
length()
all segments have a length can be 0 for signals, etc. |
java.lang.String |
mouseOver(java.awt.geom.Point2D pos)
Whenever a user mouses over the canvas, all dynamic segments receive this event. |
void |
recomp()
Called when changes are made; recompute or update any associated values. |
boolean |
singleton()
Singleton segments may only have one train in them at a time. |
| Methods inherited from class net.kolls.railworld.RailSegment |
|---|
carHidden, destNZ, getDest, getDests, getPoint, getPoints, nearEditPoint, pixelStep, setDest, setPoint, step, trains, update, update |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int POINT_BEGIN
public static final int POINT_END1
public static final int POINT_END2
public boolean flipped
| Constructor Detail |
|---|
public Switch(RailSegment bg,
RailSegment en1,
RailSegment en2,
java.awt.geom.Point2D pos)
bg - The origin segmenten1 - The straight-lined destination segmenten2 - The turn-out destination segmentpos - The location on the map| Method Detail |
|---|
public Distance length()
RailSegment
length in class RailSegmentDistance of the segment.
public java.awt.geom.Point2D getPoint(RailSegment s,
double pos)
getPoint in class RailSegments - The segment of originpos - Percentage (0-1) along the segment
Point2D indicating the actual point that location representspublic java.lang.String mouseOver(java.awt.geom.Point2D pos)
RailSegment
mouseOver in class RailSegmentpos - The mouse position
RailSegment.isDynamic()public boolean singleton()
RailSegment
singleton in class RailSegmentpublic void enter(Train t)
enter in class RailSegmentt - The train in the segment.public void recomp()
RailSegment
recomp in class RailSegment
public void draw(int z,
java.awt.Graphics2D gc)
RailSegment
draw in class RailSegmentz - The currently z-layer to drawgc - A Graphics2D graphics context.RailSegment.isDynamic()public RailSegment dest(RailSegment src)
RailSegment
dest in class RailSegmentsrc - The rail segment of origin
null if there is none.
public boolean click(java.awt.geom.Point2D pos,
RailCanvas rc)
RailSegment
click in class RailSegmentpos - The click positionrc - The current canvas which contains this segment
RailSegment.isDynamic()public boolean isDynamic()
RailSegment
isDynamic in class RailSegmentdraw events
and click events.RailSegment.draw(int, Graphics2D),
RailSegment.click(Point2D, RailCanvas)
public SegmentEditPoint createSEP(int ptIdx,
RailSegment anchor)
RailSegment
createSEP in class RailSegmentptIdx - The index into the pts array.anchor - The segment that desires to attach. (Note: do not attach the segment
automatically; it will be called through the anchor method in the edit point).
null.public javax.swing.JPanel editPanel()
RailSegmentRailSegment.ec will be set prior to this call.
So if you need to refresh the canvas or make any changes to it, you can use
that variable.
editPanel in class RailSegmentJPanel to display in the sidebar to edit this segment's properties. Please keep width at 200 pixels top.public boolean canErase()
RailSegment
canErase in class RailSegment
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||