progressmonitorconsole.java
来自「基于java的3d开发库。对坐java3d的朋友有很大的帮助。」· Java 代码 · 共 67 行
JAVA
67 行
//===========================================================================//=-------------------------------------------------------------------------=//= Module history: =//= - March 19 2006 - Oscar Chavarro: Original base version =//===========================================================================package vsdk.toolkit.gui;public class ProgressMonitorConsole extends ProgressMonitor { private double currentPercent; private double jumpPercent; private int lastPrintedLabel; public ProgressMonitorConsole() { } public void begin() { currentPercent = 0; lastPrintedLabel = 0; jumpPercent = 2; System.out.print("[ 0% "); } public void end() { System.out.println(" 100% ]"); } private boolean testLabelLimit(int limit) { if ( limit == lastPrintedLabel ) return false; if ( currentPercent - 6*jumpPercent/10 < limit && currentPercent + 6*jumpPercent/10 > limit ) { System.out.print(" " + limit + "% "); lastPrintedLabel = limit; return true; } return false; } public void update(double minValue, double maxValue, double currentValue) { double v = 100 * (currentValue - minValue) / (maxValue - minValue); while ( currentPercent + jumpPercent < v ) { currentPercent += jumpPercent; if ( !testLabelLimit(25) && !testLabelLimit(50) && !testLabelLimit(75) ) { System.out.print("-"); } } }}//===========================================================================//= EOF =//===========================================================================
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?