Package ehistory.web.server.model

Examples of ehistory.web.server.model.UIEvent


        eventsResponse = clientBean.getBackendBean().getEvents(filter);

        GregorianCalendar fromDate = eventsResponse.getFrom().getGregorianCalendar();
        events = new LinkedHashMap<String, UIEvent>(eventsResponse.getEvents().size());
        for (Event event : eventsResponse.getEvents()) {
            UIEvent uiEvent = new UIEvent(event.getUid(), event.getTitle());
            uiEvent.setFrom(TimeModel.daysBetween(fromDate, event.getTime().getFrom().getGregorianCalendar()));
            uiEvent.setTo(TimeModel.daysBetween(fromDate, event.getTime().getTo().getGregorianCalendar()));
            events.put(event.getUid(), uiEvent);
        }
        periods = eventsResponse.getPeriods();

        setLevels();
View Full Code Here


            event.setLevel(null);
        }
        int periodsSize = periods.size();
        for (int periodIndex = 0; periodIndex < periodsSize; periodIndex++) {
            Period period = periods.get(periodIndex);
            UIEvent fromEvent = events.get(period.getFrom().getUid());
            UIEvent toEvent = events.get(period.getTo().getUid());
            int from = fromEvent.getFrom();
            int to = toEvent.getTo();
            for (int level = 0; level < MAX_LEVEL; level++) {
                // try to put period on the "level" level
                boolean canPlaceOnLevel = true;
                for (int i = 0; i < periodIndex; i++) {
                    Period period1 = periods.get(i);
                    if (events.get(period1.getFrom().getUid()).getLevel() != level) {
                        continue;
                    }
                    int from1 = events.get(period1.getFrom().getUid()).getFrom();
                    int to1 = events.get(period1.getTo().getUid()).getTo();
                    if (to + DELTA > from1 &&
                            from - DELTA < to1) {
                        canPlaceOnLevel = false;
                        break;
                    }
                }
                if (canPlaceOnLevel) {
                    fromEvent.setLevel(level);
                    toEvent.setLevel(level);
                    break;
                }
            }
            if (fromEvent.getLevel() == null) {
                throw new RuntimeException("That's finally happened - we need to update algorithm");
            }
        }

        List<UIEvent> eventList = new ArrayList<UIEvent>();
        eventList.addAll(events.values());
        int eventsSize = eventList.size();
        for (int eventIndex = 0; eventIndex < eventsSize; eventIndex++) {
            UIEvent event = eventList.get(eventIndex);
            if (event.getLevel() != null) {
                continue;
            }
            int from = event.getFrom();
            int to = event.getTo();
            for (int level = 0; level < MAX_LEVEL; level++) {
                // try to place event on the level
                boolean canPlaceOnLevel = true;
                for (Period period1 : periods) {
                    if (events.get(period1.getFrom().getUid()).getLevel() != level) {
                        continue;
                    }
                    int from1 = events.get(period1.getFrom().getUid()).getFrom();
                    int to1 = events.get(period1.getTo().getUid()).getTo();
                    if (to + DELTA > from1 &&
                            from - DELTA < to1) {
                        canPlaceOnLevel = false;
                        break;
                    }
                }
                if (canPlaceOnLevel) {
                    for (int i = 0; i < eventIndex; i++) {
                        UIEvent event1 = eventList.get(i);
                        if (event1.getLevel() != level) {
                            continue;
                        }
                        int from1 = event1.getFrom();
                        int to1 = event1.getTo();
                        if (to + DELTA > from1 &&
                                from - DELTA < to1) {
                            canPlaceOnLevel = false;
                            break;
                        }
View Full Code Here

        }

        StringBuilder periodsBuilder = new StringBuilder();
        StringBuilder periodTitlesBuilder = new StringBuilder();
        for (Period period : periods) {
            UIEvent from = events.get(period.getFrom().getUid());
            UIEvent to = events.get(period.getTo().getUid());

            if (periodTitlesBuilder.length() > 0) {
                periodTitlesBuilder.append(";");
            }
            periodTitlesBuilder.append(period.getTitle());

            if (periodsBuilder.length() > 0) {
                periodsBuilder.append(";");
            }
            periodsBuilder.append(from.getX2()).append(",").append(to.getX1()).append(",").append(height - from.getY());
        }
        eventsToIntArray = eventsBuilder.toString();
        eventTitles = eventTitlesBuilder.toString();
        periodsToIntArray = periodsBuilder.toString();
        periodTitles = periodTitlesBuilder.toString();
View Full Code Here

TOP

Related Classes of ehistory.web.server.model.UIEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.