List of usage examples for org.joda.time Interval Interval
public Interval(Object interval, Chronology chronology)
From source file:de.hpi.bpmn2_0.animation.AnimationJSONBuilder.java
License:Open Source License
public AnimationJSONBuilder(ArrayList<AnimationLog> animations, Replayer replayer, ReplayParams params) { this.animations = animations; this.params = params; this.replayer = replayer; Set<DateTime> dateSet = new HashSet<>(); for (AnimationLog animationLog : animations) { dateSet.add(animationLog.getStartDate()); dateSet.add(animationLog.getEndDate()); }/*from w ww .j a va 2s. c o m*/ SortedSet<DateTime> sortedDates = TimeUtilities.sortDates(dateSet); totalRealInterval = new Interval(sortedDates.first(), sortedDates.last()); }
From source file:de.hpi.bpmn2_0.replay.AnimationLog.java
License:Open Source License
public Interval getInterval() { if (this.startDate != null && this.endDate != null) { return new Interval(this.startDate, this.endDate); } else {//from ww w . ja va2 s.co m return null; } }
From source file:de.hpi.bpmn2_0.replay.ReplayTrace.java
License:Open Source License
public Interval getInterval() { if (this.getStartDate() != null && this.getEndDate() != null) { return new Interval(this.getStartDate(), this.getEndDate()); } else {//w w w. j av a 2 s .co m return null; } }
From source file:de.hpi.bpmn2_0.replay.TimeUtilities.java
License:Open Source License
public static ArrayList<Interval> divide(Interval v1, Interval v2) { ArrayList<Interval> divide = new ArrayList(); Interval overlap = v1.overlap(v2);/* w w w . j a va2 s . c o m*/ if (overlap != null) { long overlapStart = overlap.getStartMillis(); long overlapEnd = overlap.getEndMillis(); long v1Start = v1.getStartMillis(); long v1End = v1.getEndMillis(); long v2Start = v2.getStartMillis(); long v2End = v2.getEndMillis(); long minStart = Math.min(v1Start, v2Start); long maxEnd = Math.max(v1End, v2End); divide.add(new Interval(minStart, overlapStart)); divide.add(overlap); divide.add(new Interval(overlapEnd, maxEnd)); } return divide; }
From source file:de.hpi.bpmn2_0.replay.TimeUtilities.java
License:Open Source License
public static Interval getInterval(SequenceFlow flow) { return new Interval(((TraceNode) flow.getSourceRef()).getStart(), ((TraceNode) flow.getTargetRef()).getComplete()); }
From source file:de.hpi.bpmn2_0.replay.TimeUtilities.java
License:Open Source License
private static Map<Interval, Integer> aggregateIntervals(SortedSet<Interval> intervals) { SortedSet<DateTime> timeline = new TreeSet<>(new Comparator<DateTime>() { @Override/*w ww. j a v a 2 s . c om*/ public int compare(DateTime o1, DateTime o2) { if (o1.isBefore(o2)) { return -1; } else { return +1; } } }); //----------------------------------------------------- //First, create an ordered timeline based on intervals //The date milestone on the timeline is the start and end date of each interval //Note: if two datetime are equal, two duplicate elements are on the timeline //----------------------------------------------------- Set<DateTime> starts = new HashSet(); Set<DateTime> ends = new HashSet(); for (Interval interval : intervals) { timeline.add(interval.getStart()); //added datetime will be arranged in timing order starts.add(interval.getStart()); timeline.add(interval.getEnd()); ends.add(interval.getEnd()); } //------------------------------------------------ //Then, traverse the timeline to count tokens //current-next traverses every interval on the timeline formed by two //consecutive datetime points //------------------------------------------------ DateTime current = null; DateTime next = null; Iterator<DateTime> iterator = timeline.iterator(); int intervalCount = 0; Map<Interval, Integer> intervalCountMap = new HashMap(); while (iterator.hasNext()) { if (current == null) { current = iterator.next(); } else { current = next; } if (iterator.hasNext()) { next = iterator.next(); if (starts.contains(current)) { intervalCount++; } if (ends.contains(current)) { intervalCount--; } if (current.isBefore(next)) { intervalCountMap.put(new Interval(current, next), intervalCount); } } } return intervalCountMap; }
From source file:de.hpi.bpmn2_0.replay.TimeUtilities.java
License:Open Source License
public static Map<Interval, Integer> compareIntervalMaps(Map<Interval, Integer> map1, Map<Interval, Integer> map2) { Map<Interval, Integer> resultMap = new HashMap(); SortedSet<DateTime> timeline = new TreeSet<>(new Comparator<DateTime>() { @Override/*from ww w . j av a 2 s .c o m*/ public int compare(DateTime o1, DateTime o2) { if (o1.isBefore(o2)) { return -1; } else if (o1.isEqual(o2)) { //if two points are the same, only one is added return 0; } else { return +1; } } }); //------------------------------------------- // Put all start and end points of all intervals on a timeline // Note: if two points of time are the same, only one is kept on timeline //------------------------------------------- for (Interval interval : map1.keySet()) { timeline.add(interval.getStart()); //added datetime will be arranged in timing order timeline.add(interval.getEnd()); } for (Interval interval : map2.keySet()) { timeline.add(interval.getStart()); timeline.add(interval.getEnd()); } //---------------------------------------------- //Traverse the timeline and compare intervals of map1,map2 //current-next traverses every interval on the timeline formed //by two consecutive datetime points //---------------------------------------------- DateTime current = null; DateTime next = null; Interval timelineInterval; Iterator<DateTime> iterator = timeline.iterator(); while (iterator.hasNext()) { if (current == null) { current = iterator.next(); } else { current = next; } if (iterator.hasNext()) { next = iterator.next(); if (current.isBefore(next)) { timelineInterval = new Interval(current, next); resultMap.put(timelineInterval, getIntervalCount(timelineInterval, map1) - getIntervalCount(timelineInterval, map2)); } } } return resultMap; }
From source file:de.ifgi.fmt.mongo.conv.IntervalConverter.java
License:Open Source License
/** * /*from www. ja v a2 s. co m*/ * @param c * @param o * @param i * @return * @throws MappingException */ @Override public Interval decode(Class c, Object o, MappedField i) throws MappingException { if (o == null) { return null; } else if (o instanceof DBObject) { DBObject dbo = (DBObject) o; return new Interval(getLong(dbo.get("start")), getLong(dbo.get("end"))); } return new Interval(o); }
From source file:de.kuschku.libquassel.ProtocolHandler.java
License:Open Source License
@Subscribe(threadMode = ThreadMode.MAIN) public void onEventMainThread(@NonNull HeartbeatReply heartbeat) { DateTime dateTime = DateTime.now().toDateTimeISO(); Interval interval = new Interval(heartbeat.dateTime, dateTime); long roundtrip = interval.toDurationMillis(); long lag = (long) (roundtrip * 0.5); client.setLatency(lag);//ww w.ja va 2s . co m }
From source file:de.otto.mongodb.profiler.AbstractAsyncProfiler.java
License:Apache License
@Override public synchronized boolean stopProfiling() { if (currentStopProfilingTimeout != null) { currentStopProfilingTimeout.cancel(); currentStopProfilingTimeout = null; }/*from w w w . j a va 2s . c o m*/ final boolean stopped = execute.compareAndSet(true, false); if (stopped) { profilingRuntimes.add(new Interval(profilingStarted, DateTime.now())); profilingStarted = null; } return stopped; }