📄 jsfbasiccomponent.java
字号:
package com.sunfruit.draw.basic;
import java.awt.*;
import com.sunfruit.draw.framework.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public abstract class JSFBasicComponent
implements JSFComponentface {
private int alpha;
private Color fullColor;
private Color frameColor;
private String Component_ID;
private JSFCanvasface jsfCanvasface;
protected int x=0;
protected int y=0;
protected int[][] drawRect=null;
public JSFBasicComponent(JSFCanvasface jsfCanvasface) {
super();
this.jsfCanvasface=jsfCanvasface;
}
/**
* 组件的起始点,一起始点来做出各种组件
* @param x int
* @param y int
*/
public abstract void setPoint(int x, int y);
/**
* 下降核心算法,依据不同的组件进行不同的下落算法
* @param maxY int 依据屏幕的阀值
* @return boolean
*/
public abstract boolean falling();
/**
* 左移组件算法,依据不同的组件进行不同的左移算法
* @param minX int
* @return boolean
*/
public abstract boolean moveLeft();
/**
* 右移组件算法,依据不同的组件进行不同的右移算法
* @param maxX int 依据屏幕的最大X阀值
* @return boolean
*/
public abstract boolean moveRight();
/**
* 使组件到底
*/
public abstract boolean moveBottom();
/**
* 获得当前组件的状态
* @return int
*/
public abstract int getState();
/**
* 获得组件占用的矩形编号
* @return int[][]
*/
public abstract int[][] getRects();
/**
* 设置状态以使组件旋转
* @param state int
*/
public abstract void setState(int state);
/**
* 上移组件算法,依据不同的组件进行不同的上移算法
* @return boolean
*/
public abstract boolean uping();
/**
* 获得充色的透明度
*
* @return int
* @todo Implement this com.sunfruit.draw.framework.JSFComponentface mezthod
*/
public int getAlpha() {
return alpha;
}
/**
* 获得该组件的ID
*
* @return String
* @todo Implement this com.sunfruit.draw.framework.JSFComponentface method
*/
public String getComponentID() {
return Component_ID;
}
/**
* 获得填充颜色
*
* @return Color
* @todo Implement this com.sunfruit.draw.framework.JSFComponentface method
*/
public Color getFillColor() {
return fullColor;
}
/**
* 获得边框颜色
*
* @return Color
* @todo Implement this com.sunfruit.draw.framework.JSFComponentface method
*/
public Color getFrameColor() {
return frameColor;
}
/**
* 设置填充色的透明度
*
* @param a int
* @todo Implement this com.sunfruit.draw.framework.JSFComponentface method
*/
public void setAlpha(int a) {
this.alpha=a;
}
/**
* 设置该组件的ID
*
* @param sID String
* @todo Implement this com.sunfruit.draw.framework.JSFComponentface method
*/
public void setComponentID(String sID) {
this.Component_ID=sID;
}
/**
* 设置填充颜色
*
* @param color Color
* @todo Implement this com.sunfruit.draw.framework.JSFComponentface method
*/
public void setFillColor(Color color) {
this.fullColor=color;
}
/**
* 设置边框颜色
*
* @param color Color
* @todo Implement this com.sunfruit.draw.framework.JSFComponentface method
*/
public void setFrameColor(Color color) {
this.frameColor=color;
}
/**
* 是否和左边的组件相交
* @return boolean
*/
protected boolean isIntersectsLeft()
{
boolean b=false;
boolean[][] reseau=jsfCanvasface.getReseau();
for(int i=0;i<drawRect.length;i++)
{
int x1=drawRect[i][0];
int y1=drawRect[i][1];
if(x1-1>=0)
{
if(reseau[y1][x1-1])
{
b=true;
break;
}
}else{
b=true;
break;
}
}
return b;
}
/**
* 是否和右边的组件相交
* @return boolean
*/
protected boolean isIntersectsRight()
{
boolean b=false;
boolean[][] reseau=jsfCanvasface.getReseau();
for(int i=0;i<drawRect.length;i++)
{
int x1=drawRect[i][0];
int y1=drawRect[i][1];
if(x1+1<reseau[0].length)
{
if(reseau[y1][x1+1])
{
b=true;
break;
}
}else{
b=true;
break;
}
}
return b;
}
/**
* 是否和下边的组件相交
* @return boolean
*/
protected boolean isIntersectsBottom()
{
boolean b=false;
boolean[][] reseau=jsfCanvasface.getReseau();
for(int i=0;i<drawRect.length;i++)
{
int x1=drawRect[i][0];
int y1=drawRect[i][1];
if(y1+1<reseau.length && x1<reseau[y1+1].length)
{
if(reseau[y1+1][x1])
{
b=true;
break;
}
}else{
b=true;
break;
}
}
return b;
}
/**
* 是否和上边的组件相交
* @return boolean
*/
protected boolean isIntersectsTop()
{
boolean b=false;
boolean[][] reseau=jsfCanvasface.getReseau();
for(int i=0;i<drawRect.length;i++)
{
int x1=drawRect[i][0];
int y1=drawRect[i][1];
if(y1-1>=0)
{
if(reseau[y1-1][x1])
{
b=true;
break;
}
}else{
b=true;
break;
}
}
return b;
}
/**
* 是否和底边相交
* @return boolean
*/
public boolean isBottom()
{
boolean b=false;
boolean[][] reseau=jsfCanvasface.getReseau();
for(int i=0;i<drawRect.length;i++)
{
int x1=drawRect[i][0];
int y1=drawRect[i][1];
if(y1+1<reseau.length && x1<reseau[y1+1].length)
{
if(reseau[y1+1][x1])
{
b=true;
break;
}
}else{
b=true;
break;
}
}
return b;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -