Examples of TimeFrame


Examples of net.sourceforge.ganttproject.time.TimeFrame

        // We don't want to create numerous vertical stripes for weekend units (e.g., for 16
        // non-working hours may produce 16 vertical stripes that looks awful). We
        // accumulate consecutive weekend units instead and add just a single block.
        do {
            TimeFrame currentFrame = getTimeUnitStack().createTimeFrame(
                    currentDate, getTopUnit(currentDate), myBottomUnit);
            int bottomUnitCount = currentFrame.getUnitCount(getBottomUnit());
            //int bottomUnit
            // This will be true if there is at least one working bottom unit in this time frame
            // If there are only weekend bottom units, we'll merge neighbor top units
            // (like merging two weekend days into one continuous grey stripe)
            boolean addTopUnitOffset = false;
            int bottomUnitWidth = getBottomUnitWidth();
            float offsetStep = getOffsetStep(currentFrame);
            if (bottomUnitWidth==0) {
                bottomUnitWidth = 1;
            }
            for (int i=0; i<bottomUnitCount; i++) {
                Date startDate = currentFrame.getUnitStart(getBottomUnit(), i);
                Date endDate = currentFrame.getUnitFinish(getBottomUnit(), i);
                GPCalendar.DayType dayType = getCalendar().getDayTypeDate(startDate);
                if (dayType == GPCalendar.DayType.WEEKEND) {
                    offsetEnd += offsetStep / myWeekendDecreaseFactor;
                    bottomUnitOffsets.add(new Offset(
                            getBottomUnit(), myStartDate, endDate, initialEnd+(int)(offsetEnd*bottomUnitWidth), dayType));
                    continue;
                }
                addTopUnitOffset = true;
                offsetEnd += offsetStep;
                bottomUnitOffsets.add(new Offset(
                        getBottomUnit(), myStartDate, endDate, initialEnd+(int)(offsetEnd*bottomUnitWidth), dayType));
            }
            currentDate = currentFrame.getFinishDate();
            if (!addTopUnitOffset) {
                continue;
            }
            topUnitOffsets.add(new Offset(
                    getTopUnit(), myStartDate, currentDate, initialEnd+(int)(offsetEnd*bottomUnitWidth), DayType.WORKING));
View Full Code Here

Examples of net.sourceforge.ganttproject.time.TimeFrame

    public void testDayAndHoursTimeFrameEvenBounds() throws Exception {
        Calendar c = (Calendar) GregorianCalendar.getInstance().clone();
        c.set(2000, Calendar.JANUARY, 1, 0, 0);
        GregorianTimeUnitStack stack = new GregorianTimeUnitStack();
        TimeFrame timeFrame = stack.createTimeFrame(c.getTime(),
                GregorianTimeUnitStack.DAY, GregorianTimeUnitStack.HOUR);
        assertEquals(
                "Unexpected number of days in the time frame=" + timeFrame, 1,
                timeFrame.getUnitCount(GregorianTimeUnitStack.DAY));
        assertEquals("Unexpected number of hours in the time frame="
                + timeFrame, 24, timeFrame
                .getUnitCount(GregorianTimeUnitStack.HOUR));
    }
View Full Code Here

Examples of net.sourceforge.ganttproject.time.TimeFrame

    public void testDayAndHoursTimeFrameUnevenBounds() throws Exception {
        Calendar c = (Calendar) GregorianCalendar.getInstance().clone();
        c.set(2000, Calendar.JANUARY, 1, 12, 0);
        GregorianTimeUnitStack stack = new GregorianTimeUnitStack();
        TimeFrame timeFrame = stack.createTimeFrame(c.getTime(),
                GregorianTimeUnitStack.DAY, GregorianTimeUnitStack.HOUR);
        assertEquals(
                "Unexpected number of days in the time frame=" + timeFrame, 1,
                timeFrame.getUnitCount(GregorianTimeUnitStack.DAY));
        assertEquals("Unexpected number of hours in the time frame="
                + timeFrame, 12, timeFrame
                .getUnitCount(GregorianTimeUnitStack.HOUR));
    }
View Full Code Here

Examples of net.sourceforge.ganttproject.time.TimeFrame

        c.set(2000, Calendar.JANUARY, 1, 0, 0);
        GregorianTimeUnitStack stack = new GregorianTimeUnitStack();
        TimeUnit monthUnit = ((TimeUnitFunctionOfDate) GregorianTimeUnitStack.MONTH)
                .createTimeUnit(c.getTime());
        TimeUnit dayUnit = GregorianTimeUnitStack.DAY;
        TimeFrame timeFrame = stack.createTimeFrame(c.getTime(), monthUnit,
                dayUnit);
        assertEquals("Unexpected number of monthes in the time frame="
                + timeFrame, 1, timeFrame.getUnitCount(monthUnit));
        assertEquals(
                "Unexpected number of days in the time frame=" + timeFrame, 31,
                timeFrame.getUnitCount(dayUnit));
    }
