org.nlogo.lite
Class AppletPanel

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.nlogo.lite.AppletPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, org.nlogo.util.Exceptions.Handler, org.nlogo.window.Event.LinkParent
Direct Known Subclasses:
InterfaceComponent

public abstract class AppletPanel
extends JPanel
implements org.nlogo.util.Exceptions.Handler, org.nlogo.window.Event.LinkParent

The superclass of org.nlogo.lite.InterfaceComponent. Also used by org.nlogo.lite.Applet.

See the "Controlling" section of the NetLogo User Manual for example code.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
 
Field Summary
 org.nlogo.api.AggregateManagerInterface aggregateManager
           
 org.nlogo.window.InterfacePanelLite iP
           
 List<Object> linkComponents
           
 org.nlogo.window.NetLogoListenerManager listenerManager
          The NetLogoListenerManager stored in this field can be used to add and remove org.nlogo.api.NetLogoListeners, so the embedding environment can receive notifications of events happening within NetLogo.
 org.nlogo.window.AppletAdPanel panel
           
 org.nlogo.window.ProceduresLite procedures
           
 org.nlogo.window.GUIWorkspace workspace
           
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
AppletPanel(Frame frame, MouseListener iconListener, boolean isApplet)
           
 
Method Summary
 void addLinkComponent(Object c)
          internal use only
 void command(String source)
          Runs NetLogo commands and waits for them to complete.
 void commandLater(String source)
          Runs NetLogo commands in the background.
abstract  URL getFileURL(String filename)
          internal use only
 Object[] getLinkChildren()
          internal use only
 String getProcedures()
          Returns the contents of the Procedures tab.
 void handle(Throwable throwable)
          internal use only
static void main(String[] args)
           
 void openFromSource(String name, String path, String source)
          Opens a model stored in a string.
 Object report(String source)
          Runs a NetLogo reporter.
 void requestFocus()
          AppletPanel passes the focus request to the InterfacePanel
 void setAdVisible(boolean visible)
          internal use only
 void setPrefix(URL url)
          sets the current working directory
 void setProcedures(String source)
          Replaces the contents of the Procedures tab.
static URL toURL(File file)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

iP

public final org.nlogo.window.InterfacePanelLite iP

workspace

public final org.nlogo.window.GUIWorkspace workspace

procedures

public final org.nlogo.window.ProceduresLite procedures

panel

public final org.nlogo.window.AppletAdPanel panel

aggregateManager

public final org.nlogo.api.AggregateManagerInterface aggregateManager

listenerManager

public final org.nlogo.window.NetLogoListenerManager listenerManager
The NetLogoListenerManager stored in this field can be used to add and remove org.nlogo.api.NetLogoListeners, so the embedding environment can receive notifications of events happening within NetLogo. The relevant methods on NetLogoListenerManager are addListener(), removeListener(), and clearListeners(). The first two expect a NetLogoListener as input.


linkComponents

public final List<Object> linkComponents
Constructor Detail

AppletPanel

public AppletPanel(Frame frame,
                   MouseListener iconListener,
                   boolean isApplet)
Method Detail

getFileURL

public abstract URL getFileURL(String filename)
                        throws MalformedURLException
internal use only

Throws:
MalformedURLException

requestFocus

public void requestFocus()
AppletPanel passes the focus request to the InterfacePanel

Overrides:
requestFocus in class JComponent

setAdVisible

public void setAdVisible(boolean visible)
internal use only


setPrefix

public void setPrefix(URL url)
sets the current working directory

Parameters:
url - the directory as java.net.URL

handle

public void handle(Throwable throwable)
internal use only

Specified by:
handle in interface org.nlogo.util.Exceptions.Handler

addLinkComponent

public void addLinkComponent(Object c)
internal use only


getLinkChildren

public Object[] getLinkChildren()
internal use only

Specified by:
getLinkChildren in interface org.nlogo.window.Event.LinkParent

command

public void command(String source)
             throws CompilerException
Runs NetLogo commands and waits for them to complete.

This method must not be called from the AWT event queue thread or while that thread is blocked. It is an error to do so.

Parameters:
source - The command or commands to run
Throws:
CompilerException - if the code fails to compile
IllegalStateException - if called from the AWT event queue thread
See Also:
commandLater(java.lang.String)

commandLater

public void commandLater(String source)
                  throws CompilerException
Runs NetLogo commands in the background. Returns immediately, without waiting for the commands to finish.

This method may be called from any thread.

Parameters:
source - The command or commands to run
Throws:
CompilerException - if the code fails to compile
See Also:
command(java.lang.String)

report

public Object report(String source)
              throws CompilerException
Runs a NetLogo reporter.

This method must not be called from the AWT event queue thread or while that thread is blocked. It is an error to do so.

Parameters:
source - The reporter to run
Returns:
the result reported; may be of type java.lang.Integer, java.lang.Double, java.lang.Boolean, java.lang.String, LogoList, Agent, AgentSet, or Nobody
Throws:
CompilerException - if the code fails to compile
IllegalStateException - if called from the AWT event queue thread

getProcedures

public String getProcedures()
Returns the contents of the Procedures tab.

Returns:
contents of Procedures tab

setProcedures

public void setProcedures(String source)
Replaces the contents of the Procedures tab. Does not recompile the model.

Parameters:
source - new contents

openFromSource

public void openFromSource(String name,
                           String path,
                           String source)
                    throws org.nlogo.window.InvalidVersionException
Opens a model stored in a string.

Parameters:
name - Model name (will appear in the main window's title bar)
source - The complete model, including widgets and so forth, in the same format as it would be stored in a file.
Throws:
org.nlogo.window.InvalidVersionException

main

public static void main(String[] args)

toURL

public static URL toURL(File file)
                 throws MalformedURLException
Throws:
MalformedURLException