예제 #1
0
  public static void exportFix(
      final Debrief.Wrappers.FixWrapper fix,
      final org.w3c.dom.Element parent,
      final org.w3c.dom.Document doc) {
    /*
    <!ELEMENT fix (colour?, centre)>
    <!ATTLIST fix
      course CDATA #REQUIRED
      speed CDATA #REQUIRED
      dtg CDATA #REQUIRED
      visible (TRUE|FALSE) "TRUE"
      label CDATA #IMPLIED
      LabelShowing (TRUE|FALSE) #IMPLIED
      SymbolShowing (TRUE|FALSE) "TRUE"
      LabelLocation (Top|Left|Bottom|Centre|Right) "Left"
        */
    final Element eFix = doc.createElement("fix");
    eFix.setAttribute(
        "Course", "" + writeThis(MWC.Algorithms.Conversions.Rads2Degs(fix.getCourse())));
    eFix.setAttribute("Speed", "" + writeThis(fix.getSpeed()));
    eFix.setAttribute("Dtg", writeThis(fix.getTime()));
    eFix.setAttribute("Visible", writeThis(fix.getVisible()));
    eFix.setAttribute("Label", toXML(fix.getLabel()));
    eFix.setAttribute("LabelShowing", writeThis(fix.getLabelShowing()));
    eFix.setAttribute("LineShowing", writeThis(fix.getLineShowing()));
    eFix.setAttribute("SymbolShowing", writeThis(fix.getSymbolShowing()));
    eFix.setAttribute("ArrowShowing", writeThis(fix.getArrowShowing()));
    lp.setValue(fix.getLabelLocation());
    eFix.setAttribute("LabelLocation", lp.getAsText());

    // 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 = fix.getActualColor();
    if (fCol != null) {
      // just see if the colour is different to the parent
      final java.awt.Color parentColor = fix.getTrackWrapper().getColor();
      if (fCol.equals(parentColor)) {
        // hey, don't bother outputting the parent color
      } else {
        MWC.Utilities.ReaderWriter.XML.Util.ColourHandler.exportColour(fCol, eFix, doc);
      }
    }

    // and the font
    final java.awt.Font theFont = fix.getFont();
    if (theFont != null) {
      // ok, compare the font to the parent
      if (theFont.equals(fix.getTrackWrapper().getTrackFont())) {
        // don't bother outputting the font - it's the same as the parent anyway
      } else {
        FontHandler.exportFont(theFont, eFix, doc);
      }
    }

    // and now the centre item,
    MWC.Utilities.ReaderWriter.XML.Util.LocationHandler.exportLocation(
        fix.getLocation(), "centre", eFix, doc);

    parent.appendChild(eFix);
  }
예제 #2
0
  public final void handleOurselves(final String name, final Attributes atts) {
    // create the new items
    _theFix = new MWC.TacticalData.Fix();
    _theFixWrapper = new Debrief.Wrappers.FixWrapper(_theFix);
    lp.setValue(null);

    super.handleOurselves(name, atts);
  }
예제 #3
0
  public final void handleOurselves(final String name, final Attributes atts) {
    // create the new items
    _thisSolution = new Debrief.Wrappers.TMAContactWrapper();

    // reset the label location property editor
    lp.setValue(null);

    // and handle the parameters...
    super.handleOurselves(name, atts);
  }
예제 #4
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);
  }