View Full Code Here

Examples of net.sourceforge.ganttproject.time.TimeFrame

        c.set(2000, Calendar.JANUARY, 16, 0, 0);
        GregorianTimeUnitStack stack = new GregorianTimeUnitStack();
        TimeUnit monthUnit = ((TimeUnitFunctionOfDate) GregorianTimeUnitStack.MONTH)
                .createTimeUnit(c.getTime());
        TimeUnit dayUnit = GregorianTimeUnitStack.DAY;
        TimeFrame timeFrame = stack.createTimeFrame(c.getTime(), monthUnit,
                dayUnit);
        assertEquals("Unexpected number of monthes in the time frame="
                + timeFrame, 1, timeFrame.getUnitCount(monthUnit));
        assertEquals(
                "Unexpected number of days in the time frame=" + timeFrame, 16,
                timeFrame.getUnitCount(dayUnit));
        // fail("just fail");
    }
View Full Code Here

Examples of net.sourceforge.ganttproject.time.TimeFrame

    }

    protected void paintRegularTimeFrames(Graphics g, TimeFrame[] timeFrames) {
        fireBeforeProcessingTimeFrames();
        for (int i = 0; i < timeFrames.length; i++) {
            TimeFrame next = timeFrames[i];
            fireFrameStarted(next);
            TimeUnit topUnit = next.getTopUnit();
            fireUnitLineStarted(topUnit);
            fireUnitLineFinished(topUnit);
            //
            TimeUnit bottomUnit = myBottomUnit;// next.getBottomUnit();
            fireUnitLineStarted(bottomUnit);
View Full Code Here

Examples of net.sourceforge.ganttproject.time.TimeFrame

        TimeFrame[] timeFrames = getTimeFrames(null);
        // for(int i = 0 ; i<timeFrames.length; i++)
        // System.out.println("< "+timeFrames[i].getStartDate() + "" +
        // timeFrames[i].getFinishDate()+" >");

        TimeFrame last = timeFrames[timeFrames.length - 1];
        return last.getFinishDate();
    }
View Full Code Here

Examples of net.sourceforge.ganttproject.time.TimeFrame

        ArrayList result = new ArrayList();
        int totalFramesWidth = 0;
        Date currentDate = myStartDate;
        do {

            TimeFrame currentFrame = myTimeUnitStack.createTimeFrame(
                    currentDate, getTopUnit(currentDate), myBottomUnit);
            if (exactDate != null
                    && currentFrame.getStartDate().before(exactDate)) {
                currentFrame.trimLeft(exactDate);
            }
            if (currentFrame.getStartDate().after(currentFrame.getFinishDate())) {
                throw new IllegalStateException("Frame is invalid:\n"+currentFrame+"\n date="+exactDate);
            }
            result.add(currentFrame);
            int frameWidth = myFrameWidthFunction
                    .getTimeFrameWidth(currentFrame);
            totalFramesWidth += frameWidth;
            currentDate = currentFrame.getFinishDate();

        } while (totalFramesWidth <= getBounds().getWidth());
        //
        return (TimeFrame[]) result.toArray(new TimeFrame[0]);
    }
View Full Code Here

Examples of net.sourceforge.ganttproject.time.TimeFrame

                    startDate, endDate) };
        } else if (timeUnit.isConstructedFrom(myTimeUnitStack
                .getDefaultTimeUnit())) {
            java.util.List buf = new ArrayList();
            TimeUnit defaultUnit = myTimeUnitStack.getDefaultTimeUnit();
            TimeFrame innerFrame = myTimeUnitStack.createTimeFrame(startDate,
                    timeUnit, defaultUnit);
            // System.err.println("[ChartModelImpl] topUnit="+timeUnit+"
            // bottom="+defaultUnit+"
            // count="+innerFrame.getUnitCount(defaultUnit));
            f.createAlternance(defaultUnit, innerFrame, buf);
View Full Code Here

Examples of net.sourceforge.ganttproject.time.TimeFrame

        GanttCalendar friday = new GanttCalendar(2000, 0, 7);
        task.setStart(friday);
        task.setDuration(getTaskManager().createLength(2));
        OffsetCalculatorImpl offsetCalculator = new OffsetCalculatorImpl(myStack);
        TimeUnitFunctionOfDate monthUnit = (TimeUnitFunctionOfDate) myStack.MONTH;
        TimeFrame weekTimeFrame = myStack.createTimeFrame(monday.getTime(), monthUnit.createTimeUnit(monday.getTime()), myStack.WEEK_AS_BOTTOM_UNIT);
        Offset[] offsets = offsetCalculator.calculateOffsets(weekTimeFrame, myStack.WEEK_AS_BOTTOM_UNIT, monday.getTime(), myStack.getDefaultTimeUnit(), 70);
        assertEquals("Unexpected offsets count", 7, offsets.length);
        TaskActivity fridayActivity = task.getActivities()[0];
        int pixelOffset = 0;
        for (int i=0; i<offsets.length; i++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.