org.simbrain.world.visionworld
Class VisionWorld

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.simbrain.world.World
                      extended by org.simbrain.world.visionworld.VisionWorld
All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, Agent

public class VisionWorld
extends World
implements Agent, MouseListener, MouseMotionListener

< b>VisionWorld < /b> provides visual input to a neural network in the form of a grid of pixels that can be turned on or off by the user.

Author:
RJB
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
VisionWorld()
          The default constructor, creates the world, and registers the necessary listeners.
VisionWorld(int w, int h)
          A constructor for a height and width.
VisionWorld(VisionWorldFrame pf)
          A constructor for the default size, built on a parent frame.
 
Method Summary
 void addCommandTarget(NetworkPanel net)
           
 void completedInputRound()
          Completed input round.
 ArrayList getAgentList()
          Return the list of agents for this world.
 ArrayList getCommandTargets()
           
 JMenu getMotorCommandMenu(ActionListener al)
          Not yet implemented.
 int getNumPixelsColumn()
           
 int getNumPixelsRow()
           
 VisionWorldFrame getParentFrame()
           
 World getParentWorld()
          Return the parent world for this agent.
 Pixel getPixel(int x, int y)
           
 Pixel getSelectedPixel(MouseEvent e)
           
 String getSelectedPixelToolTip(MouseEvent e)
           
 JMenu getSensorIdMenu(ActionListener al)
          Return a menu of sensor ids for this world and register the specified action listener as an action listener for the menu items in the returned menu.
 double getStimulus(String[] sensorID)
          Accepts a string in the form "x","y".
 String getType()
          Return the type of this world.
 String getWorldName()
          Return the name of this world.
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
          Drag-Flips a series of pixels.
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
          Sets the tooltip text of the mouse to the hovered-over pixel.
 void mousePressed(MouseEvent e)
          Flips a pixel, or turns on pixel dragging.
 void mouseReleased(MouseEvent e)
           
 void paint(Graphics g)
          Overrides the paint method of the JPanel component, providing special qualifiers for pixels.
 void rebuild()
          Rebuilds the world to an appropriate form.
 void redimension(int w, int h)
          Changes the dimensions of the world.
 void removeCommandTarget(NetworkPanel net)
           
 void setMotorCommand(String[] commandList, double value)
          Not yet implemented.
 void setNumPixelsColumn(int numPixelsColumn)
           
 void setNumPixelsRow(int numPixelsRow)
           
 void setParentFrame(VisionWorldFrame parentFrame)
           
 void setWorldName(String name)
           
 
Methods inherited from class org.simbrain.world.World
addWorldListener, fireWorldChanged, removeWorldListener
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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
 
Methods inherited from interface org.simbrain.world.Agent
getName
 

Constructor Detail

VisionWorld

public VisionWorld()
The default constructor, creates the world, and registers the necessary listeners.


VisionWorld

public VisionWorld(int w,
                   int h)
A constructor for a height and width.

Parameters:
w - the width of the desired world (in pixels)
h - the height of the desired world (in pixels)

VisionWorld

public VisionWorld(VisionWorldFrame pf)
A constructor for the default size, built on a parent frame.

Parameters:
pf - the parent frame calling the constructor
Method Detail

redimension

public void redimension(int w,
                        int h)
Changes the dimensions of the world.

Parameters:
h - numPixelsColumn in pixels
w - numPixelsRow in pixels

getPixel

public Pixel getPixel(int x,
                      int y)
Parameters:
x - the x location of the pixel (in pixels)
y - the y location of the pixel (in pixels)
Returns:
the pixel that is represented by the parameters

getSelectedPixel

public Pixel getSelectedPixel(MouseEvent e)
Parameters:
e - the event for which a pixel is needed
Returns:
the pixel that is underneath the mouse producing the event

getSelectedPixelToolTip

public String getSelectedPixelToolTip(MouseEvent e)
Parameters:
e - the mouseEvent for which the toolTip is needed
Returns:
the string to set as the toolTip for a given pixel

paint

public void paint(Graphics g)
Overrides the paint method of the JPanel component, providing special qualifiers for pixels.

