Search in sources :

Example 6 with TrainsCycleType

use of net.parostroj.timetable.model.TrainsCycleType 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 7 with TrainsCycleType

use of net.parostroj.timetable.model.TrainsCycleType 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)

Aggregations

TrainsCycleType (net.parostroj.timetable.model.TrainsCycleType)7 ArrayList (java.util.ArrayList)3 TrainsCycle (net.parostroj.timetable.model.TrainsCycle)3 OutputParam (net.parostroj.timetable.output2.OutputParam)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 Wrapper (net.parostroj.timetable.gui.wrappers.Wrapper)1 FNConnection (net.parostroj.timetable.model.FNConnection)1 TimeIntervalList (net.parostroj.timetable.model.TimeIntervalList)1 Train (net.parostroj.timetable.model.Train)1 TrainDiagram (net.parostroj.timetable.model.TrainDiagram)1 TrainsCycleItem (net.parostroj.timetable.model.TrainsCycleItem)1 TranslatedString (net.parostroj.timetable.model.TranslatedString)1 FreightConnection (net.parostroj.timetable.model.freight.FreightConnection)1 OutputException (net.parostroj.timetable.output2.OutputException)1