use of org.gephi.project.api.ProjectController 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;
}
use of org.gephi.project.api.ProjectController 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;
}
use of org.gephi.project.api.ProjectController in project gephi by gephi.
the class StandardTest method setUp.
@BeforeMethod
public void setUp() {
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
projectController.newProject();
workspace = projectController.getCurrentWorkspace();
graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
}
use of org.gephi.project.api.ProjectController in project gephi by gephi.
the class FilterControllerImpl method exportToNewWorkspace.
@Override
public void exportToNewWorkspace(Query query) {
Graph result;
if (model.getCurrentQuery() == query) {
GraphView view = model.getCurrentResult();
if (view == null) {
return;
}
result = model.getGraphModel().getGraph(view);
} else {
FilterProcessor processor = new FilterProcessor();
GraphModel graphModel = model.getGraphModel();
result = (Graph) processor.process((AbstractQueryImpl) query, graphModel);
}
final Graph graphView = result;
new Thread(new Runnable() {
@Override
public void run() {
ProgressTicketProvider progressProvider = Lookup.getDefault().lookup(ProgressTicketProvider.class);
ProgressTicket ticket = null;
if (progressProvider != null) {
String msg = NbBundle.getMessage(FilterControllerImpl.class, "FilterController.exportToNewWorkspace.task");
ticket = progressProvider.createTicket(msg, null);
}
Progress.start(ticket);
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
Workspace newWorkspace = pc.newWorkspace(pc.getCurrentProject());
GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel(newWorkspace);
graphModel.bridge().copyNodes(graphView.getNodes().toArray());
Progress.finish(ticket);
String workspaceName = newWorkspace.getLookup().lookup(WorkspaceInformation.class).getName();
//StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(FilterControllerImpl.class, "FilterController.exportToNewWorkspace.status", workspaceName));
}
}, "Export filter to workspace").start();
}
use of org.gephi.project.api.ProjectController in project gephi by gephi.
the class ExportControllerImpl method exportFile.
@Override
public void exportFile(File file, Exporter fileExporter) throws IOException {
if (fileExporter.getWorkspace() == null) {
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
Workspace workspace = projectController.getCurrentWorkspace();
fileExporter.setWorkspace(workspace);
}
if (fileExporter instanceof ByteExporter) {
OutputStream stream = new BufferedOutputStream(new FileOutputStream(file));
((ByteExporter) fileExporter).setOutputStream(stream);
try {
fileExporter.execute();
} catch (Exception ex) {
try {
stream.flush();
stream.close();
} catch (IOException exe) {
}
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new RuntimeException(ex);
}
try {
stream.flush();
stream.close();
} catch (IOException ex) {
}
} else if (fileExporter instanceof CharacterExporter) {
Writer writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
((CharacterExporter) fileExporter).setWriter(writer);
try {
fileExporter.execute();
} catch (Exception ex) {
try {
writer.flush();
writer.close();
} catch (IOException exe) {
}
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new RuntimeException(ex);
}
try {
writer.flush();
writer.close();
} catch (IOException ex) {
}
}
}
Aggregations