资源简介
随机路点移动模型(RWP)Java代码,要在eclipse中才能运行,有三个子文件 elib, rwp ,stat.rwp文件中放了主程序。
代码片段和文件信息
//
// Simple wrapper to get rid of flickering
// screen with simulation visualisation
//
// 1. call get_graphics with the dimensions of the drawing area
// 2. draw figure using the return Graphics handle
// 3. call ‘refresh‘ to update the figure in the visible screen
//
//
// Esa Hyyti? 2004
//
package elib;
import java.awt.*;
import java.applet.*;
public class DoubleBuffer
{
private Image offscreenI;
private Graphics offscreenG;
private Rectangle offscreenR;
private Component master;
private Color background;
public DoubleBuffer( Component m )
{
master = m;
offscreenI = null;
offscreenG = null;
offscreenR = null;
background = null;
}
public Graphics get_graphics( Rectangle r )
{
if ( r.width < 1 || r.height < 1 )
{
System.out.println( “DoubleBuffer: invalid width or height“ );
return null;
}
if ( offscreenI == null || !offscreenR.equals( r ) )
{
System.out.println( “Reserving memory for an offscreen image“ );
offscreenR = r;
offscreenI = master.createImage( r.width r.height );
if ( offscreenI == null )
return null;
offscreenG = offscreenI.getGraphics( );
}
return offscreenG;
}
public Graphics get_graphics( )
{
return get_graphics( master.getBounds() );
}
public void clear_screen( Color c )
{
if ( offscreenI == null )
return;
offscreenG.setColor( c );
offscreenG.fillRect( 0 0 offscreenR.width offscreenR.height );
}
public void clear_screen( )
{
clear_screen( background );
}
public void set_background( Color c )
{
background = c;
}
public void refresh( Graphics g )
{
if ( g != null && offscreenI != null )
g.drawImage( offscreenI 0 0 master );
}
public void refresh( )
{
refresh( master.getGraphics() );
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2088 2006-04-26 06:01 RWPdemo\elib\DoubleBuffer.java
文件 2817 2006-04-26 20:21 RWPdemo\elib\Loc.java
文件 34029 2006-04-28 18:57 RWPdemo\rwp\RWPdemo.java
文件 1010 2006-04-26 06:16 RWPdemo\stat\Bernoulli.java
文件 2177 2006-04-28 19:17 RWPdemo\stat\doubleStat.java
文件 741 2006-04-28 19:18 RWPdemo\stat\Stat.java
文件 1152 2006-04-28 19:03 RWPdemo\stat\Stat2.java
目录 0 2011-07-27 19:19 RWPdemo\elib
目录 0 2011-07-27 19:19 RWPdemo\rwp
目录 0 2011-07-27 19:19 RWPdemo\stat
目录 0 2011-07-27 19:19 RWPdemo
----------- --------- ---------- ----- ----
44014 11
- 上一篇:通信系统java
- 下一篇:获取百度网盘真实地址(java编写)
评论
共有 条评论