예제 #1
0
  /** sort out the list of observers */
  void createObservers(final String file) {
    // get the list of observers
    final MWCXMLReader mxr =
        new ObserverListHandler() {
          public void setObserverList(final Vector<ScenarioObserver> list) {
            // add these observers, initialising them as we go
            final Iterator<ScenarioObserver> ii = list.iterator();
            while (ii.hasNext()) {
              final ScenarioObserver observer = (ScenarioObserver) ii.next();
              observer.setup(_myScenario);

              // is this observer a Editable?
              if (observer instanceof Plottable) {
                final Plottable thisEditor = (Plottable) observer;

                // add to the layers
                Layer observerLayer = _theData.findLayer(OBSERVER_NAME);

                // do we have the layer?
                if (observerLayer == null) {
                  // no, create it
                  observerLayer = new BaseLayer();
                  observerLayer.setName(OBSERVER_NAME);
                  _theData.addThisLayer(observerLayer);
                }

                // and add this observer
                observerLayer.add(thisEditor);
              }
            }
          }
        };

    try {
      mxr.reportNotHandledErrors(false);
      ASSETReaderWriter.importThis(mxr, file, new java.io.FileInputStream(file));
    } catch (SAXException e) {
      e.printStackTrace();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
  }
예제 #2
0
  /** get the participant */
  protected static ParticipantType getWeapon(
      final DetectionEvent detection,
      final Status currentLocation,
      final String weapon,
      final TargetType target) {
    ParticipantType res = null;

    final String fName = null;

    // swap in the keywords
    final String working = swapKeywords(detection, currentLocation, weapon, target);

    // put the string into a stream
    //    final StringBufferInputStream sr = new StringBufferInputStream(working);
    final InputStream sr = new ByteArrayInputStream(working.getBytes());

    // extract the participant
    res = ASSETReaderWriter.importParticipant(fName, sr);

    return res;
  }