public AttributeControllerImpl() { projectController = Lookup.getDefault().lookup(ProjectController.class); projectController.addWorkspaceListener( new WorkspaceListener() { public void initialize(Workspace workspace) { AttributeModel m = workspace.getLookup().lookup(AttributeModel.class); if (m == null) { workspace.add(new IndexedAttributeModel()); } } public void select(Workspace workspace) {} public void unselect(Workspace workspace) {} public void close(Workspace workspace) {} public void disable() {} }); if (projectController.getCurrentProject() != null) { for (Workspace workspace : projectController .getCurrentProject() .getLookup() .lookup(WorkspaceProvider.class) .getWorkspaces()) { AttributeModel m = workspace.getLookup().lookup(AttributeModel.class); if (m == null) { workspace.add(new IndexedAttributeModel()); } } } }
public Element writeXML(Document document, Workspace workspace) { FilterModelImpl filterModel = workspace.getLookup().lookup(FilterModelImpl.class); if (filterModel != null) { Element filterModelE = filterModel.writeXML(document); return filterModelE; } return null; }
public synchronized AttributeModel getModel(Workspace workspace) { AttributeModel model = workspace.getLookup().lookup(AttributeModel.class); if (model != null) { return model; } model = new IndexedAttributeModel(); workspace.add(model); return model; }
@Override public StatisticsModel getModel(Workspace workspace) { StatisticsModel statModel = workspace.getLookup().lookup(StatisticsModelImpl.class); if (statModel == null) { statModel = new StatisticsModelImpl(); workspace.add(statModel); } return statModel; }
@Override public void openWorkspace(Workspace workspace) { closeCurrentWorkspace(); getCurrentProject() .getLookup() .lookup(WorkspaceProviderImpl.class) .setCurrentWorkspace(workspace); workspace.getLookup().lookup(WorkspaceInformationImpl.class).open(); // Event fireWorkspaceEvent(EventType.SELECT, workspace); }
public synchronized AttributeModel getModel() { Workspace workspace = projectController.getCurrentWorkspace(); if (workspace != null) { AttributeModel model = workspace.getLookup().lookup(AttributeModel.class); if (model != null) { return model; } model = new IndexedAttributeModel(); workspace.add(model); return model; } return null; }
public boolean execute() { GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class); Graph graph = null; if (exportVisible) { graph = graphModel.getGraphVisible(); } else { graph = graphModel.getGraph(); } try { exportData(graph); } catch (Exception e) { throw new RuntimeException(e); } return !cancel; }
@Override public synchronized TimelineModel getModel(Workspace workspace) { return workspace.getLookup().lookup(TimelineModel.class); }
@Override public void setSource(Workspace workspace, String source) { workspace.getLookup().lookup(WorkspaceInformationImpl.class).setSource(source); }
@Override public void renameWorkspace(Workspace workspace, String name) { workspace.getLookup().lookup(WorkspaceInformationImpl.class).setName(name); }
public boolean execute() { attributeModel = workspace.getLookup().lookup(AttributeModel.class); graphModel = workspace.getLookup().lookup(GraphModel.class); HierarchicalGraph graph = null; if (exportVisible) { graph = graphModel.getHierarchicalGraphVisible(); } else { graph = graphModel.getHierarchicalGraph(); } Progress.start(progress); graph.readLock(); // Options if (normalize) { calculateMinMax(graph); } // Calculate progress units count int max = 0; if (exportHierarchy) { for (Node n : graph.getNodesTree()) { max++; } for (Edge e : graph.getEdgesTree()) { max++; } } else { max = graph.getNodeCount(); for (Edge e : graph.getEdgesAndMetaEdges()) { max++; } } Progress.switchToDeterminate(progress, max); try { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.FALSE); XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(writer); xmlWriter = new IndentingXMLStreamWriter(xmlWriter); xmlWriter.writeStartDocument("UTF-8", "1.0"); xmlWriter.setPrefix("", GEXF_NAMESPACE); xmlWriter.writeStartElement(GEXF_NAMESPACE, GEXF); xmlWriter.writeNamespace("", GEXF_NAMESPACE); xmlWriter.writeAttribute(GEXF_VERSION, "1.1"); if (exportColors || exportPosition || exportSize) { xmlWriter.writeNamespace(VIZ, VIZ_NAMESPACE); } xmlWriter.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); xmlWriter.writeAttribute("xsi:schemaLocation", GEXF_NAMESPACE_LOCATION); if (exportDynamic) { DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class); dynamicModel = dynamicController != null ? dynamicController.getModel(workspace) : null; visibleInterval = dynamicModel == null ? null : exportVisible ? dynamicModel.getVisibleInterval() : new TimeInterval(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); } writeMeta(xmlWriter); writeGraph(xmlWriter, graph); xmlWriter.writeEndElement(); xmlWriter.writeEndDocument(); xmlWriter.close(); } catch (Exception e) { graph.readUnlockAll(); if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new RuntimeException(e); } graph.readUnlock(); Progress.finish(progress); return !cancel; }