edu.rice.comp440.net
Class NeuralNetworkVisualizer.NeuralNetworkPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--edu.rice.comp440.net.NeuralNetworkVisualizer.NeuralNetworkPanel
Enclosing class:
NeuralNetworkVisualizer

protected class NeuralNetworkVisualizer.NeuralNetworkPanel
extends javax.swing.JPanel
implements java.awt.event.MouseListener

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
 java.awt.Color BACKGROUND_COLOR
           
 int BORDER
           
 java.awt.Color CONNECTION_CENTER_COLOR
           
 java.awt.Color CONNECTION_MAX_COLOR
           
 java.awt.Color CONNECTION_MIN_COLOR
           
 java.awt.Color CONNECTION_SELECTED_CENTER_COLOR
           
 java.awt.Color CONNECTION_SELECTED_CENTER_COLOR_2
           
 java.awt.Color CONNECTION_SELECTED_MAX_COLOR
           
 java.awt.Color CONNECTION_SELECTED_MIN_COLOR
           
 int HEIGHT
           
 int INPUT_LENGTH
           
protected  int LEVEL_SPACING
           
protected  NeuralNetwork net
           
 int NODE_DIAMETER
           
 java.awt.Color NODE_FILL_COLOR
           
 java.awt.Color NODE_OUTLINE_COLOR
           
 java.awt.Color NODE_SELECTED_COLOR
           
protected  int[] selected
           
 java.awt.Color TEXT_COLOR
           
 java.awt.Font TEXT_FONT
           
 int WIDTH
           
 
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
 
Constructor Summary
protected NeuralNetworkVisualizer.NeuralNetworkPanel(NeuralNetwork net)
          Builds a neural network panel
 
Method Summary
protected  int[] getNode(int x, int y)
          Returns the node at the given lcoation, or null if none exists
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of this panel
protected  int getX(int level, int num)
          Returns the x-coordinate of the given node
protected  int getY(int level, int num)
          Returns the y-coordinate of the given node
protected  boolean isSelected(int level, int num)
          Returns whetehr or not the node is slected
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
          Draws this panel.
protected  void paintConnection(java.awt.Graphics2D g2, int x1, int y1, int x2, int y2, double weight, boolean selected)
          Draws one connection
protected  void paintConnections(java.awt.Graphics2D g2)
          Paints the connections between the nodes
protected  void paintNode(java.awt.Graphics2D g2, int x, int y, java.lang.String label)
          Paints a node at the given location
protected  void paintNode(java.awt.Graphics2D g2, int x, int y, java.lang.String label, boolean selected)
          Paints a node at the given location
protected  void paintNodes(java.awt.Graphics2D g2)
          Paints the nodes
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WIDTH

public final int WIDTH

HEIGHT

public final int HEIGHT

BORDER

public final int BORDER

NODE_DIAMETER

public final int NODE_DIAMETER

INPUT_LENGTH

public final int INPUT_LENGTH

TEXT_FONT

public final java.awt.Font TEXT_FONT

TEXT_COLOR

public final java.awt.Color TEXT_COLOR

BACKGROUND_COLOR

public final java.awt.Color BACKGROUND_COLOR

NODE_OUTLINE_COLOR

public final java.awt.Color NODE_OUTLINE_COLOR

NODE_FILL_COLOR

public final java.awt.Color NODE_FILL_COLOR

NODE_SELECTED_COLOR

public final java.awt.Color NODE_SELECTED_COLOR

CONNECTION_MAX_COLOR

public final java.awt.Color CONNECTION_MAX_COLOR

CONNECTION_CENTER_COLOR

public final java.awt.Color CONNECTION_CENTER_COLOR

CONNECTION_MIN_COLOR

public final java.awt.Color CONNECTION_MIN_COLOR

CONNECTION_SELECTED_MAX_COLOR

public final java.awt.Color CONNECTION_SELECTED_MAX_COLOR

CONNECTION_SELECTED_CENTER_COLOR

public final java.awt.Color CONNECTION_SELECTED_CENTER_COLOR

CONNECTION_SELECTED_CENTER_COLOR_2

public final java.awt.Color CONNECTION_SELECTED_CENTER_COLOR_2

CONNECTION_SELECTED_MIN_COLOR

public final java.awt.Color CONNECTION_SELECTED_MIN_COLOR

LEVEL_SPACING

protected int LEVEL_SPACING

selected

protected int[] selected

net

protected NeuralNetwork net
Constructor Detail

NeuralNetworkVisualizer.NeuralNetworkPanel

protected NeuralNetworkVisualizer.NeuralNetworkPanel(NeuralNetwork net)
Builds a neural network panel
Parameters:
net - The net to base this panel on
Method Detail

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of this panel
Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
The size of this panel

paint

public void paint(java.awt.Graphics g)
Draws this panel.
Overrides:
paint in class javax.swing.JComponent
Parameters:
g - Where to draw the panel

paintConnections

protected void paintConnections(java.awt.Graphics2D g2)
Paints the connections between the nodes
Parameters:
g2 - The grpahics

paintConnection

protected void paintConnection(java.awt.Graphics2D g2,
                               int x1,
                               int y1,
                               int x2,
                               int y2,
                               double weight,
                               boolean selected)
Draws one connection
Parameters:
g2 - The grpahics
x1 - start x
y1 - start y
x2 - end x
y2 - end y
weight - The weight

paintNodes

protected void paintNodes(java.awt.Graphics2D g2)
Paints the nodes
Parameters:
g2 - The grpahics

isSelected

protected boolean isSelected(int level,
                             int num)
Returns whetehr or not the node is slected

paintNode

protected void paintNode(java.awt.Graphics2D g2,
                         int x,
                         int y,
                         java.lang.String label)
Paints a node at the given location
Parameters:
g2 - The graphics
x - The x coordinate
y - The y coordinate
label - The label

paintNode

protected void paintNode(java.awt.Graphics2D g2,
                         int x,
                         int y,
                         java.lang.String label,
                         boolean selected)
Paints a node at the given location
Parameters:
g2 - The graphics
x - The x coordinate
y - The y coordinate
label - The label
hightlighed - Whetehr or not this node is selected

getX

protected int getX(int level,
                   int num)
Returns the x-coordinate of the given node
Parameters:
level - The level
num - The num

getY

protected int getY(int level,
                   int num)
Returns the y-coordinate of the given node
Parameters:
level - The level
num - The num

getNode

protected int[] getNode(int x,
                        int y)
Returns the node at the given lcoation, or null if none exists
Parameters:
x - The x location
y - The y location
Returns:
The node selected, or null

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener