Search in sources :

Example 1 with IntervalSet

use of org.gephi.graph.api.types.IntervalSet in project gephi by gephi.

the class ElementDraftImpl method addIntervals.

@Override
public void addIntervals(String intervals) {
    if (!container.getTimeRepresentation().equals(TimeRepresentation.INTERVAL)) {
        String message = NbBundle.getMessage(ElementDraftImpl.class, "ElementDraftException_NotIntervalRepresentation", id);
        container.getReport().logIssue(new Issue(message, Issue.Level.SEVERE));
        return;
    }
    IntervalSet s = (IntervalSet) AttributeUtils.parse(intervals, IntervalSet.class);
    if (timeSet == null) {
        timeSet = s;
    } else {
        for (Interval i : s.toArray()) {
            timeSet.add(i);
        }
    }
}
Also used : Issue(org.gephi.io.importer.api.Issue) IntervalSet(org.gephi.graph.api.types.IntervalSet) Interval(org.gephi.graph.api.Interval)

Example 2 with IntervalSet

use of org.gephi.graph.api.types.IntervalSet in project gephi by gephi.

the class ElementDraftImpl method addInterval.

@Override
public void addInterval(double intervalStart, double intervalEnd) {
    if (!container.getTimeRepresentation().equals(TimeRepresentation.INTERVAL)) {
        String message = NbBundle.getMessage(ElementDraftImpl.class, "ElementDraftException_NotIntervalRepresentation", id);
        container.getReport().logIssue(new Issue(message, Issue.Level.SEVERE));
        return;
    }
    try {
        Interval interval = new Interval(intervalStart, intervalEnd);
        if (timeSet == null) {
            timeSet = new IntervalSet();
        }
        timeSet.add(interval);
    } catch (Exception e) {
        String interval = "[" + intervalStart + "," + intervalEnd + "]";
        String message = NbBundle.getMessage(ElementDraftImpl.class, "ElementDraftException_IntervalSetError", interval, id, e.getMessage());
        container.getReport().logIssue(new Issue(message, Issue.Level.SEVERE));
    }
}
Also used : Issue(org.gephi.io.importer.api.Issue) IntervalSet(org.gephi.graph.api.types.IntervalSet) Interval(org.gephi.graph.api.Interval)

Example 3 with IntervalSet

use of org.gephi.graph.api.types.IntervalSet in project gephi by gephi.

the class AttributeTypesSupportCellEditor method getTableCellEditorComponent.

@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    TimeFormat timeFormat = graphModelProvider.getGraphModel().getTimeFormat();
    DateTimeZone timeZone = graphModelProvider.getGraphModel().getTimeZone();
    String valueStr;
    if (value == null) {
        valueStr = "";
    } else if (isTimestampSetType) {
        valueStr = ((TimestampSet) value).toString(timeFormat, timeZone);
    } else if (isTimestampMapType) {
        valueStr = ((TimestampMap) value).toString(timeFormat, timeZone);
    } else if (isIntervalSetType) {
        valueStr = ((IntervalSet) value).toString(timeFormat, timeZone);
    } else if (isIntervalMapType) {
        valueStr = ((IntervalMap) value).toString(timeFormat, timeZone);
    } else if (isArrayType) {
        valueStr = AttributeUtils.printArray(value);
    } else {
        valueStr = AttributeUtils.print(value, timeFormat, timeZone);
    }
    textField.setBorder(originalBorder);
    textField.setEditable(true);
    textField.setText(valueStr);
    return textField;
}
Also used : TimeFormat(org.gephi.graph.api.TimeFormat) IntervalSet(org.gephi.graph.api.types.IntervalSet) TimestampSet(org.gephi.graph.api.types.TimestampSet) DateTimeZone(org.joda.time.DateTimeZone)

Example 4 with IntervalSet

use of org.gephi.graph.api.types.IntervalSet in project gephi by gephi.

the class IntervalSetGraphicsComponentProvider method getTimeIntervalGraphicsParameters.

@Override
public TimeIntervalGraphicsParameters getTimeIntervalGraphicsParameters(TimeSet value) {
    IntervalSet intervalSet = (IntervalSet) value;
    double[] intervals = intervalSet.getIntervals();
    double[] starts = new double[intervals.length / 2];
    double[] ends = new double[intervals.length / 2];
    for (int i = 0, startIndex = 0; startIndex < intervals.length; i++, startIndex += 2) {
        starts[i] = intervals[startIndex];
        ends[i] = intervals[startIndex + 1];
    }
    return new TimeIntervalGraphicsParameters(starts, ends);
}
Also used : IntervalSet(org.gephi.graph.api.types.IntervalSet)

Example 5 with IntervalSet

use of org.gephi.graph.api.types.IntervalSet in project gephi by gephi.

the class ExporterGEXF method writeTimeSet.

private void writeTimeSet(XMLStreamWriter xmlWriter, Graph graph, Element element) throws Exception {
    Interval visibleInterval = graph.getView().getTimeInterval();
    TimeRepresentation timeRepresentation = graph.getModel().getConfiguration().getTimeRepresentation();
    TimeSet timeSet = (TimeSet) element.getAttribute("timeset");
    TimeFormat timeFormat = graph.getModel().getTimeFormat();
    DateTimeZone timeZone = graph.getModel().getTimeZone();
    if (timeSet != null && !timeSet.isEmpty()) {
        if (timeSet.size() > 1) {
            xmlWriter.writeStartElement(SPELLS);
            if (timeRepresentation.equals(TimeRepresentation.INTERVAL)) {
                for (Interval interval : ((IntervalSet) timeSet).toArray()) {
                    if (!exportVisible || interval.compareTo(visibleInterval) == 0) {
                        xmlWriter.writeStartElement(SPELL);
                        if (!Double.isInfinite(interval.getLow())) {
                            String intervalLow = AttributeUtils.printTimestampInFormat(interval.getLow(), timeFormat, timeZone);
                            xmlWriter.writeAttribute(START, intervalLow);
                        }
                        if (!Double.isInfinite(interval.getHigh())) {
                            String intervalHigh = AttributeUtils.printTimestampInFormat(interval.getHigh(), timeFormat, timeZone);
                            xmlWriter.writeAttribute(END, intervalHigh);
                        }
                        xmlWriter.writeEndElement();
                    }
                }
            } else if (timeRepresentation.equals(TimeRepresentation.TIMESTAMP)) {
                for (Double timestamp : ((TimestampSet) timeSet).toArray()) {
                    if (!exportVisible || visibleInterval.compareTo(timestamp) == 0) {
                        xmlWriter.writeStartElement(SPELL);
                        xmlWriter.writeAttribute(TIMESTAMP, AttributeUtils.printTimestampInFormat(timestamp, timeFormat, timeZone));
                        xmlWriter.writeEndElement();
                    }
                }
            }
            xmlWriter.writeEndElement();
        } else if (timeRepresentation.equals(TimeRepresentation.INTERVAL)) {
            Interval interval = ((IntervalSet) timeSet).toArray()[0];
            if (!Double.isInfinite(interval.getLow())) {
                String intervalLow = AttributeUtils.printTimestampInFormat(interval.getLow(), timeFormat, timeZone);
                xmlWriter.writeAttribute(START, intervalLow);
            }
            if (!Double.isInfinite(interval.getHigh())) {
                String intervalHigh = AttributeUtils.printTimestampInFormat(interval.getHigh(), timeFormat, timeZone);
                xmlWriter.writeAttribute(END, intervalHigh);
            }
        } else if (timeRepresentation.equals(TimeRepresentation.TIMESTAMP)) {
            Double timestamp = ((TimestampSet) timeSet).toArray()[0];
            xmlWriter.writeAttribute(TIMESTAMP, AttributeUtils.printTimestampInFormat(timestamp, timeFormat, timeZone));
        }
    }
}
Also used : TimeSet(org.gephi.graph.api.types.TimeSet) IntervalSet(org.gephi.graph.api.types.IntervalSet) DateTimeZone(org.joda.time.DateTimeZone)

Aggregations

IntervalSet (org.gephi.graph.api.types.IntervalSet)8 Interval (org.gephi.graph.api.Interval)3 Issue (org.gephi.io.importer.api.Issue)3 AttributeColumnsController (org.gephi.datalab.api.AttributeColumnsController)2 Column (org.gephi.graph.api.Column)2 Element (org.gephi.graph.api.Element)2 DateTimeZone (org.joda.time.DateTimeZone)2 TimeFormat (org.gephi.graph.api.TimeFormat)1 TimeSet (org.gephi.graph.api.types.TimeSet)1 TimestampSet (org.gephi.graph.api.types.TimestampSet)1