public class PnCellOperator extends PjWorkshop implements PvPickListenerIf, java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
static int |
CORONA |
static int |
LIFE |
static int |
MAJORITY |
static int |
NEIGHBOUR |
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
MODE_BUG, MODE_STANDARD, MODE_VALIDATE
Constructor and Description |
---|
PnCellOperator()
Constructor
|
PnCellOperator(PgElementSet geom)
Deprecated.
use constructor prj=new PnCellOperator();prj.setGeometry(geom);prj.reset();
|
Modifier and Type | Method and Description |
---|---|
int |
cellOperator(int index)
Call the appointed operating rule for a given cell.
|
void |
clear()
Set all elements to state "0".
|
void |
close()
Remove pick focus and update from cell operator, reset elementSet's colors to
global element color and destroy dialog window.
|
void |
compute()
For all cells call cell operating method.
|
void |
dragDisplay(PvPickEvent pos)
Drag a location in the display with 2d display and 3d world coordinates.
|
void |
dragInitial(PvPickEvent pos)
Drag an arbitrary point along a geometry, point may lie inside an element.
|
void |
dragVertex(PgGeometryIf geom,
int vertexIndex,
PdVector vertex)
Drag a picked vertex of a geometry.
|
void |
evaluate()
For all elements of the ElementSet show the cell values.
|
java.awt.Color |
getColor(int i)
Return color for a given cell state.
|
int |
getNumLoops()
Get the number of operating loops.
|
int |
getNumStates()
return number of possible states of a cell.
|
int |
getState(int elemNr)
Return state number of a given element.
|
void |
init()
Initialization
|
void |
makeCoronaInfluence()
For all cells store all cells touching vertices of the cell itself.
|
void |
makeInfluence()
Set list of influencing cells for all cells of the elementSet.
|
void |
makeNeighbourInfluence()
For all cells store cell itself and all neighbour cells.
|
void |
markElement(int elemNr)
Set an element to the next state.
|
void |
markElement(int elemNr,
int value)
Set an element to a given state.
|
void |
markGlider(int elemNr,
int dir)
Set a glider upon an elementSet with quadrilateral connectivity.
|
void |
markVertices(PvPickEvent markBox)
Mark a set of vertices of a geometry within a given bounding box.
|
void |
pickDisplay(PvPickEvent pos)
Get a location in the display with 2d display and 3d world coordinates.
|
void |
pickInitial(PvPickEvent pos)
Mark picked element to be a living cell.
|
void |
pickVertex(PgGeometryIf geom,
int vertexIndex,
PdVector vertex)
Get a picked vertex of a geometry.
|
void |
releasePick()
Remove pick focus from cell operator.
|
void |
requestPick()
Set pick focus upon cell operator.
|
void |
reset()
Reset workshop and geometry to original state.
|
void |
restoreColors()
Reset the ElementSet's element colors to state before calling cell operator.
|
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.
|
int |
ruleOfMajority(int index)
Every cell is set to the state of the majority state in the influence area.
|
void |
run()
Do cell operating until
m_numLoops are done or until a call of stop(). |
void |
selectGeometry(PgGeometryIf geom)
This workshop is informed when the currently active geometry
changes in the display.
|
void |
setColor(int i,
java.awt.Color aColor)
Define color for a cell state.
|
void |
setColors()
Set colors of all elements of the elementSet according to their states.
|
void |
setCurrLoop(int currLoop)
Set number of current operating loop.
|
void |
setElementTags()
Set tag for all elements of the elementSet according to their states.
|
void |
setGeometry(PgElementSet geom)
Assign a geometry on which this workshop operates.
|
void |
setInfluence(int inf)
Choose an influence area.
|
void |
setInfluence(java.lang.String aString)
Deprecated.
use setInfluence(int)
|
void |
setNumLoops(int numLoops)
Set the number of operating loops.
|
void |
setNumStates(int anInt)
Define number of possible states of a cell.
|
void |
setOutputType(int aType)
Appoint the way of viewing element states.
|
void |
setRule(int aRule)
Select an operating rule.
|
void |
setRule(java.lang.String aString)
Deprecated.
use setRule(int)
|
void |
start()
Start cell operator in separate thread.
|
void |
stop()
Stop cell operator in separate thread.
|
void |
unmarkVertices(PvPickEvent markBox)
Unmark a set of vertices of a geometry within a given bounding box.
|
boolean |
update(java.lang.Object event)
Update the class whenever a child has changed.
|
cancel, getDisplay, getDisplays, getGeometry, getMode, getSavedGeometry, getViewer, isModal, isStandalone, ok, openDialog, removeGeometry, setDisplay, setDisplays, setGeometry, setModal, setMode, setStandalone, setViewer
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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getName
getFather, getName, setParent
public static final int LIFE
public static final int MAJORITY
public static final int NEIGHBOUR
public static final int CORONA
public PnCellOperator()
public PnCellOperator(PgElementSet geom)
public void init()
init
in class PjWorkshop
public void reset()
reset
in class PjWorkshop
public boolean update(java.lang.Object event)
update
in interface PsUpdateIf
update
in class PjWorkshop
event
- sender of this update.PsObject.setParent(PsUpdateIf)
,
PsObject.getFather()
,
PsObject.addUpdateListener(PsUpdateIf)
public void setGeometry(PgElementSet geom)
public void close()
close
in class PjWorkshop
public void requestPick()
public void releasePick()
public void pickInitial(PvPickEvent pos)
pickInitial
in interface PvPickListenerIf
pos
- Pick event issued by the displayPvPickListenerIf
public void selectGeometry(PgGeometryIf geom)
This method does nothing and must be overwritten.
selectGeometry
in interface PvPickListenerIf
geom
- Now selected geometry of display.public void pickDisplay(PvPickEvent pos)
This method does nothing and must be overwritten.
pickDisplay
in interface PvPickListenerIf
pos
- Pick event issued by the displayPvPickListenerIf
public void dragDisplay(PvPickEvent pos)
This method invokes pickDisplay(PvPickEvent)
.
dragDisplay
in interface PvPickListenerIf
pos
- Pick event issued by the displayPvPickListenerIf
public void dragInitial(PvPickEvent pos)
This method invokes pickInitial(PvPickEvent)
and should be overwritten.
dragInitial
in interface PvPickListenerIf
pos
- Pick event issued by the displayPvPickListenerIf
public void pickVertex(PgGeometryIf geom, int vertexIndex, PdVector vertex)
This method does nothing and must be overwritten.
pickVertex
in interface PvPickListenerIf
geom
- Picked geometry on which vertex liesvertexIndex
- Index of vertex in vertex array of geometryvertex
- 3d coordinates of vertex positionPvPickListenerIf
public void dragVertex(PgGeometryIf geom, int vertexIndex, PdVector vertex)
This method invokes pickVertex(PgGeometryIf,int,PdVector)
and should be overwritten.
dragVertex
in interface PvPickListenerIf
geom
- Picked geometry on which vertex liesvertexIndex
- Index of vertex in vertex array of geometryvertex
- 3d coordinates of vertex positionpublic void markVertices(PvPickEvent markBox)
markVertices
in interface PvPickListenerIf
markBox
- contains four coplanar points on the bounding prism, and direction of prism.public void unmarkVertices(PvPickEvent markBox)
unmarkVertices
in interface PvPickListenerIf
markBox
- contains four coplanar points on the bounding prism, and direction of prism.public void setNumStates(int anInt)
public int getNumStates()
public void setRule(int aRule)
public void setRule(java.lang.String aString)
public void setInfluence(int inf)
public void setInfluence(java.lang.String aString)
public java.awt.Color getColor(int i)
public void setColor(int i, java.awt.Color aColor)
public int getNumLoops()
public void setNumLoops(int numLoops)
public void setCurrLoop(int currLoop)
public void markElement(int elemNr)
public void markElement(int elemNr, int value)
public void markGlider(int elemNr, int dir)
public void clear()
public int getState(int elemNr)
public void makeInfluence()
public void makeNeighbourInfluence()
public void makeCoronaInfluence()
public void compute()
public void evaluate()
public void setOutputType(int aType)
public void setColors()
public void restoreColors()
public void setElementTags()
public int cellOperator(int index)
public int ruleOfLife(int index)
public int ruleOfMajority(int index)
public void start()
public void stop()
public void run()
m_numLoops
are done or until a call of stop().run
in interface java.lang.Runnable
"