Пример #1
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);
  }