Search in sources :

Example 1 with Position

use of net.parostroj.timetable.output2.impl.Position 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);
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) PositionsExtractor(net.parostroj.timetable.output2.impl.PositionsExtractor) Position(net.parostroj.timetable.output2.impl.Position) EndPositions(net.parostroj.timetable.output2.impl.EndPositions) OutputException(net.parostroj.timetable.output2.OutputException) JAXBContext(javax.xml.bind.JAXBContext) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) OutputException(net.parostroj.timetable.output2.OutputException)

Example 2 with Position

use of net.parostroj.timetable.output2.impl.Position in project grafikon by jub77.

the class XmlStartPositionsOutput 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.getStartPositions(diagram.getEngineCycleType().getCycles(), null);
        List<Position> trainUnits = pe.getStartPositions(diagram.getTrainUnitCycleType().getCycles(), null);
        List<Cycles> customCycles = pe.getStartPositionsCustom(null);
        StartPositions sp = new StartPositions();
        sp.setEnginesPositions(engines);
        sp.setTrainUnitsPositions(trainUnits);
        sp.setCustomCycles(customCycles);
        JAXBContext context = JAXBContext.newInstance(StartPositions.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(sp, writer);
    } catch (Exception e) {
        throw new OutputException(e);
    }
}
Also used : StartPositions(net.parostroj.timetable.output2.impl.StartPositions) Cycles(net.parostroj.timetable.output2.impl.Cycles) Marshaller(javax.xml.bind.Marshaller) PositionsExtractor(net.parostroj.timetable.output2.impl.PositionsExtractor) Position(net.parostroj.timetable.output2.impl.Position) OutputException(net.parostroj.timetable.output2.OutputException) JAXBContext(javax.xml.bind.JAXBContext) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) OutputException(net.parostroj.timetable.output2.OutputException)

Example 3 with Position

use of net.parostroj.timetable.output2.impl.Position in project grafikon by jub77.

the class EndsTemplateBinding method addSpecific.

@Override
protected void addSpecific(OutputParams params, Map<String, Object> map, TrainDiagram diagram, Locale locale) {
    // 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);
    List<Cycles> customCycles = pe.getEndPositionsCustom(null);
    // call template
    map.put("engines", engines);
    map.put("train_units", trainUnits);
    map.put("custom_cycles", customCycles);
}
Also used : Cycles(net.parostroj.timetable.output2.impl.Cycles) PositionsExtractor(net.parostroj.timetable.output2.impl.PositionsExtractor) Position(net.parostroj.timetable.output2.impl.Position)

Example 4 with Position

use of net.parostroj.timetable.output2.impl.Position in project grafikon by jub77.

the class StartsTemplateBinding method addSpecific.

@Override
protected void addSpecific(OutputParams params, Map<String, Object> map, TrainDiagram diagram, Locale locale) {
    Integer startTime = params.getParamValue("start.time", Integer.class);
    // extract positions
    PositionsExtractor pe = new PositionsExtractor(diagram);
    List<Position> engines = pe.getStartPositions(diagram.getEngineCycleType().getCycles(), startTime);
    List<Position> trainUnits = pe.getStartPositions(diagram.getTrainUnitCycleType().getCycles(), startTime);
    List<Cycles> customCycles = pe.getStartPositionsCustom(startTime);
    // call template
    map.put("engines", engines);
    map.put("train_units", trainUnits);
    map.put("custom_cycles", customCycles);
    map.put("start_time", startTime);
}
Also used : Cycles(net.parostroj.timetable.output2.impl.Cycles) PositionsExtractor(net.parostroj.timetable.output2.impl.PositionsExtractor) Position(net.parostroj.timetable.output2.impl.Position)

Aggregations

Position (net.parostroj.timetable.output2.impl.Position)4 PositionsExtractor (net.parostroj.timetable.output2.impl.PositionsExtractor)4 Cycles (net.parostroj.timetable.output2.impl.Cycles)3 OutputStreamWriter (java.io.OutputStreamWriter)2 Writer (java.io.Writer)2 JAXBContext (javax.xml.bind.JAXBContext)2 Marshaller (javax.xml.bind.Marshaller)2 OutputException (net.parostroj.timetable.output2.OutputException)2 EndPositions (net.parostroj.timetable.output2.impl.EndPositions)1 StartPositions (net.parostroj.timetable.output2.impl.StartPositions)1