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);
}
}
}
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));
}
}
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;
}
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);
}
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));
}
}
}
Aggregations