Exemple #1
0
    /** ok, the importer has now finished, we can tidy up now */
    public final void doFinished() {
      // also have a pass through to set the stepper in any narratives
      // try to set the pointer to the TimeStepper in the narratives, if there are any
      Session newSession = _theApplication.getCurrentSession();
      if (newSession != null) {
        Layers theData = newSession.getData();
        Debrief.GUI.Views.PlainView pv = newSession.getCurrentView();
        if (pv instanceof Debrief.GUI.Views.AnalysisView) {
          int len = theData.size();
          for (int i = 0; i < len; i++) {
            Layer ly = theData.elementAt(i);
            if (ly instanceof Debrief.Wrappers.NarrativeWrapper) {
              @SuppressWarnings("unused")
              Debrief.Wrappers.NarrativeWrapper nw = (Debrief.Wrappers.NarrativeWrapper) ly;
            } // whether this is a narrative
          } // through the layers
        } // whether this is an analysis view
      } // if we managed to create a session

      // put the filename into the MRU
      Debrief.GUI.Frames.Application.addToMru(_theFile.getPath());

      // and restore the application cursor
      _theApplication.restoreCursor();
    }
Exemple #2
0
  public void assignTracks(final String primaryTrack, final Vector<String> secondaryTracks) {
    // ok - find the matching tracks/
    final Object theP = _theLayers.findLayer(primaryTrack);
    if (theP != null) {
      if (theP instanceof WatchableList) {
        _thePrimary = (WatchableList) theP;
      }
    }

    // do we have secondaries?
    if (secondaryTracks != null) {
      // and now the secs
      final Vector<Layer> secs = new Vector<Layer>(0, 1);
      final Iterator<String> iter = secondaryTracks.iterator();
      while (iter.hasNext()) {
        final String thisS = iter.next();
        final Layer theS = _theLayers.findLayer(thisS);
        if (theS != null)
          if (theS instanceof WatchableList) {
            secs.add(theS);
          }
      }

      if (secs.size() > 0) {
        _theSecondaries = new WatchableList[] {};
        _theSecondaries = secs.toArray(_theSecondaries);
      }
    }
  }
    public void run() {
      for (int cnt = 0; cnt < _subjects.length; cnt++) {
        final Editable thisSubject = _subjects[cnt];
        try {
          _method.invoke(thisSubject, new Object[0]);

        } catch (final IllegalArgumentException e) {
          CorePlugin.logError(Status.ERROR, "whilst firing method from right-click", e);
        } catch (final IllegalAccessException e) {
          CorePlugin.logError(Status.ERROR, "whilst firing method from right-click", e);
        } catch (final InvocationTargetException e) {
          CorePlugin.logError(Status.ERROR, "whilst firing method from right-click", e);
        }
      }

      // hmm, the method may have actually changed the data, we need to
      // find out if it
      // needs an extend
      if (_method.isAnnotationPresent(FireExtended.class)) {
        _theLayers.fireExtended(null, _topLayer);
      } else if (_method.isAnnotationPresent(FireReformatted.class)) {
        _theLayers.fireReformatted(_topLayer);
      } else {
        // hey, let's do a redraw aswell...
        _theLayers.fireModified(_topLayer);
      }
    }
Exemple #4
0
  @Override
  public void fireTracksChanged() {
    // bugger, just double-check that our layers are still in there...

    // do we have a primary?
    if (_thePrimary != null) {
      Layer found = _theLayers.findLayer(_thePrimary.getName());

      // did we find it?
      if (found == null) {
        // aah, what if it's an annotation in a base layer?
        final Enumeration<Editable> enumer = _theLayers.elements();
        while (enumer.hasMoreElements() && (found == null)) {
          final Layer thisL = (Layer) enumer.nextElement();
          if (thisL instanceof BaseLayer) {
            final BaseLayer base = (BaseLayer) thisL;
            final Enumeration<Editable> enumer2 = base.elements();
            while (enumer2.hasMoreElements()) {
              final Editable thisE = enumer2.nextElement();
              if (thisE.getName().equals(_thePrimary.getName())) {
                found = base;
                break;
              }
            }
          }
        }

        // did it work?
        if (found == null) {
          // nope, better ditch the primary
          _thePrimary = null;
        }
      }
    }

    // now the secondaries!!!
    if (_theSecondaries != null) {
      final Vector<WatchableList> secsFound = new Vector<WatchableList>(0, 1);
      for (int i = 0; i < _theSecondaries.length; i++) {
        final WatchableList thisSec = _theSecondaries[i];
        secsFound.add(thisSec);
      }

      // and store the new secs list
      final WatchableList[] demo = new WatchableList[] {};
      _theSecondaries = secsFound.toArray(demo);
    }

    if (_myDataListeners != null) {
      final Iterator<TrackDataListener> iter = _myDataListeners.iterator();
      while (iter.hasNext()) {
        final TrackDataListener list = iter.next();
        list.tracksUpdated(_thePrimary, _theSecondaries);
      }
    }
  }
