⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timeframeimpl.java

📁 It is all about project scheduling. GanttProject is a tool for creating a project schedule by means
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    // return (info.myRoundedCount/atomCount) +    // (info.myRoundedCount%atomCount==0 ? 0 : 1);    // }    // else {    // int atomCount1 = ((TimeUnit)myHighestFrameable).getAtomCount(unit);    // int count = info.myTruncatedCount*atomCount1;    // if (info.myRoundedCount>info.myTruncatedCount) {    // UnitInfo lowestInfo = calculateInfo(myLowestFrameable, info.lastDate);    // int atomCount2 = unit.getAtomCount((TimeUnit)myLowestFrameable);    // count += lowestInfo.myRoundedCount/atomCount2 +    // (lowestInfo.myRoundedCount%atomCount2==0 ? 0 : 1);    // }    // return count;    // }    // }    // else {    // UnitInfo lowestInfo = calculateInfo(myLowestFrameable, myEndDate);    // int atomCount = ((TimeUnit)myLowestFrameable).getAtomCount(unit);    // return atomCount*lowestInfo.myRoundedCount;    // }    // }    //    // private UnitInfo calculateInfo(DateFrameable frameable, Date date) {    // Date lastDate = date;    // int count = 0;    // for (;date.compareTo(myStartDate)>0; count++) {    // lastDate = date;    // date = frameable.jumpLeft(date);    // }    // int truncatedCount = date.compareTo(myStartDate)<0 ? count-1 : count;    // return new UnitInfo(truncatedCount, count, lastDate);    // }    // private Date shiftDate(Date currentDate, TimeUnit timeUnit, int    // unitCount) {    // Calendar c = (Calendar) myCalendar.clone();    // c.setTime(currentDate);    // int calendarField = getCalendarField(timeUnit);    // int currentValue = c.get(calendarField);    // clearFields(c, timeUnit);    // c.add(calendarField, unitCount);    // return c.getTime();    // }    //    // private void clearFields(Calendar c, TimeUnit topUnit) {    // for (TimeUnit currentUnit = topUnit; currentUnit!=null; currentUnit =    // currentUnit.getDirectAtomUnit()) {    // int calendarField = getCalendarField(currentUnit);    // c.clear(calendarField);    // c.getTime();    // }    // }    //    // private int getCalendarField(TimeUnit timeUnit) {    // Integer field = (Integer) ourUnit2field.get(timeUnit);    // return field.intValue();    // }    public Date getStartDate() {        return myStartDate;    }    public TimeUnit getTopUnit() {        return myTopUnit;    }    public TimeUnit getBottomUnit() {        return myBottomUnit;    }    // public int getUnitCount(TimeUnit unitLine) {    // int counter = 0;    // for (Date nextUnitStart = shiftDate(myStartDate, unitLine, counter);    // nextUnitStart.before(myNextFrameStartDate);    // nextUnitStart = shiftDate(myStartDate, unitLine, ++counter)) {    // //System.err.println("myStart="+myStartDate+"    // nextFrame="+myNextFrameStartDate+" nextUnitStart="+nextUnitStart);    // }    // return counter;    // }    public TimeUnitText getUnitText(TimeUnit unitLine, int position) {        LineHeader lineHeader = getLineHeader(unitLine);        LineItem lineItem = lineHeader == null ? null : lineHeader                .getLineItem(position);        Date startDate = lineItem == null ? null : lineItem.myStartDate;        TimeUnitText result = startDate == null ? null : getUnitText(unitLine,                startDate);        // if ("31".equals(result)) {        // System.err.println("unit line="+unitLine+" position="+position);        // }        return result;    }    private TimeUnitText getUnitText(TimeUnit unitLine, Date startDate) {        String result = null;        return unitLine.format(startDate);        // if (unitLine.equals(GregorianTimeUnitStack.DAY)) {        // result = ""+startDate.getDate();        // }        // return result;    }    public Date getUnitStart(TimeUnit unitLine, int position) {        LineHeader lineHeader = getLineHeader(unitLine);        LineItem lineItem = lineHeader == null ? null : lineHeader                .getLineItem(position);        Date result = lineItem == null ? null : lineItem.myStartDate;        return result;    }    public Date getUnitFinish(TimeUnit unitLine, int position) {        LineHeader lineHeader = getLineHeader(unitLine);        LineItem lineItem = lineHeader == null ? null : lineHeader                .getLineItem(position);        Date result = lineItem == null ? null : lineItem.myEndDate;        return result;    }    public String toString() {        return "Time frame start=" + getStartDate() + " end=" + getFinishDate()                + "\n top unit=" + getTopUnit() + "\n bottom unit="                + getBottomUnit();    }    private static class UnitInfo {        final int myTruncatedCount;        final int myRoundedCount;        private final Date lastDate;        public UnitInfo(int myTruncatedCount, int myRoundedCount, Date lastDate) {            this.myTruncatedCount = myTruncatedCount;            this.myRoundedCount = myRoundedCount;            this.lastDate = lastDate;        }    }    private static class LineHeader {        final TimeUnit myUnit;        LineItem myFirstItem;        private LineHeader myNextHeader;        private int myItemCount = -1;        public LineHeader(TimeUnit myUnit) {            this.myUnit = myUnit;        }        /**         * @return         */        public String fullDump() {            StringBuffer result = new StringBuffer(toString());            for (int i = 0; i < getItemCount(); i++) {                LineItem next = getLineItem(i);                result.append("\n" + next);            }            return result.toString();        }        public String toString() {            return myUnit.toString();        }        void append(LineHeader next) {            myNextHeader = next;        }        LineHeader next() {            return myNextHeader;        }        public int getItemCount() {            if (myItemCount == -1) {                myItemCount = 0;                for (LineItem item = myFirstItem; item != null; item = item.myNextItem) {                    myItemCount++;                }            }            return myItemCount;        }        LineItem getLineItem(int position) {            LineItem result = myFirstItem;            for (; result != null && position-- > 0; result = result.myNextItem) {                // position--;            }            return result;        }    }    private static class LineItem {        LineItem myNextItem;        final Date myStartDate;        final Date myEndDate;        public LineItem(Date myStartDate, Date myEndDate) {            this.myStartDate = myStartDate;            this.myEndDate = myEndDate;        }        public String toString() {            return myStartDate.toString() + " - " + myEndDate.toString();        }    }    public void trimLeft(Date exactDate) {        myStartDate = exactDate;        myLineHeader = null;    }    private LineHeader getLineHeader() {        if (myLineHeader == null) {            myLineHeader = calculateLines(null);        }        return myLineHeader;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -