Package org.gephi.preview.api

Examples of org.gephi.preview.api.PreviewController


    public static final String SORT_COLUMN = "sort.column";

    @Override
    public Item[] getItems(Graph graph, AttributeModel attributeModel) {
        //Get the current preview model, little hack to get the current workspace from the graph
        PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
        PreviewModel previewModel = previewController.getModel(graph.getGraphModel().getWorkspace());
       
        //Get the sort column from the properties, if any
        PreviewProperties previewProperties = previewModel.getProperties();
        final AttributeColumn sortColumn = previewProperties.getValue(SORT_COLUMN);
       
View Full Code Here


    private ProcessingTarget target;

    @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("width", width);
        props.putValue("height", height);
        target = (ProcessingTarget) controller.getRenderTarget(RenderTarget.PROCESSING_TARGET, workspace);

        try {
            target.refresh();

            PGraphicsJava2D pg2 = (PGraphicsJava2D) target.getGraphics();
View Full Code Here

    private Rectangle pageSize = PageSize.A4;

    public boolean execute() {
        Progress.start(progress);

        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();

        Rectangle size = new Rectangle(pageSize);
        if (landscape) {
            size = new Rectangle(pageSize.rotate());
        }
        Color col = props.getColorValue(PreviewProperty.BACKGROUND_COLOR);
        size.setBackgroundColor(new BaseColor(col.getRed(), col.getGreen(), col.getBlue()));

        Document document = new Document(size);
        PdfWriter pdfWriter = null;
        try {
            pdfWriter = PdfWriter.getInstance(document, stream);
            pdfWriter.setPdfVersion(PdfWriter.PDF_VERSION_1_5);
            pdfWriter.setFullCompression();

        } catch (DocumentException ex) {
            Exceptions.printStackTrace(ex);
        }
        document.open();
        PdfContentByte cb = pdfWriter.getDirectContent();
        cb.saveState();

        props.putValue(PDFTarget.LANDSCAPE, landscape);
        props.putValue(PDFTarget.PAGESIZE, size);
        props.putValue(PDFTarget.MARGIN_TOP, new Float((float) marginTop));
        props.putValue(PDFTarget.MARGIN_LEFT, new Float((float) marginLeft));
        props.putValue(PDFTarget.MARGIN_BOTTOM, new Float((float) marginBottom));
        props.putValue(PDFTarget.MARGIN_RIGHT, new Float((float) marginRight));
        props.putValue(PDFTarget.PDF_CONTENT_BYTE, cb);
        target = (PDFTarget) controller.getRenderTarget(RenderTarget.PDF_TARGET, workspace);
        if (target instanceof LongTask) {
            ((LongTask) target).setProgressTicket(progress);
        }

        try {
            controller.render(target, workspace);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        cb.restoreState();
View Full Code Here

        //background color
        ((JColorButton) backgroundButton).addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
                previewController.getModel().getProperties().putValue(PreviewProperty.BACKGROUND_COLOR, (Color) evt.getNewValue());
                PreviewUIController previewUIController = Lookup.getDefault().lookup(PreviewUIController.class);
                previewUIController.refreshPreview();
            }
        });
        southBusyLabel.setVisible(false);
View Full Code Here

    }

    public void initTarget(PreviewUIModel previewUIModel) {
        // inits the preview applet
        if (previewUIModel != null && target == null) {
            PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
            Color background = previewController.getModel().getProperties().getColorValue(PreviewProperty.BACKGROUND_COLOR);
            if (background != null) {
                setBackgroundColor(background);
            }

            target = (G2DTarget) previewController.getRenderTarget(RenderTarget.G2D_TARGET);
            if (target != null) {
                sketch = new PreviewSketch(target);
                sketchPanel.add(sketch, BorderLayout.CENTER);
            }
        } else if (previewUIModel == null) {
View Full Code Here

    @Override
    public boolean execute() {
        Progress.start(progress);

        PreviewController controller = Lookup.getDefault().lookup(PreviewController.class);
        controller.getModel(workspace).getProperties().putValue(PreviewProperty.VISIBILITY_RATIO, 1.0);

        PreviewProperties props = controller.getModel(workspace).getProperties();
        props.putValue("width", width);
        props.putValue("height", height);
        Color oldColor = props.getColorValue(PreviewProperty.BACKGROUND_COLOR);
        if (transparentBackground) {
            props.putValue(PreviewProperty.BACKGROUND_COLOR, new Color(255, 255, 255, 0));//White transparent
        }
        props.putValue(PreviewProperty.MARGIN, new Float((float) margin));
        controller.refreshPreview(workspace);
        target = (G2DTarget) controller.getRenderTarget(RenderTarget.G2D_TARGET, workspace);
        if (target instanceof LongTask) {
            ((LongTask) target).setProgressTicket(progress);
        }
        //Fix bug caused by keeping width and height in the workspace preview properties.
        //When a .gephi file is loaded later with these properties PGraphics will be created instead of a PApplet
View Full Code Here

    //Settings
    private boolean scaleStrokes = false;
    private float margin = 4;

    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\"?>");
View Full Code Here

        if (UIUtils.isAquaLookAndFeel()) {
            mainPanel.setBackground(UIManager.getColor("NbExplorerView.background"));
        }

        PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);

        // property sheet
        propertySheet = new PropertySheet();
        propertySheet.setNodes(new Node[]{new PreviewNode(propertySheet)});
        propertySheet.setDescriptionAreaVisible(false);

        // renderer manager - show only if at least 1 plugin renderer exists
        if (previewController.isAnyPluginRendererRegistered()) {
            rendererManager = new RendererManager();
        }

        if (rendererManager != null || Lookup.getDefault().lookupAll(PreviewUI.class).size() > 0) {
            //Tabs for property sheet, manager and preview UI
View Full Code Here

            }
            for (PreviewUI pui : Lookup.getDefault().lookupAll(PreviewUI.class)) {
                pui.unsetup();
            }
            if (previewModel != null) {
                PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
                PreviewModel pModel = previewController.getModel();
                //Add new tabs
                for (PreviewUI pui : Lookup.getDefault().lookupAll(PreviewUI.class)) {
                    pui.setup(pModel);
                    JPanel pluginPanel = pui.getPanel();
                    if (UIUtils.isAquaLookAndFeel()) {
View Full Code Here

@ServiceProvider(service=WorkspaceDuplicateProvider.class)
public class PreviewWorkspaceDuplicateProvider implements WorkspaceDuplicateProvider{

    @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());
        }
View Full Code Here

TOP

Related Classes of org.gephi.preview.api.PreviewController

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.