float start_ypos, float final_ypos,
float avebox_height )
{
CategoryTimeBox[] typeboxes;
CategoryTimeBox typebox;
TimeBoundingBox curr_timebox;
double head_time, tail_time;
float head_ypos, tail_ypos, gap_ypos;
boolean hasBoundary;
int idx;
if ( start_ypos < final_ypos ) {
head_ypos = start_ypos;
tail_ypos = final_ypos;
}
else {
head_ypos = final_ypos;
tail_ypos = start_ypos;
}
if ( pt.y < coord_xform.convertRowToPixel( head_ypos ) )
return null;
if ( pt.y > coord_xform.convertRowToPixel( tail_ypos ) )
return null;
// Search CategoryTimeBox[] in ascending ratio order
curr_timebox = avebox.getCurrentTimeBoundingBox();
typeboxes = avebox.arrayOfCategoryTimeBoxes();
if ( isDisplayTypeEqualWeighted()
|| isDisplayTypeCumulative() ) {
if ( head_ypos + avebox_height
< tail_ypos - avebox_height ) {
head_ypos += avebox_height;
tail_ypos -= avebox_height;
hasBoundary = true;
}
else
hasBoundary = false;
for ( idx = 0; idx < typeboxes.length; idx++ ) {
typebox = typeboxes[ idx ];
head_time = typebox.getEarliestTime();
tail_time = typebox.getLatestTime();
if ( isPixelIn( coord_xform, pt,
head_time, head_ypos,
tail_time, tail_ypos ) )
return typebox;
}
if ( hasBoundary ) {
head_ypos -= avebox_height;
tail_ypos += avebox_height;
head_time = curr_timebox.getEarliestTime();
tail_time = curr_timebox.getLatestTime();
if ( isPixelIn( coord_xform, pt,
head_time, head_ypos,
tail_time, tail_ypos ) )
return avebox;
}
}
else { // OverlapXXclusionRatio
if ( head_ypos + avebox_height
< tail_ypos - avebox_height ) {
head_ypos += avebox_height;
tail_ypos -= avebox_height;
hasBoundary = true;
}
else
hasBoundary = false;
gap_ypos = ( tail_ypos - head_ypos ) / ( typeboxes.length * 2 );
head_ypos += gap_ypos * (typeboxes.length-1);
tail_ypos -= gap_ypos * (typeboxes.length-1);
for ( idx = 0; idx < typeboxes.length; idx++ ) {
typebox = typeboxes[ idx ];
head_time = typebox.getEarliestTime();
tail_time = typebox.getLatestTime();
if ( isPixelIn( coord_xform, pt,
head_time, head_ypos,
tail_time, tail_ypos ) )
return typebox;
head_ypos -= gap_ypos;
tail_ypos += gap_ypos;
}
if ( hasBoundary ) {
head_ypos += gap_ypos;
tail_ypos -= gap_ypos;
head_ypos -= avebox_height;
tail_ypos += avebox_height;
head_time = curr_timebox.getEarliestTime();
tail_time = curr_timebox.getLatestTime();
if ( isPixelIn( coord_xform, pt,
head_time, head_ypos,
tail_time, tail_ypos ) )
return avebox;
}