ADD file via upload

main
nxist2202005026 1 year ago
parent 744387d494
commit 96e389fe8d

@ -0,0 +1,76 @@
package control;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
import model.Block;
import model.Box;
/**
*
*/
public class PreView extends JPanel {
private Color frontColor = Color.BLUE;
private Box[][] boxes =new Box[4][4];
private int style, boxWidth=25, boxHeight=25;
private boolean isTiled = false;
/**
*
*/
public PreView() {
for (int i = 0; i < boxes.length; i++) {
for (int j = 0; j < boxes[i].length; j++)
boxes[i][j] = new Box(false);
}
this.setOpaque(false);//设置透明
}
/**
*
* @param backColor Color,
* @param frontColor Color,
*/
public PreView( Color frontColor) {
this();
this.frontColor = frontColor;
}
/**
*
* @param style int,ErsBlockSTYLES28
*/
public void setStyle(int style) {
this.style = style;
repaint();
}
/**
* JComponent
* @param g
*/
public void paint(Graphics g) {
super.paint(g);
// g.drawRect(0, 0, 100, 100);
g.draw3DRect(0, 0, 101, 101, true);
int key = 0x8000;
for (int i = 0; i < boxes.length; i++) {
for (int j = 0; j < boxes[i].length; j++) {
// Color color = (((key & style) != 0) ? frontColor :
// backColor);
if ((key & style) != 0) {
g.setColor(frontColor);
g.fill3DRect(j * boxWidth, i * boxHeight, boxWidth,
boxHeight, true);
}
key >>= 1;
}
}
}
}
Loading…
Cancel
Save