java.lang.Objectobjectdraw.ObjectDrawObject
objectdraw.ObjectDrawShape
objectdraw.ObjectDrawRectangularShape
objectdraw.FramedRect
fluids.FluidContainer
fluids.Pipe
public class Pipe
A Pipe
carries water between two Tank
s, 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.
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 |
---|
public Pipe(String name, Tank inlet, Tank outlet, Background background)
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.
name
- Name of .png file to loadinlet
- 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 simulationbackground
- Background
to add this pipe toMethod Detail |
---|
public double getFlowRate()
public Tank getInlet()
Tank
this pipe feeds from.
Tank
public Tank getOutlet()
Tank
this pipe drains into.
Tank
public void setFlowRate(double rate)
rate
- New flow rate, in gallons per second.