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

📄 modeltime.java

📁 fortran并行计算包
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }    }    /*        set/get Zoom Factor    */    public void setTimeZoomFactor( double inTimeZoomFactor )    {        tZoomFactor    = inTimeZoomFactor;        logZoomFactor  = Math.log( tZoomFactor );    }    public double getTimeZoomFactor()    {        return tZoomFactor;    }    /*        set/get Zoom Focus    */    public void setTimeZoomFocus()    {        tZoom_focus = tView_init + tView_extent / 2.0;        }    public void setTimeZoomFocus( double inTimeZoomFocus )    {        tZoom_focus = inTimeZoomFocus;        updateParamDisplay();    }    public double getTimeZoomFocus()    {        return tZoom_focus;    }    /*        Zoom Level    */    public int getZoomLevel()    {        return (int) Math.round( Math.log( tZoomScale ) / logZoomFactor );    }    private void setScrollBarIncrements()    {        /*            This needs to be called after updatePixelCoords()        */        int sb_block_incre, sb_unit_incre;        if ( scrollbar != null ) {            sb_block_incre = super.getExtent();            if ( sb_block_incre <= 0 ) {                Dialogs.error( root_window,                               "You have reached the Zoom limit! "                             + "Time ScrollBar has 0 BLOCK Increment. "                             + "Zoom out or risk crashing the viewer." );                sb_block_incre = 0;            }            scrollbar.setBlockIncrement( sb_block_incre );            sb_unit_incre  =  timeRange2pixelRange( tView_extent                                       * Parameters.TIME_SCROLL_UNIT_RATIO );            if ( sb_unit_incre <= 0 ) {                Dialogs.error( root_window,                               "You have reached the Zoom limit! "                             + "Time ScrollBar has 0 UNIT Increment. "                             + "Zoom out or risk crashing the viewer." );                sb_unit_incre = 0;            }            scrollbar.setUnitIncrement( sb_unit_incre );        }    }    // tView_change is  the time measured in second.    public void scroll( double tView_change )    {        this.setTimeViewPosition( tView_init + tView_change );        this.updatePixelCoords();        // this.setScrollBarIncrements();    }    // iView_change is measured in image or viewport pixel coordinates in pixel.    // NOT measured in scrollbar's model, ie DefaultBoundRangeModel, coodinates    public void scroll( int iView_change )    {        double tView_change = (double) iView_change /iViewPerTime;        this.scroll( tView_change );    }    // iView_change is measured in image or viewport pixel coordinates in pixel.    // The following function allows scroll pass tGlobal_min and tGlobal_max.    // In general, it is not desirable, so Avoid using this scroll() function.    public void scroll( int iView_change, boolean isValueAdjusting )    {        old_tView_init = tView_init;        double tView_change = (double) iView_change / iViewPerTime;        int iScrollbar_change = this.timeRange2pixelRange( tView_change );        super.setRangeProperties( super.getValue() + iScrollbar_change,                                  super.getExtent(),                                  super.getMinimum(),                                  super.getMaximum(),                                  isValueAdjusting );        tView_init     = pixel2time( super.getValue() );        updateParamDisplay();    }    /*        Zoom Operations    */    public void zoomHome()    {        tZoomScale  = 1.0;        this.setTimeViewExtent( tGlobal_extent );        this.setTimeViewPosition( tGlobal_min );        iViewPerTime = iView_width / tView_extent;        this.updatePixelCoords();        this.setScrollBarIncrements();        // clean up all the zoom stacks.        zoom_undo_stack.clear();        zoom_redo_stack.clear();    }    private void updateZoomStack( Stack zoom_stack )    {        TimeBoundingBox vport_timebox;        vport_timebox = new TimeBoundingBox();        vport_timebox.setEarliestTime( tView_init );        vport_timebox.setLatestFromEarliest( tView_extent );        zoom_stack.push( vport_timebox );    }    /*        Zoom In/Out operations:        (tView_init , tView_extent ) are before Zoom In/Out operations        (tView_init^, tView_extent^) are after  Zoom In/Out operations        where user clicks should be constant before & after zoom in/out,        define  tView_ratio = ( tView_center - tView_init ) / tView_extent        e.g. if tView_center is the middle of viewport, tView_ratio = 1/2           tView_init + tView_extent * tView_ratio         = tView_init^ + tView_extent^ * tView_ratio         = constant        when tView_focus is within viewport            constant = tView_focus        else            constant = middle of the viewport    */    public void zoomIn()    {        this.updateZoomStack( zoom_undo_stack );        double tZoom_center;        double tView_ratio;        tZoomScale  *= tZoomFactor;        if (    tView_init  < tZoom_focus             && tZoom_focus < tView_init + tView_extent )            tZoom_center = tZoom_focus;        else            tZoom_center = tView_init + tView_extent / 2.0;        tView_ratio  = ( tZoom_center - tView_init ) / tView_extent;        this.setTimeViewExtent( tView_extent / tZoomFactor );        this.setTimeViewPosition( tZoom_center - tView_extent * tView_ratio );        iViewPerTime = iView_width / tView_extent;        this.updatePixelCoords();        this.setScrollBarIncrements();    }    public void zoomOut()    {        this.updateZoomStack( zoom_undo_stack );        double tZoom_center;        double tView_ratio;        tZoomScale  /= tZoomFactor;        if (    tView_init  < tZoom_focus             && tZoom_focus < tView_init + tView_extent )            tZoom_center = tZoom_focus;        else            tZoom_center = tView_init + tView_extent / 2.0;        tView_ratio  = ( tZoom_center - tView_init ) / tView_extent;        this.setTimeViewExtent( tView_extent * tZoomFactor );        this.setTimeViewPosition( tZoom_center - tView_extent * tView_ratio );        iViewPerTime = iView_width / tView_extent;        this.updatePixelCoords();        this.setScrollBarIncrements();    }    public void zoomRapidly( double new_tView_init, double new_tView_extent )    {        double cur_tZoomScale;        cur_tZoomScale = tView_extent / new_tView_extent;        // If this is a rapid zoom-in        // if ( cur_tZoomScale > 1.0d )            this.updateZoomStack( zoom_undo_stack );        tZoomScale  *= cur_tZoomScale;        this.setTimeViewExtent( new_tView_extent );        this.setTimeViewPosition( new_tView_init );        iViewPerTime = iView_width / tView_extent;        this.updatePixelCoords();        this.setScrollBarIncrements();    }    private void zoomBack( double new_tView_init, double new_tView_extent )    {        double cur_tZoomScale;        cur_tZoomScale = tView_extent / new_tView_extent;        tZoomScale  *= cur_tZoomScale;        this.setTimeViewExtent( new_tView_extent );        this.setTimeViewPosition( new_tView_init );        iViewPerTime = iView_width / tView_extent;        this.updatePixelCoords();        this.setScrollBarIncrements();    }    public void zoomUndo()    {        if ( ! zoom_undo_stack.empty() ) {            this.updateZoomStack( zoom_redo_stack );            TimeBoundingBox vport_timebox;            vport_timebox = (TimeBoundingBox) zoom_undo_stack.pop();            this.zoomBack( vport_timebox.getEarliestTime(),                           vport_timebox.getDuration() );            vport_timebox = null;        }    }    public void zoomRedo()    {        if ( ! zoom_redo_stack.empty() ) {            this.updateZoomStack( zoom_undo_stack );            TimeBoundingBox vport_timebox;            vport_timebox = (TimeBoundingBox) zoom_redo_stack.pop();            this.zoomBack( vport_timebox.getEarliestTime(),                           vport_timebox.getDuration() );            vport_timebox = null;        }    }    public boolean isZoomUndoStackEmpty()    {        return zoom_undo_stack.empty();    }    public boolean isZoomRedoStackEmpty()    {        return zoom_redo_stack.empty();    }    // fire StateChanged for specific listener class.    /*    public void fireStateChanged( String listenerClass )    {        // listenersList is defined in superclass DefaultBoundedRangeModel        Object[] listeners = listenerList.getListenerList();        for ( int i = listeners.length - 2; i >= 0; i -=2 ) {            if (  listeners[i] == ChangeListener.class               && listeners[i+1].getClass().getName().equals(listenerClass) ) {                if ( Debug.isActive() )                    Debug.println( "ModelTime: fireStateChanged()'s "                                 + "listeners[" + (i+1) + "] = "                                 + listeners[i+1].getClass().getName() );                if (changeEvent == null) {                    changeEvent = new ChangeEvent(this);                }                ((ChangeListener)listeners[i+1]).stateChanged(changeEvent);            }            if ( Debug.isActive() && listeners[i] == ChangeListener.class )                Debug.println( "ModelTime: fireStateChanged()'s "                             + "ChangeListeners[" + (i+1) + "] = "                             + listeners[i+1].getClass().getName() );        }    }    */    public void adjustmentValueChanged( AdjustmentEvent evt )    {        if ( Debug.isActive() ) {            Debug.println( "ModelTime: AdjustmentValueChanged()'s START: " );            Debug.println( "adj_evt = " + evt );        }        if ( Debug.isActive() )            Debug.println( "ModelTime(before) = " + this.toString() );        this.updateTimeCoords();        if ( Debug.isActive() )            Debug.println( "ModelTime(after) = " + this.toString() );        // notify all TimeListeners of changes from Adjustment Listener        this.fireTimeChanged();        if ( Debug.isActive() )            Debug.println( "ModelTime: AdjustmentValueChanged()'s END: " );    }    public String toString()    {        String str_rep = super.toString() + ",  "                       + "tGlobal_min=" + tGlobal_min + ", "                       + "tGlobal_max=" + tGlobal_max + ", "                       + "tView_init=" + tView_init + ", "                       + "tView_extent=" + tView_extent + ", "                       + "iView_width=" + iView_width + ", "                       + "iViewPerTime=" + iViewPerTime + ", "                       + "iScrollbarPerTime=" + iScrollbarPerTime                       ;        return getClass().getName() + "{" + str_rep + "}";    }}

⌨️ 快捷键说明

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