📄 tilemanager.java
字号:
/*
* TileManager.java
*
* Created on May 2, 2007, 2:10 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package hk.haha.onet.ajaxvnc;
import java.awt.image.*;
/**
*
* @author heic
*/
public class TileManager {
private boolean DEBUG = true;
public final int MAX_TILE = 10;
private Tile tiles[][];
private int numxtile;
private int numytile;
private int tilewidth;
private int tileheight;
private int screenwidth;
private int screenheight;
/** Creates a new instance of TileManager */
public TileManager() {
tiles = new Tile[MAX_TILE][MAX_TILE];
numxtile = MAX_TILE;
numytile = MAX_TILE;
setSize(640, 480);
}
public void setSize(int sw, int sh) {
screenwidth = sw;
screenheight = sh;
tilewidth = screenwidth / numxtile;
tileheight = screenheight / numytile;
}
public void processImage(BufferedImage image, int x, int y)
{
BufferedImage subimage;
int subw, subh;
boolean changed;
numxtile = x;
numytile = y;
setSize(screenwidth, screenheight);
for (int i=0; i < numxtile; i++) {
for (int j=0; j < numytile; j++) {
if (tiles[i][j]==null) tiles[i][j] = new Tile();
if (i == numxtile-1)
subw = tilewidth + (screenwidth % tilewidth);
else
subw = tilewidth;
if (j == numytile-1)
subh = tileheight + (screenheight % tileheight);
else
subh = tileheight;
subimage = image.getSubimage(i*tilewidth, j*tileheight, subw, subh);
synchronized (tiles[i][j]) {
changed = tiles[i][j].updateImage2(subimage);
if (DEBUG) {
if (changed) System.out.println(getClass().getName() + ": [" + i + "," + j + "] Changed. ["+tiles[i][j].fileSize()+"]");
}
}
}
}
}
public Tile getTile(int x, int y)
{
return tiles[x][y];
}
public int getNumXTile()
{
return numxtile;
}
public int getNumYTile()
{
return numytile;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -