use of net.parostroj.timetable.output2.OutputException 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);
}
}
use of net.parostroj.timetable.output2.OutputException in project grafikon by jub77.
the class XmlEngineCyclesOutput method writeTo.
@Override
protected void writeTo(OutputParams params, OutputStream stream, TrainDiagram diagram) throws OutputException {
try {
EngineCyclesExtractor tuce = new EngineCyclesExtractor(SelectionHelper.selectCycles(params, diagram, diagram.getEngineCycleType()));
EngineCycles cycles = new EngineCycles(tuce.getEngineCycles());
JAXBContext context = JAXBContext.newInstance(EngineCycles.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);
}
}
use of net.parostroj.timetable.output2.OutputException in project grafikon by jub77.
the class PdfTransformer method getFopFactory.
private static FopFactory getFopFactory(URIResolver resolver) throws OutputException {
try (InputStream fopCfgStream = ResourceHelper.getStream("fop/fop-cfg.xml", PdfTransformer.class.getClassLoader())) {
// base uri is empty
URI baseURI = new URI("");
FopConfParser parser = new FopConfParser(fopCfgStream, EnvironmentalProfileFactory.createRestrictedIO(baseURI, convertResolver(resolver)));
FopFactory fopFactory = parser.getFopFactoryBuilder().build();
fopFactory.getFontManager().disableFontCache();
return fopFactory;
} catch (IOException | SAXException | URISyntaxException e) {
throw new OutputException("Error creating FOP factory", e);
}
}
use of net.parostroj.timetable.output2.OutputException in project grafikon by jub77.
the class DrawOutput method processSvg.
private void processSvg(Collection<Image> images, OutputStream stream, DrawLayout layout) throws OutputException {
DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document.
String svgNS = "http://www.w3.org/2000/svg";
Document document = domImpl.createDocument(svgNS, "svg", null);
SVGGeneratorContext context = SVGGeneratorContext.createDefault(document);
context.setGraphicContextDefaults(new SVGGeneratorContext.GraphicContextDefaults());
// set default font
context.getGraphicContextDefaults().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
// set antialiasing
Map<Key, Object> map = new HashMap<>();
map.put(RenderingHints.KEY_ANTIALIASING, Boolean.TRUE);
map.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
context.getGraphicContextDefaults().setRenderingHints(new RenderingHints(map));
SVGGraphics2D g2d = new SVGGraphics2D(context, false);
List<Dimension> sizes = this.getSizes(images, g2d);
Dimension size = this.getTotalSize(sizes, layout);
g2d.setSVGCanvasSize(size);
this.drawImages(sizes, images, g2d, layout);
// write to ouput - do not use css style
boolean useCSS = false;
try {
Writer out = new OutputStreamWriter(stream, "UTF-8");
g2d.stream(out, useCSS);
} catch (IOException e) {
throw new OutputException(e.getMessage(), e);
}
}
Aggregations