JavaView® v2.00.008

jvx.geom
Class PnCellOperator

java.lang.Object
  |
  +--jv.object.PsObject
        |
        +--jv.project.PjProject
              |
              +--jvx.geom.PnCellOperator
All Implemented Interfaces:
java.lang.Cloneable, PsTimeListenerIf, PsUpdateIf, PvPickListenerIf, java.lang.Runnable, java.io.Serializable
Direct Known Subclasses:
PnMinesweeper

public class PnCellOperator
extends PjProject
implements java.lang.Runnable

Implements a cellular automata on the triangles of an element set.

Version:
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)
Author:
Ulrich Reitebuch
See Also:
Serialized Form

Field Summary
static int CORONA
           
protected  int influence
           
static int LIFE
           
protected  boolean m_bHasElementColors
          Flag, if the geometry has elementColors before calling CellOperator.
protected  boolean m_bMarkGlider
           
protected  boolean m_bShowTaggedElements
          Flag, if ShowTaggedElements was switched on before calling CellOperator.
protected  boolean m_bUpdateSender
           
protected  boolean m_bUseGlobalElementColor
          Flag, if global element color of geometry was used before calling CellOperator.
protected  java.awt.Color[] m_color
           
protected  int m_currLoop
           
protected  PnCellOperator_Dialog m_dialog
           
protected  PgElementSet m_geom
           
protected  PiVector[] m_geomElement
           
protected  PiVector[] m_geomNeighbour
           
protected  PiVector[] m_infCell
           
protected  PiVector m_markI
           
protected  int m_numLoops
           
protected  int m_numStates
           
protected  java.awt.Color[] m_originalColors
          Original element colors of geometry before calling CellOperator.
protected  int m_outputType
           
protected  PnCellOperator_IP m_panel
           
protected  int m_sleepTime
           
protected  java.lang.Thread m_thread
           
protected  PgVertexStar m_vertexStar
           
static int MAJORITY
           
static int NEIGHBOUR
           
protected  int rule
           
protected static int SET_COLOR
           
protected static int SET_ELEMENT_TAG
           
 
Fields inherited from class jv.project.PjProject
m_anim, m_bAutoFit, m_display, m_displayList, m_geometry, m_parm, m_rootGeometry
 
Fields inherited from class jv.object.PsObject
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, m_infoPanel, m_name, m_panelList, m_parent, m_tag, m_updateList, NUM_TAGS
 
Constructor Summary
PnCellOperator(PgElementSet anElementSet)
          Constructor
 
Method Summary
 int cellOperator(int index)
          Call the appointed operating rule for a given cell.
 void clear()
          Set all elements to state "0".
 void compute()
          For all cells call cell operating method.
 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.
 PnCellOperator_Dialog getDialog()
          Open a new dialog window for cell operator.
 int getNumStates()
          return number of possible states of a cell.
 int getState(int elemNr)
          Return state number of a given element.
 void init()
          Initialisation
 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 pickInitial(PvPickEvent pos)
          Mark picked element to be a living cell.
 void releasePick()
          Remove pick focus from cell operator.
 void requestPick()
          Set pick focus upon cell operator.
 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 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 setInfluence(java.lang.String aString)
          Choose an influence area.
 void setNumLoops(int numLoops)
          Appoint 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(java.lang.String aString)
          Choose a operating rule.
 void start()
          Start cell operator in separate thread.
 void stop()
          Stop cell operator in separate thread.
 boolean update(java.lang.Object event)
          Update the class whenever a child has changed.
 
Methods inherited from class jv.project.PjProject
addDisplay, addGeometry, addGeometry, dispose, dragDisplay, dragInitial, dragVertex, fitDisplays, getAnimation, getDisplay, getDisplays, getGeometry, getGeometry, getNumGeometries, getParameter, getViewer, hasAnimation, hasDisplay, isEnabledAutoFit, markVertices, pickDisplay, pickVertex, removeDisplay, removeGeometries, removeGeometry, selectDisplay, selectGeometry, setAnimation, setDisplay, setEnabledAutoFit, setParameter, setTime, setViewer, unmarkVertices
 
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, toString, updatePanels
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jv.anim.PsTimeListenerIf
getName
 
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

MAJORITY

public static final int MAJORITY

rule

protected int rule

NEIGHBOUR

public static final int NEIGHBOUR

CORONA

public static final int CORONA

influence

protected int influence

m_sleepTime

protected int m_sleepTime

m_geom

protected PgElementSet m_geom

m_color

protected java.awt.Color[] m_color

SET_ELEMENT_TAG

protected static final int SET_ELEMENT_TAG

SET_COLOR

protected static final int SET_COLOR

m_outputType

protected int m_outputType

m_markI

protected PiVector m_markI

m_numStates

protected int m_numStates

m_infCell

protected PiVector[] m_infCell

m_vertexStar

protected PgVertexStar m_vertexStar

m_geomElement

protected PiVector[] m_geomElement

m_geomNeighbour

protected PiVector[] m_geomNeighbour

m_thread

protected java.lang.Thread m_thread

m_numLoops

protected int m_numLoops

m_currLoop

protected int m_currLoop

m_panel

protected PnCellOperator_IP m_panel

m_dialog

protected PnCellOperator_Dialog m_dialog

m_bUpdateSender

protected boolean m_bUpdateSender

m_bMarkGlider

protected boolean m_bMarkGlider

m_bUseGlobalElementColor

protected boolean m_bUseGlobalElementColor
Flag, if global element color of geometry was used before calling CellOperator.

m_bHasElementColors

protected boolean m_bHasElementColors
Flag, if the geometry has elementColors before calling CellOperator.

m_bShowTaggedElements

protected boolean m_bShowTaggedElements
Flag, if ShowTaggedElements was switched on before calling CellOperator.

m_originalColors

protected java.awt.Color[] m_originalColors
Original element colors of geometry before calling CellOperator.
Constructor Detail

PnCellOperator

public PnCellOperator(PgElementSet anElementSet)
Constructor
Method Detail

init

public void init()
Initialisation
Overrides:
init in class PjProject

requestPick

public void requestPick()
Set pick focus upon cell operator.

releasePick

public void releasePick()
Remove pick focus from cell operator.

pickInitial

public void pickInitial(PvPickEvent pos)
Mark picked element to be a living cell.
Overrides:
pickInitial in class PjProject
Following copied from class: jv.project.PjProject
Parameters:
pos - Pick event issued by the display
See Also:
PvPickListenerIf

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(java.lang.String aString)
Choose a operating rule.

setInfluence

public void setInfluence(java.lang.String aString)
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.

setNumLoops

public void setNumLoops(int numLoops)
Appoint 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.

update

public boolean update(java.lang.Object event)
Update the class whenever a child has changed. Method is usually invoked from the children.
Overrides:
update in class PsObject
Following copied from interface: jv.object.PsUpdateIf
Parameters:
event - carries a lot of information
Returns:
true if event has been handled, otherwise false
See Also:
PsObject, PsUpdateIf.getFather(), PsUpdateIf.setParent(PsUpdateIf)

start

public void start()
Start cell operator in separate thread.
Overrides:
start in class PjProject
Following copied from class: jv.project.PjProject
See Also:
PvViewerIf.start(), #isEnabledAutoFit(boolean)

stop

public void stop()
Stop cell operator in separate thread.
Overrides:
stop in class PjProject
Following copied from class: jv.project.PjProject
See Also:
PvViewerIf.stop()

run

public void run()
Do cell operating until m_numLoops are done or until a call of stop().
Specified by:
run in interface java.lang.Runnable

getDialog

public PnCellOperator_Dialog getDialog()
Open a new dialog window for cell operator.

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.