fluids
Class Pipe

java.lang.Object
  extended by objectdraw.ObjectDrawObject
      extended by objectdraw.ObjectDrawShape
          extended by objectdraw.ObjectDrawRectangularShape
              extended by objectdraw.FramedRect
                  extended by fluids.FluidContainer
                      extended by fluids.Pipe
All Implemented Interfaces:
Dependent, Drawable2DInterface, DrawableInterface, DrawableStrokeInterface, LocatableInterface, Resizable2DInterface

public class Pipe
extends FluidContainer

A Pipe carries water between two Tanks, referred to as its inlet and outlet. Its only other property is the flow rate: how fast water is flowing through the pipe. Flow rate is measured in gallons per second. A positive flow rate means that water is flowing from the inlet to the outlet; a negative flow rate means water is flowing from the outlet to the inlet. The Pipe will be drawn in one of two colors, depending on whether its flow rate is positive or negative. You can get and set these with the methods setColor() and setNegativeColor(). If the flow rate is zero, the pipe is not drawn.

Author:
Russell Zahniser (russell@zahniser.net)

Field Summary
 
Fields inherited from interface objectdraw.DrawableStrokeInterface
CLICK_SIZE, DEFAULT_STROKE
 
Constructor Summary
Pipe(String name, Tank inlet, Tank outlet, Background background)
          Create a new Pipe, loading the image of the given name from the model belonging to background.
 
Method Summary
 double getFlowRate()
          Get the flow rate.
 Tank getInlet()
          Get the Tank this pipe feeds from.
 Tank getOutlet()
          Get the Tank this pipe drains into.
 void setFlowRate(double rate)
          Set the flow rate.
 
Methods inherited from class fluids.FluidContainer
contains, getBackground, getNegativeColor, removeFromCanvas, setColor, setNegativeColor
 
Methods inherited from class objectdraw.FramedRect
addToCanvas, getCanvas, getColor, getDoubleHeight, getDoubleWidth, getDoubleX, getDoubleY, getHeight, getLineWidth, getLocation, getStroke, getWidth, getX, getY, hide, isHidden, makeShape, move, moveTo, moveTo, overlaps, sendBackward, sendForward, sendToBack, sendToFront, setHeight, setLineWidth, setSize, setStroke, setWidth, show, toString
 
Methods inherited from class objectdraw.ObjectDrawRectangularShape
getBounds
 
Methods inherited from class objectdraw.ObjectDrawShape
clearCanvas, draw, draw, getDrawables, getShape, removeCanvas, setMyShape, update
 
Methods inherited from class objectdraw.ObjectDrawObject
deferUpdates, depend, runUpdates, undepend
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface objectdraw.DrawableInterface
draw, getShape
 

Constructor Detail

Pipe

public Pipe(String name,
            Tank inlet,
            Tank outlet,
            Background background)
Create a new Pipe, loading the image of the given name from the model belonging to background. It will connect the given inlet and outlet, either of which may be null to specify that the pipe is attached to something outside the simulation. The dimensions of the pipe will be set to reflect the area of the image where this pipe is drawn, and contains() will return true only for points within the pipe.

Parameters:
name - Name of .png file to load
inlet - Tank the pipe feeds from, or null if it is connected to some outside source.
outlet - Tank the pipe drains into, or null if it leads outside of the simulation
background - Background to add this pipe to
Method Detail

getFlowRate

public double getFlowRate()
Get the flow rate.

Returns:
The flow rate, in gallons per second.

getInlet

public Tank getInlet()
Get the Tank this pipe feeds from.

Returns:
the inlet Tank

getOutlet

public Tank getOutlet()
Get the Tank this pipe drains into.

Returns:
the outlet Tank

setFlowRate

public void setFlowRate(double rate)
Set the flow rate.

Parameters:
rate - New flow rate, in gallons per second.