Package org.gephi.project.impl

Examples of org.gephi.project.impl.WorkspaceProviderImpl


    }

    public void writeProject(XMLStreamWriter writer, Project project) throws Exception {
        ProjectInformation info = project.getLookup().lookup(ProjectInformation.class);
        ProjectMetaData metaData = project.getLookup().lookup(ProjectMetaData.class);
        WorkspaceProviderImpl workspaces = project.getLookup().lookup(WorkspaceProviderImpl.class);

        writer.writeStartElement("project");
        writer.writeAttribute("name", info.getName());

        //MetaData
        writer.writeStartElement("metadata");

        writer.writeStartElement("title");
        writer.writeCharacters(metaData.getTitle());
        writer.writeEndElement();

        writer.writeStartElement("keywords");
        writer.writeCharacters(metaData.getKeywords());
        writer.writeEndElement();

        writer.writeStartElement("description");
        writer.writeCharacters(metaData.getDescription());
        writer.writeEndElement();

        writer.writeStartElement("author");
        writer.writeCharacters(metaData.getAuthor());
        writer.writeEndElement();

        writer.writeEndElement();

        //Workspaces
        writer.writeStartElement("workspaces");
        for (Workspace ws : workspaces.getWorkspaces()) {
            writeWorkspace(writer, ws);
        }
        writer.writeEndElement();
        writer.writeEndElement();
    }
View Full Code Here


        return true;
    }

    public Project readAll(XMLStreamReader reader, Project project) throws Exception {
        ProjectInformationImpl info = project.getLookup().lookup(ProjectInformationImpl.class);
        WorkspaceProviderImpl workspaces = project.getLookup().lookup(WorkspaceProviderImpl.class);
        this.project = (ProjectImpl) project;

        boolean end = false;
        while (reader.hasNext() && !end) {
            Integer eventType = reader.next();
            if (eventType.equals(XMLEvent.START_ELEMENT)) {
                String name = reader.getLocalName();
                if ("gephiFile".equalsIgnoreCase(name)) {
                    //Version
                    String version = reader.getAttributeValue(null, "version");
                    if (version == null || version.isEmpty() || Double.parseDouble(version) < 0.7) {
                        throw new GephiFormatException("Gephi project file version must be at least 0.7");
                    }
                } else if ("project".equalsIgnoreCase(name)) {
                    info.setName(reader.getAttributeValue(null, "name"));
                } else if ("workspace".equalsIgnoreCase(name)) {
                    Workspace workspace = readWorkspace(reader);

                    //Current workspace
                    if (workspace.getLookup().lookup(WorkspaceInformationImpl.class).isOpen()) {
                        workspaces.setCurrentWorkspace(workspace);
                    }
                }
            } else if (eventType.equals(XMLStreamReader.END_ELEMENT)) {
                if ("project".equalsIgnoreCase(reader.getLocalName())) {
                    end = true;
View Full Code Here

                                is = zip.getInputStream(entry);
                                Matcher matcher = Pattern.compile("Workspace_([0-9]*)_(.*)_bytes").matcher(name);
                                matcher.find();
                                String workspaceId = matcher.group(1);
                                String providerId = matcher.group(2);
                                WorkspaceProviderImpl workspaceProvider = project.getLookup().lookup(WorkspaceProviderImpl.class);
                                Workspace workspace = workspaceProvider.getWorkspace(Integer.parseInt(workspaceId));
                                if (workspace != null) {
                                    readWorkspaceBytes(is, workspace, providerId);
                                }
                            } finally {
                                if (is != null) {
View Full Code Here

                    }
                    pc.setTemporaryOpeningWorkspace(null);

                    //Current workspace
                    if (info.isOpen()) {
                        WorkspaceProviderImpl workspaces = project.getLookup().lookup(WorkspaceProviderImpl.class);
                        workspaces.setCurrentWorkspace(workspace);
                    }
                }
            } else if (eventType.equals(XMLStreamReader.END_ELEMENT)) {
                if ("workspace".equalsIgnoreCase(reader.getLocalName())) {
                    end = true;
View Full Code Here

TOP

Related Classes of org.gephi.project.impl.WorkspaceProviderImpl

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.