Overrides:
paint in class JComponent
Parameters:
g - the Graphics object for this world

rebuild

public void rebuild()
Rebuilds the world to an appropriate form.


getParentWorld

public World getParentWorld()
Description copied from interface: Agent
Return the parent world for this agent.

Specified by:
getParentWorld in interface Agent
Returns:
this world

getStimulus

public double getStimulus(String[] sensorID)
Accepts a string in the form "x","y".

Specified by:
getStimulus in interface Agent
Parameters:
sensorID - is the sensor identification array
Returns:
stimulus for attached node

setMotorCommand

public void setMotorCommand(String[] commandList,
                            double value)
Not yet implemented.

Specified by:
setMotorCommand in interface Agent
Parameters:
commandList - the list of command strings
value - the value to set on the given commanded item

getType

public String getType()
Description copied from class: World
Return the type of this world.

Specified by:
getType in class World
Returns:
the Type of this world

getAgentList

public ArrayList getAgentList()
Description copied from class: World
Return the list of agents for this world.

Specified by:
getAgentList in class World
Returns:
an arraylist representing this world/agent

getMotorCommandMenu

public JMenu getMotorCommandMenu(ActionListener al)
Not yet implemented.

Specified by:
getMotorCommandMenu in class World
Parameters:
al - the action listener to be attached to these menu items
Returns:
the menu of available motor commands

getSensorIdMenu

public JMenu getSensorIdMenu(ActionListener al)
Description copied from class: World
Return a menu of sensor ids for this world and register the specified action listener as an action listener for the menu items in the returned menu.

Specified by:
getSensorIdMenu in class World
Parameters:
al - the action listener to attach to the menu items
Returns:
the menu of available sensors

addCommandTarget

public void addCommandTarget(NetworkPanel net)
Parameters:
net - the network to add as a command target

removeCommandTarget

public void removeCommandTarget(NetworkPanel net)
Parameters:
net - the network to remove as a command target

getCommandTargets

public ArrayList getCommandTargets()
Returns:
commandTargets

getParentFrame

public VisionWorldFrame getParentFrame()
Returns:
the parent frame

setParentFrame

public void setParentFrame(VisionWorldFrame parentFrame)
Parameters:
parentFrame - the parent frame to be set

setWorldName

public void setWorldName(String name)
Parameters:
name - the name to be set for this world, also, the title for the parent frame

getWorldName

public String getWorldName()
Description copied from class: World
Return the name of this world.

Specified by:
getWorldName in class World
Returns:
the name of this world

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener
Parameters:
e - the MouseEvent triggering the method

mousePressed

public void mousePressed(MouseEvent e)
Flips a pixel, or turns on pixel dragging.

Specified by:
mousePressed in interface MouseListener
Parameters:
e - the MouseEvent triggering the method

mouseDragged

public void mouseDragged(MouseEvent e)
Drag-Flips a series of pixels.

Specified by:
mouseDragged in interface MouseMotionListener
Parameters:
e - the MouseEvent triggering the method

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
Parameters:
e - the MouseEvent triggering the method

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener
Parameters:
e - the MouseEvent triggering the method

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener
Parameters:
e - the MouseEvent triggering the method

mouseMoved

public void mouseMoved(MouseEvent e)
Sets the tooltip text of the mouse to the hovered-over pixel.

Specified by:
mouseMoved in interface MouseMotionListener
Parameters:
e - the MouseEvent triggering the method

getNumPixelsColumn

public int getNumPixelsColumn()
Returns:
numPixelsColumn

setNumPixelsColumn

public void setNumPixelsColumn(int numPixelsColumn)
Parameters:
numPixelsColumn - the numPixelsColumn to set

getNumPixelsRow

public int getNumPixelsRow()
Returns:
numPixelsRow

setNumPixelsRow

public void setNumPixelsRow(int numPixelsRow)
Parameters:
numPixelsRow - the numPixelsRow to set

completedInputRound

public void completedInputRound()
Completed input round.

Specified by:
completedInputRound in interface Agent