Package org.gephi.project.impl

Examples of org.gephi.project.impl.ProjectImpl


            });
            XMLStreamReader reader = inputFactory.createXMLStreamReader(fileObject.getInputStream());

            if (!cancel) {
                //Project instance
                Project project = new ProjectImpl();
                project.getLookup().lookup(ProjectInformationImpl.class).setFile(file);

                //GephiReader
                gephiReader = new GephiReader();
                project = gephiReader.readAll(reader, project);
View Full Code Here


    public void run() {
        Progress.start(progressTicket);
        Progress.setDisplayName(progressTicket, NbBundle.getMessage(LoadTask.class, "LoadTask.name"));

        try {
            ProjectImpl project = null;
            ZipFile zip = null;
            try {
                zip = new ZipFile(file);

                //Reader
                gephiReader = new GephiReader();

                //Project
                ZipEntry entry = zip.getEntry("Project_xml");
                if (entry != null) {
                    InputStream is = null;
                    try {
                        is = zip.getInputStream(entry);
                        project = readProject(is);
                    } finally {
                        if (is != null) {
                            is.close();
                        }
                    }
                }

                //Workspace Xml
                if (project != null) {
                    for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements();) {
                        entry = e.nextElement();
                        InputStream is = null;
                        String name = entry.getName();
                        if (name.matches("Workspace_[0-9]*_xml")) {
                            try {
                                is = zip.getInputStream(entry);
                                readWorkspace(is, project);
                            } finally {
                                if (is != null) {
                                    is.close();
                                }
                            }
                        }
                    }
                }

                //Other Workspace data
                if (project != null) {
                    for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements();) {
                        entry = e.nextElement();
                        InputStream is = null;
                        String name = entry.getName();
                        if (name.matches("Workspace_[0-9]*_.*_bytes")) {
                            try {
                                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 {
View Full Code Here

            filterReader = new Xml10FilterReader(isReader);
            reader = inputFactory.createXMLStreamReader(filterReader);

            ProjectControllerImpl projectController = Lookup.getDefault().lookup(ProjectControllerImpl.class);
            ProjectsImpl projects = projectController.getProjects();
            ProjectImpl project = gephiReader.readProject(reader, projects);
            project.getLookup().lookup(ProjectInformationImpl.class).setFile(file);
            return project;
        } finally {
            if (reader != null) {
                reader.close();
            }
View Full Code Here

        cancel = true;
        return true;
    }

    public ProjectImpl readProject(XMLStreamReader reader, ProjectsImpl projects) throws Exception {
        ProjectImpl project = null;
        boolean end = false;
        while (reader.hasNext() && !end) {
            Integer eventType = reader.next();
            if (eventType.equals(XMLEvent.START_ELEMENT)) {
                String name = reader.getLocalName();
                if ("projectFile".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)) {
                    String projectName = reader.getAttributeValue(null, "name");
                    project = new ProjectImpl(projectName);
                    project.getLookup().lookup(WorkspaceProviderImpl.class);

                    if (reader.getAttributeValue(null, "ids") != null) {
                        Integer workspaceIds = Integer.parseInt(reader.getAttributeValue(null, "ids"));
                        project.setWorkspaceIds(workspaceIds);
                    }
                }
            } else if (eventType.equals(XMLStreamReader.END_ELEMENT)) {
                if ("project".equalsIgnoreCase(reader.getLocalName())) {
                    end = true;
View Full Code Here

TOP

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

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.