Package base.statistics

Examples of base.statistics.CategoryTimeBox$CountOrder


    public static void setTimeBoundingBox( TimeAveBox  avebox,
                                           double      starttime,
                                           double      finaltime )
    {
        CategoryTimeBox[]  typeboxes;
        CategoryTimeBox    typebox;
        boolean            isInclusive;
        double             interval, duration;
        int                idx;

        // exclusive ratio is alway zero for summary arrow
        typeboxes  = avebox.arrayOfCategoryTimeBoxes();
        Arrays.sort( typeboxes, CategoryTimeBox.INCL_RATIO_ORDER );

        isInclusive  = true// alway true for arrow
        duration     = finaltime - starttime;
        for ( idx = typeboxes.length-1; idx >= 0; idx-- ) {
            typebox   = typeboxes[ idx ];
            interval  = duration * typebox.getCategoryRatio( isInclusive );
            typebox.setEarliestTime( starttime );
            typebox.setLatestFromEarliest( interval );
        }
    }
View Full Code Here


    public  static int  draw( Graphics2D  g, TimeAveBox  avebox,
                              CoordPixelXform  coord_xform,
                              float start_ypos, float final_ypos )
    {
        CategoryTimeBox[]  typeboxes;
        CategoryTimeBox    typebox;
        Color              color;
        Stroke             arrow_stroke;
        double             head_time, tail_time;
        float              head_ypos, tail_ypos;
        double             slope, intercept;
        int                count, idx;

        head_ypos  = start_ypos;
        tail_ypos  = final_ypos;
        typeboxes  = avebox.arrayOfCategoryTimeBoxes();

        count        = 0;
        arrow_stroke = getArrowStroke( avebox.getAveNumOfRealObjects() );
        typebox      = typeboxes[ typeboxes.length-1 ];
        head_time    = typebox.getEarliestTime();
        tail_time    = typebox.getLatestTime();
        slope        = (double) ( tail_ypos - head_ypos )
                              / ( tail_time - head_time );
        intercept    = (double) head_ypos - slope * head_time;
        for ( idx = typeboxes.length-1; idx >= 0; idx-- ) {
            typebox      = typeboxes[ idx ];
            color        = typebox.getCategoryColor();
            head_time    = typebox.getEarliestTime()// independent of idx
            tail_time    = typebox.getLatestTime();
            tail_ypos    = (float) ( slope * tail_time + intercept );
            count  += drawForward( g, color, arrow_stroke, coord_xform,
                                   head_time, head_ypos,
                                   tail_time, tail_ypos );
        }
View Full Code Here

    public static Object containsPixel( TimeAveBox  avebox,
                                        CoordPixelXform coord_xform, Point pt,
                                        float start_ypos, float final_ypos )
    {
        CategoryTimeBox[]  typeboxes;
        CategoryTimeBox    typebox;
        double             head_time, tail_time;
        float              head_ypos, tail_ypos;
        double             slope, intercept;
        int                idx;

        head_ypos  = start_ypos;
        tail_ypos  = final_ypos;
        typeboxes  = avebox.arrayOfCategoryTimeBoxes();

        typebox      = typeboxes[ typeboxes.length-1 ];
        head_time    = typebox.getEarliestTime();
        tail_time    = typebox.getLatestTime();
        slope        = (double) ( tail_ypos - head_ypos )
                              / ( tail_time - head_time );
        intercept    = (double) head_ypos - slope * head_time;
        for ( idx = 0; idx < typeboxes.length; idx++ ) {
            typebox      = typeboxes[ idx ];
            head_time    = typebox.getEarliestTime();
            tail_time    = typebox.getLatestTime();
            tail_ypos    = (float) ( slope * tail_time + intercept );
            if ( Line.containsPixel( coord_xform, pt,
                                     head_time, head_ypos,
                                     tail_time, tail_ypos ) )
                return avebox;
View Full Code Here

                              CoordPixelXform  coord_xform,
                              float  start_ypos, float  final_ypos,
                              float  avebox_height )
    {
        CategoryTimeBox[]  typeboxes;
        CategoryTimeBox    typebox;
        TimeBoundingBox    curr_timebox;
        Color              color;
        double             head_time, tail_time;
        float              head_ypos, tail_ypos, gap_ypos;
        int                count, idx;

        if ( start_ypos < final_ypos ) {
            head_ypos  = start_ypos;
            tail_ypos  = final_ypos;
        }
        else {
            head_ypos  = final_ypos;
            tail_ypos  = start_ypos;
        }

        // Draw CategoryTimeBox[] in descending ratio order
        count         = 0;
        curr_timebox  = avebox.getCurrentTimeBoundingBox();
        typeboxes     = avebox.arrayOfCategoryTimeBoxes();
        if (    isDisplayTypeEqualWeighted()
             || isDisplayTypeCumulative() ) {
            if (   head_ypos + avebox_height
                 < tail_ypos - avebox_height ) {
                head_time  = curr_timebox.getEarliestTime();
                tail_time  = curr_timebox.getLatestTime();
                count += drawForward( g, null, coord_xform,
                                      head_time, head_ypos,
                                      tail_time, tail_ypos );
                head_ypos += avebox_height;
                tail_ypos -= avebox_height;
            }
            for ( idx = typeboxes.length-1; idx >= 0; idx-- ) {
                typebox    = typeboxes[ idx ];
                color      = typebox.getCategoryColor();
                head_time  = typebox.getEarliestTime();
                tail_time  = typebox.getLatestTime();
                count += drawForward( g, color, coord_xform,
                                      head_time, head_ypos,
                                      tail_time, tail_ypos );
            }
        }
        else { // OverlapXXclusionRatio
            if (   head_ypos + avebox_height
                 < tail_ypos - avebox_height ) {
                head_time  = curr_timebox.getEarliestTime();
                tail_time  = curr_timebox.getLatestTime();
                count += drawForward( g, null, coord_xform,
                                      head_time, head_ypos,
                                      tail_time, tail_ypos );
                head_ypos += avebox_height;
                tail_ypos -= avebox_height;
            }
            gap_ypos = ( tail_ypos - head_ypos ) / ( typeboxes.length * 2 );
            for ( idx = typeboxes.length-1; idx >= 0; idx-- ) {
                typebox    = typeboxes[ idx ];
                color      = typebox.getCategoryColor();
                head_time  = typebox.getEarliestTime();
                tail_time  = typebox.getLatestTime();
                count += drawForward( g, color, coord_xform,
                                      head_time, head_ypos,
                                      tail_time, tail_ypos );
                head_ypos += gap_ypos;
                tail_ypos -= gap_ypos;
View Full Code Here

                                        CoordPixelXform coord_xform, Point pt,
                                        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;
View Full Code Here

    public static void setTimeBoundingBox( TimeAveBox  avebox,
                                           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 );
                    }
               }
            }
        }
View Full Code Here

TOP

Related Classes of base.statistics.CategoryTimeBox$CountOrder

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.