Search in sources :

Example 1 with Cycles

use of net.parostroj.timetable.output2.impl.Cycles 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 2 with Cycles

use of net.parostroj.timetable.output2.impl.Cycles 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 3 with Cycles

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

the class CustomCyclesTemplateBinding method addSpecific.

@Override
protected void addSpecific(OutputParams params, Map<String, Object> binding, TrainDiagram diagram, Locale locale) {
    // check for type
    OutputParam param = params.get("cycle_type");
    TrainsCycleType type = param != null ? param.getValue(TrainsCycleType.class) : null;
    // extract cycles
    CustomCyclesExtractor ece = new CustomCyclesExtractor(SelectionHelper.selectCycles(params, diagram, type));
    List<CustomCycle> cycles = ece.getCycles();
    // call template
    binding.put("cycles", cycles);
}
Also used : OutputParam(net.parostroj.timetable.output2.OutputParam) TrainsCycleType(net.parostroj.timetable.model.TrainsCycleType)

Example 4 with Cycles

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

the class XmlCustomCyclesOutput method writeTo.

@Override
protected void writeTo(OutputParams params, OutputStream stream, TrainDiagram diagram) throws OutputException {
    try {
        // check for type
        OutputParam param = params.get("cycle_type");
        TrainsCycleType type = param != null ? param.getValue(TrainsCycleType.class) : null;
        // extract
        CustomCyclesExtractor tuce = new CustomCyclesExtractor(SelectionHelper.selectCycles(params, diagram, type));
        CustomCycles cycles = new CustomCycles(tuce.getCycles());
        JAXBContext context = JAXBContext.newInstance(CustomCycles.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(cycles, writer);
    } catch (Exception e) {
        throw new OutputException(e);
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) CustomCycles(net.parostroj.timetable.output2.impl.CustomCycles) OutputParam(net.parostroj.timetable.output2.OutputParam) OutputException(net.parostroj.timetable.output2.OutputException) CustomCyclesExtractor(net.parostroj.timetable.output2.impl.CustomCyclesExtractor) JAXBContext(javax.xml.bind.JAXBContext) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) OutputException(net.parostroj.timetable.output2.OutputException) TrainsCycleType(net.parostroj.timetable.model.TrainsCycleType)

Example 5 with Cycles

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

the class XmlDriverCyclesOutput method writeTo.

@Override
protected void writeTo(OutputParams params, OutputStream stream, TrainDiagram diagram) throws OutputException {
    try {
        DriverCyclesExtractor dce = new DriverCyclesExtractor(diagram, SelectionHelper.selectCycles(params, diagram, diagram.getDriverCycleType()), true);
        DriverCycles cycles = dce.getDriverCycles();
        JAXBContext context = JAXBContext.newInstance(DriverCycles.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(cycles, writer);
    } catch (Exception e) {
        throw new OutputException(e);
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) OutputException(net.parostroj.timetable.output2.OutputException) JAXBContext(javax.xml.bind.JAXBContext) OutputStreamWriter(java.io.OutputStreamWriter) DriverCyclesExtractor(net.parostroj.timetable.output2.impl.DriverCyclesExtractor) DriverCycles(net.parostroj.timetable.output2.impl.DriverCycles) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) OutputException(net.parostroj.timetable.output2.OutputException)

Aggregations

OutputStreamWriter (java.io.OutputStreamWriter)4 Writer (java.io.Writer)4 JAXBContext (javax.xml.bind.JAXBContext)4 Marshaller (javax.xml.bind.Marshaller)4 OutputException (net.parostroj.timetable.output2.OutputException)4 Cycles (net.parostroj.timetable.output2.impl.Cycles)3 Position (net.parostroj.timetable.output2.impl.Position)3 PositionsExtractor (net.parostroj.timetable.output2.impl.PositionsExtractor)3 TrainsCycleType (net.parostroj.timetable.model.TrainsCycleType)2 OutputParam (net.parostroj.timetable.output2.OutputParam)2 CustomCycles (net.parostroj.timetable.output2.impl.CustomCycles)1 CustomCyclesExtractor (net.parostroj.timetable.output2.impl.CustomCyclesExtractor)1 DriverCycles (net.parostroj.timetable.output2.impl.DriverCycles)1 DriverCyclesExtractor (net.parostroj.timetable.output2.impl.DriverCyclesExtractor)1 EngineCycles (net.parostroj.timetable.output2.impl.EngineCycles)1 EngineCyclesExtractor (net.parostroj.timetable.output2.impl.EngineCyclesExtractor)1 StartPositions (net.parostroj.timetable.output2.impl.StartPositions)1