📄 taskseriescollection.html
字号:
<FONT color="green">547</FONT> /**<a name="line.547"></a><FONT color="green">548</FONT> * Returns the end value of a sub-interval for a given item.<a name="line.548"></a><FONT color="green">549</FONT> *<a name="line.549"></a><FONT color="green">550</FONT> * @param rowKey the row key.<a name="line.550"></a><FONT color="green">551</FONT> * @param columnKey the column key.<a name="line.551"></a><FONT color="green">552</FONT> * @param subinterval the subinterval.<a name="line.552"></a><FONT color="green">553</FONT> *<a name="line.553"></a><FONT color="green">554</FONT> * @return The end value (possibly <code>null</code>).<a name="line.554"></a><FONT color="green">555</FONT> */<a name="line.555"></a><FONT color="green">556</FONT> public Number getEndValue(Comparable rowKey, Comparable columnKey, <a name="line.556"></a><FONT color="green">557</FONT> int subinterval) {<a name="line.557"></a><FONT color="green">558</FONT> Number result = null;<a name="line.558"></a><FONT color="green">559</FONT> int row = getRowIndex(rowKey);<a name="line.559"></a><FONT color="green">560</FONT> TaskSeries series = (TaskSeries) this.data.get(row);<a name="line.560"></a><FONT color="green">561</FONT> Task task = series.get(columnKey.toString());<a name="line.561"></a><FONT color="green">562</FONT> if (task != null) {<a name="line.562"></a><FONT color="green">563</FONT> Task sub = task.getSubtask(subinterval);<a name="line.563"></a><FONT color="green">564</FONT> if (sub != null) {<a name="line.564"></a><FONT color="green">565</FONT> TimePeriod duration = sub.getDuration();<a name="line.565"></a><FONT color="green">566</FONT> result = new Long(duration.getEnd().getTime());<a name="line.566"></a><FONT color="green">567</FONT> }<a name="line.567"></a><FONT color="green">568</FONT> }<a name="line.568"></a><FONT color="green">569</FONT> return result;<a name="line.569"></a><FONT color="green">570</FONT> }<a name="line.570"></a><FONT color="green">571</FONT> <a name="line.571"></a><FONT color="green">572</FONT> /**<a name="line.572"></a><FONT color="green">573</FONT> * Returns the percentage complete value of a sub-interval for a given item.<a name="line.573"></a><FONT color="green">574</FONT> *<a name="line.574"></a><FONT color="green">575</FONT> * @param row the row index (zero-based).<a name="line.575"></a><FONT color="green">576</FONT> * @param column the column index (zero-based).<a name="line.576"></a><FONT color="green">577</FONT> * @param subinterval the sub-interval.<a name="line.577"></a><FONT color="green">578</FONT> *<a name="line.578"></a><FONT color="green">579</FONT> * @return The percent complete value (possibly <code>null</code>).<a name="line.579"></a><FONT color="green">580</FONT> */<a name="line.580"></a><FONT color="green">581</FONT> public Number getPercentComplete(int row, int column, int subinterval) {<a name="line.581"></a><FONT color="green">582</FONT> Comparable rowKey = getRowKey(row);<a name="line.582"></a><FONT color="green">583</FONT> Comparable columnKey = getColumnKey(column);<a name="line.583"></a><FONT color="green">584</FONT> return getPercentComplete(rowKey, columnKey, subinterval);<a name="line.584"></a><FONT color="green">585</FONT> }<a name="line.585"></a><FONT color="green">586</FONT> <a name="line.586"></a><FONT color="green">587</FONT> /**<a name="line.587"></a><FONT color="green">588</FONT> * Returns the percentage complete value of a sub-interval for a given item.<a name="line.588"></a><FONT color="green">589</FONT> *<a name="line.589"></a><FONT color="green">590</FONT> * @param rowKey the row key.<a name="line.590"></a><FONT color="green">591</FONT> * @param columnKey the column key.<a name="line.591"></a><FONT color="green">592</FONT> * @param subinterval the sub-interval.<a name="line.592"></a><FONT color="green">593</FONT> *<a name="line.593"></a><FONT color="green">594</FONT> * @return The precent complete value (possibly <code>null</code>).<a name="line.594"></a><FONT color="green">595</FONT> */<a name="line.595"></a><FONT color="green">596</FONT> public Number getPercentComplete(Comparable rowKey, Comparable columnKey, <a name="line.596"></a><FONT color="green">597</FONT> int subinterval) {<a name="line.597"></a><FONT color="green">598</FONT> Number result = null;<a name="line.598"></a><FONT color="green">599</FONT> int row = getRowIndex(rowKey);<a name="line.599"></a><FONT color="green">600</FONT> TaskSeries series = (TaskSeries) this.data.get(row);<a name="line.600"></a><FONT color="green">601</FONT> Task task = series.get(columnKey.toString());<a name="line.601"></a><FONT color="green">602</FONT> if (task != null) {<a name="line.602"></a><FONT color="green">603</FONT> Task sub = task.getSubtask(subinterval);<a name="line.603"></a><FONT color="green">604</FONT> if (sub != null) {<a name="line.604"></a><FONT color="green">605</FONT> result = sub.getPercentComplete();<a name="line.605"></a><FONT color="green">606</FONT> }<a name="line.606"></a><FONT color="green">607</FONT> }<a name="line.607"></a><FONT color="green">608</FONT> return result;<a name="line.608"></a><FONT color="green">609</FONT> }<a name="line.609"></a><FONT color="green">610</FONT> <a name="line.610"></a><FONT color="green">611</FONT> /**<a name="line.611"></a><FONT color="green">612</FONT> * Called when a series belonging to the dataset changes.<a name="line.612"></a><FONT color="green">613</FONT> *<a name="line.613"></a><FONT color="green">614</FONT> * @param event information about the change.<a name="line.614"></a><FONT color="green">615</FONT> */<a name="line.615"></a><FONT color="green">616</FONT> public void seriesChanged(SeriesChangeEvent event) {<a name="line.616"></a><FONT color="green">617</FONT> refreshKeys();<a name="line.617"></a><FONT color="green">618</FONT> fireDatasetChanged();<a name="line.618"></a><FONT color="green">619</FONT> }<a name="line.619"></a><FONT color="green">620</FONT> <a name="line.620"></a><FONT color="green">621</FONT> /**<a name="line.621"></a><FONT color="green">622</FONT> * Refreshes the keys.<a name="line.622"></a><FONT color="green">623</FONT> */<a name="line.623"></a><FONT color="green">624</FONT> private void refreshKeys() {<a name="line.624"></a><FONT color="green">625</FONT> <a name="line.625"></a><FONT color="green">626</FONT> this.keys.clear();<a name="line.626"></a><FONT color="green">627</FONT> for (int i = 0; i < getSeriesCount(); i++) {<a name="line.627"></a><FONT color="green">628</FONT> TaskSeries series = (TaskSeries) this.data.get(i);<a name="line.628"></a><FONT color="green">629</FONT> // look for any keys that we don't already know about...<a name="line.629"></a><FONT color="green">630</FONT> Iterator iterator = series.getTasks().iterator();<a name="line.630"></a><FONT color="green">631</FONT> while (iterator.hasNext()) {<a name="line.631"></a><FONT color="green">632</FONT> Task task = (Task) iterator.next();<a name="line.632"></a><FONT color="green">633</FONT> String key = task.getDescription();<a name="line.633"></a><FONT color="green">634</FONT> int index = this.keys.indexOf(key);<a name="line.634"></a><FONT color="green">635</FONT> if (index < 0) {<a name="line.635"></a><FONT color="green">636</FONT> this.keys.add(key);<a name="line.636"></a><FONT color="green">637</FONT> }<a name="line.637"></a><FONT color="green">638</FONT> }<a name="line.638"></a><FONT color="green">639</FONT> }<a name="line.639"></a><FONT color="green">640</FONT> <a name="line.640"></a><FONT color="green">641</FONT> }<a name="line.641"></a><FONT color="green">642</FONT> <a name="line.642"></a><FONT color="green">643</FONT> /**<a name="line.643"></a><FONT color="green">644</FONT> * Tests this instance for equality with an arbitrary object.<a name="line.644"></a><FONT color="green">645</FONT> * <a name="line.645"></a><FONT color="green">646</FONT> * @param obj the object (<code>null</code> permitted).<a name="line.646"></a><FONT color="green">647</FONT> * <a name="line.647"></a><FONT color="green">648</FONT> * @return A boolean.<a name="line.648"></a><FONT color="green">649</FONT> */<a name="line.649"></a><FONT color="green">650</FONT> public boolean equals(Object obj) {<a name="line.650"></a><FONT color="green">651</FONT> if (obj == this) {<a name="line.651"></a><FONT color="green">652</FONT> return true;<a name="line.652"></a><FONT color="green">653</FONT> }<a name="line.653"></a><FONT color="green">654</FONT> if (!(obj instanceof TaskSeriesCollection)) {<a name="line.654"></a><FONT color="green">655</FONT> return false;<a name="line.655"></a><FONT color="green">656</FONT> }<a name="line.656"></a><FONT color="green">657</FONT> TaskSeriesCollection that = (TaskSeriesCollection) obj;<a name="line.657"></a><FONT color="green">658</FONT> if (!ObjectUtilities.equal(this.data, that.data)) {<a name="line.658"></a><FONT color="green">659</FONT> return false;<a name="line.659"></a><FONT color="green">660</FONT> }<a name="line.660"></a><FONT color="green">661</FONT> return true;<a name="line.661"></a><FONT color="green">662</FONT> }<a name="line.662"></a><FONT color="green">663</FONT> <a name="line.663"></a><FONT color="green">664</FONT> }<a name="line.664"></a></PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -