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
-
Element()
- Constructs basic Element.
-
checkVoltage(int, double, double)
- Function used to check the result of calculation, when more than one result obtained
-
connect()
- This function runs once, when the graph for the simulation was built,
but the simulation hasn't started yet.
-
getContVertex(int)
- Get vertex of specified contact
-
getCurrent(int, double)
- Main function for calculations.
-
getImage(int)
-
Returns image for this element.
-
getImage(int, double)
-
Returns image for this element.
-
getInfo(int)
-
Returns information for this element, such as voltage, current etc.
-
getLastCurrent(int)
- Returns last current in given direction
-
getTip(int)
-
Returns tool tip for this element.
-
getTipLocation(Container)
-
Returns tool tip location for this element.
-
hasContact(int)
- Check if contact exist.
-
initImages(Applet)
- Load all images.
-
isVertexSet(int)
- Check if vertex seted to specified contact
-
paint(Graphics, int, Dimension, boolean, boolean)
-
Paints the element on the given graphic context.
-
parseString(String)
- This method is called to load new values to element from string.
-
reset()
- Function resets element conditions.
-
setContVertex(int, Vertex)
- Set vertex to specified contact
-
showPropertiesDialog(Frame)
-
-
toString()
- Returns a string representation of the object.
-
valueOf(double, int)
- Return real value of propertie, by calculating it using unit's order
-
vertexReset()
- Reset all vertice to null
Element
public Element()
- Constructs basic Element.
hasContact
public boolean hasContact(int dir)
- Check if contact exist.
- Parameters:
- dir - direction on contact
- Returns:
- returns true if contact exists
setContVertex
public void setContVertex(int dir,
Vertex vert)
- Set vertex to specified contact
- Parameters:
- dir - direction of contact
- vert - vertex to connect
getContVertex
public Vertex getContVertex(int dir)
- Get vertex of specified contact
- Parameters:
- dir - direction of contact
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
vertexReset
public void vertexReset()
- Reset all vertice to null
showPropertiesDialog
public void showPropertiesDialog(Frame f)
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.
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
toString
public String toString()
- Returns a string representation of the object.
- Returns:
- a string representation of the object.
- Overrides:
- toString in class Object
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.
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.
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.
reset
public void reset()
- Function resets element conditions. Called each time new graph is build.
initImages
public void initImages(Applet theApplet)
- Load all images. Called once.
- Parameters:
- theApplet - instace of current applet
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.
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.
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.
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.
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.
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.
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