use of org.gephi.preview.api.PreviewProperties in project gephi by gephi.
the class SVGExporter method execute.
@Override
public boolean execute() {
PreviewController controller = Lookup.getDefault().lookup(PreviewController.class);
controller.getModel(workspace).getProperties().putValue(PreviewProperty.VISIBILITY_RATIO, 1.0);
controller.refreshPreview(workspace);
PreviewProperties props = controller.getModel(workspace).getProperties();
props.putValue(SVGTarget.SCALE_STROKES, scaleStrokes);
props.putValue(PreviewProperty.MARGIN, new Float((float) margin));
target = (SVGTarget) controller.getRenderTarget(RenderTarget.SVG_TARGET, workspace);
if (target instanceof LongTask) {
((LongTask) target).setProgressTicket(progress);
}
try {
controller.render(target, workspace);
// creates SVG-to-SVG transcoder
SVGTranscoder t = new SVGTranscoder();
t.addTranscodingHint(SVGTranscoder.KEY_XML_DECLARATION, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
// sets transcoder input and output
TranscoderInput input = new TranscoderInput(target.getDocument());
// performs transcoding
try {
TranscoderOutput output = new TranscoderOutput(writer);
t.transcode(input, output);
} finally {
writer.close();
props.removeSimpleValue(PreviewProperty.MARGIN);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
Progress.finish(progress);
return !cancel;
}
use of org.gephi.preview.api.PreviewProperties in project gephi by gephi.
the class PDFRenderTargetBuilder method buildRenderTarget.
@Override
public RenderTarget buildRenderTarget(PreviewModel previewModel) {
CanvasSize cs = previewModel.getGraphicsCanvasSize();
PreviewProperties properties = previewModel.getProperties();
float marginBottom = properties.getFloatValue(PDFTarget.MARGIN_BOTTOM);
float marginLeft = properties.getFloatValue(PDFTarget.MARGIN_LEFT);
float marginRight = properties.getFloatValue(PDFTarget.MARGIN_RIGHT);
float marginTop = properties.getFloatValue(PDFTarget.MARGIN_TOP);
com.itextpdf.text.Rectangle pageSize = properties.getValue(PDFTarget.PAGESIZE);
boolean landscape = properties.getBooleanValue(PDFTarget.LANDSCAPE);
PdfContentByte cb = properties.getValue(PDFTarget.PDF_CONTENT_BYTE);
PDFRenderTargetImpl renderTarget = new PDFRenderTargetImpl(cb, cs, pageSize, marginLeft, marginRight, marginTop, marginBottom, landscape);
return renderTarget;
}
Aggregations