use of org.gephi.preview.api.PreviewModel in project gephi by gephi.
the class RendererManager method loadModelManagedRenderers.
/**
* Obtain renderers enabled state and order from the preview model.
*/
private void loadModelManagedRenderers() {
renderersList.clear();
PreviewModel model = previewController.getModel();
if (model != null) {
if (model.getManagedRenderers() != null) {
for (ManagedRenderer mr : model.getManagedRenderers()) {
renderersList.add(new RendererCheckBox(mr.getRenderer(), mr.isEnabled()));
}
} else {
restoreRenderersList();
}
}
}
use of org.gephi.preview.api.PreviewModel in project gephi by gephi.
the class RendererManager method setup.
private void setup() {
PreviewModel model = previewController.getModel();
setControlsEnabled(model != null);
refresh();
}
use of org.gephi.preview.api.PreviewModel in project gephi by gephi.
the class PNGExporter method execute.
@Override
public boolean execute() {
Progress.start(progress);
PreviewController ctrl = Lookup.getDefault().lookup(PreviewController.class);
PreviewModel m = ctrl.getModel(workspace);
setExportProperties(m);
ctrl.refreshPreview(workspace);
target = (G2DTarget) ctrl.getRenderTarget(RenderTarget.G2D_TARGET, workspace);
if (target instanceof LongTask) {
((LongTask) target).setProgressTicket(progress);
}
try {
target.refresh();
Progress.switchToIndeterminate(progress);
Image sourceImg = target.getImage();
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
img.getGraphics().drawImage(sourceImg, 0, 0, null);
ImageIO.write(img, "png", stream);
stream.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
discardExportProperties(m);
Progress.finish(progress);
return !cancel;
}
use of org.gephi.preview.api.PreviewModel in project gephi by gephi.
the class PreviewWorkspaceDuplicateProvider method duplicate.
@Override
public void duplicate(Workspace source, Workspace destination) {
PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
PreviewModel sourceModel = previewController.getModel(source);
PreviewModel destModel = previewController.getModel(destination);
destModel.setManagedRenderers(sourceModel.getManagedRenderers());
for (PreviewProperty property : sourceModel.getProperties().getProperties()) {
destModel.getProperties().putValue(property.getName(), property.getValue());
}
for (Entry<String, Object> property : sourceModel.getProperties().getSimpleValues()) {
destModel.getProperties().putValue(property.getKey(), property.getValue());
}
}
use of org.gephi.preview.api.PreviewModel in project gephi by gephi.
the class RendererManager method updateModelManagedRenderers.
/**
* Sets current renderers enabled state and order to the preview model.
*/
private void updateModelManagedRenderers() {
PreviewModel model = previewController.getModel();
if (model != null) {
ArrayList<ManagedRenderer> managedRenderers = new ArrayList<>();
for (RendererCheckBox rendererCheckBox : renderersList) {
managedRenderers.add(new ManagedRenderer(rendererCheckBox.renderer, rendererCheckBox.isSelected()));
}
model.setManagedRenderers(managedRenderers.toArray(new ManagedRenderer[0]));
}
}
Aggregations