📄 pools.java
字号:
package dujid.araneid;
import javax.swing.*;
import java.awt.*;
import java.util.Iterator;
import java.util.Stack;
public class Pools extends JPanel{
Thread runner;
private int notecardindex = 0;
private int cardWidth = 71;
private int cardHeight = 96;
private int cardSpace = 0;
private int cardSpaceCoeff = 0;
private int poolIndex;
private Stack cards = new Stack();
private boolean mouseEnter = false;
private int mouseIndex = 1;
private Araneid main;
public Pools(Araneid main) {
super();
this.main = main;
}
public Pools(int index, Araneid main) {
super();
this.poolIndex=index;
this.main = main;
}
public void putCard(Card card) {
if (card!=null) {
card.setPool(this);
cards.push(card);
this.removeNoteCard();
}
}
public void removeCard() {
cards.pop();
this.removeNoteCard();
}
public void paintComponent(Graphics g) {
Graphics2D comp = (Graphics2D)g;
comp.setColor(main.backgroundcolor);
comp.fillRect(0,0,this.getSize().width,getSize().height);
Iterator cardlist = cards.iterator();
int y=0;
int notecardstart = 0;
int mouseindexstart = 0;
int count=0;
while(cardlist.hasNext()) {
Card card = (Card)cardlist.next();
comp.drawImage(card.getCurrent(),0,y,this);
if (card.getCurrent() == card.getRear())
this.cardSpace=5;
else
this.cardSpace=5+this.cardSpaceCoeff;
if (this.notecardindex==cards.size()-count++) {
notecardstart = y;
}
if (this.mouseIndex==cards.size()-count+1) {
mouseindexstart = y;
}
y += this.cardSpace;
}
if (this.notecardindex>0) {
comp.setColor(Color.blue);
for (int i=0;i<3;i++) {
comp.drawRect(i,notecardstart+i,this.getSize().width-1-i*2,(this.cardSpace)*(this.notecardindex-1)+this.cardHeight-1-i*2);
}
}
if (this.mouseEnter==true && this.mouseIndex>0) {
comp.setColor(Color.green);
int height = this.cards.size()<=0?this.cardHeight:(this.mouseIndex-1)*this.cardSpace+this.cardHeight;
if (main.mousepanel.isVisible()) {
if (this.cards.size()>0) {
AutoRobot robot = new AutoRobot(this.main);
Card cardprev = (Card)cards.lastElement();
Card cardnext = (Card)main.mousepanel.cards.firstElement();
if (!robot.isAddAble(cardprev,cardnext)) {
comp.setColor(Color.red);
}
}
mouseindexstart=y;
if (main.mousepanel.isVisible()) {
height = main.mousepanel.getSize().height;
}
}
if (height<this.cardHeight) height=this.cardHeight;
for (int i=0;i<3;i++) {
comp.drawRect(i,mouseindexstart+i,this.cardWidth-i*2-1,height-1-i*2);
}
}
}
public void setMouseEnter(boolean value) {
this.mouseEnter=value;
}
public void removeAllCard() {
this.cards.clear();
}
public void setNoteCard(Card card) {
if (card!=null && this.cards.size()>0) {
this.notecardindex = cards.search(card);
}
}
public void removeNoteCard() {
this.notecardindex=0;
}
public void setCardSpaceCoeff(int value) {
this.cardSpaceCoeff=value;
}
public int getCardSpaceCoeff() {
return this.cardSpaceCoeff;
}
public void setCardIndexOnMouse(int value) {
this.mouseIndex=value;
}
public int getCardIndexOnMouse() {
return this.mouseIndex;
}
public int getPoolIndex() {
return this.poolIndex;
}
public Stack getCards() {
return this.cards;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -