Add wrapped AWT for headless platform
This commit is contained in:
1 parent
05a09dd437
commit
d038e80c04
21 files changed
+264
No files matched your search
@@ -0,0 +1,4 @@
|
||||
package net.zhuoweizhang.makeshift.java.awt;
|
||||
|
||||
public class BorderLayout extends LayoutManager {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package jdpi.awt;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class Canvas extends Component {
|
||||
|
||||
public void setPreferredSize(Dimension dim) {
|
||||
}
|
||||
|
||||
public Graphics getGraphics() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return GLFW.mGLFWWindowWidth;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return GLFW.mGLFWWindowHeight;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package jdpi.awt;
|
||||
|
||||
public class Color extends java.awt.Color {
|
||||
public Color(int r, int g, int b) {
|
||||
super(r, g, b);
|
||||
}
|
||||
|
||||
public Color(int r, int g, int b, int a) {
|
||||
super(r, g, b, a);
|
||||
}
|
||||
|
||||
public Color(int rgb) {
|
||||
super(rgb);
|
||||
}
|
||||
|
||||
public Color(int rgba, boolean hasalpha) {
|
||||
super(rgba, hasalpha);
|
||||
}
|
||||
|
||||
public Color(float r, float g, float b) {
|
||||
super(r, g, b);
|
||||
}
|
||||
|
||||
public Color(float r, float g, float b, float a) {
|
||||
super(r, g, b, a);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package jdpi.awt;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class Component {
|
||||
//setPreferredSize
|
||||
|
||||
public int getWidth() {
|
||||
return GLFW.mGLFWWindowWidth;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return GLFW.mGLFWWindowHeight;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package jdpi.awt;
|
||||
|
||||
public class Container extends Component {
|
||||
public void add(Component component, Object something) {
|
||||
}
|
||||
|
||||
public void setLayout(LayoutManager mgr) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package jdpi.awt;
|
||||
|
||||
public class Dimension extends java.awt.Dimension {
|
||||
public Dimension() {
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
public Dimension(Dimension d) {
|
||||
this(d.width, d.height);
|
||||
}
|
||||
|
||||
public Dimension(int width, int height) {
|
||||
super(width, height);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package jdpi.awt;
|
||||
|
||||
public class Frame extends Window {
|
||||
public Frame(String title) {
|
||||
super(title);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package jdpi.awt;
|
||||
|
||||
import jdpi.awt.image.*;
|
||||
|
||||
public class Graphics {
|
||||
protected java.awt.Graphics2D g2d;
|
||||
|
||||
public Graphics(java.awt.Graphics g2d) {
|
||||
this((java.awt.Graphics2D) g2d);
|
||||
}
|
||||
|
||||
public Graphics(java.awt.Graphics2D g2d) {
|
||||
this.g2d = g2d;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
g2d.setColor(color);
|
||||
}
|
||||
|
||||
public void fillRect(int x, int y, int width, int height) {
|
||||
g2d.fillRect(x, y, width, height);
|
||||
}
|
||||
|
||||
public void drawString(String s, int x, int y) {
|
||||
g2d.drawString(s, x, y);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
g2d.dispose();
|
||||
}
|
||||
|
||||
public boolean drawImage(Image image, int x, int y, ImageObserver observer) {
|
||||
if (!(image instanceof BufferedImage)) return true;
|
||||
return g2d.drawImage(((BufferedImage) image).getBaseImage());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package jdpi.awt;
|
||||
|
||||
public class Graphics2D extends Graphics {
|
||||
public Graphics2D(java.awt.Graphics2D g2d) {
|
||||
super(g2d);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package jdpi.awt;
|
||||
public class GraphicsEnvironment {
|
||||
public static boolean isHeadless() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package jdpi.awt;
|
||||
|
||||
public abstract class Image {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package jdpi.awt;
|
||||
|
||||
public class LayoutManager {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package jdpi.awt;
|
||||
|
||||
import jdpi.awt.event.*;
|
||||
|
||||
public class Window extends Container {
|
||||
public Window(String title) {
|
||||
}
|
||||
|
||||
public void addWindowListener(WindowListener listener) {
|
||||
}
|
||||
|
||||
public void pack() {
|
||||
}
|
||||
|
||||
public void setLocationRelativeTo(Component comp) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package jdpi.awt.event;
|
||||
|
||||
public class WindowAdapter implements WindowListener {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package jdpi.awt.event;
|
||||
|
||||
public interface WindowListener {
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package jdpi.awt;
|
||||
|
||||
import jdpi.awt.Image;
|
||||
|
||||
public class BufferedImage extends Inage {
|
||||
private java.awt.BufferedImage mImg;
|
||||
public BufferedImage(int width, int height, int imageType) {
|
||||
mImg = new java.awt.BufferedImage(width, height, imageType);
|
||||
}
|
||||
|
||||
public Graphics getGraphics() {
|
||||
return new Graphics2D(mImg.getGraphics());
|
||||
}
|
||||
|
||||
public Graphics2D createGraphics() {
|
||||
return new Graphics2D(mImg.createGraphics());
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return mImg.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return mImg.getHeight();
|
||||
}
|
||||
|
||||
public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) {
|
||||
return mImg.getRGB(startX, startY, w, h, rgbArray, offset, scansize);
|
||||
}
|
||||
|
||||
public void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) {
|
||||
mImg.setRGB(startX, startY, w, h, rgbArray, offset, scansize);
|
||||
}
|
||||
|
||||
public WritableRaster getRaster() {
|
||||
return new WritableRaster(mIng.getRaster());
|
||||
}
|
||||
|
||||
public java.awt.BufferedImage getBaseImage() {
|
||||
return mImg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package jdpi.awt.image;
|
||||
|
||||
public class DataBuffer {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package jdpi.awt.image;
|
||||
|
||||
public class DataBufferInt extends DataBuffer {
|
||||
private int[] array;
|
||||
public DataBufferInt(int[] array, int size) {
|
||||
this.array = array;
|
||||
}
|
||||
public int[] getData() {
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package jdpi.awt.image;
|
||||
|
||||
public class ImageObserver {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package jdpi.awt.image;
|
||||
|
||||
public interface RenderedImage {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package jdpi.awt.image;
|
||||
|
||||
public class WritableRaster {
|
||||
private BufferedImage image;
|
||||
public WritableRaster(BufferedImage image) {
|
||||
this.image = image;
|
||||
}
|
||||
public DataBuffer getDataBuffer() {
|
||||
int[] theBuf = new int[image.getWidth() * image.getHeight()];
|
||||
image.getRGB(0, 0, image.getWidth(), image.getHeight(), theBuf, 0, image.getWidth());
|
||||
return new DataBufferInt(theBuf, theBuf.length);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user