Ejemplo n.º 1
0
  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());
        }
      }
    }
  }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
  @Override
  public void deleteWorkspace(Workspace workspace) {
    Project project = workspace.getProject();
    WorkspaceProviderImpl workspaceProvider =
        project.getLookup().lookup(WorkspaceProviderImpl.class);

    Workspace toSelectWorkspace = null;
    if (getCurrentWorkspace() == workspace) {
      toSelectWorkspace = workspaceProvider.getPrecedingWorkspace(workspace);
    }

    workspaceProvider.removeWorkspace(workspace);

    // Event
    fireWorkspaceEvent(EventType.CLOSE, workspace);

    if (getCurrentWorkspace() == workspace) {
      // Select the one before, or after
      if (toSelectWorkspace == null) {
        closeCurrentProject();
      } else {
        openWorkspace(toSelectWorkspace);
      }
    }
  }
 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;
 }
Ejemplo n.º 7
0
  @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 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;
  }
Ejemplo n.º 9
0
 @Override
 public synchronized TimelineModel getModel(Workspace workspace) {
   return workspace.getLookup().lookup(TimelineModel.class);
 }
Ejemplo n.º 10
0
 @Override
 public void setSource(Workspace workspace, String source) {
   workspace.getLookup().lookup(WorkspaceInformationImpl.class).setSource(source);
 }
Ejemplo n.º 11
0
 @Override
 public void renameWorkspace(Workspace workspace, String name) {
   workspace.getLookup().lookup(WorkspaceInformationImpl.class).setName(name);
 }
 public void readXML(Element element, Workspace workspace) {
   FilterModelImpl filterModel = new FilterModelImpl();
   filterModel.readXML(element);
   workspace.add(filterModel);
 }
Ejemplo n.º 13
0
  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;
  }