|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ptft.JGrid
ptft.JCellularAutomata
ptft.JPtftCellularAutomata
ptft.JPaintCellularAutomata
Adds the functionality of a simple paint program so that the user can paint cells a different strategy or ethnicity color.
| Nested Class Summary |
| Nested classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
protected int |
m_activeEthnicity
|
protected int |
m_activeStrategy
|
protected java.awt.Cursor |
m_bucketCursor
|
protected boolean[][] |
m_isFlooded
|
protected boolean |
m_isMouseButtonPressed
|
protected boolean |
m_isPaintModeEnabled
|
protected boolean |
m_isPencil
|
protected JPtftCell |
m_lastDrawnCell
|
protected java.awt.Cursor |
m_pencilCursor
|
| Fields inherited from class ptft.JPtftCellularAutomata |
m_ethnicColors, m_isSegregated, m_isStrategyDisplayed, m_strategyColors |
| Fields inherited from class ptft.JCellularAutomata |
m_payoffs, m_sleepDelay, m_thread |
| Fields inherited from class ptft.JGrid |
innerPanel, m_cellPadding, m_cellWidth, m_columns, m_grid, m_rows, m_strategies |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
JPaintCellularAutomata()
Creates new form JCellularAutomataPaint |
|
| Method Summary | |
protected void |
drawCell(JPtftCell cell)
Depending on whether we're viewing strategies or ethnicities, changes the cell's strategy or ethnicity to m_activeStrategy
or m_activeEthnicity. |
protected void |
drawLine(JPtftCell c1,
JPtftCell c2)
Draws a line recursively connecting two cells |
void |
fillWithBucket(JPtftCell cell,
int strategy,
int ethnicity)
|
protected void |
floodFill(JPtftCell cell,
int fillColor,
int oldColor,
java.lang.String text)
Fills regions of color "old" with the new color "fill" starting at the given coordinates |
protected JPtftCell |
getCell(java.awt.Point p)
Returns the cell located at the pixel coordinate p. |
boolean |
isPaintModeEnabled()
|
boolean |
isPencil()
|
void |
mouseClicked(java.awt.event.MouseEvent e)
|
void |
mouseDragged(java.awt.event.MouseEvent e)
|
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mouseMoved(java.awt.event.MouseEvent e)
|
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
protected boolean |
sameColor(JPtftCell cell,
int color)
|
void |
setActiveEthnicity(int ethnicity)
User-painting will be done with this ethnicity color |
void |
setActiveStrategy(int strategy)
User-painting will be done with this strategy color |
protected void |
setCell(JPtftCell cell,
int color)
|
void |
setPaintMode(boolean isEnabled,
boolean isPencil)
enables paint mode |
| Methods inherited from class ptft.JPtftCellularAutomata |
createCells, integrate, isSegregated, isStrategyDisplayed, playNeighbor, restart, segregate, setRandomEthnicities, setRandomEthnicities, toggleViews |
| Methods inherited from class ptft.JCellularAutomata |
getWinningStrategy, isRunning, pause, playCell, playRound, playRound, run, setPayoffs, setSleepDelay, start |
| Methods inherited from class ptft.JGrid |
createCells, getCell, getLeftColumn, getLowerRow, getNeighbor, getRightColumn, getTotalColumns, getTotalRows, getUpperRow, paintComponent, setBackground, setBorderColor, setGridColor, setLayout, setRandomStrategies, setRandomStrategies |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected int m_activeStrategy
protected int m_activeEthnicity
protected JPtftCell m_lastDrawnCell
protected boolean m_isPaintModeEnabled
protected boolean m_isPencil
protected boolean m_isMouseButtonPressed
protected java.awt.Cursor m_pencilCursor
protected java.awt.Cursor m_bucketCursor
protected boolean[][] m_isFlooded
| Constructor Detail |
public JPaintCellularAutomata()
| Method Detail |
public void setPaintMode(boolean isEnabled,
boolean isPencil)
public boolean isPaintModeEnabled()
public boolean isPencil()
public void setActiveStrategy(int strategy)
public void setActiveEthnicity(int ethnicity)
protected void drawLine(JPtftCell c1,
JPtftCell c2)
c1 - starting point of the linec2 - ending point of the lineprotected void drawCell(JPtftCell cell)
m_activeStrategy
or m_activeEthnicity.
setActiveStrategy(int),
setActiveEthnicity(int),
JPtftCellularAutomata.toggleViews()protected JPtftCell getCell(java.awt.Point p)
p.
This also helps us avoid missing mouse clicks that are in-between cells.
public void fillWithBucket(JPtftCell cell,
int strategy,
int ethnicity)
protected void setCell(JPtftCell cell,
int color)
protected boolean sameColor(JPtftCell cell,
int color)
protected void floodFill(JPtftCell cell,
int fillColor,
int oldColor,
java.lang.String text)
cell - starting cell for the flood filloldColor - color to paint withpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenerpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenerpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenerpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenerpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||