net.kolls.railworld.tuic
Class TrainPainter

java.lang.Object
  extended by net.kolls.railworld.TrainUIController
      extended by net.kolls.railworld.tuic.TrainPainter

public class TrainPainter
extends TrainUIController

Paints a train on the map. This follows each segment, and paints the car or partial car onto it.

Author:
Steve Kollmansberger

Field Summary
 boolean didFollow
          Did we submit new coords for this train yet?
 
Constructor Summary
TrainPainter(RailCanvas rc, java.awt.Graphics2D mg, boolean f, Car sel)
          Create a new TrainPainter.
 
Method Summary
 void car(Car c, CLoc begin, CLoc end)
          For each Car, including a beginning and ending position.
static java.awt.image.BufferedImage image(Car c, java.awt.Component mp)
          Generates an image representing the Car.
 void segment(Car c, java.awt.geom.Line2D l)
          For each visible segment (there may be multiple segments per car, or even 0 if the car is hidden).
 
Methods inherited from class net.kolls.railworld.TrainUIController
act
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

didFollow

public boolean didFollow
Did we submit new coords for this train yet?

Constructor Detail

TrainPainter

public TrainPainter(RailCanvas rc,
                    java.awt.Graphics2D mg,
                    boolean f,
                    Car sel)
Create a new TrainPainter.

Parameters:
rc - The RailCanvas for submitting follow-me coordinates.
mg - The graphics context to draw on
f - Should we follow (move display to) the given car sel?
sel - The selected car. A green selected arrow will be drawn on it.
Method Detail

segment

public void segment(Car c,
                    java.awt.geom.Line2D l)
Description copied from class: TrainUIController
For each visible segment (there may be multiple segments per car, or even 0 if the car is hidden).

Specified by:
segment in class TrainUIController
Parameters:
c - The Car involved.
l - The current segment. There may be multiple calls to segment per Car.

car

public void car(Car c,
                CLoc begin,
                CLoc end)
Description copied from class: TrainUIController
For each Car, including a beginning and ending position. These are given regardless of whether or not the Car is all or partially hidden.

Specified by:
car in class TrainUIController
Parameters:
c - The Car involved.
begin - Starting position.
end - Final position.

image

public static final java.awt.image.BufferedImage image(Car c,
                                                       java.awt.Component mp)
Generates an image representing the Car. This may be used for train builders or informational panes. This is not used for actually rendering a Car, because Cars may be at various angles or or partially visible. The rendering size depends on the current zoom level.

Parameters:
c - Car to generate image for
mp - A component used to derive the GraphicsConfiguration
Returns:
BufferedImage containing the Car.