Examples of Issue


Examples of org.gephi.io.importer.api.Issue

                id = reader.getAttributeValue(i);
            }
        }

        if (id.isEmpty()) {
            report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_nodeid"), Issue.Level.SEVERE));
            return;
        }

        NodeDraft node = null;
        if (container.nodeExists(id)) {
View Full Code Here

Examples of org.gephi.io.importer.api.Issue

                fore = reader.getAttributeValue(i);
            }
        }

        if (fore.isEmpty()) {
            report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_datakey", node), Issue.Level.SEVERE));
            return;
        }

        boolean end = false;
        while (reader.hasNext() && !end) {
            int xmltype = reader.next();

            switch (xmltype) {
                case XMLStreamReader.CHARACTERS:
                    if (!xmlReader.isWhiteSpace()) {
                        value += xmlReader.getText();
                    }
                    break;
                case XMLStreamReader.END_ELEMENT:
                    if (ATTVALUE.equalsIgnoreCase(xmlReader.getLocalName())) {
                        end = true;
                    }
                    break;
            }
        }

        if (!value.isEmpty()) {
            //Property
            NodeProperties prop = nodePropertiesAttributes.get(fore);
            if (prop != null) {
                try {
                    switch (prop) {
                        case X:
                            node.setX(parseFloat(value));
                            break;
                        case Y:
                            node.setY(parseFloat(value));
                            break;
                        case Z:
                            node.setZ(parseFloat(value));
                            break;
                        case SIZE:
                            node.setSize(parseFloat(value));
                            break;
                        case LABEL:
                            node.setLabel(value);
                            break;
                        case R:
                            if (node.getColor() == null) {
                                node.setColor(Integer.parseInt(value), 0, 0);
                            } else {
                                node.setColor(Integer.parseInt(value), node.getColor().getGreen(), node.getColor().getBlue());
                            }
                            break;
                        case G:
                            if (node.getColor() == null) {
                                node.setColor(0, Integer.parseInt(value), 0);
                            } else {
                                node.setColor(node.getColor().getRed(), Integer.parseInt(value), node.getColor().getBlue());
                            }
                            break;
                        case B:
                            if (node.getColor() == null) {
                                node.setColor(0, 0, Integer.parseInt(value));
                            } else {
                                node.setColor(node.getColor().getRed(), node.getColor().getGreen(), Integer.parseInt(value));
                            }
                            break;
                    }
                } catch (Exception e) {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_datavalue", fore, node, prop.toString()), Issue.Level.SEVERE));
                }
                return;
            }

            //Data attribute value
            AttributeColumn column = container.getAttributeModel().getNodeTable().getColumn(fore);
            if (column != null) {
                try {
                    Object val = column.getType().parse(value);
                    node.addAttributeValue(column, val);
                } catch (Exception e) {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_datavalue", fore, node, column.getTitle()), Issue.Level.SEVERE));
                }
            }
        }
    }
View Full Code Here

Examples of org.gephi.io.importer.api.Issue

            if (directed.equalsIgnoreCase("true")) {
                edge.setType(EdgeDraft.EdgeType.DIRECTED);
            } else if (directed.equalsIgnoreCase("false")) {
                edge.setType(EdgeDraft.EdgeType.UNDIRECTED);
            } else {
                report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_edgetype", directed, edge), Issue.Level.SEVERE));
            }
        }

        //Id
        if (!id.isEmpty()) {
View Full Code Here

Examples of org.gephi.io.importer.api.Issue

                fore = reader.getAttributeValue(i);
            }
        }

        if (fore.isEmpty()) {
            report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_datakey", edge), Issue.Level.SEVERE));
            return;
        }

        boolean end = false;
        while (reader.hasNext() && !end) {
            int xmltype = reader.next();

            switch (xmltype) {
                case XMLStreamReader.CHARACTERS:
                    if (!xmlReader.isWhiteSpace()) {
                        value += xmlReader.getText();
                    }
                    break;
                case XMLStreamReader.END_ELEMENT:
                    if (ATTVALUE.equalsIgnoreCase(xmlReader.getLocalName())) {
                        end = true;
                    }
                    break;
            }
        }

        if (!value.isEmpty()) {
            EdgeProperties prop = edgePropertiesAttributes.get(fore);
            if (prop != null) {
                try {
                    switch (prop) {
                        case WEIGHT:
                            edge.setWeight(parseFloat(value));
                            break;
                        case LABEL:
                            edge.setLabel(value);
                            break;
                        case ID:
                            edge.setId(value);
                            break;
                        case R:
                            if (edge.getColor() == null) {
                                edge.setColor(Integer.parseInt(value), 0, 0);
                            } else {
                                edge.setColor(Integer.parseInt(value), edge.getColor().getGreen(), edge.getColor().getBlue());
                            }
                            break;
                        case G:
                            if (edge.getColor() == null) {
                                edge.setColor(0, Integer.parseInt(value), 0);
                            } else {
                                edge.setColor(edge.getColor().getRed(), Integer.parseInt(value), edge.getColor().getBlue());
                            }
                            break;
                        case B:
                            if (edge.getColor() == null) {
                                edge.setColor(0, 0, Integer.parseInt(value));
                            } else {
                                edge.setColor(edge.getColor().getRed(), edge.getColor().getGreen(), Integer.parseInt(value));
                            }
                            break;
                    }
                } catch (Exception e) {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_datavalue", fore, edge, prop.toString()), Issue.Level.SEVERE));
                }
                return;
            }

            //Data attribute value
            AttributeColumn column = container.getAttributeModel().getEdgeTable().getColumn(fore);
            if (column != null) {
                try {
                    Object val = column.getType().parse(value);
                    edge.addAttributeValue(column, val);
                } catch (Exception e) {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_datavalue", fore, edge, column.getTitle()), Issue.Level.SEVERE));
                }
            }
        }
    }
View Full Code Here

Examples of org.gephi.io.importer.api.Issue

            }
            if (property) {
                return;
            }
        } else {
            report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributeempty", title), Issue.Level.SEVERE));
            return;
        }

        if (!property && type.isEmpty()) {
            report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributetype1", title), Issue.Level.SEVERE));
            type = "string";
        }

        if (!property) {
            //Class type
            if (forStr.isEmpty() || !(forStr.equalsIgnoreCase("node") || forStr.equalsIgnoreCase("edge") || forStr.equalsIgnoreCase("all"))) {
                report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributeclass", title), Issue.Level.SEVERE));
                return;
            }

            //Default?
            boolean end = false;
            boolean defaultFlag = false;
            while (reader.hasNext() && !end) {
                int xmltype = reader.next();

                switch (xmltype) {
                    case XMLStreamReader.START_ELEMENT:
                        if (ATTRIBUTE_DEFAULT.equalsIgnoreCase(xmlReader.getLocalName())) {
                            defaultFlag = true;
                        }
                        break;
                    case XMLStreamReader.CHARACTERS:
                        if (defaultFlag && !xmlReader.isWhiteSpace()) {
                            defaultStr = xmlReader.getText();
                        }
                        break;
                    case XMLStreamReader.END_ELEMENT:
                        if (ATTRIBUTE.equalsIgnoreCase(xmlReader.getLocalName())) {
                            end = true;
                        }
                        break;
                }
            }

            //Type
            AttributeType attributeType = AttributeType.STRING;
            if (type.equalsIgnoreCase("boolean") || type.equalsIgnoreCase("bool")) {
                attributeType = AttributeType.BOOLEAN;
            } else if (type.equalsIgnoreCase("integer") || type.equalsIgnoreCase("int")) {
                attributeType = AttributeType.INT;
            } else if (type.equalsIgnoreCase("long")) {
                attributeType = AttributeType.LONG;
            } else if (type.equalsIgnoreCase("float")) {
                attributeType = AttributeType.FLOAT;
            } else if (type.equalsIgnoreCase("double")) {
                attributeType = AttributeType.DOUBLE;
            } else if (type.equalsIgnoreCase("string")) {
                attributeType = AttributeType.STRING;
            } else if (type.equalsIgnoreCase("bigdecimal")) {
                attributeType = AttributeType.BIGDECIMAL;
            } else if (type.equalsIgnoreCase("biginteger")) {
                attributeType = AttributeType.BIGINTEGER;
            } else if (type.equalsIgnoreCase("byte")) {
                attributeType = AttributeType.BYTE;
            } else if (type.equalsIgnoreCase("char")) {
                attributeType = AttributeType.CHAR;
            } else if (type.equalsIgnoreCase("short")) {
                attributeType = AttributeType.SHORT;
            } else if (type.equalsIgnoreCase("listboolean")) {
                attributeType = AttributeType.LIST_BOOLEAN;
            } else if (type.equalsIgnoreCase("listint")) {
                attributeType = AttributeType.LIST_INTEGER;
            } else if (type.equalsIgnoreCase("listlong")) {
                attributeType = AttributeType.LIST_LONG;
            } else if (type.equalsIgnoreCase("listfloat")) {
                attributeType = AttributeType.LIST_FLOAT;
            } else if (type.equalsIgnoreCase("listdouble")) {
                attributeType = AttributeType.LIST_DOUBLE;
            } else if (type.equalsIgnoreCase("liststring")) {
                attributeType = AttributeType.LIST_STRING;
            } else if (type.equalsIgnoreCase("listbigdecimal")) {
                attributeType = AttributeType.LIST_BIGDECIMAL;
            } else if (type.equalsIgnoreCase("listbiginteger")) {
                attributeType = AttributeType.LIST_BIGINTEGER;
            } else if (type.equalsIgnoreCase("listbyte")) {
                attributeType = AttributeType.LIST_BYTE;
            } else if (type.equalsIgnoreCase("listchar")) {
                attributeType = AttributeType.LIST_CHARACTER;
            } else if (type.equalsIgnoreCase("listshort")) {
                attributeType = AttributeType.LIST_SHORT;
            } else {
                report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributetype2", type), Issue.Level.SEVERE));
                return;
            }

            //Default Object
            Object defaultValue = null;
            if (!defaultStr.isEmpty()) {
                try {
                    defaultValue = attributeType.parse(defaultStr);
                    report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_log_default", defaultStr, title));
                } catch (Exception e) {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributedefault", title, attributeType.getTypeString()), Issue.Level.SEVERE));
                }
            }

            //Add to model
            if ("node".equalsIgnoreCase(forStr) || "all".equalsIgnoreCase(forStr)) {
                if (container.getAttributeModel().getNodeTable().hasColumn(id) || container.getAttributeModel().getNodeTable().hasColumn(title)) {
                    report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributecolumn_exist", id));
                    return;
                }
                container.getAttributeModel().getNodeTable().addColumn(id, title, attributeType, AttributeOrigin.DATA, defaultValue);
                report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_log_nodeattribute", title, attributeType.getTypeString()));
            } else if ("edge".equalsIgnoreCase(forStr) || "all".equalsIgnoreCase(forStr)) {
                if (container.getAttributeModel().getEdgeTable().hasColumn(id) || container.getAttributeModel().getEdgeTable().hasColumn(title)) {
                    report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributecolumn_exist", id));
                    return;
                }
                container.getAttributeModel().getEdgeTable().addColumn(id, title, attributeType, AttributeOrigin.DATA, defaultValue);
                report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_log_edgeattribute", title, attributeType.getTypeString()));
            }
        } else {
            report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributeempty", title), Issue.Level.SEVERE));
        }
    }
View Full Code Here

