use of net.parostroj.timetable.output2.impl.EndPositions in project grafikon by jub77.
the class XmlEndPositionsOutput method writeTo.
@Override
protected void writeTo(OutputParams params, OutputStream stream, TrainDiagram diagram) throws OutputException {
try {
// extract positions
PositionsExtractor pe = new PositionsExtractor(diagram);
List<Position> engines = pe.getEndPositions(diagram.getEngineCycleType().getCycles(), null);
List<Position> trainUnits = pe.getEndPositions(diagram.getTrainUnitCycleType().getCycles(), null);
EndPositions ep = new EndPositions();
ep.setEnginesPositions(engines);
ep.setTrainUnitsPositions(trainUnits);
JAXBContext context = JAXBContext.newInstance(EndPositions.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_ENCODING, this.getCharset().name());
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
Writer writer = new OutputStreamWriter(stream, this.getCharset());
m.marshal(ep, writer);
} catch (Exception e) {
throw new OutputException(e);
}
}
Aggregations