Search in sources :

Example 6 with PreviewModel

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();
        }
    }
}
Also used : PreviewModel(org.gephi.preview.api.PreviewModel) ManagedRenderer(org.gephi.preview.api.ManagedRenderer)

Example 7 with PreviewModel

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();
}
Also used : PreviewModel(org.gephi.preview.api.PreviewModel)

Example 8 with PreviewModel

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;
}
Also used : PreviewModel(org.gephi.preview.api.PreviewModel) LongTask(org.gephi.utils.longtask.spi.LongTask) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) PreviewController(org.gephi.preview.api.PreviewController) BufferedImage(java.awt.image.BufferedImage)

Example 9 with PreviewModel

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());
    }
}
Also used : PreviewModel(org.gephi.preview.api.PreviewModel) PreviewProperty(org.gephi.preview.api.PreviewProperty) PreviewController(org.gephi.preview.api.PreviewController)

Example 10 with PreviewModel

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]));
    }
}
Also used : PreviewModel(org.gephi.preview.api.PreviewModel) ArrayList(java.util.ArrayList) ManagedRenderer(org.gephi.preview.api.ManagedRenderer)

Aggregations

PreviewModel (org.gephi.preview.api.PreviewModel)11 PreviewController (org.gephi.preview.api.PreviewController)5 ManagedRenderer (org.gephi.preview.api.ManagedRenderer)3 PreviewPreset (org.gephi.preview.api.PreviewPreset)2 PreviewProperty (org.gephi.preview.api.PreviewProperty)2 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 Image (java.awt.Image)1 BufferedImage (java.awt.image.BufferedImage)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 JPanel (javax.swing.JPanel)1 PreviewUIController (org.gephi.desktop.preview.api.PreviewUIController)1 Column (org.gephi.graph.api.Column)1 Node (org.gephi.graph.api.Node)1 Item (org.gephi.preview.api.Item)1 PreviewProperties (org.gephi.preview.api.PreviewProperties)1 PreviewUI (org.gephi.preview.spi.PreviewUI)1 Renderer (org.gephi.preview.spi.Renderer)1