Exemple #5
0
    // TODO FIX-TEST
    public final void NtestRead() {
      final DebriefXMLReaderWriter reader = new DebriefXMLReaderWriter(null);
      final Layers res = new Layers();
      final String fName = "../org.mwc.debrief.legacy/src/test_tma_read_write.xml";

      final java.io.File fileTest = new File(fName);
      assertTrue("Test file not found:" + fName, fileTest.exists());

      try {
        final java.io.FileInputStream fis = new java.io.FileInputStream(fName);
        reader.importThis(fName, fis, res);

        // right, now check it contains our data
        final Layer layer = res.findLayer("TOMATO");
        assertNotNull("found tomato track");

        final TrackWrapper tw = (TrackWrapper) layer;
        final Enumeration<Editable> solutions = tw.getSolutions().elements();
        assertNotNull("found solutions", solutions);

        // find our solution track
        while (solutions.hasMoreElements()) {
          final TMAWrapper wrapper = (TMAWrapper) solutions.nextElement();
          assertEquals("found our solution", "TRACK_060", wrapper.getName());

          final Enumeration<Editable> contacts = wrapper.elements();
          while (contacts.hasMoreElements()) {
            final TMAContactWrapper contactWrapper = (TMAContactWrapper) contacts.nextElement();
            assertEquals("found first contact", "Trial label", contactWrapper.getLabel());
            assertEquals("correct symbol set", "Submarine", contactWrapper.getSymbol());
            assertEquals("correct vis set", true, contactWrapper.getVisible());
            assertEquals("correct label vis", true, contactWrapper.getLabelVisible());
            assertEquals("correct colour set", new Color(230, 200, 20), contactWrapper.getColor());
            assertEquals("correct ellipse vis", true, contactWrapper.getEllipseVisible());
            assertEquals("correct symbol vis", true, contactWrapper.getSymbolVisible());
            assertEquals("correct line vis", true, contactWrapper.getLineVisible());
            assertEquals(
                "correct label loc",
                new Integer(MWC.GUI.Properties.LocationPropertyEditor.RIGHT),
                contactWrapper.getLabelLocation());
            assertEquals("correct line course", 50, contactWrapper.getTargetCourse(), 0d);
            assertEquals("correct line speed", 12.4, contactWrapper.getSpeed(), 0d);
            assertEquals("correct line depth", 100, contactWrapper.getDepth(), 0d);
            final EllipseShape es = contactWrapper.buildGetEllipse();
            assertEquals("correct orientation", 45, es.getOrientation(), 0d);
            assertEquals(
                "correct maxima", 4000, es.getMaxima().getValueIn(WorldDistance.YARDS), 0.00001d);
            assertEquals(
                "correct minima", 2000, es.getMinima().getValueIn(WorldDistance.YARDS), 0.0001d);
          }
        }
      } catch (final FileNotFoundException e) {
        e.printStackTrace(); // To change body of catch statement use Options |
        // File Templates.
      }
    }
  /** create the painter which shows the points in this path */
  private void showPath() {
    final Layers theLayers = getChart().getLayers();
    Layer bl = theLayers.findLayer(editorName);
    if (bl == null) {
      bl = new BaseLayer();
      bl.setName(editorName);
      theLayers.addThisLayer(bl);
    }

    // now add ourselves to the editor layer
    bl.add(_myPlotter);
  }
 private void fireUpdate() {
   // hmm, the method may have actually changed the data, we need to
   // find out if it
   // needs an extend
   if (_setter.isAnnotationPresent(FireExtended.class)) {
     _layers.fireExtended(null, _parentLayer);
   } else if (_setter.isAnnotationPresent(FireReformatted.class)) {
     _layers.fireReformatted(_parentLayer);
   } else {
     // hey, let's do a redraw aswell...
     _layers.fireModified(_parentLayer);
   }
 }
