vgadriver.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 82 行
JAVA
82 行
/*
* $Id: VGADriver.java,v 1.2 2003/12/21 07:59:15 epr Exp $
*/
package org.jnode.driver.video.vga;
import java.awt.image.IndexColorModel;
import org.jnode.driver.DeviceException;
import org.jnode.driver.DriverException;
import org.jnode.driver.video.AbstractFrameBufferDriver;
import org.jnode.driver.video.AlreadyOpenException;
import org.jnode.driver.video.FrameBufferConfiguration;
import org.jnode.driver.video.Surface;
import org.jnode.driver.video.UnknownConfigurationException;
import org.jnode.driver.video.vgahw.VgaConstants;
import org.jnode.system.ResourceNotFreeException;
/**
* @author epr
*/
public class VGADriver extends AbstractFrameBufferDriver implements VgaConstants {
static final IndexColorModel COLOR_MODEL = new IndexColorModel(4, 16, REDS, GREENS, BLUES);
private static final FrameBufferConfiguration[] CONFIGS = { new VGAConfiguration(640, 480, COLOR_MODEL)};
private FrameBufferConfiguration currentConfig;
private VGASurface vga;
/**
* @see org.jnode.driver.Driver#stopDevice()
*/
protected synchronized void stopDevice() throws DriverException {
if (vga != null) {
vga.close();
}
super.stopDevice();
}
/**
* @see org.jnode.driver.video.FrameBufferAPI#getConfigurations()
*/
public FrameBufferConfiguration[] getConfigurations() {
return CONFIGS;
}
/**
* @see org.jnode.driver.video.FrameBufferAPI#getCurrentConfiguration()
*/
public FrameBufferConfiguration getCurrentConfiguration() {
return currentConfig;
}
/**
* @see org.jnode.driver.video.FrameBufferAPI#open(org.jnode.driver.video.FrameBufferConfiguration)
*/
public synchronized Surface open(FrameBufferConfiguration config) throws UnknownConfigurationException, AlreadyOpenException, DeviceException {
if (currentConfig != null) {
throw new AlreadyOpenException();
} else if (config.equals(CONFIGS[0])) {
try {
vga = new VGASurface(this);
currentConfig = config;
vga.open(config);
return vga;
} catch (ResourceNotFreeException ex) {
throw new DeviceException(ex);
}
} else {
throw new UnknownConfigurationException();
}
}
/**
* The given surface is closed.
*/
synchronized void close(VGASurface vga) {
vga = null;
currentConfig = null;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?