org.simbrain.world.textworld
Class TextWorld

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.textworld.TextWorld
All Implemented Interfaces:
ActionListener, KeyListener, MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class TextWorld
extends World
implements KeyListener, MouseListener, ActionListener

TextWorld acts as a text interface to neural ntworks, for use in language parsing and other tasks. Users input text which parsed into vector form and sent to the network, and vectors from the network are converted into text and sent to this world.

See Also:
Serialized Form

Nested Class Summary
(package private)  class TextWorld.MyHighlightPainter
          A private subclass of the default highlight painter.
 
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
TextWorld(TextWorldFrame ws)
          Constructs an instance of TextWorld.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Responds to action events.
 void addCommandTarget(NetworkPanel net)
          Adds command to agent selected.
 ArrayList getAgentList()
          Return the list of agents for this world.
 ArrayList getCommandTargets()
          Gets commands currently attached to agent.
 String getCurrentLine()
          Returns the current line of text.
 Color getHilightColor()
           
 JMenu getMotorCommandMenu(ActionListener al)
          Return a menu of motor commands for this world and register the specified action listener as an action listener for the menu items in the returned menu.
 TextWorldFrame getParentFrame()
           
 boolean getParseChar()
           
 boolean getSendEnter()
           
 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.
 String getType()
          Return the type of this world.
 String getWorldName()
          Return the name of this world.
 void highlight(int begin, int end)
          Highlight word beginning at begin nd ending at end.
 void keyPressed(KeyEvent e)
          Responds to key pressed events.
 void keyReleased(KeyEvent arg0)
          Responds to key released events.
 void keyTyped(KeyEvent arg0)
          Responds to the key typed.
 void mouseClicked(MouseEvent arg0)
          Responds to mouse button click events.
 void mouseEntered(MouseEvent arg0)
          Responds to events when mouse is in area.
 void mouseExited(MouseEvent arg0)
          Responds to events when mouse is outside area.
 void mousePressed(MouseEvent arg0)
          Responds to events when mouse button is pressed.
 void mouseReleased(MouseEvent arg0)
          Responds to events when mouse button is released.
 void parseText(String text)
          Parse a line of text.
 void parseWord(char[] text)
          Break text into space-delimited words to send to network.
 void removeCommandTarget(NetworkPanel net)
          Removes command from agent selected.
 void removeHighlights(JTextComponent textComp)
          Removes highlights from specified component.
 void setHilightColor(Color hilightColor)
           
 void setParentFrame(TextWorldFrame parentFrame)
           
 void setParseChar(boolean parseChar)
          Set whether to parse by character.
 void setSendEnter(boolean sendEnter)
           
 void setWorldName(String worldName)
           
 void showTextWorldDialog()
          Displays a dialog for settable TextWorld preferences.
 
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, paint, 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
 

Constructor Detail

TextWorld

public TextWorld(TextWorldFrame ws)
Constructs an instance of TextWorld.

Parameters:
ws - Instance of TextWorldFrame
Method Detail

showTextWorldDialog

public void showTextWorldDialog()
Displays a dialog for settable TextWorld preferences.


getType

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

Specified by:
getType in class World
Returns:
type of 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:
List of agents in the world.

getMotorCommandMenu

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

Specified by:
getMotorCommandMenu in class World
Parameters:
al - ActionListener
Returns:
Motor commands that can be used to manipulate agent in world.

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 - ActionListener
Returns:
Agent sensors.

addCommandTarget

public void addCommandTarget(NetworkPanel net)
Adds command to agent selected.

Parameters:
net - Network panel

removeCommandTarget

public void removeCommandTarget(NetworkPanel net)
Removes command from agent selected.

Parameters:
net - Network Panel

getCommandTargets

public ArrayList getCommandTargets()
Gets commands currently attached to agent.

Returns:
Command Targets

keyPressed

public void keyPressed(KeyEvent e)
Responds to key pressed events.

Specified by:
keyPressed in interface KeyListener
Parameters:
e - KeyEvent

keyReleased

public void keyReleased(KeyEvent arg0)
Responds to key released events.

Specified by:
keyReleased in interface KeyListener
Parameters:
arg0 - KeyEvent

keyTyped

public void keyTyped(KeyEvent arg0)
Responds to the key typed.

Specified by:
keyTyped in interface KeyListener
Parameters:
arg0 - KeyEvent

mouseClicked

public void mouseClicked(MouseEvent arg0)
Responds to mouse button click events.

Specified by:
mouseClicked in interface MouseListener
Parameters:
arg0 - MouseEvent

mouseEntered

public void mouseEntered(MouseEvent arg0)
Responds to events when mouse is in area.

Specified by:
mouseEntered in interface MouseListener
Parameters:
arg0 - MouseEvent

mouseExited

public void mouseExited(MouseEvent arg0)
Responds to events when mouse is outside area.

Specified by:
mouseExited in interface MouseListener
Parameters:
arg0 - MouseEvent

mousePressed

public void mousePressed(MouseEvent arg0)
Responds to events when mouse button is pressed.

Specified by:
mousePressed in interface MouseListener
Parameters:
arg0 - MouseEvent

mouseReleased

public void mouseReleased(MouseEvent arg0)
Responds to events when mouse button is released.

Specified by:
mouseReleased in interface MouseListener
Parameters:
arg0 - MouseEvent

getParentFrame

public TextWorldFrame getParentFrame()
Returns:
Returns the parentFrame.

setParentFrame

public void setParentFrame(TextWorldFrame parentFrame)
Parameters:
parentFrame - The parentFrame to set.

actionPerformed

public void actionPerformed(ActionEvent e)
Responds to action events.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - ActionEvent

parseText

public void parseText(String text)
Parse a line of text.

Parameters:
text - text to parse

parseWord

public void parseWord(char[] text)
Break text into space-delimited words to send to network.

Parameters:
text - text to parse.

getCurrentLine

public String getCurrentLine()
Returns the current line of text.

Returns:
current line of text.

getParseChar

public boolean getParseChar()
Returns:
Boolean to parse by character.

setParseChar

public void setParseChar(boolean parseChar)
Set whether to parse by character.

Parameters:
parseChar - boolean parse by character

highlight

public void highlight(int begin,
                      int end)
Highlight word beginning at begin nd ending at end.

Parameters:
begin - offset of beginning of highlight
end - offset of end of highlight

removeHighlights

public void removeHighlights(JTextComponent textComp)
Removes highlights from specified component.

Parameters:
textComp - text component to remove highlights from.

getHilightColor

public Color getHilightColor()
Returns:
highlightColor.

setHilightColor

public void setHilightColor(Color hilightColor)
Parameters:
hilightColor - Color of highlighter.

getSendEnter

public boolean getSendEnter()
Returns:
sendEnter.

setSendEnter

public void setSendEnter(boolean sendEnter)
Parameters:
sendEnter - Sets whether enter sends current line.

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 the world.

setWorldName

public void setWorldName(String worldName)
Parameters:
worldName - The worldName to set.