Exemple #8
0
  /**
   * pass through the data, and assign any watchables as primary and secondary
   *
   * @param onlyAssignTracks only put TracksWrappers on the tote
   */
  public void autoAssign(final boolean onlyAssignTracks) {

    // check we have some data to search
    if (_theLayers != null) {

      // pass through the data to find the WatchableLists
      for (int l = 0; l < _theLayers.size(); l++) {
        final Layer layer = _theLayers.elementAt(l);

        if (layer instanceof WatchableList) {
          if (_theSecondaries != null) {
            // have we got our full set of secondarires yet?
            if (_theSecondaries.length >= MAX_SECONDARIES) {
              MWC.GUI.Dialogs.DialogFactory.showMessage("Secondary limit reached", MAX_MESSAGE);
              return;
            }
          }

          processWatchableList((WatchableList) layer, onlyAssignTracks);
        } else {
          final Enumeration<Editable> iter = layer.elements();
          while (iter.hasMoreElements()) {
            final Plottable p = (Plottable) iter.nextElement();
            if (p instanceof WatchableList) {

              if (_theSecondaries != null) {
                // have we got our full set of secondarires yet?
                if (_theSecondaries.length >= MAX_SECONDARIES) {
                  MWC.GUI.Dialogs.DialogFactory.showMessage("Secondary limit reached", MAX_MESSAGE);
                  return;
                }
              }

              processWatchableList((WatchableList) p, onlyAssignTracks);
            }
          }
        }
      }
    }
  }
Exemple #9
0
    public void testLists() {
      final TrackWrapper ta = new TrackWrapper();
      ta.setName("ta");
      final TrackWrapper tb = new TrackWrapper();
      tb.setName("tb");
      final TrackWrapper tc = new TrackWrapper();
      tc.setName("tc");
      final Layers theLayers = new Layers();
      theLayers.addThisLayer(ta);
      theLayers.addThisLayer(tb);
      theLayers.addThisLayer(tc);

      final String pri_a = "ta";
      final String pri_b = "tz";
      final String sec_b = "tb";
      final String sec_c = "tc";
      final String sec_d = "tz";
      final Vector<String> secs = new Vector<String>(0, 1);
      secs.add(sec_b);
      secs.add(sec_c);

      // create the mgr
      final TrackManager tm = new TrackManager(theLayers);

      // do some checks
      assertNull("pri empty", tm._thePrimary);
      assertNull("secs empty", tm._theSecondaries);
      assertNotNull("layers assigned", tm._theLayers);

      // now get going
      tm.assignTracks(pri_a, secs);

      // and do the tests
      assertNotNull("pri assigned", tm._thePrimary);
      assertEquals("pri matches", tm._thePrimary, ta);

      // and the secs
      assertNotNull("sec assigned", tm._theSecondaries);
      assertEquals("correct num", 2, tm._theSecondaries.length);

      // setup duff data
      secs.clear();
      secs.add(sec_b);
      secs.add(sec_d);

      // assign duff data
      tm.assignTracks(pri_b, secs);

      // and test duff data
      assertNotNull("pri still assigned", tm._thePrimary);
      assertEquals("pri matches", tm._thePrimary, ta);
      assertNotNull("sec assigned", tm._theSecondaries);
      assertEquals("correct num", 1, tm._theSecondaries.length);

      // assign more real data
      tm.assignTracks(sec_c, secs);

      // and test duff data
      assertNotNull("pri still assigned", tm._thePrimary);
      assertEquals("pri matches", tm._thePrimary, tc);
      assertNotNull("sec assigned", tm._theSecondaries);
      assertEquals("correct num", 1, tm._theSecondaries.length);
    }
 private void fireUpdate() {
   _layers.fireExtended(null, _parentLayer);
 }