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

📄 summarystate.java

📁 fortran并行计算包
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *  (C) 2001 by Argonne National Laboratory *      See COPYRIGHT in top-level directory. *//* *  @author  Anthony Chan */package base.topology;import java.awt.Graphics2D;import java.awt.Insets;import java.awt.Color;import java.awt.Point;import java.util.Arrays;import base.drawable.CoordPixelXform;import base.drawable.TimeBoundingBox;import base.statistics.CategoryTimeBox;import base.statistics.TimeAveBox;public class SummaryState{    // private static StateBorder BorderStyle = StateBorder.COLOR_XOR_BORDER;    private static StateBorder BorderStyle  = StateBorder.WHITE_RAISED_BORDER;    private static StateBorder BackBorder   = StateBorder.COLOR_XOR_BORDER;    private static Color       BackColor    = Color.black;    public  static Color       ForeColor    = Color.white;    public static void setBorderStyle( final StateBorder state_border )    { BorderStyle = state_border; }    public static void setBackgroundColor( Color color )    {        BackColor   = color;        if ( BackColor == Color.black )            ForeColor = Color.lightGray;        else if ( BackColor == Color.white )            ForeColor = Color.darkGray;        else if ( BackColor == Color.darkGray )            ForeColor = Color.white;        else if ( BackColor == Color.lightGray )            ForeColor = Color.darkGray;        else            ForeColor = Color.white;    }    // The constant String's should be the same as those in PreviewState    public  static final String FIT_MOST_LEGENDS                                = PreviewState.FIT_MOST_LEGENDS;    private static final int    FIT_MOST_LEGENDS_ID     = 0;    public  static final String OVERLAP_INCLUSION                                = PreviewState.OVERLAP_INCLUSION;    private static final int    OVERLAP_INCLUSION_ID    = 1;    public  static final String OVERLAP_EXCLUSION                                = PreviewState.OVERLAP_EXCLUSION;    private static final int    OVERLAP_EXCLUSION_ID    = 3;    public  static final String CUMULATIVE_EXCLUSION                                = PreviewState.CUMULATIVE_EXCLUSION;    private static final int    CUMULATIVE_EXCLUSION_ID = 4;    private static       int    DisplayType             = OVERLAP_INCLUSION_ID;    public static void setDisplayType( String new_display_type )    {        if ( new_display_type.equals( FIT_MOST_LEGENDS ) )            DisplayType = FIT_MOST_LEGENDS_ID;        else if ( new_display_type.equals( OVERLAP_INCLUSION ) )            DisplayType = OVERLAP_INCLUSION_ID;        else if ( new_display_type.equals( OVERLAP_EXCLUSION ) )            DisplayType = OVERLAP_EXCLUSION_ID;        else if ( new_display_type.equals( CUMULATIVE_EXCLUSION ) )            DisplayType = CUMULATIVE_EXCLUSION_ID;        else            DisplayType = OVERLAP_INCLUSION_ID;    }    public static boolean isDisplayTypeEqualWeighted()    {        return DisplayType == FIT_MOST_LEGENDS_ID;    }    public static boolean isDisplayTypeExclusiveRatio()    {        return    DisplayType == OVERLAP_EXCLUSION_ID               || DisplayType == CUMULATIVE_EXCLUSION_ID;    }    public static boolean isDisplayTypeCumulative()    {        return    DisplayType == CUMULATIVE_EXCLUSION_ID;    }    private static        int    MinCategoryHeight          = 2;      private static        int    MinCategorySeparation      = 4;      public static void setMinCategoryHeight( int new_min_category_height )    {        MinCategoryHeight  = new_min_category_height;    }    /*        Draw a Rectangle between left-upper vertex (start_time, start_ypos)         and right-lower vertex (final_time, final_ypos)        Assume caller guarantees the order of timestamps and ypos, such that        start_time <= final_time  and  start_ypos <= final_ypos.    */    private static int  drawForward( Graphics2D g, Color color,                                     CoordPixelXform coord_xform,                                     double start_time, float start_ypos,                                     double final_time, float final_ypos )    {        int      iStart, jStart, iFinal, jFinal;        iStart   = coord_xform.convertTimeToPixel( start_time );        iFinal   = coord_xform.convertTimeToPixel( final_time );        jStart   = coord_xform.convertRowToPixel( start_ypos );        jFinal   = coord_xform.convertRowToPixel( final_ypos );        boolean  isStartVtxInImg, isFinalVtxInImg;        isStartVtxInImg = ( iStart >= 0 ) ;        isFinalVtxInImg = ( iFinal <  coord_xform.getImageWidth() );        int iHead, iTail, jHead, jTail;        // jHead = slope * ( iHead - iStart ) + jStart        if ( isStartVtxInImg )            iHead = iStart;        else            iHead = 0;            // iHead = -1;        jHead    = jStart;        // jTail = slope * ( iTail - iFinal ) + jFinal        if ( isFinalVtxInImg )            iTail = iFinal;        else            iTail = coord_xform.getImageWidth() - 1;            // iTail = coord_xform.getImageWidth();        jTail    = jFinal;        if ( color == null )            color = ForeColor;              // Fill the color of the rectangle        g.setColor( color );        g.fillRect( iHead, jHead, iTail-iHead+1, jTail-jHead+1 );        BorderStyle.paintStateBorder( g, color,                                      iHead, jHead, isStartVtxInImg,                                      iTail, jTail, isFinalVtxInImg );        return 1;    }    /*        Check if a point in pixel coordinate is in a Rectangle        specified between left-upper vertex (start_time, start_ypos)         and right-lower vertex (final_time, final_ypos)        Assume caller guarantees the order of timestamps and ypos, such that        start_time <= final_time  and  start_ypos <= final_ypos        Same as State.isPixelIn()    */    private static boolean isPixelIn( CoordPixelXform coord_xform, Point pt,                                      double start_time, float start_ypos,                                      double final_time, float final_ypos )    {        int      iStart, jStart, iFinal, jFinal;        int      pt_x, pt_y;        pt_y     = pt.y;        jStart   = coord_xform.convertRowToPixel( start_ypos );        if ( pt_y < jStart  )            return false;        jFinal   = coord_xform.convertRowToPixel( final_ypos );        if ( pt_y > jFinal )            return false;        pt_x     = pt.x;        iStart   = coord_xform.convertTimeToPixel( start_time );        if ( pt_x < iStart )            return false;        iFinal   = coord_xform.convertTimeToPixel( final_time );        if ( pt_x > iFinal )            return false;        return true;    }    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++ ;

⌨️ 快捷键说明

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