use of com.willwinder.ugs.nbp.designer.entities.EntityGroup in project Universal-G-Code-Sender by winder.
the class UgsDesignWriter method write.
@Override
public void write(OutputStream outputStream, Controller controller) {
try {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
DesignV1 design = new DesignV1();
design.setSettings(convertSettings(controller));
EntityGroup rootEntity = (EntityGroup) controller.getDrawing().getRootEntity();
design.setEntities(rootEntity.getChildren().stream().map(this::convertToEntity).collect(Collectors.toList()));
IOUtils.write(gson.toJson(design), outputStream, StandardCharsets.UTF_8);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.willwinder.ugs.nbp.designer.entities.EntityGroup in project Universal-G-Code-Sender by winder.
the class EntitiesTree method onSelectionEvent.
@Override
public void onSelectionEvent(SelectionEvent selectionEvent) {
EntityGroup rootEntity = (EntityGroup) controller.getDrawing().getRootEntity();
List<TreePath> treePathList = EntityTreeUtils.getSelectedPaths(controller, rootEntity, Collections.emptyList());
TreePath[] treePaths = treePathList.toArray(new TreePath[0]);
tree.setSelectionPaths(treePaths);
}
use of com.willwinder.ugs.nbp.designer.entities.EntityGroup in project Universal-G-Code-Sender by winder.
the class UgsDesignReaderTest method convertEntityToString.
private String convertEntityToString(Entity entity) {
when(controller.getSettings()).thenReturn(new Settings());
when(controller.getDrawing()).thenReturn(drawing);
EntityGroup group = new EntityGroup();
group.addChild(entity);
when(drawing.getRootEntity()).thenReturn(group);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
UgsDesignWriter writer = new UgsDesignWriter();
writer.write(baos, controller);
return new String(baos.toByteArray());
}
Aggregations