Example #1
0
  public final void elementClosed() {
    // ok, find out how the ellipse is defined

    // do we have a centre?
    if (_theOrigin != null) {
      // so, this is an absolute position solution
      _thisSolution.buildSetOrigin(_theOrigin);

      // and reset the vector
      _thisSolution.buildSetVector(0d, null, 0d);
    } else {
      // aah, it's relative - build up the vector
      final double theDepth = 0;
      _thisSolution.buildSetVector(_theBearingDegs, _theRange, theDepth);

      // and reset the position
      _thisSolution.buildSetOrigin(null);
    }

    // and carry on with the other parameters
    _thisSolution.buildSetTargetState(_course, _speed, _depth);

    // and the ellipse
    _thisSolution.buildSetEllipse(_orientationDegs, _maxima, _minima);

    addSolution(_thisSolution);

    // reset our variables
    _thisSolution = null;
    _theRange = null;
    _theOrigin = null;
    _orientationDegs = 0d;
    _maxima = null;
    _minima = null;
  }
Example #2
0
  public static void exportSolution(
      final Debrief.Wrappers.TMAContactWrapper contact, final Element parent, final Document doc) {
    /*
     *
     * <!ELEMENT tma_solution (colour?, centre?)> <!ATTLIST tma_solution Dtg
     * CDATA #REQUIRED Bearing CDATA #IMPLIED Range CDATA #IMPLIED Visible (TRUE
     * | FALSE) "TRUE" Label CDATA #REQUIRED LabelShowing (TRUE | FALSE) "TRUE"
     * LineShowing (TRUE | FALSE) "TRUE" EllipseShowing (TRUE | FALSE) "TRUE"
     * SymbolShowing (TRUE | FALSE) "TRUE" LabelLocation (Top | Left | Bottom |
     * Centre | Right) "Left" Course CDATA #REQUIRED Speed CDATA #REQUIRED Depth
     * CDATA #REQUIRED Orientation CDATA #REQUIRED Maxima CDATA #REQUIRED Minima
     * CDATA #REQUIRED >
     */
    final Element eFix = doc.createElement(MY_NAME);

    // note, we are accessing the "actual" colour for this fix, we are not using
    // the
    // normal getColor method which may return the track colour
    final java.awt.Color fCol = contact.getActualColor();
    if (fCol != null) ColourHandler.exportColour(fCol, eFix, doc);

    // are we absolute or relative?
    final WorldLocation origin = contact.buildGetOrigin();
    if (origin != null) {
      // so, absolute - output it
      LocationHandler.exportLocation(origin, "centre", eFix, doc);
    } else {
      // so, relative - output it
      eFix.setAttribute("Bearing", writeThis(contact.getBearing()));

      // don't do range by hand, automate it
      WorldDistanceHandler.exportDistance(RANGE, contact.getRange(), eFix, doc);
    }

    // carry on with the common parameters
    eFix.setAttribute("Dtg", writeThis(contact.getDTG()));
    eFix.setAttribute("Visible", writeThis(contact.getVisible()));

    // now the label/visibility
    eFix.setAttribute("Symbol", contact.getSymbol());
    eFix.setAttribute("Label", toXML(contact.getLabel()));
    eFix.setAttribute("LabelShowing", writeThis(contact.getLabelVisible()));

    final Boolean lineVis = contact.getRawLineVisible();
    // is this the same as the parent?
    if (lineVis != null) {
      // only output the line visibility if it is different to the parent.
      eFix.setAttribute("LineShowing", writeThis(lineVis.booleanValue()));
    }

    eFix.setAttribute("EllipseShowing", writeThis(contact.getEllipseVisible()));
    eFix.setAttribute("SymbolShowing", writeThis(contact.getSymbolVisible()));

    // where is the label?
    lp.setValue(contact.getLabelLocation());
    final String val = lp.getAsText();
    if (val != null) eFix.setAttribute("LabelLocation", lp.getAsText());
    else System.out.println("WRONG LABEL VALUE!!!");

    // and the target vector
    eFix.setAttribute("Course", writeThis(contact.getTargetCourse()));
    eFix.setAttribute("Speed", writeThis(contact.getSpeed()));
    eFix.setAttribute("Depth", writeThis(contact.getDepth()));

    // and ellipse shape
    final EllipseShape ellipse = contact.buildGetEllipse();
    final double maxima = ellipse.getMaxima().getValueIn(WorldDistance.YARDS);
    final double minima = ellipse.getMinima().getValueIn(WorldDistance.YARDS);

    // did we find ellipse data?
    if ((maxima > 0.0001d) && (minima > 0.0001d)) {
      // yes, write it out
      eFix.setAttribute("Orientation", writeThis(ellipse.getOrientation()));

      WorldDistanceHandler.exportDistance(MAXIMA, ellipse.getMaxima(), eFix, doc);
      WorldDistanceHandler.exportDistance(MINIMA, ellipse.getMinima(), eFix, doc);
    }

    // done
    parent.appendChild(eFix);
  }