jvx.cellular
Class PnCellOperator
- java.lang.Object
-
- jv.object.PsObject
-
- jvx.project.PjWorkshop
-
- jvx.cellular.PnCellOperator
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Runnable, PsUpdateIf, PjWorkshopIf, PvPickListenerIf
- Direct Known Subclasses:
- PnMinesweeper
public class PnCellOperator extends PjWorkshop implements PvPickListenerIf, java.lang.Runnable
Implements a cellular automata on the triangles of an element set.- See Also:
- Serialized Form
- Author:
- Ulrich Reitebuch
- Version:
- 14.06.02, 3.10 revised (ur) Some tunings.
28.12.01, 3.00 revised (kp) Full revision when incorporating the new workshop handling.
27.06.00, 2.10 revised (ur) Marked cells output by ElementTag added. 02.05.00, 2.00 revised (kp) Class derived from PjProject in order to reuse interface methods.
02.05.00, 1.20 revised (kp) Removed the static getDialog() method which implicitly constructed a PnCellOperator.
02.04.00, 1.10 revised (kp) PdColor replaced with Color.
18.09.99, 1.01 revised (kp) Added two additional method to fulfill PvPickListenerIf.
02.08.99, 1.00 created (ur)
-
-
Field Summary
Fields Modifier and Type Field and Description static intCORONAstatic intLIFEstatic intMAJORITYstatic intNEIGHBOUR-
Fields inherited from class jv.object.PsObject
HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS
-
Fields inherited from interface jv.project.PjWorkshopIf
MODE_BUG, MODE_STANDARD, MODE_VALIDATE
-
-
Constructor Summary
Constructors Constructor and Description PnCellOperator()ConstructorPnCellOperator(PgElementSet geom)Deprecated.use constructor prj=new PnCellOperator();prj.setGeometry(geom);prj.reset();
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description intcellOperator(int index)Call the appointed operating rule for a given cell.voidclear()Set all elements to state "0".voidclose()Remove pick focus and update from cell operator, reset elementSet's colors to global element color and destroy dialog window.voidcompute()For all cells call cell operating method.voiddragDisplay(PvPickEvent pos)Drag a location in the display with 2d display and 3d world coordinates.voiddragInitial(PvPickEvent pos)Drag an arbitrary point along a geometry, point may lie inside an element.voiddragVertex(PgGeometryIf geom, int vertexIndex, PdVector vertex)Drag a picked vertex of a geometry.voidevaluate()For all elements of the ElementSet show the cell values.java.awt.ColorgetColor(int i)Return color for a given cell state.intgetNumLoops()Get the number of operating loops.intgetNumStates()return number of possible states of a cell.intgetState(int elemNr)Return state number of a given element.voidinit()InitializationvoidmakeCoronaInfluence()For all cells store all cells touching vertices of the cell itself.voidmakeInfluence()Set list of influencing cells for all cells of the elementSet.voidmakeNeighbourInfluence()For all cells store cell itself and all neighbour cells.voidmarkElement(int elemNr)Set an element to the next state.voidmarkElement(int elemNr, int value)Set an element to a given state.voidmarkGlider(int elemNr, int dir)Set a glider upon an elementSet with quadrilateral connectivity.voidmarkVertices(PvPickEvent markBox)Mark a set of vertices of a geometry within a given bounding box.voidpickDisplay(PvPickEvent pos)Get a location in the display with 2d display and 3d world coordinates.voidpickInitial(PvPickEvent pos)Mark picked element to be a living cell.voidpickVertex(PgGeometryIf geom, int vertexIndex, PdVector vertex)Get a picked vertex of a geometry.voidreleasePick()Remove pick focus from cell operator.voidrequestPick()Set pick focus upon cell operator.voidreset()Reset workshop and geometry to original state.voidrestoreColors()Reset the ElementSet's element colors to state before calling cell operator.intruleOfLife(int index)Evaluate rule of life: Dead cells with exactly three living influencing cells are set alive, living cells with three or four living influencing cells stay alive, all other cells are dead.intruleOfMajority(int index)Every cell is set to the state of the majority state in the influence area.voidrun()Do cell operating untilm_numLoopsare done or until a call of stop().voidselectGeometry(PgGeometryIf geom)This workshop is informed when the currently active geometry changes in the display.voidsetColor(int i, java.awt.Color aColor)Define color for a cell state.voidsetColors()Set colors of all elements of the elementSet according to their states.voidsetCurrLoop(int currLoop)Set number of current operating loop.voidsetElementTags()Set tag for all elements of the elementSet according to their states.voidsetGeometry(PgElementSet geom)Assign a geometry on which this workshop operates.voidsetInfluence(int inf)Choose an influence area.voidsetInfluence(java.lang.String aString)Deprecated.use setInfluence(int)voidsetNumLoops(int numLoops)Set the number of operating loops.voidsetNumStates(int anInt)Define number of possible states of a cell.voidsetOutputType(int aType)Appoint the way of viewing element states.voidsetRule(int aRule)Select an operating rule.voidsetRule(java.lang.String aString)Deprecated.use setRule(int)voidstart()Start cell operator in separate thread.voidstop()Stop cell operator in separate thread.voidunmarkVertices(PvPickEvent markBox)Unmark a set of vertices of a geometry within a given bounding box.booleanupdate(java.lang.Object event)Update the class whenever a child has changed.-
Methods inherited from class jvx.project.PjWorkshop
cancel, getDisplay, getDisplays, getGeometry, getMode, getSavedGeometry, getViewer, isModal, isStandalone, ok, removeGeometry, setDisplay, setDisplays, setGeometry, setModal, setMode, setStandalone, setViewer
-
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, toString, updatePanels
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jv.project.PvPickListenerIf
getName
-
Methods inherited from interface jv.object.PsUpdateIf
getFather, getName, setParent
-
-
-
-
Field Detail
-
LIFE
public static final int LIFE
- See Also:
- Constant Field Values
-
MAJORITY
public static final int MAJORITY
- See Also:
- Constant Field Values
-
NEIGHBOUR
public static final int NEIGHBOUR
- See Also:
- Constant Field Values
-
CORONA
public static final int CORONA
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PnCellOperator
public PnCellOperator()
Constructor
-
PnCellOperator
public PnCellOperator(PgElementSet geom)
Deprecated. use constructor prj=new PnCellOperator();prj.setGeometry(geom);prj.reset();Constructor.
-
-
Method Detail
-
init
public void init()
Initialization- Overrides:
initin classPjWorkshop
-
reset
public void reset()
Reset workshop and geometry to original state.- Overrides:
resetin classPjWorkshop
-
update
public boolean update(java.lang.Object event)
Update the class whenever a child has changed. Method is usually invoked from the children.- Specified by:
updatein interfacePsUpdateIf- Overrides:
updatein classPjWorkshop- Parameters:
event- sender of this update.- Returns:
- true if update was correctly handled by superclass.
- See Also:
PsObject.setParent(PsUpdateIf),PsObject.getFather(),PsObject.addUpdateListener(PsUpdateIf)
-
setGeometry
public void setGeometry(PgElementSet geom)
Assign a geometry on which this workshop operates.
-
close
public void close()
Remove pick focus and update from cell operator, reset elementSet's colors to global element color and destroy dialog window.- Overrides:
closein classPjWorkshop
-
requestPick
public void requestPick()
Set pick focus upon cell operator.- Version:
- 06.07.02, 1.10 revised (kp) Avoid NullPointerException when geometry has no displays yet.
-
releasePick
public void releasePick()
Remove pick focus from cell operator.- Version:
- 06.07.02, 1.10 revised (kp) Avoid NullPointerException when geometry has no displays yet.
-
pickInitial
public void pickInitial(PvPickEvent pos)
Mark picked element to be a living cell.- Specified by:
pickInitialin interfacePvPickListenerIf- Parameters:
pos- Pick event issued by the display- See Also:
PvPickListenerIf
-
selectGeometry
public void selectGeometry(PgGeometryIf geom)
This workshop is informed when the currently active geometry changes in the display. This method is automatically invoked from a display if this workshop is registered as pick listener.This method does nothing and must be overwritten.
- Specified by:
selectGeometryin interfacePvPickListenerIf- Parameters:
geom- Now selected geometry of display.
-
pickDisplay
public void pickDisplay(PvPickEvent pos)
Get a location in the display with 2d display and 3d world coordinates. Point may be independent of any geometry.This method does nothing and must be overwritten.
- Specified by:
pickDisplayin interfacePvPickListenerIf- Parameters:
pos- Pick event issued by the display- See Also:
PvPickListenerIf
-
dragDisplay
public void dragDisplay(PvPickEvent pos)
Drag a location in the display with 2d display and 3d world coordinates. Point may be independent of any geometry.This method invokes
pickDisplay(PvPickEvent).- Specified by:
dragDisplayin interfacePvPickListenerIf- Parameters:
pos- Pick event issued by the display- See Also:
PvPickListenerIf
-
dragInitial
public void dragInitial(PvPickEvent pos)
Drag an arbitrary point along a geometry, point may lie inside an element.This method invokes
pickInitial(PvPickEvent)and should be overwritten.- Specified by:
dragInitialin interfacePvPickListenerIf- Parameters:
pos- Pick event issued by the display- See Also:
PvPickListenerIf
-
pickVertex
public void pickVertex(PgGeometryIf geom, int vertexIndex, PdVector vertex)
Get a picked vertex of a geometry.This method does nothing and must be overwritten.
- Specified by:
pickVertexin interfacePvPickListenerIf- Parameters:
geom- Picked geometry on which vertex liesvertexIndex- Index of vertex in vertex array of geometryvertex- 3d coordinates of vertex position- See Also:
PvPickListenerIf
-
dragVertex
public void dragVertex(PgGeometryIf geom, int vertexIndex, PdVector vertex)
Drag a picked vertex of a geometry.This method invokes
pickVertex(PgGeometryIf,int,PdVector)and should be overwritten.- Specified by:
dragVertexin interfacePvPickListenerIf- Parameters:
geom- Picked geometry on which vertex liesvertexIndex- Index of vertex in vertex array of geometryvertex- 3d coordinates of vertex position
-
markVertices
public void markVertices(PvPickEvent markBox)
Mark a set of vertices of a geometry within a given bounding box.- Specified by:
markVerticesin interfacePvPickListenerIf- Parameters:
markBox- contains four coplanar points on the bounding prism, and direction of prism.
-
unmarkVertices
public void unmarkVertices(PvPickEvent markBox)
Unmark a set of vertices of a geometry within a given bounding box.- Specified by:
unmarkVerticesin interfacePvPickListenerIf- Parameters:
markBox- contains four coplanar points on the bounding prism, and direction of prism.
-
setNumStates
public void setNumStates(int anInt)
Define number of possible states of a cell.
-
getNumStates
public int getNumStates()
return number of possible states of a cell.
-
setRule
public void setRule(int aRule)
Select an operating rule.- Since:
- JavaView 2.34
- Version:
- 28.08.02, 1.00 created (kp)
-
setRule
public void setRule(java.lang.String aString)
Deprecated. use setRule(int)Choose an operating rule.
-
setInfluence
public void setInfluence(int inf)
Choose an influence area.- Since:
- JavaView 2.34
- Version:
- 28.08.02, 1.00 created (kp)
-
setInfluence
public void setInfluence(java.lang.String aString)
Deprecated. use setInfluence(int)Choose an influence area.
-
getColor
public java.awt.Color getColor(int i)
Return color for a given cell state.
-
setColor
public void setColor(int i, java.awt.Color aColor)Define color for a cell state.
-
getNumLoops
public int getNumLoops()
Get the number of operating loops.- Since:
- JavaView 2.48.007
- Version:
- 25.12.02, 1.00 created (kp)
-
setNumLoops
public void setNumLoops(int numLoops)
Set the number of operating loops.
-
setCurrLoop
public void setCurrLoop(int currLoop)
Set number of current operating loop.
-
markElement
public void markElement(int elemNr)
Set an element to the next state.
-
markElement
public void markElement(int elemNr, int value)Set an element to a given state.
-
markGlider
public void markGlider(int elemNr, int dir)Set a glider upon an elementSet with quadrilateral connectivity.
-
clear
public void clear()
Set all elements to state "0".
-
getState
public int getState(int elemNr)
Return state number of a given element.
-
makeInfluence
public void makeInfluence()
Set list of influencing cells for all cells of the elementSet.
-
makeNeighbourInfluence
public void makeNeighbourInfluence()
For all cells store cell itself and all neighbour cells.
-
makeCoronaInfluence
public void makeCoronaInfluence()
For all cells store all cells touching vertices of the cell itself.
-
compute
public void compute()
For all cells call cell operating method.
-
evaluate
public void evaluate()
For all elements of the ElementSet show the cell values.
-
setOutputType
public void setOutputType(int aType)
Appoint the way of viewing element states.
-
setColors
public void setColors()
Set colors of all elements of the elementSet according to their states.
-
restoreColors
public void restoreColors()
Reset the ElementSet's element colors to state before calling cell operator.
-
setElementTags
public void setElementTags()
Set tag for all elements of the elementSet according to their states.
-
cellOperator
public int cellOperator(int index)
Call the appointed operating rule for a given cell.
-
ruleOfLife
public int ruleOfLife(int index)
Evaluate rule of life: Dead cells with exactly three living influencing cells are set alive, living cells with three or four living influencing cells stay alive, all other cells are dead.
-
ruleOfMajority
public int ruleOfMajority(int index)
Every cell is set to the state of the majority state in the influence area.
-
start
public void start()
Start cell operator in separate thread.
-
stop
public void stop()
Stop cell operator in separate thread.
-
run
public void run()
Do cell operating untilm_numLoopsare done or until a call of stop().- Specified by:
runin interfacejava.lang.Runnable
-
-
"