net.kolls.railworld.segment
Class LUSegment

java.lang.Object
  extended by net.kolls.railworld.RailSegment
      extended by net.kolls.railworld.segment.TrackSegment
          extended by net.kolls.railworld.segment.LUSegment
Direct Known Subclasses:
HiddenLUSegment

public class LUSegment
extends TrackSegment

Load/unload segment.

Author:
Steve Kollmansberger

Nested Class Summary
 
Nested classes/interfaces inherited from class net.kolls.railworld.segment.TrackSegment
TrackSegment.TSEP
 
Field Summary
protected  boolean drawAc
          Indicates if the segment should draw the cars it accepts.
 
Fields inherited from class net.kolls.railworld.segment.TrackSegment
cap, coords, POINT_BEGIN, POINT_END, railBedStroke, railStroke
 
Fields inherited from class net.kolls.railworld.RailSegment
dests, ec, MOUSE_NEAR, pts, RAIL_BED_WIDTH, RAIL_WIDTH, trains
 
Constructor Summary
LUSegment(RailSegment bg, RailSegment en, java.awt.geom.Line2D crds, Car[] accept, boolean drawAccept)
          Create a load/unload segment.
 
Method Summary
 boolean canLU(Car c)
           
 boolean doesDrawAccept()
           
 void draw(int z, java.awt.Graphics2D gc)
          Draw the segment.
protected  void drawAccept(java.awt.Graphics2D gc)
          Draw the cars which this LU segment accepts.
 javax.swing.JPanel editPanel()
          You are guaranteed that the variable RailSegment.ec will be set prior to this call.
 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.
 Car[] lu()
           
 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.
 void setDrawAccept(boolean drawAccept)
           
 
Methods inherited from class net.kolls.railworld.segment.TrackSegment
canErase, createSEP, dest, getCoords, getPoint, length, setCap
 
Methods inherited from class net.kolls.railworld.RailSegment
carHidden, click, destNZ, enter, getDest, getDests, getPoint, getPoints, nearEditPoint, pixelStep, setDest, setPoint, singleton, step, trains, update, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

drawAc

protected boolean drawAc
Indicates if the segment should draw the cars it accepts.

Constructor Detail

LUSegment

public LUSegment(RailSegment bg,
                 RailSegment en,
                 java.awt.geom.Line2D crds,
                 Car[] accept,
                 boolean drawAccept)
Create a load/unload segment.

Parameters:
bg - Begin segment
en - End segment
crds - Line coords
accept - Which cars do we accept (load or unload) here.
drawAccept - Draw cars that we accept?
Method Detail

lu

public Car[] lu()
Returns:
An array contain the Cars the segment accepts.

setDrawAccept

public void setDrawAccept(boolean drawAccept)
Parameters:
drawAccept - Should the segment draw accepted cars or not?

doesDrawAccept

public boolean doesDrawAccept()
Returns:
If the segment draws accepted cars

recomp

public void recomp()
Description copied from class: RailSegment
Called when changes are made; recompute or update any associated values.

Overrides:
recomp in class TrackSegment

mouseOver

public java.lang.String mouseOver(java.awt.geom.Point2D pos)
Description copied from class: RailSegment
Whenever a user mouses over the canvas, all dynamic segments receive this event. Check to see if the position is at your segment (as in click). Return a describe if applicable, otherwise null. Defaults to returning null.

Overrides:
mouseOver in class TrackSegment
Parameters:
pos - The mouse position
Returns:
Description if applicable, otherwise null
See Also:
RailSegment.isDynamic()

isDynamic

public boolean isDynamic()
Description copied from class: RailSegment
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. Defaults to false (not dynamic). Non-dynamic segments also may not receive notifications for various events.

Overrides:
isDynamic in class RailSegment
Returns:
Indicates if the segment should receive z=4 draw events and click events.
See Also:
RailSegment.draw(int, Graphics2D), RailSegment.click(Point2D, RailCanvas)

drawAccept

protected void drawAccept(java.awt.Graphics2D gc)
Draw the cars which this LU segment accepts. The cars are drawn next to the segment.

Parameters:
gc - The graphics context to draw on

canLU

public boolean canLU(Car c)
Parameters:
c - A Car
Returns:
If that car can be loaded/unloaded at this segment.

draw

public void draw(int z,
                 java.awt.Graphics2D gc)
Description copied from class: RailSegment
Draw the segment. Segments have several z-layers to allowed slightly overlaping pieces to still look nice. z = 1 is a static layer (lowest) z = 2 is a static layer (highest) z = 3 is reserved z = 4 is the dynamic layer. This is redrawn frequently, if requested by the segment.

Overrides:
draw in class TrackSegment
Parameters:
z - The currently z-layer to draw
gc - A Graphics2D graphics context.
See Also:
RailSegment.isDynamic()

editPanel

public javax.swing.JPanel editPanel()
Description copied from class: RailSegment
You are guaranteed that the variable RailSegment.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.

Overrides:
editPanel in class TrackSegment
Returns:
A JPanel to display in the sidebar to edit this segment's properties. Please keep width at 200 pixels top.