Examples of org.gephi.io.importer.api.Issue

            // ignore everything until we see '*Vertices'
            String curLine = skip(reader, "*vertices");

            if (curLine == null) // no vertices in the graph; return empty graph
            {
                report.logIssue(new Issue(NbBundle.getMessage(ImporterPajek.class, "importerNET_error_dataformat1"), Issue.Level.CRITICAL));
            }

            // create appropriate number of vertices
            StringTokenizer stringTokenizer = new StringTokenizer(curLine);
            stringTokenizer.nextToken(); // skip past "*vertices";
            int num_vertices = Integer.parseInt(stringTokenizer.nextToken());

            Progress.switchToDeterminate(progressTicket, num_vertices);        //Progress

            verticesArray = new NodeDraft[num_vertices];
            for (int i = 0; i < num_vertices; i++) {
                NodeDraft node = container.factory().newNodeDraft();
                String label = "" + (i + 1);
                node.setId(label);
                node.setLabel(label);
                verticesArray[i] = node;
            }

            curLine = null;
            while (reader.ready()) {
                if (cancel) {
                    reader.close();
                    return;
                }
                curLine = reader.readLine();
                if (curLine == null || curLine.startsWith("*")) {
                    break;
                }
                if (curLine.isEmpty()) { // skip blank lines
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterPajek.class, "importerNET_error_dataformat2", reader.getLineNumber()), Issue.Level.WARNING));
                    continue;
                }

                try {
                    readVertex(curLine, num_vertices);
View Full Code Here

Examples of org.gephi.io.importer.api.Issue

        // if there are quote marks on this line, split on them; label is surrounded by them
        if (curLine.indexOf('"') != -1) {
            String[] initial_split = curLine.trim().split("\"");
            // if there are any quote marks, there should be exactly 2
            if (initial_split.length < 1 || initial_split.length > 3) {
                report.logIssue(new Issue(NbBundle.getMessage(ImporterPajek.class, "importerNET_error_dataformat3", lineReader.getLineNumber()), Issue.Level.SEVERE));
            }
            index = initial_split[0].trim();
            if (initial_split.length > 1) {
                label = initial_split[1].trim();
            }

            if (initial_split.length == 3) {
                parts = initial_split[2].trim().split("\\s+", -1);
            }
            firstParts = 0;
        } else // no quote marks, but are there coordinates?
        {
            parts = curLine.trim().split("\\s+", -1);
            index = parts[0];
            switch (parts.length) {
                case 1:         // just the ID; nothing to do, continue
                    break;
                case 2:         // just the ID and a label
                    label = parts[1];
                    break;
                case 3:         // ID, no label, coordinates
                    firstParts = 1;
                    break;
                case 4:         // ID, label, (x,y) coordinates
                    firstParts = 2;
                    break;
            }
        }
        int v_id = Integer.parseInt(index) - 1; // go from 1-based to 0-based index
        if (v_id >= num_vertices || v_id < 0) {
            report.logIssue(new Issue(NbBundle.getMessage(ImporterPajek.class, "importerNET_error_dataformat4", v_id, num_vertices), Issue.Level.SEVERE));
        }

        NodeDraft node = verticesArray[v_id];

        // only attach the label if there's one to attach
        if (label != null && label.length() > 0) {
            node.setLabel(label);
        }

        // parse the rest of the line
        if (firstParts != -1 && parts != null && parts.length >= firstParts + 2) {
            int i = firstParts;
            //Coordinates
            if (i < parts.length - 1) {
                try {
                    float x = Float.parseFloat(parts[i]);
                    float y = Float.parseFloat(parts[i + 1]);

                    node.setX(x);
                    node.setY(y);

                    i++;
                } catch (Exception e) {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterPajek.class, "importerNET_error_dataformat5", lineReader.getLineNumber()), Issue.Level.WARNING));
                }
            }

            // parse colors
            for (; i < parts.length - 1; i++) {
View Full Code Here

Examples of org.gephi.io.importer.api.Issue

            nextLine = br.readLine();
            if (nextLine == null || nextLine.startsWith("*")) {
                break;
            }
            if (nextLine.equals("")) { // skip blank lines
                report.logIssue(new Issue(NbBundle.getMessage(ImporterPajek.class, "importerNET_error_dataformat2", lineReader.getLineNumber()), Issue.Level.WARNING));
                continue;
            }

            StringTokenizer st = new StringTokenizer(nextLine.trim());

            int vid1 = Integer.parseInt(st.nextToken()) - 1;
            NodeDraft nodeFrom = verticesArray[vid1];

            if (is_list) // one source, multiple destinations
            {
                do {
                    int vid2 = Integer.parseInt(st.nextToken()) - 1;
                    NodeDraft nodeTo = verticesArray[vid2];
                    EdgeDraft edge = container.factory().newEdgeDraft();
                    edge.setSource(nodeFrom);
                    edge.setTarget(nodeTo);
                    container.addEdge(edge);
                } while (st.hasMoreTokens());
            } else // one source, one destination, at most one weight
            {
                int vid2 = Integer.parseInt(st.nextToken()) - 1;
                NodeDraft nodeTo = verticesArray[vid2];
                EdgeDraft edge = container.factory().newEdgeDraft();
                edge.setSource(nodeFrom);
                edge.setTarget(nodeTo);

                // get the edge weight if we care
                if (st.hasMoreTokens()) {
                    float edgeWeight = 1f;
                    try {
                        edgeWeight = new Float(st.nextToken());
                    } catch (Exception e) {
                        report.logIssue(new Issue(NbBundle.getMessage(ImporterPajek.class, "importerNET_error_dataformat5", lineReader.getLineNumber()), Issue.Level.WARNING));
                    }

                    edge.setWeight(edgeWeight);
                }

View Full Code Here

Examples of org.gephi.io.importer.api.Issue

                    stmtList(streamTokenizer);
                }
            }
        }
        if (!found) {
            report.logIssue(new Issue(NbBundle.getMessage(ImporterDOT.class, "importerDOT_error_nothingfound"), Issue.Level.SEVERE));
        }
    }
