Search in sources :

Example 1 with ContainerUnloader

use of org.gephi.io.importer.api.ContainerUnloader in project gephi-plugins-bootcamp by gephi.

the class InitalPositionProcessor method process.

@Override
public void process() {
    if (containers.length > 1) {
        throw new RuntimeException("This processor can only handle single containers");
    }
    ContainerUnloader container = containers[0];
    long hash = 0;
    //Calculate the hash of the current graph
    for (NodeDraft nodeDraft : container.getNodes()) {
        String id = nodeDraft.getId();
        hash += id.hashCode();
    }
    //Create a random with this seed
    Random random = new Random(hash);
    for (NodeDraft nodeDraft : container.getNodes()) {
        nodeDraft.setX((float) ((0.01 + random.nextDouble()) * 1000) - 500);
        nodeDraft.setY((float) ((0.01 + random.nextDouble()) * 1000) - 500);
    }
    //Call default processor
    super.process();
}
Also used : ContainerUnloader(org.gephi.io.importer.api.ContainerUnloader) Random(java.util.Random) NodeDraft(org.gephi.io.importer.api.NodeDraft)

Example 2 with ContainerUnloader

use of org.gephi.io.importer.api.ContainerUnloader in project gephi by gephi.

the class AppendProcessor method process.

@Override
public void process() {
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    if (containers.length > 1) {
        throw new RuntimeException("This processor can only handle single containers");
    }
    ContainerUnloader container = containers[0];
    //Workspace
    if (workspace == null) {
        workspace = pc.getCurrentWorkspace();
        if (workspace == null) {
            //Append mode but no workspace
            workspace = pc.newWorkspace(pc.getCurrentProject());
            pc.openWorkspace(workspace);
            processConfiguration(container, workspace);
        }
    }
    if (container.getSource() != null) {
        pc.setSource(workspace, container.getSource());
    }
    process(container, workspace);
    //Clean
    workspace = null;
    graphModel = null;
    containers = null;
    progressTicket = null;
}
Also used : ContainerUnloader(org.gephi.io.importer.api.ContainerUnloader) ProjectController(org.gephi.project.api.ProjectController)

Example 3 with ContainerUnloader

use of org.gephi.io.importer.api.ContainerUnloader in project gephi by gephi.

the class MergeProcessor method process.

@Override
public void process() {
    if (containers.length <= 1) {
        throw new RuntimeException("This processor can only handle multiple containers");
    }
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    //Workspace
    if (workspace == null) {
        workspace = pc.newWorkspace(pc.getCurrentProject());
        pc.openWorkspace(workspace);
    }
    processConfiguration(containers[0], workspace);
    for (ContainerUnloader container : containers) {
        process(container, workspace);
    }
    //Clean
    workspace = null;
    graphModel = null;
    containers = null;
    progressTicket = null;
}
Also used : ContainerUnloader(org.gephi.io.importer.api.ContainerUnloader) ProjectController(org.gephi.project.api.ProjectController)

Example 4 with ContainerUnloader

use of org.gephi.io.importer.api.ContainerUnloader in project gephi by gephi.

the class MultiProcessor method process.

@Override
public void process() {
    if (containers.length <= 1) {
        throw new RuntimeException("This processor can only handle multiple containers");
    }
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    for (ContainerUnloader container : containers) {
        if (workspace != null) {
            pc.openWorkspace(workspace);
        } else {
            workspace = pc.newWorkspace(pc.getCurrentProject());
        }
        processConfiguration(container, workspace);
        process(container, workspace);
        workspace = null;
    }
    //Clean
    workspace = null;
    graphModel = null;
    containers = null;
    progressTicket = null;
}
Also used : ContainerUnloader(org.gephi.io.importer.api.ContainerUnloader) ProjectController(org.gephi.project.api.ProjectController)

Example 5 with ContainerUnloader

use of org.gephi.io.importer.api.ContainerUnloader in project gephi by gephi.

the class DefaultProcessor method process.

@Override
public void process() {
    if (containers.length > 1) {
        throw new RuntimeException("This processor can only handle single containers");
    }
    ContainerUnloader container = containers[0];
    //Workspace
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    if (workspace == null) {
        workspace = pc.newWorkspace(pc.getCurrentProject());
        pc.openWorkspace(workspace);
    }
    processConfiguration(container, workspace);
    if (container.getSource() != null) {
        pc.setSource(workspace, container.getSource());
    }
    process(container, workspace);
    //Clean
    workspace = null;
    graphModel = null;
    containers = null;
    progressTicket = null;
}
Also used : ContainerUnloader(org.gephi.io.importer.api.ContainerUnloader) ProjectController(org.gephi.project.api.ProjectController)

Aggregations

ContainerUnloader (org.gephi.io.importer.api.ContainerUnloader)6 ProjectController (org.gephi.project.api.ProjectController)4 Random (java.util.Random)1 Container (org.gephi.io.importer.api.Container)1 NodeDraft (org.gephi.io.importer.api.NodeDraft)1 Scaler (org.gephi.io.processor.spi.Scaler)1