## org.ascape.view.nonvis
Class ScapeFromXMLView

    java.lang.Object
      org.ascape.model.event.DefaultScapeListener
          org.ascape.view.nonvis.NonGraphicView
              org.ascape.view.nonvis.ScapeFromXMLView

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, java.util.EventListener, ScapeListener, HasName

    public class ScapeFromXMLView

extends NonGraphicView

A view that instantiates a scape with the contents of an XML file. Agents will be assigned properties based on the values as defined in this example. <agent> </agent> This would create an agent of with a foodState of 0.66542, a mode of 1, a timeWaitingForFood of 14, and a vision of 40. All values specified in the header must be Java properties; that is, there must be getters and setters defined in the agent for each value. How these agents are created is specified by the attributes sizeMode, readOrder, and assignmentOrder. SizeMode determines whether the scape's size will be set by the number of agents defined in the XML file or by the default size of the scape. AssignmentOrder determines whether agents will be selected to receive XML data randomly or sequentially. ReadOrder determines whether XML data will be read randomly or sequentially. These flags are set in the input file (where the data is), and not in the Control file (typically "run.xml"). If values for any or all of these attributes are not specified in the XML file, the defaults are: size by file, and sequentially for both orders. This was written by drawing extensively from ScapeFromFileView. User: jmiller Date: Jan 10, 2006 Time: 10:22:32 AM To change this template use Options | File Templates.

See Also:
  Serialized Form

Field Summary
`static int` `RANDOM_ORDER` The Constant RANDOM_ORDER.
`static int` `SEQUENTIAL_ORDER` The Constant SEQUENTIAL_ORDER.
`static int` `SIZE_BY_FILE` Set scape size by the number of entries in the xml file.
`static int` `SIZE_BY_SCAPE` Set scape size by the existing size of the scape.
`static int` `UNDEFINED_MODE` The Constant UNDEFINED_MODE.
`static int` `UNDEFINED_ORDER` The Constant UNDEFINED_ORDER.

Fields inherited from class org.ascape.model.event.DefaultScapeListener
`listeningToScape, name, scape`

Constructor Summary
`ScapeFromXMLView()`

Method Summary
`int` `getAssignmentOrder()` Gets the assignment order.
`int` `getMode()` Gets the mode.
`int` `getReadOrder()` Gets the read order.
`void` `parseFile(java.lang.String inputFileName)` Parse in the XML file, and set the root element and set flags (mode, assignmentOrder, readOrder).
`void` `parseStream(java.io.InputStream is)` Parse in the XML file, and set the root element and set flags (mode, assignmentOrder, readOrder).
`void` `scapeAdded(ScapeEvent scapeEvent)` Add the view to the scape, registering it as a listener, and ensuring that it hasn't been added to any other scapes.
`void` `scapeInitialized(ScapeEvent scapeEvent)` Called immediatly after the scape is initialized.
`void` `setAssignmentOrder(int assignmentOrder)` Sets the assignment order.
`void` `setMode(int mode)` Sets the mode.
`void` `setReadOrder(int readOrder)` Sets the read order.

Methods inherited from class org.ascape.view.nonvis.NonGraphicView
`isGraphic`

Methods inherited from class org.ascape.model.event.DefaultScapeListener
`clone, environmentQuiting, getName, getScape, isLifeOfScape, isNotifyScapeAutomatically, notifyScapeUpdated, scapeClosing, scapeDeserialized, scapeIterated, scapeNotification, scapeRemoved, scapeSetup, scapeStarted, scapeStopped, setName, setNotifyScapeAutomatically, toString`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### UNDEFINED_MODE

    public static final int UNDEFINED_MODE

  The Constant UNDEFINED_MODE.

  See Also:
    Constant Field Values

### SIZE_BY_FILE

    public static final int SIZE_BY_FILE

  Set scape size by the number of entries in the xml file.

  See Also:
    Constant Field Values

### SIZE_BY_SCAPE

    public static final int SIZE_BY_SCAPE

  Set scape size by the existing size of the scape.

  See Also:
    Constant Field Values

### UNDEFINED_ORDER

    public static final int UNDEFINED_ORDER

  The Constant UNDEFINED_ORDER.

  See Also:
    Constant Field Values

### RANDOM_ORDER

    public static final int RANDOM_ORDER

  The Constant RANDOM_ORDER.

  See Also:
    Constant Field Values

### SEQUENTIAL_ORDER

    public static final int SEQUENTIAL_ORDER

  The Constant SEQUENTIAL_ORDER.

  See Also:
    Constant Field Values

Constructor Detail

### ScapeFromXMLView

    public ScapeFromXMLView()

Method Detail

### parseFile

    public void parseFile(java.lang.String inputFileName)

  Parse in the XML file, and set the root element and set flags (mode, assignmentOrder, readOrder).

  Parameters:
    `inputFileName` - the input file name

### parseStream

    public void parseStream(java.io.InputStream is)

  Parse in the XML file, and set the root element and set flags (mode, assignmentOrder, readOrder).

  Parameters:
    `is` - the is

### scapeAdded

    public void scapeAdded(ScapeEvent scapeEvent)
                    throws java.util.TooManyListenersException

  Add the view to the scape, registering it as a listener, and ensuring that it hasn't been added to any other scapes.

  Specified by:
    `scapeAdded` in interface `ScapeListener`
  Overrides:
    `scapeAdded` in class `DefaultScapeListener`
  Parameters:
    `scapeEvent` - the event for this scape to make this view the observer of
  Throws:
    `java.util.TooManyListenersException` - the too many listeners exception
    `java.util.TooManyListenersException` - on attempt to add a scape when one is allready added

### scapeInitialized

    public void scapeInitialized(ScapeEvent scapeEvent)

  Called immediatly after the scape is initialized.

  Specified by:
    `scapeInitialized` in interface `ScapeListener`
  Overrides:
    `scapeInitialized` in class `DefaultScapeListener`
  Parameters:
    `scapeEvent` - the scape event

### getAssignmentOrder

    public int getAssignmentOrder()

  Gets the assignment order.

  Returns:
    the assignment order

### setAssignmentOrder

    public void setAssignmentOrder(int assignmentOrder)

  Sets the assignment order.

  Parameters:
    `assignmentOrder` - the new assignment order

### getReadOrder

    public int getReadOrder()

  Gets the read order.

  Returns:
    the read order

### setReadOrder

    public void setReadOrder(int readOrder)

  Sets the read order.

  Parameters:
    `readOrder` - the new read order

### getMode

    public int getMode()

  Gets the mode.

  Returns:
    the mode

### setMode

    public void setMode(int mode)

  Sets the mode.

  Parameters:
    `mode` - the new mode