double starttime,
double finaltime )
{
CategoryTimeBox[] typeboxes;
CategoryTimeBox typebox;
TimeBoundingBox curr_timebox;
boolean isInclusive;
double prev_time, interval, duration;
int vis_typeboxes_length, idx;
typeboxes = avebox.arrayOfCategoryTimeBoxes();
if ( isDisplayTypeExclusiveRatio() )
Arrays.sort( typeboxes, CategoryTimeBox.EXCL_RATIO_ORDER );
else // OverlapInclusionRatio, CumulativeInclusionRatio, FitMostLegends
Arrays.sort( typeboxes, CategoryTimeBox.INCL_RATIO_ORDER );
/*
CategoryTimeBox[] is in ascending order of the respective ratio
set TimeBoundingBox of CategoryTimeBox[] in descending ratio order
*/
curr_timebox = avebox.getCurrentTimeBoundingBox();
curr_timebox.reinitialize();
if ( isDisplayTypeEqualWeighted() ) {
vis_typeboxes_length = 0;
for ( idx = typeboxes.length-1; idx >= 0; idx-- ) {
if ( typeboxes[ idx ].isCategoryVisiblySearchable() )
vis_typeboxes_length++ ;
}
prev_time = starttime;
interval = ( finaltime - starttime ) / vis_typeboxes_length;
for ( idx = typeboxes.length-1; idx >= 0; idx-- ) {
typebox = typeboxes[ idx ];
if ( typebox.isCategoryVisiblySearchable() ) {
typebox.setEarliestTime( prev_time );
typebox.setLatestFromEarliest( interval );
prev_time = typebox.getLatestTime();
curr_timebox.affectTimeBounds( typebox );
}
}
}
else {
isInclusive = ! isDisplayTypeExclusiveRatio();
if ( isDisplayTypeCumulative() ) { // CumulativeXXclusionRatio
prev_time = starttime;
duration = finaltime - starttime;
for ( idx = typeboxes.length-1; idx >= 0; idx-- ) {
typebox = typeboxes[ idx ];
if ( typebox.isCategoryVisiblySearchable() ) {
interval = duration
* typebox.getCategoryRatio( isInclusive );
typebox.setEarliestTime( prev_time );
typebox.setLatestFromEarliest( interval );
prev_time = typebox.getLatestTime();
curr_timebox.affectTimeBounds( typebox );
}
}
}
else { // OverlapInclusionRatio, OverlapExclusiveRatio
duration = finaltime - starttime;
for ( idx = typeboxes.length-1; idx >= 0; idx-- ) {
typebox = typeboxes[ idx ];
if ( typebox.isCategoryVisiblySearchable() ) {
interval = duration
* typebox.getCategoryRatio( isInclusive );
typebox.setEarliestTime( starttime );
typebox.setLatestFromEarliest( interval );
curr_timebox.affectTimeBounds( typebox );
}
}
}
}
}