Class Element

java.lang.Object
   |
   +----Element

public abstract class Element
extends Object
implements ToolTips
Abstract class for basic electrical element Each electrical element should inherit from Element, or from of his sons It includes all basic public methods for easy working with it (simulate), without knowing what kind of part we're dealing with


Constructor Index

 o Element()
Constructs basic Element.

Method Index

 o checkVoltage(int, double, double)
Function used to check the result of calculation, when more than one result obtained
 o connect()
This function runs once, when the graph for the simulation was built, but the simulation hasn't started yet.
 o getContVertex(int)
Get vertex of specified contact
 o getCurrent(int, double)
Main function for calculations.
 o getImage(int)
Returns image for this element.
 o getImage(int, double)
Returns image for this element.
 o getInfo(int)
Returns information for this element, such as voltage, current etc.
 o getLastCurrent(int)
Returns last current in given direction
 o getTip(int)
Returns tool tip for this element.
 o getTipLocation(Container)
Returns tool tip location for this element.
 o hasContact(int)
Check if contact exist.
 o initImages(Applet)
Load all images.
 o isVertexSet(int)
Check if vertex seted to specified contact
 o paint(Graphics, int, Dimension, boolean, boolean)
Paints the element on the given graphic context.
 o parseString(String)
This method is called to load new values to element from string.
 o reset()
Function resets element conditions.
 o setContVertex(int, Vertex)
Set vertex to specified contact
 o showPropertiesDialog(Frame)
 o toString()
Returns a string representation of the object.
 o valueOf(double, int)
Return real value of propertie, by calculating it using unit's order
 o vertexReset()
Reset all vertice to null

Constructors

 o Element
 public Element()
Constructs basic Element.

Methods

 o hasContact
 public boolean hasContact(int dir)
Check if contact exist.

Parameters:
dir - direction on contact
Returns:
returns true if contact exists
 o setContVertex
 public void setContVertex(int dir,
                           Vertex vert)
Set vertex to specified contact

Parameters:
dir - direction of contact
vert - vertex to connect
 o getContVertex
 public Vertex getContVertex(int dir)
Get vertex of specified contact

Parameters:
dir - direction of contact
 o isVertexSet
 public boolean isVertexSet(int dir)
Check if vertex seted to specified contact

Parameters:
dir - direction to check
Returns:
true if it is and false otherwise
 o vertexReset
 public void vertexReset()
Reset all vertice to null

 o showPropertiesDialog
 public void showPropertiesDialog(Frame f)
 o valueOf
 public double valueOf(double val,
                       int order)
Return real value of propertie, by calculating it using unit's order

Parameters:
val - properte's value
order - units' order
Returns:
a real value of propertie.
 o checkVoltage
 public boolean checkVoltage(int dir,
                             double timeStep,
                             double newVoltage)
Function used to check the result of calculation, when more than one result obtained

Parameters:
dir - direction of contact
timeStep - time step of iteration
newVoltage - result to check
 o toString
 public String toString()
Returns a string representation of the object.

Returns:
a string representation of the object.
Overrides:
toString in class Object
 o parseString
 public void parseString(String values) throws ParseException
This method is called to load new values to element from string. String should be like "value,order;value,order;etc.".

Parameters:
values - new values for element in string in format given above.
Throws: ParseException
if string format is incorrect.
 o getCurrent
 public abstract Polynom getCurrent(int dir,
                                    double timeStep)
Main function for calculations. Returns polynom with coefficients, while the variable X is voltage of specified connection, and result of polynom is current. i = a*V^2 + b*V + c : a, b & c are returned.

Parameters:
dir - direction of current - NORTH, SOUTH, WEST or EAST.
timeStep - current time step.
Returns:
polynom of current for KCL.
 o getLastCurrent
 public Polynom getLastCurrent(int dir)
Returns last current in given direction

Parameters:
dir - direction of current - NORTH, SOUTH, WEST or EAST.
Returns:
polynom of last current in the element.
 o reset
 public void reset()
Function resets element conditions. Called each time new graph is build.

 o initImages
 public void initImages(Applet theApplet)
Load all images. Called once.

Parameters:
theApplet - instace of current applet
 o getImage
 public Image getImage(int angle)
Returns image for this element.

Parameters:
angle - angle of current graphical representation for the element.
Returns:
image of the element.
 o getImage
 public Image getImage(int angle,
                       double time)
Returns image for this element.

Parameters:
angle - angle of current graphical representation for the element.
time - current time
Returns:
image of the element.
 o getInfo
 public String[] getInfo(int angle)
Returns information for this element, such as voltage, current etc.

Parameters:
angle - angle of current graphical representation for the element.
Returns:
array of Strings with information.
 o getTip
 public String getTip(int type)
Returns tool tip for this element.

Parameters:
type - type of tip receiver: 1 - for Matrix, 0 - for other.
Returns:
the tool tip.
 o getTipLocation
 public Point getTipLocation(Container painter)
Returns tool tip location for this element.

Parameters:
painter - container which will paint this tip.
Returns:
location for the tool tip.
 o connect
 public void connect()
This function runs once, when the graph for the simulation was built, but the simulation hasn't started yet. Can be overriden to make any action at this time.

 o paint
 public void paint(Graphics g,
                   int angle,
                   Dimension size,
                   boolean isSimulating,
                   boolean animated)
Paints the element on the given graphic context.

Parameters:
g - the graphic context
angle - how much the element is rotated
size - size of element on the screen
isSimulating - is the applet simulating now
animated - is the element should be animated or should be static like in Toolbar