View Full Code Here

Examples of org.gephi.io.importer.api.Issue

                if (streamTokenizer.ttype == '=') {
                    streamTokenizer.nextToken();
                    if (streamTokenizer.ttype == StreamTokenizer.TT_WORD || streamTokenizer.ttype == '"') {
                        nodeDraft.setLabel(streamTokenizer.sval);
                    } else {
                        report.logIssue(new Issue(NbBundle.getMessage(ImporterDOT.class, "importerDOT_error_labelunreachable", streamTokenizer.lineno()), Issue.Level.WARNING));
                        streamTokenizer.pushBack();
                    }
                } else {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterDOT.class, "importerDOT_error_labelunreachable", streamTokenizer.lineno()), Issue.Level.WARNING));
                    streamTokenizer.pushBack();
                }
            } else if (streamTokenizer.sval.equalsIgnoreCase("color")) {
                streamTokenizer.nextToken();
                if (streamTokenizer.ttype == '=') {
                    streamTokenizer.nextToken();
                    if (streamTokenizer.ttype == StreamTokenizer.TT_WORD || streamTokenizer.ttype == '"') {
                        if (colorTable.containsKey(streamTokenizer.sval)) {
                            nodeDraft.setColor(colorTable.get(streamTokenizer.sval));
                        } else {
                            try {
                                String[] colors = streamTokenizer.sval.split(" ");
                                nodeDraft.setColor(Float.parseFloat(colors[0]), Float.parseFloat(colors[1]), Float.parseFloat(colors[2]));
                            } catch (Exception e) {
                            }
                        }
                    } else {
                        report.logIssue(new Issue(NbBundle.getMessage(ImporterDOT.class, "importerDOT_error_colorunreachable", streamTokenizer.lineno()), Issue.Level.WARNING));
                        streamTokenizer.pushBack();
                    }
                } else {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterDOT.class, "importerDOT_error_colorunreachable", streamTokenizer.lineno()), Issue.Level.WARNING));
                    streamTokenizer.pushBack();
                }
            } else if (streamTokenizer.sval.equalsIgnoreCase("pos")) {
                streamTokenizer.nextToken();
                if (streamTokenizer.ttype == '=') {
                    streamTokenizer.nextToken();
                    if (streamTokenizer.ttype == StreamTokenizer.TT_WORD || streamTokenizer.ttype == '"') {
                        try {
                            String[] positions = streamTokenizer.sval.split(",");
                            if (positions.length == 2) {
                                nodeDraft.setX(Float.parseFloat(positions[0]));
                                nodeDraft.setY(Float.parseFloat(positions[1]));
                            } else if (positions.length == 3) {
                                nodeDraft.setX(Float.parseFloat(positions[0]));
                                nodeDraft.setY(Float.parseFloat(positions[1]));
                                nodeDraft.setZ(Float.parseFloat(positions[2]));
                            }
                        } catch (Exception e) {
                        }
                    } else {
                        report.logIssue(new Issue(NbBundle.getMessage(ImporterDOT.class, "importerDOT_error_posunreachable", streamTokenizer.lineno()), Issue.Level.WARNING));
                        streamTokenizer.pushBack();
                    }
                } else {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterDOT.class, "importerDOT_error_posunreachable", streamTokenizer.lineno()), Issue.Level.WARNING));
                    streamTokenizer.pushBack();
                }
            } else if (streamTokenizer.sval.equalsIgnoreCase("style")) {
                streamTokenizer.nextToken();
                if (streamTokenizer.ttype == '=') {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.