Package net.sourceforge.ganttproject.time

Examples of net.sourceforge.ganttproject.time.TimeFrame


            int offsetEnd = 0;
            Date currentDate = myStartDate;
            do {
                final TimeUnit bottomUnit = getBottomUnit();
                final TimeUnit defaultUnit = myTimeUnitStack.getDefaultTimeUnit();
                TimeFrame currentFrame = myTimeUnitStack.createTimeFrame(
                        currentDate, bottomUnit, defaultUnit);
                Date endDate = currentFrame.getFinishDate();
                offsetEnd += getBottomUnitWidth();
                bottomUnitOffsets.add(
                        new Offset(
                                bottomUnit,
                                myStartDate,
                                endDate,
                                offsetEnd,
                                null));
                currentDate = endDate;
            } while (offsetEnd <= getChartWidth());
        }
        {
            int offsetEnd = 0;
            Date currentDate = myStartDate;
            SkewedFramesWidthFunction widthFunction = new SkewedFramesWidthFunction();
            widthFunction.initialize();
            do {
                final TimeUnit topUnit = getTopUnit(currentDate);
                final TimeUnit defaultUnit = myTimeUnitStack.getDefaultTimeUnit();
                final TimeFrame currentFrame = myTimeUnitStack.createTimeFrame(
                        currentDate, topUnit, defaultUnit);

                Date endDate = currentFrame.getFinishDate();
                offsetEnd += widthFunction.getTimeFrameWidth(currentFrame);
                topUnitOffsets.add(
                        new Offset(
                                topUnit,
                                myStartDate,
View Full Code Here


        myStartDate = startDate;
        fireStartDateChanged(e);
    }

    private TimeFrame scrollTimeFrame(Date scrolledDate) {
        TimeFrame result = null;
        if (getTopTimeUnit().isConstructedFrom(getBottomTimeUnit())) {
            result = myTimeUnitStack.createTimeFrame(scrolledDate,
                    getTopTimeUnit(), getBottomTimeUnit());
        } else {
            result = myTimeUnitStack.createTimeFrame(scrolledDate,
View Full Code Here

            result = new Offset[] {new Offset(offsetUnit, bottomUnitStartDate, bottomUnitStartDate, 0, null)};
        }
        else if (frameBottomUnit.isConstructedFrom(offsetUnit)) {
            //java.util.List buf = new ArrayList();
            int outerFrameUnitCount = timeFrame.getUnitCount(offsetUnit);
            TimeFrame innerFrame = myStack.createTimeFrame(bottomUnitStartDate,
                    frameBottomUnit, offsetUnit);
            int offsetUnitCount = innerFrame.getUnitCount(offsetUnit);
            result = new Offset[offsetUnitCount];
            for (int i=0; i<offsetUnitCount; i++) {
                Date offsetEnd = innerFrame.getUnitFinish(offsetUnit, i);
                int offsetPixels = (i+1)*frameBottomUnitWidth/outerFrameUnitCount;
                result[i] = new Offset(offsetUnit, bottomUnitStartDate, offsetEnd, offsetPixels, null);
            }
        } else {
            throw new RuntimeException("We should not be here");
View Full Code Here

        // 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

    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

    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

        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

        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

    }

    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

        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

TOP

Related Classes of net.sourceforge.ganttproject.time.TimeFrame

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.