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

📄 viewporttime.java

📁 fortran并行计算包
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            line_time = timebox.getLatestTime();            if ( coord_xform.contains( line_time ) ) {                x2_pos = coord_xform.convertTimeToPixel( line_time );                g.setColor( line_color );                g.drawLine( x2_pos, 0, x2_pos, this.getHeight() );            }            else                x2_pos = this.getWidth();            if ( x2_pos > x1_pos ) {                g.setColor( area_color );                g.fillRect( x1_pos+1, 0, x2_pos-x1_pos-1, this.getHeight() );            }        }    }    public void paint( Graphics g )    {        Iterator    itr;        InfoDialog  info_popup;        double      popup_time;        double      focus_time;        int         x_pos;        if ( Debug.isActive() )            Debug.println( "ViewportTime: paint()'s START: " );        // Need to get the FOCUS so KeyListener will respond.        // requestFocus();        //  "( (Component) view_img ).repaint()" may have been invoked        //  in JComponent's paint() method's paintChildren() ?!        super.paint( g );        /*  Initialization  */        vport_timebox.setEarliestTime( time_model.getTimeViewPosition() );        vport_timebox.setLatestFromEarliest( time_model.getTimeViewExtent() );        coord_xform.resetTimeBounds( vport_timebox );        // Draw a line at time_model.getTimeZoomFocus()         if ( ! Parameters.LEFTCLICK_INSTANT_ZOOM ) {            focus_time = time_model.getTimeZoomFocus();            if ( coord_xform.contains( focus_time ) ) {                x_pos = coord_xform.convertTimeToPixel( focus_time );                g.setColor( FOCUS_LINE_COLOR );                g.drawLine( x_pos, 0, x_pos, this.getHeight() );            }        }        /*  Draw zoom boundary  */        if ( zoom_timebox != null )            this.drawShadyTimeBoundingBox( g, zoom_timebox,                                           ZOOM_LINE_COLOR,                                           ZOOM_AREA_COLOR );        if ( info_timebox != null )            this.drawShadyTimeBoundingBox( g, info_timebox,                                           INFO_LINE_COLOR,                                           INFO_AREA_COLOR );        /*  Draw the InfoDialog marker  */        itr = info_dialogs.iterator();        while ( itr.hasNext() ) {            info_popup = (InfoDialog) itr.next();            if ( info_popup instanceof InfoDialogForDuration ) {                InfoDialogForDuration  popup;                popup = (InfoDialogForDuration) info_popup;                this.drawShadyTimeBoundingBox( g, popup.getTimeBoundingBox(),                                               INFO_LINE_COLOR,                                               INFO_AREA_COLOR );            }            else {                popup_time = info_popup.getClickedTime();                if ( coord_xform.contains( popup_time ) ) {                    x_pos = coord_xform.convertTimeToPixel( popup_time );                    g.setColor( INFO_LINE_COLOR );                    g.drawLine( x_pos, 0, x_pos, this.getHeight() );                }            }        }        if ( Debug.isActive() )            Debug.println( "ViewportTime: paint()'s END: " );    }    /*        Implementation of HierarchyBoundsListener    *//*    public void ancestorMoved( HierarchyEvent evt )    {        if ( Debug.isActive() ) {            Debug.println( "ViewportTime: ancestorMoved()'s START: " );            Debug.println( "hrk_evt = " + evt );            Debug.println( "ViewportTime: ancestorMoved()'s END: " );        }    }    public void ancestorResized( HierarchyEvent evt )    {        if ( Debug.isActive() ) {            Debug.println( "ViewportTime: ancestorResized()'s START: " );            Debug.println( "hrk_evt = " + evt );            if ( view_img != null ) {                Debug.println( "ViewportTime: "                             + "view_img.getXaxisViewPosition() = "                             + view_pt.x );                Debug.println( "ViewportTime: [before] getViewPosition() = "                             + super.getViewPosition() );                Debug.println( "ViewportTime: ancestorMoved()'s this = "                             + this );            }        }        if ( view_img != null ) {            //  ScrollableView.setJComponentSize(),            //  JViewport.setPreferredSize() and JViewport.setViewPosition()            //  need to be called when the topmost container in the            //  containment hierarchy is            //  resized but this class is moved but NOT resized.  In             //  this scenario, the resizing of topmost container seems             //  to reset the location of scrollable to (0,0) as well as             //  the size of the ScrollableView to the visible size of             //  the JViewport.            //  view_img.setJComponentSize();            this.setPreferredSize( getSize() );            view_pt.x = view_img.getXaxisViewPosition();            super.setViewPosition( view_pt );            // calling view.repaint() to ensure the view is repainted            // after setViewPosition is called.            // -- apparently, this.repaint(), the RepaintManager, has invoked             //    ( (Component) view_img ).repaint();            // -- JViewport.setViewPosition() may have invoked super.repaint()            this.repaint();        }        if ( Debug.isActive() ) {            if ( view_img != null ) {                Debug.println( "ViewportTime: "                             + "view_img.getXaxisViewPosition() = "                             + view_pt.x );                Debug.println( "ViewportTime: [after] getViewPosition() = "                             + super.getViewPosition() );                Debug.println( "ViewportTime: ancestorMoved()'s this = "                             + this );            }            Debug.println( "ViewportTime: ancestorResized()'s END: " );        }    }*/    private URL getURL( String filename )    {        return getClass().getResource( filename );    }    public void initLeftMouseToZoom( boolean in_isLeftMouseClick4Zoom )    {        ButtonGroup  btn_group;        ImageIcon    icon, icon_shaded;        URL          icon_URL;        isLeftMouseClick4Zoom  = in_isLeftMouseClick4Zoom;        btn_group              = new ButtonGroup();        icon_URL  = getURL( Const.IMG_PATH + "ZoomBW16.gif" );        if ( icon_URL != null ) {            icon         = new ImageIcon( icon_URL );            icon_shaded  = new ImageIcon(                           GrayFilter.createDisabledImage( icon.getImage() ) );            /*            System.out.println( "ZoomBW16.gif: icon = (" + icon.getIconWidth()                              + "," + icon.getIconHeight() + "),  "                              + "icon_shaded = (" + icon_shaded.getIconWidth()                              + "," + icon_shaded.getIconHeight() + ")" );            */            zoom_btn     = new JRadioButton( icon_shaded );            zoom_btn.setSelectedIcon( icon );            zoom_btn.setBorderPainted( true );        }        else            zoom_btn = new JRadioButton( "zoom" );        zoom_btn.setToolTipText( "Left mouse button click to Zoom" );        zoom_btn.addActionListener( new ActionListener() {            public void actionPerformed( ActionEvent evt )            {                if ( zoom_btn.isSelected() )                    isLeftMouseClick4Zoom = true;            }        } );        if ( isLeftMouseClick4Zoom )            zoom_btn.doClick();        btn_group.add( zoom_btn );        icon_URL  = getURL( Const.IMG_PATH + "HandOpen16.gif" );        if ( icon_URL != null ) {            icon         = new ImageIcon( icon_URL );            icon_shaded  = new ImageIcon(                           GrayFilter.createDisabledImage( icon.getImage() ) );            hand_btn = new JRadioButton( icon_shaded );            hand_btn.setSelectedIcon( icon );            hand_btn.setBorderPainted( true );        }        else            hand_btn = new JRadioButton( "hand" );        hand_btn.setToolTipText( "Left mouse button click to Scroll" );        hand_btn.addActionListener( new ActionListener() {            public void actionPerformed( ActionEvent evt )            {                if ( hand_btn.isSelected() )                    isLeftMouseClick4Zoom = false;            }        } );        if ( !isLeftMouseClick4Zoom )            hand_btn.doClick();        btn_group.add( hand_btn );    }    public JPanel createLeftMouseModePanel( int boxlayout_mode )    {        JPanel   btn_panel = null;        btn_panel = null;        if ( zoom_btn != null && hand_btn != null ) {            btn_panel = new JPanel();            btn_panel.setLayout( new BoxLayout( btn_panel, boxlayout_mode ) );            btn_panel.add( zoom_btn );            btn_panel.add( hand_btn );            btn_panel.setBorder( BorderFactory.createEtchedBorder() );        }        return btn_panel;    }        // Override the Component.setCursor()        public void setCursor( Cursor new_cursor )        {            /*               Replace the DEFAULT_CURSOR by ZoomPlus or HandOpen cursor.               i.e. the default cursor for this class is either                ZoomPlus or HandOpen cursor depending on isLeftMouseClick4Zoom.            */            if ( new_cursor == CustomCursor.Normal ) {                if ( isLeftMouseClick4Zoom )                    super.setCursor( CustomCursor.ZoomPlus );                else                    super.setCursor( CustomCursor.HandOpen );            }            else                super.setCursor( new_cursor );        }        /*            Interface to fulfill MouseInputListener()        */        public void mouseMoved( MouseEvent mouse_evt ) {}        public void mouseEntered( MouseEvent mouse_evt )        {            super.requestFocus();            if ( isLeftMouseClick4Zoom )                super.setCursor( CustomCursor.ZoomPlus );            else                super.setCursor( CustomCursor.HandOpen );        }        public void mouseExited( MouseEvent mouse_evt )        {            /*               useless to reset cursor here because of similarity of the               overriden this.setCursor() above and mouseEntered().            */            // super.setCursor( CustomCursor.Normal );        }        public void mouseClicked( MouseEvent mouse_evt )        {            Point  vport_click;            double focus_time;            if ( SwingUtilities.isLeftMouseButton( mouse_evt ) ) {                if ( isLeftMouseClick4Zoom ) {  // Zoom Mode                    vport_click = mouse_evt.getPoint();                    focus_time  = coord_xform.convertPixelToTime(                                              vport_click.x );                    time_model.setTimeZoomFocus( focus_time );                    if ( Parameters.LEFTCLICK_INSTANT_ZOOM ) {                        // Left clicking with Shift to Zoom Out,                        // Left clinking to Zoom In.                        if ( mouse_evt.isShiftDown() ) {                            time_model.zoomOut();                            super.setCursor( CustomCursor.ZoomMinus );                        }                        else {                            time_model.zoomIn();                            super.setCursor( CustomCursor.ZoomPlus );                        }                        super.requestFocus();                        if ( toolbar != null )

⌨️ 快捷键说明

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