use of org.kie.workbench.common.stunner.svg.gen.model.impl.ViewDefinitionImpl in project kie-wb-common by kiegroup.
the class SVGGeneratorImpl method parseSVGViewSource.
private void parseSVGViewSource(final String viewId, final String svgPath, final StyleSheetDefinition styleSheetDefinition, final Consumer<ViewDefinitionImpl> viewDefinitionConsumer) {
final InputStream svgStream = loadResource(svgPath);
if (null != svgStream) {
try {
final ViewDefinitionImpl viewDefinition = parseSVGView(viewId, svgPath, svgStream, styleSheetDefinition);
viewDefinitionConsumer.accept(viewDefinition);
} catch (Exception e) {
throw new RuntimeException("Error while processing the SVG file [" + svgPath + "]", e);
}
} else {
throw new RuntimeException("No SVG file found at [" + svgPath + "]");
}
}
use of org.kie.workbench.common.stunner.svg.gen.model.impl.ViewDefinitionImpl in project kie-wb-common by kiegroup.
the class SVGGeneratorImpl method translate.
private ViewDefinitionImpl translate(final String viewId, final String svgPath, final Document document, final StyleSheetDefinition styleSheetDefinition) throws Exception {
final Path path = Paths.get(svgPath);
final String relativePath = path.getNameCount() > 1 ? path.subpath(0, path.getNameCount() - 1).toString() : "";
final SVGTranslatorContext context = new SVGTranslatorContext(document, relativePath, styleSheetDefinition);
if (null != viewId) {
context.setViewId(viewId);
}
final ViewDefinitionImpl viewDefinition = (ViewDefinitionImpl) translator.translate(context);
viewDefinition.setPath(svgPath);
viewDefinition.getStaticFields().putAll(context.getStaticStringMembers());
return viewDefinition;
}
use of org.kie.workbench.common.stunner.svg.gen.model.impl.ViewDefinitionImpl in project kie-wb-common by kiegroup.
the class SVGViewDefinitionGeneratorTest method testCheckReferencesExist.
@Test(expected = RuntimeException.class)
public void testCheckReferencesExist() throws Exception {
final ViewFactory viewFactory = new ViewFactoryImpl("view1", "org.kie.test", "MyType.¢lass");
final RectDefinition mainDef = new RectDefinition("rect1", 1, 2, 0);
final CircleDefinition circleDefinition = new CircleDefinition("circle1", 25);
final ViewDefinitionImpl viewDefinition = new ViewDefinitionImpl(ID, X, Y, WIDTH, HEIGHT, styleSheetDefinition, new ViewBoxDefinitionImpl(VBOX_MIN_X, VBOX_MIN_Y, VBOX_WIDTH, VBOX_HEIGHT), null, mainDef, circleDefinition);
viewDefinition.setFactoryMethodName("svgViewTest");
viewDefinition.setPath("svg-view-test.svg");
final ViewRefDefinition refDefinition = new ViewRefDefinitionImpl("#circle1", "rect1", "circle1", "circle1");
viewDefinition.getSVGViewRefs().add(refDefinition);
tested.generate(viewFactory, viewDefinition).toString();
}
Aggregations