public final void exportThisPlottable( final MWC.GUI.Plottable plottable, final org.w3c.dom.Element parent, final org.w3c.dom.Document doc) { // output the shape related stuff first final org.w3c.dom.Element ePlottable = doc.createElement(_myType); // export the common attributes super.exportThisPlottable(plottable, ePlottable, doc); // and the vector bits final Debrief.Wrappers.ShapeWrapper sw = (Debrief.Wrappers.ShapeWrapper) plottable; final MWC.GUI.Shapes.PlainShape ps = sw.getShape(); if (ps instanceof MWC.GUI.Shapes.VectorShape) { // export the attributes final MWC.GUI.Shapes.VectorShape cs = (MWC.GUI.Shapes.VectorShape) ps; MWC.Utilities.ReaderWriter.XML.Util.LocationHandler.exportLocation( cs.getLine_Start(), TL, ePlottable, doc); WorldDistanceHandler.exportDistance(DISTANCE, cs.getDistance(), ePlottable, doc); ePlottable.setAttribute(BEARING, writeThis(cs.getBearing())); ePlottable.setAttribute(ARROW_AT_END, writeThis(cs.getArrowAtEnd())); } else { throw new java.lang.RuntimeException("wrong shape passed to line exporter"); } // add ourselves to the output parent.appendChild(ePlottable); }
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); }