&& attribute.equals(AttributeType.MEAL) && i % 2 == 0 && i != 0) { currentPoint.getPointAttributes().addAttribute(attribute); currentPoint.getIntervalAttributes().addAttribute(attribute); newPoint.getPointAttributes().addAttribute(attribute); newPoint.getIntervalAttributes().removeAttribute(attribute);
&& attribute.equals(AttributeType.MEAL) && workedPoints % 2 == 0 && workedPoints != 0) { TimePoint mealStart = findIntervalStartPointByAttribute(AttributeType.MEAL); TimePoint newMealStart = findStartLunchBreak(null); if (!mealStart.getPointAttributes().contains( DomainConstants.WORKED_ATTRIBUTES) && newMealStart != null && newMealStart.isBefore(mealStart)) { int newMealIndex = getTimePointIndex(newMealStart); if (newMealIndex != -1) { newMealStart.getPointAttributes() .removeAttribute(AttributeType.MEAL); newMealStart.getPointAttributes().addAttribute(AttributeType.MEAL); newMealStart.getIntervalAttributes() .addAttribute(AttributeType.MEAL); addIntervalAttributeToNextPoints(newMealIndex, new Attributes( AttributeType.MEAL)); } } TimePoint mealEnd = findIntervalEndPointByAttribute(AttributeType.MEAL); if (mealEnd != null) { if (!mealEnd.getPointAttributes().contains( DomainConstants.WORKED_ATTRIBUTES)) { int oldMealIndex = getTimePointIndex(mealEnd); if (oldMealIndex != -1) { mealEnd.getPointAttributes().removeAttribute(attribute); addIntervalAttributeToNextPoints(oldMealIndex, new Attributes( AttributeType.MEAL)); } newPoint.getPointAttributes().addAttribute(attribute); insideIntervals.addAttribute(attribute); } } else { newPoint.getPointAttributes().addAttribute(attribute); insideIntervals.addAttribute(attribute); }
    public void plotPoint(TimePoint newPoint) {        int timeLineSize = getNumberOfTimePoints();        Attributes insideIntervals = new Attributes();        for (int i = 0; i < timeLineSize; i++) {            TimePoint currentPoint = getTimeLinePosition(i);            if (newPoint.isAtSameTime(currentPoint)) {                if (insideIntervals.contains(newPoint.getPointAttributes())) {                    // the interval is open and we're going to close it right away                    pointClosesInterval(insideIntervals, newPoint, i);                    // TODO verificar isto! - apaguei, em principio e' redundante                    // currentPoint.getPointAttributes().removeAttributes(newPoint.getPointAttributes().getAttributes());                    // // remove the newPoint attributes from the current point                    currentPoint.getPointAttributes().addAttributes(                            newPoint.getPointAttributes().getAttributes());                    // since the time is the same we will not add the new point but use the current                } else { // the interval is not open, let's create it                    pointOpensInterval(insideIntervals, newPoint, i);                    insideIntervals.addAttributes(currentPoint.getIntervalAttributes().getAttributes());                    currentPoint.getPointAttributes().addAttributes(                            newPoint.getPointAttributes().getAttributes());                    // since the time is the same we will not add the new point but use the current                }                return;            } else if (newPoint.isBefore(currentPoint)) {                addPoint(i, newPoint);                // adds the point in this position and shifts the current point to the next position                // (i+1) se attrib ponto do novo ponto estao em intervalos abertos => intervalo vai-se                // fechar                if (insideIntervals.contains(newPoint.getPointAttributes())) {                    // inserted point only has 1 attribute                    pointClosesInterval(insideIntervals, newPoint, i);                } else { // novo intervalo                    pointOpensInterval(insideIntervals, newPoint, i);                }                return; // get off the for loop            } else {                // is after caso em q o intervalo ja esta' aberto faz o update do atributo no ponto                for (AttributeType attribute : currentPoint.getPointAttributes().getAttributes()) {                    if (insideIntervals.contains(attribute)) {                        newPoint.getIntervalAttributes().removeAttribute(attribute);                        // removes the current point attribute to new point interval attributes                        insideIntervals.removeAttribute(attribute);                    } else {                        if (newPoint.getPointAttributes().contains(DomainConstants.WORKED_ATTRIBUTES)                                && attribute.equals(AttributeType.MEAL) && i % 2 == 0 && i != 0) {                            currentPoint.getPointAttributes().addAttribute(attribute);                            currentPoint.getIntervalAttributes().addAttribute(attribute);                            newPoint.getPointAttributes().addAttribute(attribute);                            newPoint.getIntervalAttributes().removeAttribute(attribute);                        } else {                            newPoint.getIntervalAttributes().addAttribute(attribute);                            // adds the current point attribute to new point interval attributes                            insideIntervals.addAttribute(attribute);                        }                    }                }            }        }        TimePoint lastTimelinePoint = getTimeLinePosition(timeLineSize - 1);        // the newpoint is after the last point in the timeline        newPoint.setTime(lastTimelinePoint.getTime());        newPoint.setNextDay(lastTimelinePoint.isNextDay());        addPoint(timeLineSize - 1, newPoint);        // adds the point in this position and shifts the current point to the next position        // (i+1) se attrib ponto do novo ponto estao em intervalos abertos => intervalo vai-se        // fechar        if (insideIntervals.contains(newPoint.getPointAttributes())) {            // inserted point only has 1 attribute            pointClosesInterval(insideIntervals, newPoint, timeLineSize - 1);        } else { // novo intervalo            pointOpensInterval(insideIntervals, newPoint, timeLineSize - 1);        }    }