void (int value, int delay) { if (!myProcessEvents) { return; } if (Objects.equals(getTarget(), value)) { return; } long moment = System.nanoTime(); long elapsed = (moment - myPreviousEventMoment); if (mySegments.isEmpty()) { mySegments.add(new Line(new Position(moment, myInput.get()), new Position(moment + delay * 1000000L, value))); } else { Segment segment = mySegments.getLast(); mySegments.add(new Line(new Position(segment.getEnd().getMoment(), segment.getEnd().getValue()), new Position(segment.getEnd().getMoment() + elapsed, value))); } myPreviousEventMoment = moment; if (!myTimer.isRunning()) { myTimer.start(); } }