mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
refactoring
This commit is contained in:
@@ -196,7 +196,7 @@
|
||||
|
||||
<!-- Checks for class design -->
|
||||
<!-- See http://checkstyle.sf.net/config_design.html -->
|
||||
<module name="DesignForExtension"/>
|
||||
<!-- <module name="DesignForExtension"/> -->
|
||||
<module name="FinalClass"/>
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
<module name="InterfaceIsType"/>
|
||||
|
||||
@@ -75,20 +75,21 @@ public class CardArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
*/
|
||||
public CardArea(final JScrollPane scrollPane) {
|
||||
super(scrollPane);
|
||||
setBackground(Color.white);
|
||||
this.setBackground(Color.white);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final CardPanel getCardPanel(final int x, final int y) {
|
||||
if (isVertical) {
|
||||
for (int i = cardPanels.size() - 1; i >= 0; i--) {
|
||||
CardPanel panel = cardPanels.get(i);
|
||||
int panelX = panel == mouseDragPanel ? mouseDragStartX : panel.getCardX();
|
||||
int panelY = panel == mouseDragPanel ? mouseDragStartY : panel.getCardY();
|
||||
int panelWidth = panel.getCardWidth();
|
||||
int panelHeight = panel.getCardHeight();
|
||||
if (x > panelX && x < panelX + panelWidth) {
|
||||
if (y > panelY && y < panelY + panelHeight) {
|
||||
if (this.isVertical) {
|
||||
for (int i = this.getCardPanels().size() - 1; i >= 0; i--) {
|
||||
final CardPanel panel = this.getCardPanels().get(i);
|
||||
final int panelX = panel == this.getMouseDragPanel() ? this.mouseDragStartX : panel.getCardX();
|
||||
final int panelY = panel == this.getMouseDragPanel() ? this.mouseDragStartY : panel.getCardY();
|
||||
final int panelWidth = panel.getCardWidth();
|
||||
final int panelHeight = panel.getCardHeight();
|
||||
if ((x > panelX) && (x < (panelX + panelWidth))) {
|
||||
if ((y > panelY) && (y < (panelY + panelHeight))) {
|
||||
if (!panel.isDisplayEnabled()) {
|
||||
return null;
|
||||
}
|
||||
@@ -97,14 +98,14 @@ public class CardArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0, n = cardPanels.size(); i < n; i++) {
|
||||
CardPanel panel = cardPanels.get(i);
|
||||
int panelX = panel == mouseDragPanel ? mouseDragStartX : panel.getCardX();
|
||||
int panelY = panel == mouseDragPanel ? mouseDragStartY : panel.getCardY();
|
||||
int panelWidth = panel.getCardWidth();
|
||||
int panelHeight = panel.getCardHeight();
|
||||
if (x > panelX && x < panelX + panelWidth) {
|
||||
if (y > panelY && y < panelY + panelHeight) {
|
||||
for (int i = 0, n = this.getCardPanels().size(); i < n; i++) {
|
||||
final CardPanel panel = this.getCardPanels().get(i);
|
||||
final int panelX = panel == this.getMouseDragPanel() ? this.mouseDragStartX : panel.getCardX();
|
||||
final int panelY = panel == this.getMouseDragPanel() ? this.mouseDragStartY : panel.getCardY();
|
||||
final int panelWidth = panel.getCardWidth();
|
||||
final int panelHeight = panel.getCardHeight();
|
||||
if ((x > panelX) && (x < (panelX + panelWidth))) {
|
||||
if ((y > panelY) && (y < (panelY + panelHeight))) {
|
||||
if (!panel.isDisplayEnabled()) {
|
||||
return null;
|
||||
}
|
||||
@@ -123,143 +124,145 @@ public class CardArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
*
|
||||
* @since 1.0.15
|
||||
*/
|
||||
@Override
|
||||
public final void doLayout() {
|
||||
if (cardPanels.isEmpty()) {
|
||||
if (this.getCardPanels().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Rectangle rect = scrollPane.getVisibleRect();
|
||||
Insets insets = scrollPane.getInsets();
|
||||
final Rectangle rect = this.getScrollPane().getVisibleRect();
|
||||
final Insets insets = this.getScrollPane().getInsets();
|
||||
rect.width -= insets.left;
|
||||
rect.height -= insets.top;
|
||||
rect.width -= insets.right;
|
||||
rect.height -= insets.bottom;
|
||||
|
||||
int cardAreaWidth = rect.width;
|
||||
int cardAreaHeight = rect.height;
|
||||
int cardWidth = cardWidthMax;
|
||||
final int cardAreaWidth = rect.width;
|
||||
final int cardAreaHeight = rect.height;
|
||||
int cardWidth = this.getCardWidthMax();
|
||||
int cardHeight;
|
||||
int cardSpacingY;
|
||||
|
||||
int maxWidth = 0, maxHeight = 0;
|
||||
if (isVertical) {
|
||||
if (this.isVertical) {
|
||||
while (true) {
|
||||
cardHeight = Math.round(cardWidth * CardPanel.ASPECT_RATIO);
|
||||
cardSpacingX = Math.round(cardWidth * VERT_CARD_SPACING_X);
|
||||
cardSpacingY = cardHeight + Math.round(cardWidth * VERT_CARD_SPACING_Y);
|
||||
int maxRows = (int) Math.floor((cardAreaWidth - GUTTER_X * 2 + cardSpacingX)
|
||||
/ (cardWidth + cardSpacingX));
|
||||
this.cardSpacingX = Math.round(cardWidth * CardArea.VERT_CARD_SPACING_X);
|
||||
cardSpacingY = cardHeight + Math.round(cardWidth * CardArea.VERT_CARD_SPACING_Y);
|
||||
int maxRows = (int) Math.floor(((cardAreaWidth - (CardArea.GUTTER_X * 2)) + this.cardSpacingX)
|
||||
/ (cardWidth + this.cardSpacingX));
|
||||
if (this.maxRows > 0) {
|
||||
maxRows = Math.min(this.maxRows, maxRows);
|
||||
}
|
||||
int availableRowHeight = cardAreaHeight - GUTTER_Y * 2;
|
||||
int availableCardsPerRow = (int) Math.floor((availableRowHeight - (cardHeight - cardSpacingY))
|
||||
final int availableRowHeight = cardAreaHeight - (CardArea.GUTTER_Y * 2);
|
||||
final int availableCardsPerRow = (int) Math.floor((availableRowHeight - (cardHeight - cardSpacingY))
|
||||
/ (double) cardSpacingY);
|
||||
actualCardsPerRow = Math
|
||||
.max(availableCardsPerRow, (int) Math.ceil(cardPanels.size() / (float) maxRows));
|
||||
int actualRowHeight = (int) Math.floor((actualCardsPerRow - 1) * cardSpacingY + cardHeight);
|
||||
float overflow = actualRowHeight - availableRowHeight;
|
||||
this.actualCardsPerRow = Math.max(availableCardsPerRow,
|
||||
(int) Math.ceil(this.getCardPanels().size() / (float) maxRows));
|
||||
int actualRowHeight = (int) Math.floor(((this.actualCardsPerRow - 1) * cardSpacingY) + cardHeight);
|
||||
final float overflow = actualRowHeight - availableRowHeight;
|
||||
if (overflow > 0) {
|
||||
float offsetY = overflow / (actualCardsPerRow - 1);
|
||||
offsetY = Math.min(offsetY, cardHeight * maxCoverage);
|
||||
float offsetY = overflow / (this.actualCardsPerRow - 1);
|
||||
offsetY = Math.min(offsetY, cardHeight * this.maxCoverage);
|
||||
cardSpacingY -= offsetY;
|
||||
}
|
||||
actualRowHeight = (int) Math.floor((actualCardsPerRow - 1) * cardSpacingY + cardHeight);
|
||||
if (actualRowHeight >= 0 && actualRowHeight <= availableRowHeight) {
|
||||
actualRowHeight = (int) Math.floor(((this.actualCardsPerRow - 1) * cardSpacingY) + cardHeight);
|
||||
if ((actualRowHeight >= 0) && (actualRowHeight <= availableRowHeight)) {
|
||||
break;
|
||||
}
|
||||
cardWidth--;
|
||||
if (cardWidth == cardWidthMin) {
|
||||
if (cardWidth == this.getCardWidthMin()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float x = GUTTER_X;
|
||||
int y = GUTTER_Y;
|
||||
int zOrder = cardPanels.size() - 1, rowCount = 0;
|
||||
for (CardPanel panel : cardPanels) {
|
||||
if (panel != mouseDragPanel) {
|
||||
float x = CardArea.GUTTER_X;
|
||||
int y = CardArea.GUTTER_Y;
|
||||
int zOrder = this.getCardPanels().size() - 1, rowCount = 0;
|
||||
for (final CardPanel panel : this.getCardPanels()) {
|
||||
if (panel != this.getMouseDragPanel()) {
|
||||
panel.setCardBounds((int) Math.floor(x), y, cardWidth, cardHeight);
|
||||
}
|
||||
y += cardSpacingY;
|
||||
maxWidth = Math.round(x) + cardWidth + GUTTER_X;
|
||||
maxHeight = Math.max(maxHeight, (y + (cardHeight - cardSpacingY) + GUTTER_Y));
|
||||
setComponentZOrder(panel, zOrder);
|
||||
maxWidth = Math.round(x) + cardWidth + CardArea.GUTTER_X;
|
||||
maxHeight = Math.max(maxHeight, (y + (cardHeight - cardSpacingY) + CardArea.GUTTER_Y));
|
||||
this.setComponentZOrder(panel, zOrder);
|
||||
zOrder--;
|
||||
rowCount++;
|
||||
if (rowCount == actualCardsPerRow) {
|
||||
if (rowCount == this.actualCardsPerRow) {
|
||||
rowCount = 0;
|
||||
x += cardWidth + cardSpacingX;
|
||||
y = GUTTER_Y;
|
||||
x += cardWidth + this.cardSpacingX;
|
||||
y = CardArea.GUTTER_Y;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (true) {
|
||||
cardHeight = Math.round(cardWidth * CardPanel.ASPECT_RATIO);
|
||||
int extraCardSpacingX = Math.round(cardWidth * HORIZ_CARD_SPACING_X);
|
||||
cardSpacingY = Math.round(cardHeight * HORIZ_CARD_SPACING_Y);
|
||||
cardSpacingX = cardWidth + extraCardSpacingX;
|
||||
int maxRows = (int) Math.floor((cardAreaHeight - GUTTER_Y * 2 + cardSpacingY)
|
||||
final int extraCardSpacingX = Math.round(cardWidth * CardArea.HORIZ_CARD_SPACING_X);
|
||||
cardSpacingY = Math.round(cardHeight * CardArea.HORIZ_CARD_SPACING_Y);
|
||||
this.cardSpacingX = cardWidth + extraCardSpacingX;
|
||||
int maxRows = (int) Math.floor(((cardAreaHeight - (CardArea.GUTTER_Y * 2)) + cardSpacingY)
|
||||
/ (double) (cardHeight + cardSpacingY));
|
||||
if (this.maxRows > 0) {
|
||||
maxRows = Math.min(this.maxRows, maxRows);
|
||||
}
|
||||
int availableRowWidth = cardAreaWidth - GUTTER_X * 2;
|
||||
int availableCardsPerRow = (int) Math.floor((availableRowWidth - (cardWidth - cardSpacingX))
|
||||
/ cardSpacingX);
|
||||
actualCardsPerRow = Math
|
||||
.max(availableCardsPerRow, (int) Math.ceil(cardPanels.size() / (float) maxRows));
|
||||
int actualRowWidth = (int) Math.floor((actualCardsPerRow - 1) * cardSpacingX + cardWidth);
|
||||
float overflow = actualRowWidth - availableRowWidth;
|
||||
final int availableRowWidth = cardAreaWidth - (CardArea.GUTTER_X * 2);
|
||||
final int availableCardsPerRow = (int) Math.floor((availableRowWidth - (cardWidth - this.cardSpacingX))
|
||||
/ this.cardSpacingX);
|
||||
this.actualCardsPerRow = Math.max(availableCardsPerRow,
|
||||
(int) Math.ceil(this.getCardPanels().size() / (float) maxRows));
|
||||
int actualRowWidth = (int) Math.floor(((this.actualCardsPerRow - 1) * this.cardSpacingX) + cardWidth);
|
||||
final float overflow = actualRowWidth - availableRowWidth;
|
||||
if (overflow > 0) {
|
||||
float offsetX = overflow / (actualCardsPerRow - 1);
|
||||
offsetX = Math.min(offsetX, cardWidth * maxCoverage);
|
||||
cardSpacingX -= offsetX;
|
||||
float offsetX = overflow / (this.actualCardsPerRow - 1);
|
||||
offsetX = Math.min(offsetX, cardWidth * this.maxCoverage);
|
||||
this.cardSpacingX -= offsetX;
|
||||
}
|
||||
actualRowWidth = (int) Math.floor((actualCardsPerRow - 1) * cardSpacingX + cardWidth);
|
||||
actualRowWidth = (int) Math.floor(((this.actualCardsPerRow - 1) * this.cardSpacingX) + cardWidth);
|
||||
if (actualRowWidth <= availableRowWidth) {
|
||||
break;
|
||||
}
|
||||
cardWidth--;
|
||||
if (cardWidth == cardWidthMin) {
|
||||
if (cardWidth == this.getCardWidthMin()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float x = GUTTER_X;
|
||||
int y = GUTTER_Y;
|
||||
float x = CardArea.GUTTER_X;
|
||||
int y = CardArea.GUTTER_Y;
|
||||
int zOrder = 0, rowCount = 0;
|
||||
for (CardPanel panel : cardPanels) {
|
||||
if (panel != mouseDragPanel) {
|
||||
for (final CardPanel panel : this.getCardPanels()) {
|
||||
if (panel != this.getMouseDragPanel()) {
|
||||
panel.setCardBounds((int) Math.floor(x), y, cardWidth, cardHeight);
|
||||
}
|
||||
x += cardSpacingX;
|
||||
maxWidth = Math.max(maxWidth, Math.round(x + (cardWidth - cardSpacingX) + GUTTER_X) - 1);
|
||||
maxHeight = Math.max(maxHeight, y + (cardHeight - cardSpacingY) + GUTTER_Y);
|
||||
setComponentZOrder(panel, zOrder);
|
||||
x += this.cardSpacingX;
|
||||
maxWidth = Math.max(maxWidth, Math.round(x + (cardWidth - this.cardSpacingX) + CardArea.GUTTER_X) - 1);
|
||||
maxHeight = Math.max(maxHeight, y + (cardHeight - cardSpacingY) + CardArea.GUTTER_Y);
|
||||
this.setComponentZOrder(panel, zOrder);
|
||||
zOrder++;
|
||||
rowCount++;
|
||||
if (rowCount == actualCardsPerRow) {
|
||||
if (rowCount == this.actualCardsPerRow) {
|
||||
rowCount = 0;
|
||||
x = GUTTER_X;
|
||||
x = CardArea.GUTTER_X;
|
||||
y += cardHeight + cardSpacingY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dimension oldPreferredSize = getPreferredSize();
|
||||
setPreferredSize(new Dimension(maxWidth, maxHeight));
|
||||
if (oldPreferredSize.width != maxWidth || oldPreferredSize.height != maxHeight) {
|
||||
getParent().invalidate();
|
||||
getParent().validate();
|
||||
final Dimension oldPreferredSize = this.getPreferredSize();
|
||||
this.setPreferredSize(new Dimension(maxWidth, maxHeight));
|
||||
if ((oldPreferredSize.width != maxWidth) || (oldPreferredSize.height != maxHeight)) {
|
||||
this.getParent().invalidate();
|
||||
this.getParent().validate();
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void paint(final Graphics g) {
|
||||
boolean hasScrollbars = scrollPane.getVerticalScrollBar().isVisible();
|
||||
final boolean hasScrollbars = this.getScrollPane().getVerticalScrollBar().isVisible();
|
||||
if (hasScrollbars != this.hasScrollbars) {
|
||||
revalidate();
|
||||
this.revalidate();
|
||||
}
|
||||
this.hasScrollbars = hasScrollbars;
|
||||
|
||||
@@ -267,63 +270,67 @@ public class CardArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void mouseDragStart(final CardPanel dragPanel, final MouseEvent evt) {
|
||||
super.mouseDragStart(dragPanel, evt);
|
||||
|
||||
mouseDragStartX = dragPanel.getCardX();
|
||||
mouseDragStartY = dragPanel.getCardY();
|
||||
this.mouseDragStartX = dragPanel.getCardX();
|
||||
this.mouseDragStartY = dragPanel.getCardY();
|
||||
dragPanel.setDisplayEnabled(false);
|
||||
|
||||
CardPanel.dragAnimationPanel = new CardPanel(dragPanel.gameCard);
|
||||
CardPanel.dragAnimationPanel.setImage(dragPanel);
|
||||
JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);
|
||||
CardPanel.setDragAnimationPanel(new CardPanel(dragPanel.getGameCard()));
|
||||
CardPanel.getDragAnimationPanel().setImage(dragPanel);
|
||||
final JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);
|
||||
final JLayeredPane layeredPane = frame.getLayeredPane();
|
||||
layeredPane.add(CardPanel.dragAnimationPanel);
|
||||
layeredPane.moveToFront(CardPanel.dragAnimationPanel);
|
||||
Point p = SwingUtilities.convertPoint(this, mouseDragStartX, mouseDragStartY, layeredPane);
|
||||
CardPanel.dragAnimationPanel.setCardBounds(p.x, p.y, dragPanel.getCardWidth(), dragPanel.getCardHeight());
|
||||
layeredPane.add(CardPanel.getDragAnimationPanel());
|
||||
layeredPane.moveToFront(CardPanel.getDragAnimationPanel());
|
||||
final Point p = SwingUtilities.convertPoint(this, this.mouseDragStartX, this.mouseDragStartY, layeredPane);
|
||||
CardPanel.getDragAnimationPanel().setCardBounds(p.x, p.y, dragPanel.getCardWidth(), dragPanel.getCardHeight());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void mouseDragged(final CardPanel dragPanel, final int dragOffsetX, final int dragOffsetY,
|
||||
final MouseEvent evt) {
|
||||
super.mouseDragged(dragPanel, dragOffsetX, dragOffsetY, evt);
|
||||
|
||||
int mouseX = evt.getX();
|
||||
int mouseY = evt.getY();
|
||||
int dragPanelX = mouseX + dragOffsetX;
|
||||
int dragPanelY = mouseY + dragOffsetY;
|
||||
Point p = SwingUtilities.convertPoint(this, dragPanelX, dragPanelY, CardPanel.dragAnimationPanel.getParent());
|
||||
CardPanel.dragAnimationPanel.setLocation(p.x, p.y);
|
||||
final int mouseX = evt.getX();
|
||||
final int mouseY = evt.getY();
|
||||
final int dragPanelX = mouseX + dragOffsetX;
|
||||
final int dragPanelY = mouseY + dragOffsetY;
|
||||
final Point p = SwingUtilities.convertPoint(this, dragPanelX, dragPanelY, CardPanel.getDragAnimationPanel()
|
||||
.getParent());
|
||||
CardPanel.getDragAnimationPanel().setLocation(p.x, p.y);
|
||||
|
||||
CardPanel panel = getCardPanel(mouseX, mouseY);
|
||||
if (panel == null || panel == dragPanel) {
|
||||
final CardPanel panel = this.getCardPanel(mouseX, mouseY);
|
||||
if ((panel == null) || (panel == dragPanel)) {
|
||||
return;
|
||||
}
|
||||
int index = cardPanels.size();
|
||||
int index = this.getCardPanels().size();
|
||||
while (--index >= 0) {
|
||||
if (cardPanels.get(index) == panel) {
|
||||
if (this.getCardPanels().get(index) == panel) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
cardPanels.remove(dragPanel);
|
||||
cardPanels.add(index, dragPanel);
|
||||
mouseDragStartX = panel.getCardX();
|
||||
mouseDragStartY = panel.getCardY();
|
||||
revalidate();
|
||||
this.getCardPanels().remove(dragPanel);
|
||||
this.getCardPanels().add(index, dragPanel);
|
||||
this.mouseDragStartX = panel.getCardX();
|
||||
this.mouseDragStartY = panel.getCardY();
|
||||
this.revalidate();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void mouseDragEnd(final CardPanel dragPanel, final MouseEvent evt) {
|
||||
super.mouseDragEnd(dragPanel, evt);
|
||||
doLayout();
|
||||
JLayeredPane layeredPane = SwingUtilities.getRootPane(CardPanel.dragAnimationPanel).getLayeredPane();
|
||||
int startX = CardPanel.dragAnimationPanel.getCardX();
|
||||
int startY = CardPanel.dragAnimationPanel.getCardY();
|
||||
int startWidth = CardPanel.dragAnimationPanel.getCardWidth();
|
||||
Point endPos = SwingUtilities.convertPoint(this, dragPanel.getCardLocation(), layeredPane);
|
||||
int endWidth = dragPanel.getCardWidth();
|
||||
Animation.moveCard(startX, startY, startWidth, endPos.x, endPos.y, endWidth, CardPanel.dragAnimationPanel,
|
||||
this.doLayout();
|
||||
final JLayeredPane layeredPane = SwingUtilities.getRootPane(CardPanel.getDragAnimationPanel()).getLayeredPane();
|
||||
final int startX = CardPanel.getDragAnimationPanel().getCardX();
|
||||
final int startY = CardPanel.getDragAnimationPanel().getCardY();
|
||||
final int startWidth = CardPanel.getDragAnimationPanel().getCardWidth();
|
||||
final Point endPos = SwingUtilities.convertPoint(this, dragPanel.getCardLocation(), layeredPane);
|
||||
final int endWidth = dragPanel.getCardWidth();
|
||||
Animation.moveCard(startX, startY, startWidth, endPos.x, endPos.y, endWidth, CardPanel.getDragAnimationPanel(),
|
||||
dragPanel, layeredPane, 200);
|
||||
}
|
||||
|
||||
@@ -335,7 +342,7 @@ public class CardArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* @return a float.
|
||||
*/
|
||||
public final float getMaxCoverage() {
|
||||
return maxCoverage;
|
||||
return this.maxCoverage;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,7 +353,7 @@ public class CardArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* @param maxCoverage
|
||||
* a float.
|
||||
*/
|
||||
public final void setMaxCoverage(float maxCoverage) {
|
||||
public final void setMaxCoverage(final float maxCoverage) {
|
||||
this.maxCoverage = maxCoverage;
|
||||
}
|
||||
|
||||
@@ -358,7 +365,7 @@ public class CardArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* @param maxRows
|
||||
* a int.
|
||||
*/
|
||||
public final void setMaxRows(int maxRows) {
|
||||
public final void setMaxRows(final int maxRows) {
|
||||
this.maxRows = maxRows;
|
||||
}
|
||||
|
||||
@@ -370,7 +377,7 @@ public class CardArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getMaxRows() {
|
||||
return maxRows;
|
||||
return this.maxRows;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,6 +400,6 @@ public class CardArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isVertical() {
|
||||
return isVertical;
|
||||
return this.isVertical;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
/**
|
||||
* Constant <code>dragAnimationPanel</code>.
|
||||
*/
|
||||
public static CardPanel dragAnimationPanel;
|
||||
private static CardPanel dragAnimationPanel;
|
||||
|
||||
/** Constant <code>ROUNDED_CORNER_SIZE=0.1f</code>. */
|
||||
private static final float ROUNDED_CORNER_SIZE = 0.1f;
|
||||
@@ -70,41 +70,41 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* Constant
|
||||
* <code>rotCenterToTopCorner=1.0295630140987000315797369464196f</code>.
|
||||
*/
|
||||
private static final float rotCenterToTopCorner = 1.0295630140987000315797369464196f;
|
||||
private static final float ROT_CENTER_TO_TOP_CORNER = 1.0295630140987000315797369464196f;
|
||||
/**
|
||||
* Constant
|
||||
* <code>rotCenterToBottomCorner=0.7071067811865475244008443621048f</code>.
|
||||
*/
|
||||
private static final float rotCenterToBottomCorner = 0.7071067811865475244008443621048f;
|
||||
private static final float ROT_CENTER_TO_BOTTOM_CORNER = 0.7071067811865475244008443621048f;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Card gameCard;
|
||||
private Card gameCard;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CardPanel attachedToPanel;
|
||||
private CardPanel attachedToPanel;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public List<CardPanel> attachedPanels = new ArrayList<CardPanel>();
|
||||
private List<CardPanel> attachedPanels = new ArrayList<CardPanel>();
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean tapped;
|
||||
private boolean tapped;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public double tappedAngle = 0;
|
||||
private double tappedAngle = 0;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ScaledImagePanel imagePanel;
|
||||
private final ScaledImagePanel imagePanel;
|
||||
|
||||
private GlowText titleText;
|
||||
private GlowText ptText;
|
||||
private List<CardPanel> imageLoadListeners = new ArrayList<CardPanel>(2);
|
||||
private final GlowText titleText;
|
||||
private final GlowText ptText;
|
||||
private final List<CardPanel> imageLoadListeners = new ArrayList<CardPanel>(2);
|
||||
private boolean displayEnabled = true;
|
||||
private boolean isAnimationPanel;
|
||||
private int cardXOffset, cardYOffset, cardWidth, cardHeight;
|
||||
@@ -120,44 +120,44 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
public CardPanel(final Card newGameCard) {
|
||||
this.gameCard = newGameCard;
|
||||
this.setGameCard(newGameCard);
|
||||
|
||||
setBackground(Color.black);
|
||||
setOpaque(false);
|
||||
this.setBackground(Color.black);
|
||||
this.setOpaque(false);
|
||||
|
||||
titleText = new GlowText();
|
||||
titleText.setFont(getFont().deriveFont(Font.BOLD, 13f));
|
||||
titleText.setForeground(Color.white);
|
||||
titleText.setGlow(Color.black, TEXT_GLOW_SIZE, TEXT_GLOW_INTENSITY);
|
||||
titleText.setWrap(true);
|
||||
add(titleText);
|
||||
this.titleText = new GlowText();
|
||||
this.titleText.setFont(this.getFont().deriveFont(Font.BOLD, 13f));
|
||||
this.titleText.setForeground(Color.white);
|
||||
this.titleText.setGlow(Color.black, CardPanel.TEXT_GLOW_SIZE, CardPanel.TEXT_GLOW_INTENSITY);
|
||||
this.titleText.setWrap(true);
|
||||
this.add(this.titleText);
|
||||
|
||||
ptText = new GlowText();
|
||||
ptText.setFont(getFont().deriveFont(Font.BOLD, 13f));
|
||||
ptText.setForeground(Color.white);
|
||||
ptText.setGlow(Color.black, TEXT_GLOW_SIZE, TEXT_GLOW_INTENSITY);
|
||||
add(ptText);
|
||||
this.ptText = new GlowText();
|
||||
this.ptText.setFont(this.getFont().deriveFont(Font.BOLD, 13f));
|
||||
this.ptText.setForeground(Color.white);
|
||||
this.ptText.setGlow(Color.black, CardPanel.TEXT_GLOW_SIZE, CardPanel.TEXT_GLOW_INTENSITY);
|
||||
this.add(this.ptText);
|
||||
|
||||
imagePanel = new ScaledImagePanel();
|
||||
add(imagePanel);
|
||||
imagePanel.setScaleLarger(true);
|
||||
imagePanel.setScalingType(ScalingType.nearestNeighbor);
|
||||
imagePanel.setScalingBlur(true);
|
||||
imagePanel.setScalingMultiPassType(MultipassType.none);
|
||||
this.imagePanel = new ScaledImagePanel();
|
||||
this.add(this.imagePanel);
|
||||
this.imagePanel.setScaleLarger(true);
|
||||
this.imagePanel.setScalingType(ScalingType.nearestNeighbor);
|
||||
this.imagePanel.setScalingBlur(true);
|
||||
this.imagePanel.setScalingMultiPassType(MultipassType.none);
|
||||
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
this.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentShown(final ComponentEvent e) {
|
||||
setCard(gameCard);
|
||||
CardPanel.this.setCard(CardPanel.this.getGameCard());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentResized(final ComponentEvent e) {
|
||||
setCard(gameCard);
|
||||
CardPanel.this.setCard(CardPanel.this.getGameCard());
|
||||
}
|
||||
});
|
||||
|
||||
setCard(newGameCard);
|
||||
this.setCard(newGameCard);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,16 +173,16 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* a {@link java.awt.Image} object.
|
||||
*/
|
||||
private void setImage(final Image srcImage, final Image srcImageBlurred) {
|
||||
synchronized (imagePanel) {
|
||||
imagePanel.setImage(srcImage, srcImageBlurred);
|
||||
repaint();
|
||||
for (CardPanel cardPanel : imageLoadListeners) {
|
||||
synchronized (this.imagePanel) {
|
||||
this.imagePanel.setImage(srcImage, srcImageBlurred);
|
||||
this.repaint();
|
||||
for (final CardPanel cardPanel : this.imageLoadListeners) {
|
||||
cardPanel.setImage(srcImage, srcImageBlurred);
|
||||
cardPanel.repaint();
|
||||
}
|
||||
imageLoadListeners.clear();
|
||||
this.imageLoadListeners.clear();
|
||||
}
|
||||
doLayout();
|
||||
this.doLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +196,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
public final void setImage(final CardPanel panel) {
|
||||
synchronized (panel.imagePanel) {
|
||||
if (panel.imagePanel.hasImage()) {
|
||||
setImage(panel.imagePanel.srcImage, panel.imagePanel.srcImageBlurred);
|
||||
this.setImage(panel.imagePanel.getSrcImage(), panel.imagePanel.getSrcImageBlurred());
|
||||
} else {
|
||||
panel.imageLoadListeners.add(this);
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* a {@link arcane.ui.ScaledImagePanel.ScalingType} object.
|
||||
*/
|
||||
public final void setScalingType(final ScalingType scalingType) {
|
||||
imagePanel.setScalingType(scalingType);
|
||||
this.imagePanel.setScalingType(scalingType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,7 +235,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isDisplayEnabled() {
|
||||
return displayEnabled;
|
||||
return this.displayEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,7 +260,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
*/
|
||||
public final void setSelected(final boolean isSelected) {
|
||||
this.isSelected = isSelected;
|
||||
repaint();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,49 +276,56 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void paint(final Graphics g) {
|
||||
if (!displayEnabled) {
|
||||
if (!this.displayEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!isValid()) {
|
||||
if (!this.isValid()) {
|
||||
super.validate();
|
||||
}
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
if (tappedAngle > 0) {
|
||||
if (this.getTappedAngle() > 0) {
|
||||
g2d = (Graphics2D) g2d.create();
|
||||
float edgeOffset = cardWidth / 2f;
|
||||
g2d.rotate(tappedAngle, cardXOffset + edgeOffset, cardYOffset + cardHeight - edgeOffset);
|
||||
final float edgeOffset = this.cardWidth / 2f;
|
||||
g2d.rotate(this.getTappedAngle(), this.cardXOffset + edgeOffset, (this.cardYOffset + this.cardHeight)
|
||||
- edgeOffset);
|
||||
}
|
||||
super.paint(g2d);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected final void paintComponent(final Graphics g) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
final Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// + White borders for Core sets Unlimited - 9th +
|
||||
int cornerSize = Math.max(4, Math.round(cardWidth * ROUNDED_CORNER_SIZE));
|
||||
final int cornerSize = Math.max(4, Math.round(this.cardWidth * CardPanel.ROUNDED_CORNER_SIZE));
|
||||
|
||||
if (this.gameCard != null) {
|
||||
if ((!this.gameCard.getImageFilename().equals("none")) && (!this.gameCard.getName().equals("Morph"))) {
|
||||
if ((this.gameCard.getCurSetCode().equals("2ED")) || (this.gameCard.getCurSetCode().equals("3ED"))
|
||||
|| (this.gameCard.getCurSetCode().equals("4ED"))
|
||||
|| (this.gameCard.getCurSetCode().equals("5ED"))
|
||||
|| (this.gameCard.getCurSetCode().equals("6ED"))
|
||||
|| (this.gameCard.getCurSetCode().equals("7ED"))
|
||||
|| (this.gameCard.getCurSetCode().equals("8ED"))
|
||||
|| (this.gameCard.getCurSetCode().equals("9ED"))
|
||||
|| (this.gameCard.getCurSetCode().equals("CHR"))
|
||||
|| (this.gameCard.getCurSetCode().equals("S99"))
|
||||
|| (this.gameCard.getCurSetCode().equals("PTK"))
|
||||
|| (this.gameCard.getCurSetCode().equals("S00"))) {
|
||||
if (!isSelected) {
|
||||
if (this.getGameCard() != null) {
|
||||
if ((!this.getGameCard().getImageFilename().equals("none"))
|
||||
&& (!this.getGameCard().getName().equals("Morph"))) {
|
||||
if ((this.getGameCard().getCurSetCode().equals("2ED"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("3ED"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("4ED"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("5ED"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("6ED"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("7ED"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("8ED"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("9ED"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("CHR"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("S99"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("PTK"))
|
||||
|| (this.getGameCard().getCurSetCode().equals("S00"))) {
|
||||
if (!this.isSelected) {
|
||||
g2d.setColor(Color.black);
|
||||
int offset = tapped ? 1 : 0;
|
||||
for (int i = 1, n = Math.max(1, Math.round(cardWidth * SELECTED_BORDER_SIZE)); i <= n; i++) {
|
||||
g2d.drawRoundRect(cardXOffset - i, cardYOffset - i + offset, cardWidth + i * 2 - 1,
|
||||
cardHeight + i * 2 - 1, cornerSize, cornerSize);
|
||||
final int offset = this.isTapped() ? 1 : 0;
|
||||
for (int i = 1, n = Math.max(1, Math.round(this.cardWidth
|
||||
* CardPanel.SELECTED_BORDER_SIZE)); i <= n; i++) {
|
||||
g2d.drawRoundRect(this.cardXOffset - i, (this.cardYOffset - i) + offset,
|
||||
(this.cardWidth + (i * 2)) - 1, (this.cardHeight + (i * 2)) - 1, cornerSize,
|
||||
cornerSize);
|
||||
}
|
||||
}
|
||||
g2d.setColor(Color.white);
|
||||
@@ -329,88 +336,92 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
}
|
||||
// - White borders for Core sets Unlimited - 9th -
|
||||
|
||||
g2d.fillRoundRect(cardXOffset, cardYOffset, cardWidth, cardHeight, cornerSize, cornerSize);
|
||||
if (isSelected) {
|
||||
g2d.fillRoundRect(this.cardXOffset, this.cardYOffset, this.cardWidth, this.cardHeight, cornerSize, cornerSize);
|
||||
if (this.isSelected) {
|
||||
g2d.setColor(Color.green);
|
||||
int offset = tapped ? 1 : 0;
|
||||
for (int i = 1, n = Math.max(1, Math.round(cardWidth * SELECTED_BORDER_SIZE)); i <= n; i++) {
|
||||
g2d.drawRoundRect(cardXOffset - i, cardYOffset - i + offset, cardWidth + i * 2 - 1, cardHeight + i * 2
|
||||
- 1, cornerSize, cornerSize);
|
||||
final int offset = this.isTapped() ? 1 : 0;
|
||||
for (int i = 1, n = Math.max(1, Math.round(this.cardWidth * CardPanel.SELECTED_BORDER_SIZE)); i <= n; i++) {
|
||||
g2d.drawRoundRect(this.cardXOffset - i, (this.cardYOffset - i) + offset,
|
||||
(this.cardWidth + (i * 2)) - 1, (this.cardHeight + (i * 2)) - 1, cornerSize, cornerSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected final void paintChildren(final Graphics g) {
|
||||
super.paintChildren(g);
|
||||
|
||||
boolean canDrawOverCard = showCastingCost && !isAnimationPanel;
|
||||
final boolean canDrawOverCard = this.showCastingCost && !this.isAnimationPanel;
|
||||
|
||||
if (!canDrawOverCard) {
|
||||
return;
|
||||
}
|
||||
|
||||
int width = ManaSymbols.getWidth(gameCard.getManaCost());
|
||||
if (cardWidth < 200) {
|
||||
ManaSymbols.draw(g, gameCard.getManaCost(), cardXOffset + cardWidth / 2 - width / 2, cardYOffset
|
||||
+ cardHeight / 2);
|
||||
int width = ManaSymbols.getWidth(this.getGameCard().getManaCost());
|
||||
if (this.cardWidth < 200) {
|
||||
ManaSymbols.draw(g, this.getGameCard().getManaCost(), (this.cardXOffset + (this.cardWidth / 2))
|
||||
- (width / 2), this.cardYOffset + (this.cardHeight / 2));
|
||||
}
|
||||
|
||||
int counters = getCard().getNumberOfCounters();
|
||||
final int counters = this.getCard().getNumberOfCounters();
|
||||
|
||||
if (counters == 1) {
|
||||
ManaSymbols.drawSymbol("counters1", g, cardXOffset - 15, cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
||||
ManaSymbols.drawSymbol("counters1", g, this.cardXOffset - 15, (this.cardYOffset + this.cardHeight)
|
||||
- (this.cardHeight / 3) - 40);
|
||||
} else if (counters == 2) {
|
||||
ManaSymbols.drawSymbol("counters2", g, cardXOffset - 15, cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
||||
ManaSymbols.drawSymbol("counters2", g, this.cardXOffset - 15, (this.cardYOffset + this.cardHeight)
|
||||
- (this.cardHeight / 3) - 40);
|
||||
} else if (counters == 3) {
|
||||
ManaSymbols.drawSymbol("counters3", g, cardXOffset - 15, cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
||||
ManaSymbols.drawSymbol("counters3", g, this.cardXOffset - 15, (this.cardYOffset + this.cardHeight)
|
||||
- (this.cardHeight / 3) - 40);
|
||||
} else if (counters > 3) {
|
||||
ManaSymbols.drawSymbol("countersMulti", g, cardXOffset - 15, cardYOffset + cardHeight - (cardHeight / 3)
|
||||
- 40);
|
||||
ManaSymbols.drawSymbol("countersMulti", g, this.cardXOffset - 15, (this.cardYOffset + this.cardHeight)
|
||||
- (this.cardHeight / 3) - 40);
|
||||
}
|
||||
|
||||
// int yOff = (cardHeight/4) + 2;
|
||||
if (getCard().isAttacking()) {
|
||||
ManaSymbols.drawSymbol("attack", g, cardXOffset + cardWidth / 4 - 16, cardYOffset + cardHeight
|
||||
- (cardHeight / 8) - 16);
|
||||
} else if (getCard().isBlocking()) {
|
||||
ManaSymbols.drawSymbol("defend", g, cardXOffset + cardWidth / 4 - 16, cardYOffset + cardHeight
|
||||
- (cardHeight / 8) - 16);
|
||||
if (this.getCard().isAttacking()) {
|
||||
ManaSymbols.drawSymbol("attack", g, (this.cardXOffset + (this.cardWidth / 4)) - 16,
|
||||
(this.cardYOffset + this.cardHeight) - (this.cardHeight / 8) - 16);
|
||||
} else if (this.getCard().isBlocking()) {
|
||||
ManaSymbols.drawSymbol("defend", g, (this.cardXOffset + (this.cardWidth / 4)) - 16,
|
||||
(this.cardYOffset + this.cardHeight) - (this.cardHeight / 8) - 16);
|
||||
}
|
||||
|
||||
if (getCard().isCreature() && getCard().hasSickness() && AllZoneUtil.isCardInPlay(getCard())) {
|
||||
ManaSymbols.drawSymbol("summonsick", g, cardXOffset + cardWidth / 2 - 16, cardYOffset + cardHeight
|
||||
- (cardHeight / 8) - 16);
|
||||
if (this.getCard().isCreature() && this.getCard().hasSickness() && AllZoneUtil.isCardInPlay(this.getCard())) {
|
||||
ManaSymbols.drawSymbol("summonsick", g, (this.cardXOffset + (this.cardWidth / 2)) - 16,
|
||||
(this.cardYOffset + this.cardHeight) - (this.cardHeight / 8) - 16);
|
||||
}
|
||||
|
||||
if (getCard().isPhasedOut()) {
|
||||
ManaSymbols.drawSymbol("phasing", g, cardXOffset + cardWidth / 2 - 16, cardYOffset + cardHeight
|
||||
- (cardHeight / 8) - 16);
|
||||
if (this.getCard().isPhasedOut()) {
|
||||
ManaSymbols.drawSymbol("phasing", g, (this.cardXOffset + (this.cardWidth / 2)) - 16,
|
||||
(this.cardYOffset + this.cardHeight) - (this.cardHeight / 8) - 16);
|
||||
}
|
||||
|
||||
if (getCard() != null) {
|
||||
if (this.gameCard.getFoil() > 0) {
|
||||
String fl = String.format("foil%02d", getCard().getFoil());
|
||||
int z = Math.round(cardWidth * BLACK_BORDER_SIZE);
|
||||
ManaSymbols.draw(g, fl, cardXOffset + z, cardYOffset + z, cardWidth - (2 * z), cardHeight - (2 * z));
|
||||
if (this.getCard() != null) {
|
||||
if (this.getGameCard().getFoil() > 0) {
|
||||
final String fl = String.format("foil%02d", this.getCard().getFoil());
|
||||
final int z = Math.round(this.cardWidth * CardPanel.BLACK_BORDER_SIZE);
|
||||
ManaSymbols.draw(g, fl, this.cardXOffset + z, this.cardYOffset + z, this.cardWidth - (2 * z),
|
||||
this.cardHeight - (2 * z));
|
||||
}
|
||||
|
||||
if (getCard().getName().equals("Mana Pool") && !isAnimationPanel) {
|
||||
if (this.getCard().getName().equals("Mana Pool") && !this.isAnimationPanel) {
|
||||
|
||||
if (AllZone.getHumanPlayer().getManaPool() != null) {
|
||||
String s = AllZone.getHumanPlayer().getManaPool().getManaList();
|
||||
final String s = AllZone.getHumanPlayer().getManaPool().getManaList();
|
||||
if (!s.equals("|||||||||||")) {
|
||||
|
||||
String[] mList = s.split("\\|", 12);
|
||||
final String[] mList = s.split("\\|", 12);
|
||||
|
||||
int n = 0;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 6; j++) {
|
||||
if (!mList[n].equals("")) {
|
||||
width = ManaSymbols.getWidth(mList[n]);
|
||||
ManaSymbols.draw(g, mList[n],
|
||||
cardXOffset + ((i + 1) * (cardWidth / 3)) - width / 2, cardYOffset
|
||||
+ ((j + 1) * (cardHeight / 7)));
|
||||
ManaSymbols.draw(g, mList[n], (this.cardXOffset + ((i + 1) * (this.cardWidth / 3)))
|
||||
- (width / 2), this.cardYOffset + ((j + 1) * (this.cardHeight / 7)));
|
||||
}
|
||||
|
||||
n++;
|
||||
@@ -429,30 +440,33 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
*
|
||||
* @since 1.0.15
|
||||
*/
|
||||
@Override
|
||||
public final void doLayout() {
|
||||
int borderSize = Math.round(cardWidth * BLACK_BORDER_SIZE);
|
||||
imagePanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
|
||||
imagePanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
|
||||
final int borderSize = Math.round(this.cardWidth * CardPanel.BLACK_BORDER_SIZE);
|
||||
this.imagePanel.setLocation(this.cardXOffset + borderSize, this.cardYOffset + borderSize);
|
||||
this.imagePanel.setSize(this.cardWidth - (borderSize * 2), this.cardHeight - (borderSize * 2));
|
||||
|
||||
int fontHeight = Math.round(cardHeight * (27f / 680));
|
||||
boolean showText = !imagePanel.hasImage() || (!isAnimationPanel && fontHeight < 12);
|
||||
titleText.setVisible(showText);
|
||||
ptText.setVisible(showText);
|
||||
final int fontHeight = Math.round(this.cardHeight * (27f / 680));
|
||||
final boolean showText = !this.imagePanel.hasImage() || (!this.isAnimationPanel && (fontHeight < 12));
|
||||
this.titleText.setVisible(showText);
|
||||
this.ptText.setVisible(showText);
|
||||
|
||||
int titleX = Math.round(cardWidth * (20f / 480));
|
||||
int titleY = Math.round(cardHeight * (9f / 680));
|
||||
titleText.setBounds(cardXOffset + titleX, cardYOffset + titleY, cardWidth - titleX, cardHeight);
|
||||
final int titleX = Math.round(this.cardWidth * (20f / 480));
|
||||
final int titleY = Math.round(this.cardHeight * (9f / 680));
|
||||
this.titleText.setBounds(this.cardXOffset + titleX, this.cardYOffset + titleY, this.cardWidth - titleX,
|
||||
this.cardHeight);
|
||||
|
||||
Dimension ptSize = ptText.getPreferredSize();
|
||||
ptText.setSize(ptSize.width, ptSize.height);
|
||||
int ptX = Math.round(cardWidth * (420f / 480)) - ptSize.width / 2;
|
||||
int ptY = Math.round(cardHeight * (675f / 680)) - ptSize.height;
|
||||
ptText.setLocation(cardXOffset + ptX - TEXT_GLOW_SIZE / 2, cardYOffset + ptY - TEXT_GLOW_SIZE / 2);
|
||||
final Dimension ptSize = this.ptText.getPreferredSize();
|
||||
this.ptText.setSize(ptSize.width, ptSize.height);
|
||||
final int ptX = Math.round(this.cardWidth * (420f / 480)) - (ptSize.width / 2);
|
||||
final int ptY = Math.round(this.cardHeight * (675f / 680)) - ptSize.height;
|
||||
this.ptText.setLocation((this.cardXOffset + ptX) - (CardPanel.TEXT_GLOW_SIZE / 2), (this.cardYOffset + ptY)
|
||||
- (CardPanel.TEXT_GLOW_SIZE / 2));
|
||||
|
||||
if (isAnimationPanel || cardWidth < 200) {
|
||||
imagePanel.setScalingType(ScalingType.nearestNeighbor);
|
||||
if (this.isAnimationPanel || (this.cardWidth < 200)) {
|
||||
this.imagePanel.setScalingType(ScalingType.nearestNeighbor);
|
||||
} else {
|
||||
imagePanel.setScalingType(ScalingType.bilinear);
|
||||
this.imagePanel.setScalingType(ScalingType.bilinear);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,8 +477,9 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return gameCard.getName();
|
||||
return this.getGameCard().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,19 +497,19 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* a int.
|
||||
*/
|
||||
public final void setCardBounds(final int x, final int y, int width, int height) {
|
||||
cardWidth = width;
|
||||
cardHeight = height;
|
||||
int rotCenterX = Math.round(width / 2f);
|
||||
int rotCenterY = height - rotCenterX;
|
||||
int rotCenterToTopCorner = Math.round(width * CardPanel.rotCenterToTopCorner);
|
||||
int rotCenterToBottomCorner = Math.round(width * CardPanel.rotCenterToBottomCorner);
|
||||
int xOffset = rotCenterX - rotCenterToBottomCorner;
|
||||
int yOffset = rotCenterY - rotCenterToTopCorner;
|
||||
cardXOffset = -xOffset;
|
||||
cardYOffset = -yOffset;
|
||||
this.cardWidth = width;
|
||||
this.cardHeight = height;
|
||||
final int rotCenterX = Math.round(width / 2f);
|
||||
final int rotCenterY = height - rotCenterX;
|
||||
final int rotCenterToTopCorner = Math.round(width * CardPanel.ROT_CENTER_TO_TOP_CORNER);
|
||||
final int rotCenterToBottomCorner = Math.round(width * CardPanel.ROT_CENTER_TO_BOTTOM_CORNER);
|
||||
final int xOffset = rotCenterX - rotCenterToBottomCorner;
|
||||
final int yOffset = rotCenterY - rotCenterToTopCorner;
|
||||
this.cardXOffset = -xOffset;
|
||||
this.cardYOffset = -yOffset;
|
||||
width = -xOffset + rotCenterX + rotCenterToTopCorner;
|
||||
height = -yOffset + rotCenterY + rotCenterToBottomCorner;
|
||||
setBounds(x + xOffset, y + yOffset, width, height);
|
||||
this.setBounds(x + xOffset, y + yOffset, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,13 +517,14 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* repaint.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public final void repaint() {
|
||||
Rectangle b = getBounds();
|
||||
JRootPane rootPane = SwingUtilities.getRootPane(this);
|
||||
final Rectangle b = this.getBounds();
|
||||
final JRootPane rootPane = SwingUtilities.getRootPane(this);
|
||||
if (rootPane == null) {
|
||||
return;
|
||||
}
|
||||
Point p = SwingUtilities.convertPoint(getParent(), b.x, b.y, rootPane);
|
||||
final Point p = SwingUtilities.convertPoint(this.getParent(), b.x, b.y, rootPane);
|
||||
rootPane.repaint(p.x, p.y, b.width, b.height);
|
||||
}
|
||||
|
||||
@@ -520,7 +536,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getCardX() {
|
||||
return getX() + cardXOffset;
|
||||
return this.getX() + this.cardXOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -531,7 +547,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getCardY() {
|
||||
return getY() + cardYOffset;
|
||||
return this.getY() + this.cardYOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -542,7 +558,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getCardWidth() {
|
||||
return cardWidth;
|
||||
return this.cardWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -553,7 +569,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getCardHeight() {
|
||||
return cardHeight;
|
||||
return this.cardHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -564,9 +580,9 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* @return a {@link java.awt.Point} object.
|
||||
*/
|
||||
public final Point getCardLocation() {
|
||||
Point p = getLocation();
|
||||
p.x += cardXOffset;
|
||||
p.y += cardYOffset;
|
||||
final Point p = this.getLocation();
|
||||
p.x += this.cardXOffset;
|
||||
p.y += this.cardYOffset;
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -579,27 +595,27 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
public final void setText(final Card card) {
|
||||
if (card == null || !Singletons.getModel().getPreferences().cardOverlay) {
|
||||
if ((card == null) || !Singletons.getModel().getPreferences().cardOverlay) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (card.isFaceDown()) {
|
||||
titleText.setText("");
|
||||
showCastingCost = false;
|
||||
this.titleText.setText("");
|
||||
this.showCastingCost = false;
|
||||
} else {
|
||||
titleText.setText(card.getName());
|
||||
showCastingCost = true;
|
||||
this.titleText.setText(card.getName());
|
||||
this.showCastingCost = true;
|
||||
}
|
||||
|
||||
if (card.isCreature() && card.isPlaneswalker()) {
|
||||
ptText.setText(card.getNetAttack() + "/" + card.getNetDefense() + " ("
|
||||
this.ptText.setText(card.getNetAttack() + "/" + card.getNetDefense() + " ("
|
||||
+ String.valueOf(card.getCounters(Counters.LOYALTY)) + ")");
|
||||
} else if (card.isCreature()) {
|
||||
ptText.setText(card.getNetAttack() + "/" + card.getNetDefense());
|
||||
this.ptText.setText(card.getNetAttack() + "/" + card.getNetDefense());
|
||||
} else if (card.isPlaneswalker()) {
|
||||
ptText.setText(String.valueOf(card.getCounters(Counters.LOYALTY)));
|
||||
this.ptText.setText(String.valueOf(card.getCounters(Counters.LOYALTY)));
|
||||
} else {
|
||||
ptText.setText("");
|
||||
this.ptText.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,26 +626,146 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
*
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
@Override
|
||||
public final Card getCard() {
|
||||
return gameCard;
|
||||
return this.getGameCard();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void setCard(final Card card) {
|
||||
if (gameCard != null && gameCard.equals(card) && isAnimationPanel && imagePanel.hasImage()) {
|
||||
if ((this.getGameCard() != null) && this.getGameCard().equals(card) && this.isAnimationPanel
|
||||
&& this.imagePanel.hasImage()) {
|
||||
return;
|
||||
}
|
||||
this.gameCard = card;
|
||||
if (!isShowing()) {
|
||||
this.setGameCard(card);
|
||||
if (!this.isShowing()) {
|
||||
return;
|
||||
}
|
||||
Insets i = getInsets();
|
||||
Image image = card == null ? null : ImageCache.getImage(card, getWidth() - i.left - i.right, getHeight()
|
||||
- i.top - i.bottom);
|
||||
if (gameCard != null && Singletons.getModel().getPreferences().cardOverlay) {
|
||||
setText(gameCard);
|
||||
final Insets i = this.getInsets();
|
||||
final Image image = card == null ? null : ImageCache.getImage(card, this.getWidth() - i.left - i.right,
|
||||
this.getHeight() - i.top - i.bottom);
|
||||
if ((this.getGameCard() != null) && Singletons.getModel().getPreferences().cardOverlay) {
|
||||
this.setText(this.getGameCard());
|
||||
}
|
||||
|
||||
setImage(image, image);
|
||||
this.setImage(image, image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the game card.
|
||||
*
|
||||
* @return the gameCard
|
||||
*/
|
||||
public final Card getGameCard() {
|
||||
return this.gameCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the game card.
|
||||
*
|
||||
* @param gameCard
|
||||
* the gameCard to set
|
||||
*/
|
||||
public final void setGameCard(final Card gameCard) {
|
||||
this.gameCard = gameCard; // TODO: Add 0 to parameter's name.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the drag animation panel.
|
||||
*
|
||||
* @return the dragAnimationPanel
|
||||
*/
|
||||
public static CardPanel getDragAnimationPanel() {
|
||||
return CardPanel.dragAnimationPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the drag animation panel.
|
||||
*
|
||||
* @param dragAnimationPanel
|
||||
* the dragAnimationPanel to set
|
||||
*/
|
||||
public static void setDragAnimationPanel(final CardPanel dragAnimationPanel) {
|
||||
CardPanel.dragAnimationPanel = dragAnimationPanel; // TODO: Add 0 to
|
||||
// parameter's name.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attached to panel.
|
||||
*
|
||||
* @return the attachedToPanel
|
||||
*/
|
||||
public final CardPanel getAttachedToPanel() {
|
||||
return this.attachedToPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attached to panel.
|
||||
*
|
||||
* @param attachedToPanel
|
||||
* the attachedToPanel to set
|
||||
*/
|
||||
public final void setAttachedToPanel(final CardPanel attachedToPanel) {
|
||||
this.attachedToPanel = attachedToPanel; // TODO: Add 0 to parameter's
|
||||
// name.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attached panels.
|
||||
*
|
||||
* @return the attachedPanels
|
||||
*/
|
||||
public final List<CardPanel> getAttachedPanels() {
|
||||
return this.attachedPanels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attached panels.
|
||||
*
|
||||
* @param attachedPanels
|
||||
* the attachedPanels to set
|
||||
*/
|
||||
public final void setAttachedPanels(final List<CardPanel> attachedPanels) {
|
||||
this.attachedPanels = attachedPanels; // TODO: Add 0 to parameter's
|
||||
// name.
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is tapped.
|
||||
*
|
||||
* @return the tapped
|
||||
*/
|
||||
public final boolean isTapped() {
|
||||
return this.tapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tapped.
|
||||
*
|
||||
* @param tapped
|
||||
* the tapped to set
|
||||
*/
|
||||
public final void setTapped(final boolean tapped) {
|
||||
this.tapped = tapped; // TODO: Add 0 to parameter's name.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tapped angle.
|
||||
*
|
||||
* @return the tappedAngle
|
||||
*/
|
||||
public final double getTappedAngle() {
|
||||
return this.tappedAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tapped angle.
|
||||
*
|
||||
* @param tappedAngle
|
||||
* the tappedAngle to set
|
||||
*/
|
||||
public final void setTappedAngle(final double tappedAngle) {
|
||||
this.tappedAngle = tappedAngle; // TODO: Add 0 to parameter's name.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,21 +34,25 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
||||
private List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected JScrollPane scrollPane;
|
||||
private JScrollPane scrollPane;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected int cardWidthMin = 50, cardWidthMax = Constant.Runtime.width[0];
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected CardPanel mouseOverPanel, mouseDownPanel, mouseDragPanel;
|
||||
private int cardWidthMin = 50;
|
||||
|
||||
private List<CardPanelMouseListener> listeners = new ArrayList<CardPanelMouseListener>(2);
|
||||
private int cardWidthMax = Constant.Runtime.width[0];
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private CardPanel mouseOverPanel;
|
||||
private CardPanel mouseDownPanel;
|
||||
private CardPanel mouseDragPanel;
|
||||
|
||||
private final List<CardPanelMouseListener> listeners = new ArrayList<CardPanelMouseListener>(2);
|
||||
private int mouseDragOffsetX, mouseDragOffsetY;
|
||||
private int intialMouseDragX = -1, intialMouseDragY;
|
||||
private boolean dragEnabled;
|
||||
@@ -65,94 +69,101 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
public CardPanelContainer(final JScrollPane scrollPane) {
|
||||
this.scrollPane = scrollPane;
|
||||
|
||||
setOpaque(true);
|
||||
this.setOpaque(true);
|
||||
|
||||
addMouseMotionListener(new MouseMotionListener() {
|
||||
this.addMouseMotionListener(new MouseMotionListener() {
|
||||
@Override
|
||||
public void mouseDragged(final MouseEvent evt) {
|
||||
if (!dragEnabled) {
|
||||
mouseOutPanel(evt);
|
||||
if (!CardPanelContainer.this.dragEnabled) {
|
||||
CardPanelContainer.this.mouseOutPanel(evt);
|
||||
return;
|
||||
}
|
||||
if (mouseDragPanel != null) {
|
||||
CardPanelContainer.this.mouseDragged(mouseDragPanel, mouseDragOffsetX, mouseDragOffsetY, evt);
|
||||
if (CardPanelContainer.this.getMouseDragPanel() != null) {
|
||||
CardPanelContainer.this.mouseDragged(CardPanelContainer.this.getMouseDragPanel(),
|
||||
CardPanelContainer.this.mouseDragOffsetX, CardPanelContainer.this.mouseDragOffsetY, evt);
|
||||
return;
|
||||
}
|
||||
int x = evt.getX();
|
||||
int y = evt.getY();
|
||||
CardPanel panel = getCardPanel(x, y);
|
||||
final int x = evt.getX();
|
||||
final int y = evt.getY();
|
||||
final CardPanel panel = CardPanelContainer.this.getCardPanel(x, y);
|
||||
if (panel == null) {
|
||||
return;
|
||||
}
|
||||
if (panel != mouseDownPanel) {
|
||||
if (panel != CardPanelContainer.this.mouseDownPanel) {
|
||||
return;
|
||||
}
|
||||
if (intialMouseDragX == -1) {
|
||||
intialMouseDragX = x;
|
||||
intialMouseDragY = y;
|
||||
if (CardPanelContainer.this.intialMouseDragX == -1) {
|
||||
CardPanelContainer.this.intialMouseDragX = x;
|
||||
CardPanelContainer.this.intialMouseDragY = y;
|
||||
return;
|
||||
}
|
||||
if (Math.abs(x - intialMouseDragX) < DRAG_SMUDGE && Math.abs(y - intialMouseDragY) < DRAG_SMUDGE) {
|
||||
if ((Math.abs(x - CardPanelContainer.this.intialMouseDragX) < CardPanelContainer.DRAG_SMUDGE)
|
||||
&& (Math.abs(y - CardPanelContainer.this.intialMouseDragY) < CardPanelContainer.DRAG_SMUDGE)) {
|
||||
return;
|
||||
}
|
||||
mouseDownPanel = null;
|
||||
mouseDragPanel = panel;
|
||||
mouseDragOffsetX = panel.getX() - intialMouseDragX;
|
||||
mouseDragOffsetY = panel.getY() - intialMouseDragY;
|
||||
CardPanelContainer.this.mouseDragStart(mouseDragPanel, evt);
|
||||
CardPanelContainer.this.mouseDownPanel = null;
|
||||
CardPanelContainer.this.setMouseDragPanel(panel);
|
||||
CardPanelContainer.this.mouseDragOffsetX = panel.getX() - CardPanelContainer.this.intialMouseDragX;
|
||||
CardPanelContainer.this.mouseDragOffsetY = panel.getY() - CardPanelContainer.this.intialMouseDragY;
|
||||
CardPanelContainer.this.mouseDragStart(CardPanelContainer.this.getMouseDragPanel(), evt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(final MouseEvent evt) {
|
||||
CardPanel panel = getCardPanel(evt.getX(), evt.getY());
|
||||
if (mouseOverPanel != null && mouseOverPanel != panel) {
|
||||
final CardPanel panel = CardPanelContainer.this.getCardPanel(evt.getX(), evt.getY());
|
||||
if ((CardPanelContainer.this.mouseOverPanel != null)
|
||||
&& (CardPanelContainer.this.mouseOverPanel != panel)) {
|
||||
CardPanelContainer.this.mouseOutPanel(evt);
|
||||
}
|
||||
if (panel == null) {
|
||||
return;
|
||||
}
|
||||
mouseOverPanel = panel;
|
||||
mouseOverPanel.setSelected(true);
|
||||
CardPanelContainer.this.mouseOverPanel = panel;
|
||||
CardPanelContainer.this.mouseOverPanel.setSelected(true);
|
||||
CardPanelContainer.this.mouseOver(panel, evt);
|
||||
}
|
||||
});
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
private boolean[] buttonsDown = new boolean[4];
|
||||
this.addMouseListener(new MouseAdapter() {
|
||||
private final boolean[] buttonsDown = new boolean[4];
|
||||
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent evt) {
|
||||
int button = evt.getButton();
|
||||
if (button < 1 || button > 3) {
|
||||
final int button = evt.getButton();
|
||||
if ((button < 1) || (button > 3)) {
|
||||
return;
|
||||
}
|
||||
buttonsDown[button] = true;
|
||||
mouseDownPanel = getCardPanel(evt.getX(), evt.getY());
|
||||
this.buttonsDown[button] = true;
|
||||
CardPanelContainer.this.mouseDownPanel = CardPanelContainer.this.getCardPanel(evt.getX(), evt.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(final MouseEvent evt) {
|
||||
int button = evt.getButton();
|
||||
if (button < 1 || button > 3) {
|
||||
final int button = evt.getButton();
|
||||
if ((button < 1) || (button > 3)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dragEnabled) {
|
||||
intialMouseDragX = -1;
|
||||
if (mouseDragPanel != null) {
|
||||
CardPanel panel = mouseDragPanel;
|
||||
mouseDragPanel = null;
|
||||
if (CardPanelContainer.this.dragEnabled) {
|
||||
CardPanelContainer.this.intialMouseDragX = -1;
|
||||
if (CardPanelContainer.this.getMouseDragPanel() != null) {
|
||||
final CardPanel panel = CardPanelContainer.this.getMouseDragPanel();
|
||||
CardPanelContainer.this.setMouseDragPanel(null);
|
||||
CardPanelContainer.this.mouseDragEnd(panel, evt);
|
||||
}
|
||||
}
|
||||
|
||||
if (!buttonsDown[button]) {
|
||||
if (!this.buttonsDown[button]) {
|
||||
return;
|
||||
}
|
||||
buttonsDown[button] = false;
|
||||
this.buttonsDown[button] = false;
|
||||
|
||||
CardPanel panel = getCardPanel(evt.getX(), evt.getY());
|
||||
if (panel != null && mouseDownPanel == panel) {
|
||||
final CardPanel panel = CardPanelContainer.this.getCardPanel(evt.getX(), evt.getY());
|
||||
if ((panel != null) && (CardPanelContainer.this.mouseDownPanel == panel)) {
|
||||
int downCount = 0;
|
||||
for (int i = 1; i < buttonsDown.length; i++) {
|
||||
if (buttonsDown[i]) {
|
||||
buttonsDown[i] = false;
|
||||
for (int i = 1; i < this.buttonsDown.length; i++) {
|
||||
if (this.buttonsDown[i]) {
|
||||
this.buttonsDown[i] = false;
|
||||
downCount++;
|
||||
}
|
||||
}
|
||||
@@ -168,10 +179,12 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(final MouseEvent evt) {
|
||||
mouseOutPanel(evt);
|
||||
CardPanelContainer.this.mouseOutPanel(evt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(final MouseEvent e) {
|
||||
}
|
||||
});
|
||||
@@ -186,12 +199,12 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* a {@link java.awt.event.MouseEvent} object.
|
||||
*/
|
||||
private void mouseOutPanel(final MouseEvent evt) {
|
||||
if (mouseOverPanel == null) {
|
||||
if (this.mouseOverPanel == null) {
|
||||
return;
|
||||
}
|
||||
mouseOverPanel.setSelected(false);
|
||||
mouseOut(mouseOverPanel, evt);
|
||||
mouseOverPanel = null;
|
||||
this.mouseOverPanel.setSelected(false);
|
||||
this.mouseOut(this.mouseOverPanel, evt);
|
||||
this.mouseOverPanel = null;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -220,13 +233,13 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
public final CardPanel addCard(final Card card) {
|
||||
final CardPanel placeholder = new CardPanel(card);
|
||||
placeholder.setDisplayEnabled(false);
|
||||
cardPanels.add(placeholder);
|
||||
add(placeholder);
|
||||
doLayout();
|
||||
this.getCardPanels().add(placeholder);
|
||||
this.add(placeholder);
|
||||
this.doLayout();
|
||||
// int y = Math.min(placeholder.getHeight(),
|
||||
// scrollPane.getVisibleRect().height);
|
||||
scrollRectToVisible(new Rectangle(placeholder.getCardX(), placeholder.getCardY(), placeholder.getCardWidth(),
|
||||
placeholder.getCardHeight()));
|
||||
this.scrollRectToVisible(new Rectangle(placeholder.getCardX(), placeholder.getCardY(), placeholder
|
||||
.getCardWidth(), placeholder.getCardHeight()));
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
@@ -240,8 +253,8 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @return a {@link arcane.ui.CardPanel} object.
|
||||
*/
|
||||
public final CardPanel getCardPanel(final int gameCardID) {
|
||||
for (CardPanel panel : cardPanels) {
|
||||
if (panel.gameCard.getUniqueNumber() == gameCardID) {
|
||||
for (final CardPanel panel : this.getCardPanels()) {
|
||||
if (panel.getGameCard().getUniqueNumber() == gameCardID) {
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
@@ -258,19 +271,20 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
*/
|
||||
public final void removeCardPanel(final CardPanel fromPanel) {
|
||||
UI.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mouseDragPanel != null) {
|
||||
CardPanel.dragAnimationPanel.setVisible(false);
|
||||
CardPanel.dragAnimationPanel.repaint();
|
||||
cardPanels.remove(CardPanel.dragAnimationPanel);
|
||||
remove(CardPanel.dragAnimationPanel);
|
||||
mouseDragPanel = null;
|
||||
if (CardPanelContainer.this.getMouseDragPanel() != null) {
|
||||
CardPanel.getDragAnimationPanel().setVisible(false);
|
||||
CardPanel.getDragAnimationPanel().repaint();
|
||||
CardPanelContainer.this.getCardPanels().remove(CardPanel.getDragAnimationPanel());
|
||||
CardPanelContainer.this.remove(CardPanel.getDragAnimationPanel());
|
||||
CardPanelContainer.this.setMouseDragPanel(null);
|
||||
}
|
||||
mouseOverPanel = null;
|
||||
cardPanels.remove(fromPanel);
|
||||
remove(fromPanel);
|
||||
invalidate();
|
||||
repaint();
|
||||
CardPanelContainer.this.mouseOverPanel = null;
|
||||
CardPanelContainer.this.getCardPanels().remove(fromPanel);
|
||||
CardPanelContainer.this.remove(fromPanel);
|
||||
CardPanelContainer.this.invalidate();
|
||||
CardPanelContainer.this.repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -282,13 +296,14 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
*/
|
||||
public final void clear() {
|
||||
UI.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
cardPanels.clear();
|
||||
removeAll();
|
||||
setPreferredSize(new Dimension(0, 0));
|
||||
invalidate();
|
||||
getParent().validate();
|
||||
repaint();
|
||||
CardPanelContainer.this.getCardPanels().clear();
|
||||
CardPanelContainer.this.removeAll();
|
||||
CardPanelContainer.this.setPreferredSize(new Dimension(0, 0));
|
||||
CardPanelContainer.this.invalidate();
|
||||
CardPanelContainer.this.getParent().validate();
|
||||
CardPanelContainer.this.repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -301,7 +316,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @return a {@link javax.swing.JScrollPane} object.
|
||||
*/
|
||||
public final JScrollPane getScrollPane() {
|
||||
return scrollPane;
|
||||
return this.scrollPane;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,7 +327,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getCardWidthMin() {
|
||||
return cardWidthMin;
|
||||
return this.cardWidthMin;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -323,7 +338,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @param cardWidthMin
|
||||
* a int.
|
||||
*/
|
||||
public final void setCardWidthMin(int cardWidthMin) {
|
||||
public final void setCardWidthMin(final int cardWidthMin) {
|
||||
this.cardWidthMin = cardWidthMin;
|
||||
}
|
||||
|
||||
@@ -335,7 +350,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getCardWidthMax() {
|
||||
return cardWidthMax;
|
||||
return this.cardWidthMax;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,7 +361,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @param cardWidthMax
|
||||
* a int.
|
||||
*/
|
||||
public final void setCardWidthMax(int cardWidthMax) {
|
||||
public final void setCardWidthMax(final int cardWidthMax) {
|
||||
this.cardWidthMax = cardWidthMax;
|
||||
}
|
||||
|
||||
@@ -358,7 +373,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isDragEnabled() {
|
||||
return dragEnabled;
|
||||
return this.dragEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -369,7 +384,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @param dragEnabled
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setDragEnabled(boolean dragEnabled) {
|
||||
public final void setDragEnabled(final boolean dragEnabled) {
|
||||
this.dragEnabled = dragEnabled;
|
||||
}
|
||||
|
||||
@@ -382,7 +397,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* a {@link arcane.ui.util.CardPanelMouseListener} object.
|
||||
*/
|
||||
public final void addCardPanelMouseListener(final CardPanelMouseListener listener) {
|
||||
listeners.add(listener);
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -396,7 +411,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* a {@link java.awt.event.MouseEvent} object.
|
||||
*/
|
||||
public void mouseLeftClicked(final CardPanel panel, final MouseEvent evt) {
|
||||
for (CardPanelMouseListener listener : listeners) {
|
||||
for (final CardPanelMouseListener listener : this.listeners) {
|
||||
listener.mouseLeftClicked(panel, evt);
|
||||
}
|
||||
}
|
||||
@@ -412,7 +427,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* a {@link java.awt.event.MouseEvent} object.
|
||||
*/
|
||||
public final void mouseRightClicked(final CardPanel panel, final MouseEvent evt) {
|
||||
for (CardPanelMouseListener listener : listeners) {
|
||||
for (final CardPanelMouseListener listener : this.listeners) {
|
||||
listener.mouseRightClicked(panel, evt);
|
||||
}
|
||||
}
|
||||
@@ -428,7 +443,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* a {@link java.awt.event.MouseEvent} object.
|
||||
*/
|
||||
public final void mouseMiddleClicked(final CardPanel panel, final MouseEvent evt) {
|
||||
for (CardPanelMouseListener listener : listeners) {
|
||||
for (final CardPanelMouseListener listener : this.listeners) {
|
||||
listener.mouseMiddleClicked(panel, evt);
|
||||
}
|
||||
}
|
||||
@@ -444,7 +459,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* a {@link java.awt.event.MouseEvent} object.
|
||||
*/
|
||||
public void mouseDragEnd(final CardPanel dragPanel, final MouseEvent evt) {
|
||||
for (CardPanelMouseListener listener : listeners) {
|
||||
for (final CardPanelMouseListener listener : this.listeners) {
|
||||
listener.mouseDragEnd(dragPanel, evt);
|
||||
}
|
||||
}
|
||||
@@ -465,8 +480,8 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
*/
|
||||
public void mouseDragged(final CardPanel dragPanel, final int dragOffsetX, final int dragOffsetY,
|
||||
final MouseEvent evt) {
|
||||
for (CardPanelMouseListener listener : listeners) {
|
||||
listener.mouseDragged(mouseDragPanel, mouseDragOffsetX, mouseDragOffsetY, evt);
|
||||
for (final CardPanelMouseListener listener : this.listeners) {
|
||||
listener.mouseDragged(this.getMouseDragPanel(), this.mouseDragOffsetX, this.mouseDragOffsetY, evt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,8 +496,8 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* a {@link java.awt.event.MouseEvent} object.
|
||||
*/
|
||||
public void mouseDragStart(final CardPanel dragPanel, final MouseEvent evt) {
|
||||
for (CardPanelMouseListener listener : listeners) {
|
||||
listener.mouseDragStart(mouseDragPanel, evt);
|
||||
for (final CardPanelMouseListener listener : this.listeners) {
|
||||
listener.mouseDragStart(this.getMouseDragPanel(), evt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,8 +512,8 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* a {@link java.awt.event.MouseEvent} object.
|
||||
*/
|
||||
public final void mouseOut(final CardPanel panel, final MouseEvent evt) {
|
||||
for (CardPanelMouseListener listener : listeners) {
|
||||
listener.mouseOut(mouseOverPanel, evt);
|
||||
for (final CardPanelMouseListener listener : this.listeners) {
|
||||
listener.mouseOut(this.mouseOverPanel, evt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,7 +528,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* a {@link java.awt.event.MouseEvent} object.
|
||||
*/
|
||||
public final void mouseOver(final CardPanel panel, final MouseEvent evt) {
|
||||
for (CardPanelMouseListener listener : listeners) {
|
||||
for (final CardPanelMouseListener listener : this.listeners) {
|
||||
listener.mouseOver(panel, evt);
|
||||
}
|
||||
}
|
||||
@@ -526,8 +541,8 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public final Card getCardFromMouseOverPanel() {
|
||||
if (mouseOverPanel != null) {
|
||||
return mouseOverPanel.gameCard;
|
||||
if (this.mouseOverPanel != null) {
|
||||
return this.mouseOverPanel.getGameCard();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -541,7 +556,7 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getZoneID() {
|
||||
return zoneID;
|
||||
return this.zoneID;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -552,7 +567,46 @@ public abstract class CardPanelContainer extends JPanel {
|
||||
* @param zoneID
|
||||
* a int.
|
||||
*/
|
||||
public void setZoneID(final int zoneID) {
|
||||
public final void setZoneID(final int zoneID) {
|
||||
this.zoneID = zoneID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the card panels.
|
||||
*
|
||||
* @return the cardPanels
|
||||
*/
|
||||
public final List<CardPanel> getCardPanels() {
|
||||
return this.cardPanels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the card panels.
|
||||
*
|
||||
* @param cardPanels
|
||||
* the cardPanels to set
|
||||
*/
|
||||
public final void setCardPanels(final List<CardPanel> cardPanels) {
|
||||
this.cardPanels = cardPanels; // TODO: Add 0 to parameter's name.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mouse drag panel.
|
||||
*
|
||||
* @return the mouseDragPanel
|
||||
*/
|
||||
public CardPanel getMouseDragPanel() {
|
||||
return this.mouseDragPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mouse drag panel.
|
||||
*
|
||||
* @param mouseDragPanel
|
||||
* the mouseDragPanel to set
|
||||
*/
|
||||
public void setMouseDragPanel(final CardPanel mouseDragPanel) {
|
||||
this.mouseDragPanel = mouseDragPanel; // TODO: Add 0 to parameter's
|
||||
// name.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,33 +32,41 @@ public class HandArea extends CardArea {
|
||||
public HandArea(final JScrollPane scrollPane, final Frame frame) {
|
||||
super(scrollPane);
|
||||
|
||||
setDragEnabled(true);
|
||||
setVertical(true);
|
||||
this.setDragEnabled(true);
|
||||
this.setVertical(true);
|
||||
|
||||
addCardPanelMouseListener(new CardPanelMouseListener() {
|
||||
this.addCardPanelMouseListener(new CardPanelMouseListener() {
|
||||
@Override
|
||||
public void mouseRightClicked(final CardPanel panel, final MouseEvent evt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseOver(final CardPanel panel, final MouseEvent evt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseOut(final CardPanel panel, final MouseEvent evt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMiddleClicked(final CardPanel panel, final MouseEvent evt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseLeftClicked(final CardPanel panel, final MouseEvent evt) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(final CardPanel dragPanel, final int dragOffsetX, final int dragOffsetY,
|
||||
final MouseEvent evt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragStart(final CardPanel dragPanel, final MouseEvent evt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragEnd(final CardPanel dragPanel, final MouseEvent evt) {
|
||||
}
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
private int landStackMax = 5;
|
||||
|
||||
private boolean stackVertical;
|
||||
private boolean mirror;
|
||||
private final boolean mirror;
|
||||
|
||||
// Computed in layout.
|
||||
private List<Row> rows = new ArrayList<Row>();
|
||||
@@ -61,7 +61,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
*/
|
||||
public PlayArea(final JScrollPane scrollPane, final boolean mirror) {
|
||||
super(scrollPane);
|
||||
setBackground(Color.white);
|
||||
this.setBackground(Color.white);
|
||||
this.mirror = mirror;
|
||||
}
|
||||
|
||||
@@ -72,14 +72,15 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
*
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public void doLayout() {
|
||||
int tokenStackMax = 5;
|
||||
@Override
|
||||
public final void doLayout() {
|
||||
final int tokenStackMax = 5;
|
||||
// Collect lands.
|
||||
Row allLands = new Row();
|
||||
final Row allLands = new Row();
|
||||
outerLoop:
|
||||
//
|
||||
for (CardPanel panel : cardPanels) {
|
||||
if (!panel.gameCard.isLand() || panel.gameCard.isCreature()) {
|
||||
for (final CardPanel panel : this.getCardPanels()) {
|
||||
if (!panel.getGameCard().isLand() || panel.getGameCard().isCreature()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -87,18 +88,18 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
|
||||
// Find lands with the same name.
|
||||
for (int i = 0, n = allLands.size(); i < n; i++) {
|
||||
Stack stack = allLands.get(i);
|
||||
CardPanel firstPanel = stack.get(0);
|
||||
if (firstPanel.gameCard.getName().equals(panel.gameCard.getName())) {
|
||||
if (!firstPanel.attachedPanels.isEmpty() || firstPanel.gameCard.isEnchanted()) {
|
||||
final Stack stack = allLands.get(i);
|
||||
final CardPanel firstPanel = stack.get(0);
|
||||
if (firstPanel.getGameCard().getName().equals(panel.getGameCard().getName())) {
|
||||
if (!firstPanel.getAttachedPanels().isEmpty() || firstPanel.getGameCard().isEnchanted()) {
|
||||
// Put this land to the left of lands with the same name
|
||||
// and attachments.
|
||||
insertIndex = i;
|
||||
break;
|
||||
}
|
||||
if (!panel.attachedPanels.isEmpty()
|
||||
|| !panel.gameCard.getCounters().equals(firstPanel.gameCard.getCounters())
|
||||
|| firstPanel.gameCard.isEnchanted() || stack.size() == landStackMax) {
|
||||
if (!panel.getAttachedPanels().isEmpty()
|
||||
|| !panel.getGameCard().getCounters().equals(firstPanel.getGameCard().getCounters())
|
||||
|| firstPanel.getGameCard().isEnchanted() || (stack.size() == this.landStackMax)) {
|
||||
// If this land has attachments or the stack is full,
|
||||
// put it to the right.
|
||||
insertIndex = i + 1;
|
||||
@@ -113,17 +114,17 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
}
|
||||
|
||||
Stack stack = new Stack();
|
||||
final Stack stack = new Stack();
|
||||
stack.add(panel);
|
||||
allLands.add(insertIndex == -1 ? allLands.size() : insertIndex, stack);
|
||||
}
|
||||
|
||||
// Collect tokens.
|
||||
Row allTokens = new Row();
|
||||
final Row allTokens = new Row();
|
||||
outerLoop:
|
||||
//
|
||||
for (CardPanel panel : cardPanels) {
|
||||
if (!panel.gameCard.isToken()) {
|
||||
for (final CardPanel panel : this.getCardPanels()) {
|
||||
if (!panel.getGameCard().isToken()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -131,21 +132,21 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
|
||||
// Find tokens with the same name.
|
||||
for (int i = 0, n = allTokens.size(); i < n; i++) {
|
||||
Stack stack = allTokens.get(i);
|
||||
CardPanel firstPanel = stack.get(0);
|
||||
if (firstPanel.gameCard.getName().equals(panel.gameCard.getName())) {
|
||||
if (!firstPanel.attachedPanels.isEmpty()) {
|
||||
final Stack stack = allTokens.get(i);
|
||||
final CardPanel firstPanel = stack.get(0);
|
||||
if (firstPanel.getGameCard().getName().equals(panel.getGameCard().getName())) {
|
||||
if (!firstPanel.getAttachedPanels().isEmpty()) {
|
||||
// Put this token to the left of tokens with the same
|
||||
// name and attachments.
|
||||
insertIndex = i;
|
||||
break;
|
||||
}
|
||||
if (!panel.attachedPanels.isEmpty()
|
||||
|| !panel.gameCard.getCounters().equals(firstPanel.gameCard.getCounters())
|
||||
|| panel.gameCard.isSick() != firstPanel.gameCard.isSick()
|
||||
|| panel.gameCard.getNetAttack() != firstPanel.gameCard.getNetAttack()
|
||||
|| panel.gameCard.getNetDefense() != firstPanel.gameCard.getNetDefense()
|
||||
|| stack.size() == tokenStackMax) {
|
||||
if (!panel.getAttachedPanels().isEmpty()
|
||||
|| !panel.getGameCard().getCounters().equals(firstPanel.getGameCard().getCounters())
|
||||
|| (panel.getGameCard().isSick() != firstPanel.getGameCard().isSick())
|
||||
|| (panel.getGameCard().getNetAttack() != firstPanel.getGameCard().getNetAttack())
|
||||
|| (panel.getGameCard().getNetDefense() != firstPanel.getGameCard().getNetDefense())
|
||||
|| (stack.size() == tokenStackMax)) {
|
||||
// If this token has attachments or the stack is full,
|
||||
// put it to the right.
|
||||
insertIndex = i + 1;
|
||||
@@ -160,112 +161,112 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
}
|
||||
|
||||
Stack stack = new Stack();
|
||||
final Stack stack = new Stack();
|
||||
stack.add(panel);
|
||||
allTokens.add(insertIndex == -1 ? allTokens.size() : insertIndex, stack);
|
||||
}
|
||||
|
||||
Row allCreatures = new Row(cardPanels, RowType.creatureNonToken);
|
||||
Row allOthers = new Row(cardPanels, RowType.other);
|
||||
final Row allCreatures = new Row(this.getCardPanels(), RowType.creatureNonToken);
|
||||
final Row allOthers = new Row(this.getCardPanels(), RowType.other);
|
||||
|
||||
cardWidth = cardWidthMax;
|
||||
Rectangle rect = scrollPane.getVisibleRect();
|
||||
playAreaWidth = rect.width;
|
||||
playAreaHeight = rect.height;
|
||||
this.cardWidth = this.getCardWidthMax();
|
||||
final Rectangle rect = this.getScrollPane().getVisibleRect();
|
||||
this.playAreaWidth = rect.width;
|
||||
this.playAreaHeight = rect.height;
|
||||
while (true) {
|
||||
rows.clear();
|
||||
cardHeight = Math.round(cardWidth * CardPanel.ASPECT_RATIO);
|
||||
extraCardSpacingX = Math.round(cardWidth * EXTRA_CARD_SPACING_X);
|
||||
cardSpacingX = cardHeight - cardWidth + extraCardSpacingX;
|
||||
cardSpacingY = Math.round(cardHeight * CARD_SPACING_Y);
|
||||
stackSpacingX = stackVertical ? 0 : (int) Math.round(cardWidth * STACK_SPACING_X);
|
||||
stackSpacingY = Math.round(cardHeight * STACK_SPACING_Y);
|
||||
Row creatures = (Row) allCreatures.clone();
|
||||
Row tokens = (Row) allTokens.clone();
|
||||
Row lands = (Row) allLands.clone();
|
||||
this.rows.clear();
|
||||
this.cardHeight = Math.round(this.cardWidth * CardPanel.ASPECT_RATIO);
|
||||
this.extraCardSpacingX = Math.round(this.cardWidth * PlayArea.EXTRA_CARD_SPACING_X);
|
||||
this.cardSpacingX = (this.cardHeight - this.cardWidth) + this.extraCardSpacingX;
|
||||
this.cardSpacingY = Math.round(this.cardHeight * PlayArea.CARD_SPACING_Y);
|
||||
this.stackSpacingX = this.stackVertical ? 0 : (int) Math.round(this.cardWidth * PlayArea.STACK_SPACING_X);
|
||||
this.stackSpacingY = Math.round(this.cardHeight * PlayArea.STACK_SPACING_Y);
|
||||
final Row creatures = (Row) allCreatures.clone();
|
||||
final Row tokens = (Row) allTokens.clone();
|
||||
final Row lands = (Row) allLands.clone();
|
||||
Row others = (Row) allOthers.clone();
|
||||
int afterFirstRow;
|
||||
if (mirror) {
|
||||
if (this.mirror) {
|
||||
// Wrap all creatures and lands.
|
||||
wrap(lands, rows, -1);
|
||||
afterFirstRow = rows.size();
|
||||
wrap(tokens, rows, afterFirstRow);
|
||||
wrap(creatures, rows, rows.size());
|
||||
this.wrap(lands, this.rows, -1);
|
||||
afterFirstRow = this.rows.size();
|
||||
this.wrap(tokens, this.rows, afterFirstRow);
|
||||
this.wrap(creatures, this.rows, this.rows.size());
|
||||
} else {
|
||||
// Wrap all creatures and lands.
|
||||
wrap(creatures, rows, -1);
|
||||
afterFirstRow = rows.size();
|
||||
wrap(tokens, rows, afterFirstRow);
|
||||
wrap(lands, rows, rows.size());
|
||||
this.wrap(creatures, this.rows, -1);
|
||||
afterFirstRow = this.rows.size();
|
||||
this.wrap(tokens, this.rows, afterFirstRow);
|
||||
this.wrap(lands, this.rows, this.rows.size());
|
||||
}
|
||||
// Store the current rows and others.
|
||||
List<Row> storedRows = new ArrayList<Row>(rows.size());
|
||||
for (Row row : rows) {
|
||||
final List<Row> storedRows = new ArrayList<Row>(this.rows.size());
|
||||
for (final Row row : this.rows) {
|
||||
storedRows.add((Row) row.clone());
|
||||
}
|
||||
Row storedOthers = (Row) others.clone();
|
||||
final Row storedOthers = (Row) others.clone();
|
||||
// Fill in all rows with others.
|
||||
for (Row row : rows) {
|
||||
fillRow(others, rows, row);
|
||||
for (final Row row : this.rows) {
|
||||
this.fillRow(others, this.rows, row);
|
||||
}
|
||||
// Stop if everything fits, otherwise revert back to the stored
|
||||
// values.
|
||||
if (creatures.isEmpty() && tokens.isEmpty() && lands.isEmpty() && others.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
rows = storedRows;
|
||||
this.rows = storedRows;
|
||||
others = storedOthers;
|
||||
// Try to put others on their own row(s) and fill in the rest.
|
||||
wrap(others, rows, afterFirstRow);
|
||||
for (Row row : rows) {
|
||||
fillRow(others, rows, row);
|
||||
this.wrap(others, this.rows, afterFirstRow);
|
||||
for (final Row row : this.rows) {
|
||||
this.fillRow(others, this.rows, row);
|
||||
}
|
||||
// If that still doesn't fit, scale down.
|
||||
if (creatures.isEmpty() && tokens.isEmpty() && lands.isEmpty() && others.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
cardWidth--;
|
||||
this.cardWidth--;
|
||||
}
|
||||
|
||||
// Get size of all the rows.
|
||||
int x, y = GUTTER_Y;
|
||||
int x, y = PlayArea.GUTTER_Y;
|
||||
int maxRowWidth = 0;
|
||||
for (Row row : rows) {
|
||||
for (final Row row : this.rows) {
|
||||
int rowBottom = 0;
|
||||
x = GUTTER_X;
|
||||
x = PlayArea.GUTTER_X;
|
||||
for (int stackIndex = 0, stackCount = row.size(); stackIndex < stackCount; stackIndex++) {
|
||||
Stack stack = row.get(stackIndex);
|
||||
final Stack stack = row.get(stackIndex);
|
||||
rowBottom = Math.max(rowBottom, y + stack.getHeight());
|
||||
x += stack.getWidth();
|
||||
}
|
||||
y = rowBottom;
|
||||
maxRowWidth = Math.max(maxRowWidth, x);
|
||||
}
|
||||
setPreferredSize(new Dimension(maxRowWidth - cardSpacingX, y - cardSpacingY));
|
||||
revalidate();
|
||||
this.setPreferredSize(new Dimension(maxRowWidth - this.cardSpacingX, y - this.cardSpacingY));
|
||||
this.revalidate();
|
||||
|
||||
// Position all card panels.
|
||||
x = 0;
|
||||
y = GUTTER_Y;
|
||||
for (Row row : rows) {
|
||||
y = PlayArea.GUTTER_Y;
|
||||
for (final Row row : this.rows) {
|
||||
int rowBottom = 0;
|
||||
x = GUTTER_X;
|
||||
x = PlayArea.GUTTER_X;
|
||||
for (int stackIndex = 0, stackCount = row.size(); stackIndex < stackCount; stackIndex++) {
|
||||
Stack stack = row.get(stackIndex);
|
||||
final Stack stack = row.get(stackIndex);
|
||||
// Align others to the right.
|
||||
if (RowType.other.isType(stack.get(0).gameCard)) {
|
||||
x = playAreaWidth - GUTTER_X + extraCardSpacingX;
|
||||
if (RowType.other.isType(stack.get(0).getGameCard())) {
|
||||
x = (this.playAreaWidth - PlayArea.GUTTER_X) + this.extraCardSpacingX;
|
||||
for (int i = stackIndex, n = row.size(); i < n; i++) {
|
||||
x -= row.get(i).getWidth();
|
||||
}
|
||||
}
|
||||
for (int panelIndex = 0, panelCount = stack.size(); panelIndex < panelCount; panelIndex++) {
|
||||
CardPanel panel = stack.get(panelIndex);
|
||||
int stackPosition = panelCount - panelIndex - 1;
|
||||
setComponentZOrder(panel, panelIndex);
|
||||
int panelX = x + (stackPosition * stackSpacingX);
|
||||
int panelY = y + (stackPosition * stackSpacingY);
|
||||
panel.setCardBounds(panelX, panelY, cardWidth, cardHeight);
|
||||
final CardPanel panel = stack.get(panelIndex);
|
||||
final int stackPosition = panelCount - panelIndex - 1;
|
||||
this.setComponentZOrder(panel, panelIndex);
|
||||
final int panelX = x + (stackPosition * this.stackSpacingX);
|
||||
final int panelY = y + (stackPosition * this.stackSpacingY);
|
||||
panel.setCardBounds(panelX, panelY, this.cardWidth, this.cardHeight);
|
||||
}
|
||||
rowBottom = Math.max(rowBottom, y + stack.getHeight());
|
||||
x += stack.getWidth();
|
||||
@@ -290,19 +291,20 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
private int wrap(final Row sourceRow, final List<Row> rows, final int insertIndex) {
|
||||
// The cards are sure to fit (with vertical scrolling) at the minimum
|
||||
// card width.
|
||||
boolean allowHeightOverflow = cardWidth == cardWidthMin;
|
||||
final boolean allowHeightOverflow = this.cardWidth == this.getCardWidthMin();
|
||||
|
||||
Row currentRow = new Row();
|
||||
for (int i = 0, n = sourceRow.size() - 1; i <= n; i++) {
|
||||
Stack stack = sourceRow.get(i);
|
||||
final Stack stack = sourceRow.get(i);
|
||||
// If the row is not empty and this stack doesn't fit, add the row.
|
||||
int rowWidth = currentRow.getWidth();
|
||||
if (!currentRow.isEmpty() && rowWidth + stack.getWidth() > playAreaWidth) {
|
||||
final int rowWidth = currentRow.getWidth();
|
||||
if (!currentRow.isEmpty() && ((rowWidth + stack.getWidth()) > this.playAreaWidth)) {
|
||||
// Stop processing if the row is too wide or tall.
|
||||
if (!allowHeightOverflow && rowWidth > playAreaWidth) {
|
||||
if (!allowHeightOverflow && (rowWidth > this.playAreaWidth)) {
|
||||
break;
|
||||
}
|
||||
if (!allowHeightOverflow && getRowsHeight(rows) + sourceRow.getHeight() > playAreaHeight) {
|
||||
if (!allowHeightOverflow && ((this.getRowsHeight(rows)
|
||||
+ sourceRow.getHeight()) > this.playAreaHeight)) {
|
||||
break;
|
||||
}
|
||||
rows.add(insertIndex == -1 ? rows.size() : insertIndex, currentRow);
|
||||
@@ -312,16 +314,17 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
// Add the last row if it is not empty and it fits.
|
||||
if (!currentRow.isEmpty()) {
|
||||
int rowWidth = currentRow.getWidth();
|
||||
if (allowHeightOverflow || rowWidth <= playAreaWidth) {
|
||||
if (allowHeightOverflow || getRowsHeight(rows) + sourceRow.getHeight() <= playAreaHeight) {
|
||||
final int rowWidth = currentRow.getWidth();
|
||||
if (allowHeightOverflow || (rowWidth <= this.playAreaWidth)) {
|
||||
if (allowHeightOverflow || ((this.getRowsHeight(rows)
|
||||
+ sourceRow.getHeight()) <= this.playAreaHeight)) {
|
||||
rows.add(insertIndex == -1 ? rows.size() : insertIndex, currentRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove the wrapped stacks from the source row.
|
||||
for (Row row : rows) {
|
||||
for (Stack stack : row) {
|
||||
for (final Row row : rows) {
|
||||
for (final Stack stack : row) {
|
||||
sourceRow.remove(stack);
|
||||
}
|
||||
}
|
||||
@@ -342,16 +345,16 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* @param row
|
||||
* a {@link arcane.ui.PlayArea.Row} object.
|
||||
*/
|
||||
private void fillRow(final Row sourceRow, final List<Row> rows, Row row) {
|
||||
private void fillRow(final Row sourceRow, final List<Row> rows, final Row row) {
|
||||
int rowWidth = row.getWidth();
|
||||
while (!sourceRow.isEmpty()) {
|
||||
Stack stack = sourceRow.get(0);
|
||||
final Stack stack = sourceRow.get(0);
|
||||
rowWidth += stack.getWidth();
|
||||
if (rowWidth > playAreaWidth) {
|
||||
if (rowWidth > this.playAreaWidth) {
|
||||
break;
|
||||
}
|
||||
if (stack.getHeight() > row.getHeight()) {
|
||||
if (getRowsHeight(rows) - row.getHeight() + stack.getHeight() > playAreaHeight) {
|
||||
if (((this.getRowsHeight(rows) - row.getHeight()) + stack.getHeight()) > this.playAreaHeight) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -368,23 +371,24 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* a {@link java.util.List} object.
|
||||
* @return a int.
|
||||
*/
|
||||
private int getRowsHeight(List<Row> rows) {
|
||||
private int getRowsHeight(final List<Row> rows) {
|
||||
int height = 0;
|
||||
for (Row row : rows) {
|
||||
for (final Row row : rows) {
|
||||
height += row.getHeight();
|
||||
}
|
||||
return height - cardSpacingY + GUTTER_Y * 2;
|
||||
return (height - this.cardSpacingY) + (PlayArea.GUTTER_Y * 2);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final CardPanel getCardPanel(final int x, final int y) {
|
||||
for (Row row : rows) {
|
||||
for (Stack stack : row) {
|
||||
for (CardPanel panel : stack) {
|
||||
int panelX = panel.getCardX();
|
||||
for (final Row row : this.rows) {
|
||||
for (final Stack stack : row) {
|
||||
for (final CardPanel panel : stack) {
|
||||
final int panelX = panel.getCardX();
|
||||
int panelY = panel.getCardY();
|
||||
int panelWidth, panelHeight;
|
||||
if (panel.tapped) {
|
||||
if (panel.isTapped()) {
|
||||
panelWidth = panel.getCardHeight();
|
||||
panelHeight = panel.getCardWidth();
|
||||
panelY += panelWidth - panelHeight;
|
||||
@@ -392,8 +396,8 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
panelWidth = panel.getCardWidth();
|
||||
panelHeight = panel.getCardHeight();
|
||||
}
|
||||
if (x > panelX && x < panelX + panelWidth) {
|
||||
if (y > panelY && y < panelY + panelHeight) {
|
||||
if ((x > panelX) && (x < (panelX + panelWidth))) {
|
||||
if ((y > panelY) && (y < (panelY + panelHeight))) {
|
||||
if (!panel.isDisplayEnabled()) {
|
||||
return null;
|
||||
}
|
||||
@@ -407,8 +411,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void mouseLeftClicked(final CardPanel panel, final MouseEvent evt) {
|
||||
if (panel.tappedAngle != 0 && panel.tappedAngle != CardPanel.TAPPED_ANGLE) {
|
||||
if ((panel.getTappedAngle() != 0) && (panel.getTappedAngle() != CardPanel.TAPPED_ANGLE)) {
|
||||
return;
|
||||
}
|
||||
super.mouseLeftClicked(panel, evt);
|
||||
@@ -422,7 +427,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getLandStackMax() {
|
||||
return landStackMax;
|
||||
return this.landStackMax;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -433,7 +438,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* @param landStackMax
|
||||
* a int.
|
||||
*/
|
||||
public final void setLandStackMax(int landStackMax) {
|
||||
public final void setLandStackMax(final int landStackMax) {
|
||||
this.landStackMax = landStackMax;
|
||||
}
|
||||
|
||||
@@ -445,7 +450,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean getStackVertical() {
|
||||
return stackVertical;
|
||||
return this.stackVertical;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -456,7 +461,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
* @param stackVertical
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setStackVertical(boolean stackVertical) {
|
||||
public final void setStackVertical(final boolean stackVertical) {
|
||||
this.stackVertical = stackVertical;
|
||||
}
|
||||
|
||||
@@ -488,43 +493,44 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
|
||||
public Row(final List<CardPanel> cardPanels, final RowType type) {
|
||||
this();
|
||||
addAll(cardPanels, type);
|
||||
this.addAll(cardPanels, type);
|
||||
}
|
||||
|
||||
private void addAll(final List<CardPanel> cardPanels, final RowType type) {
|
||||
for (CardPanel panel : cardPanels) {
|
||||
if (!type.isType(panel.gameCard) || panel.attachedToPanel != null) {
|
||||
for (final CardPanel panel : cardPanels) {
|
||||
if (!type.isType(panel.getGameCard()) || (panel.getAttachedToPanel() != null)) {
|
||||
continue;
|
||||
}
|
||||
Stack stack = new Stack();
|
||||
final Stack stack = new Stack();
|
||||
stack.add(panel);
|
||||
add(stack);
|
||||
this.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(final Collection<? extends Stack> c) {
|
||||
boolean changed = super.addAll(c);
|
||||
final boolean changed = super.addAll(c);
|
||||
c.clear();
|
||||
return changed;
|
||||
}
|
||||
|
||||
private int getWidth() {
|
||||
if (isEmpty()) {
|
||||
if (this.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
int width = 0;
|
||||
for (Stack stack : this) {
|
||||
for (final Stack stack : this) {
|
||||
width += stack.getWidth();
|
||||
}
|
||||
return width + GUTTER_X * 2 - extraCardSpacingX;
|
||||
return (width + (PlayArea.GUTTER_X * 2)) - PlayArea.this.extraCardSpacingX;
|
||||
}
|
||||
|
||||
private int getHeight() {
|
||||
if (isEmpty()) {
|
||||
if (this.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
int height = 0;
|
||||
for (Stack stack : this) {
|
||||
for (final Stack stack : this) {
|
||||
height = Math.max(height, stack.getHeight());
|
||||
}
|
||||
return height;
|
||||
@@ -538,20 +544,23 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
super(8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(final CardPanel panel) {
|
||||
boolean appended = super.add(panel);
|
||||
for (CardPanel attachedPanel : panel.attachedPanels) {
|
||||
add(attachedPanel);
|
||||
final boolean appended = super.add(panel);
|
||||
for (final CardPanel attachedPanel : panel.getAttachedPanels()) {
|
||||
this.add(attachedPanel);
|
||||
}
|
||||
return appended;
|
||||
}
|
||||
|
||||
private int getWidth() {
|
||||
return cardWidth + (size() - 1) * stackSpacingX + cardSpacingX;
|
||||
return PlayArea.this.cardWidth + ((this.size() - 1) * PlayArea.this.stackSpacingX)
|
||||
+ PlayArea.this.cardSpacingX;
|
||||
}
|
||||
|
||||
private int getHeight() {
|
||||
return cardHeight + (size() - 1) * stackSpacingY + cardSpacingY;
|
||||
return PlayArea.this.cardHeight + ((this.size() - 1) * PlayArea.this.stackSpacingY)
|
||||
+ PlayArea.this.cardSpacingY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,10 @@ import java.awt.image.BufferedImage;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
* <p>ScaledImagePanel class.</p>
|
||||
*
|
||||
* <p>
|
||||
* ScaledImagePanel class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
@@ -21,11 +23,11 @@ public class ScaledImagePanel extends JPanel {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public volatile Image srcImage;
|
||||
private volatile Image srcImage;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public volatile Image srcImageBlurred;
|
||||
private volatile Image srcImageBlurred;
|
||||
|
||||
private ScalingType scalingType = ScalingType.bilinear;
|
||||
private boolean scaleLarger;
|
||||
@@ -33,92 +35,116 @@ public class ScaledImagePanel extends JPanel {
|
||||
private boolean blur;
|
||||
|
||||
/**
|
||||
* <p>Constructor for ScaledImagePanel.</p>
|
||||
* <p>
|
||||
* Constructor for ScaledImagePanel.
|
||||
* </p>
|
||||
*/
|
||||
public ScaledImagePanel() {
|
||||
super(false);
|
||||
setOpaque(false);
|
||||
this.setOpaque(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setImage.</p>
|
||||
*
|
||||
* @param srcImage a {@link java.awt.Image} object.
|
||||
* @param srcImageBlurred a {@link java.awt.Image} object.
|
||||
*
|
||||
* <p>
|
||||
* setImage.
|
||||
* </p>
|
||||
*
|
||||
* @param srcImage
|
||||
* a {@link java.awt.Image} object.
|
||||
* @param srcImageBlurred
|
||||
* a {@link java.awt.Image} object.
|
||||
*
|
||||
*/
|
||||
public final void setImage(final Image srcImage, Image srcImageBlurred) {
|
||||
this.srcImage = srcImage;
|
||||
this.srcImageBlurred = srcImageBlurred;
|
||||
public final void setImage(final Image srcImage, final Image srcImageBlurred) {
|
||||
this.setSrcImage(srcImage);
|
||||
this.setSrcImageBlurred(srcImageBlurred);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>clearImage.</p>
|
||||
* <p>
|
||||
* clearImage.
|
||||
* </p>
|
||||
*/
|
||||
public final void clearImage() {
|
||||
srcImage = null;
|
||||
srcImageBlurred = null;
|
||||
repaint();
|
||||
this.setSrcImage(null);
|
||||
this.setSrcImageBlurred(null);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setScalingMultiPassType.</p>
|
||||
*
|
||||
* @param multiPassType a {@link arcane.ui.ScaledImagePanel.MultipassType} object.
|
||||
* <p>
|
||||
* setScalingMultiPassType.
|
||||
* </p>
|
||||
*
|
||||
* @param multiPassType
|
||||
* a {@link arcane.ui.ScaledImagePanel.MultipassType} object.
|
||||
*/
|
||||
public final void setScalingMultiPassType(final MultipassType multiPassType) {
|
||||
this.multiPassType = multiPassType;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>scalingType</code>.</p>
|
||||
*
|
||||
* @param scalingType a {@link arcane.ui.ScaledImagePanel.ScalingType} object.
|
||||
* <p>
|
||||
* Setter for the field <code>scalingType</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param scalingType
|
||||
* a {@link arcane.ui.ScaledImagePanel.ScalingType} object.
|
||||
*/
|
||||
public final void setScalingType(final ScalingType scalingType) {
|
||||
this.scalingType = scalingType;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setScalingBlur.</p>
|
||||
*
|
||||
* @param blur a boolean.
|
||||
* <p>
|
||||
* setScalingBlur.
|
||||
* </p>
|
||||
*
|
||||
* @param blur
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setScalingBlur(final boolean blur) {
|
||||
this.blur = blur;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>scaleLarger</code>.</p>
|
||||
*
|
||||
* @param scaleLarger a boolean.
|
||||
* <p>
|
||||
* Setter for the field <code>scaleLarger</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param scaleLarger
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setScaleLarger(final boolean scaleLarger) {
|
||||
this.scaleLarger = scaleLarger;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>hasImage.</p>
|
||||
*
|
||||
* <p>
|
||||
* hasImage.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean hasImage() {
|
||||
return srcImage != null;
|
||||
return this.getSrcImage() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getScalingInfo.</p>
|
||||
*
|
||||
* <p>
|
||||
* getScalingInfo.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
||||
*/
|
||||
private ScalingInfo getScalingInfo() {
|
||||
int panelWidth = getWidth();
|
||||
int panelHeight = getHeight();
|
||||
int srcWidth = srcImage.getWidth(null);
|
||||
int srcHeight = srcImage.getHeight(null);
|
||||
final int panelWidth = this.getWidth();
|
||||
final int panelHeight = this.getHeight();
|
||||
final int srcWidth = this.getSrcImage().getWidth(null);
|
||||
final int srcHeight = this.getSrcImage().getHeight(null);
|
||||
int targetWidth = srcWidth;
|
||||
int targetHeight = srcHeight;
|
||||
if (scaleLarger || srcWidth > panelWidth || srcHeight > panelHeight) {
|
||||
if (this.scaleLarger || (srcWidth > panelWidth) || (srcHeight > panelHeight)) {
|
||||
targetWidth = Math.round(panelHeight * (srcWidth / (float) srcHeight));
|
||||
if (targetWidth > panelWidth) {
|
||||
targetHeight = Math.round(panelWidth * (srcHeight / (float) srcWidth));
|
||||
@@ -127,65 +153,76 @@ public class ScaledImagePanel extends JPanel {
|
||||
targetHeight = panelHeight;
|
||||
}
|
||||
}
|
||||
ScalingInfo info = new ScalingInfo();
|
||||
final ScalingInfo info = new ScalingInfo();
|
||||
info.targetWidth = targetWidth;
|
||||
info.targetHeight = targetHeight;
|
||||
info.srcWidth = srcWidth;
|
||||
info.srcHeight = srcHeight;
|
||||
info.x = panelWidth / 2 - targetWidth / 2;
|
||||
info.y = panelHeight / 2 - targetHeight / 2;
|
||||
info.x = (panelWidth / 2) - (targetWidth / 2);
|
||||
info.y = (panelHeight / 2) - (targetHeight / 2);
|
||||
return info;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void paint(final Graphics g) {
|
||||
if (srcImage == null) {
|
||||
if (this.getSrcImage() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
ScalingInfo info = getScalingInfo();
|
||||
final Graphics2D g2 = (Graphics2D) g.create();
|
||||
final ScalingInfo info = this.getScalingInfo();
|
||||
|
||||
switch (scalingType) {
|
||||
case nearestNeighbor:
|
||||
scaleWithDrawImage(g2, info, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
|
||||
break;
|
||||
case bilinear:
|
||||
scaleWithDrawImage(g2, info, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
break;
|
||||
case bicubic:
|
||||
scaleWithDrawImage(g2, info, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
||||
break;
|
||||
case areaAveraging:
|
||||
scaleWithGetScaledInstance(g2, info, Image.SCALE_AREA_AVERAGING);
|
||||
break;
|
||||
case replicate:
|
||||
scaleWithGetScaledInstance(g2, info, Image.SCALE_REPLICATE);
|
||||
break;
|
||||
switch (this.scalingType) {
|
||||
case nearestNeighbor:
|
||||
this.scaleWithDrawImage(g2, info, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
|
||||
break;
|
||||
case bilinear:
|
||||
this.scaleWithDrawImage(g2, info, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
break;
|
||||
case bicubic:
|
||||
this.scaleWithDrawImage(g2, info, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
||||
break;
|
||||
case areaAveraging:
|
||||
this.scaleWithGetScaledInstance(g2, info, Image.SCALE_AREA_AVERAGING);
|
||||
break;
|
||||
case replicate:
|
||||
this.scaleWithGetScaledInstance(g2, info, Image.SCALE_REPLICATE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>scaleWithGetScaledInstance.</p>
|
||||
*
|
||||
* @param g2 a {@link java.awt.Graphics2D} object.
|
||||
* @param info a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
||||
* @param hints a int.
|
||||
* <p>
|
||||
* scaleWithGetScaledInstance.
|
||||
* </p>
|
||||
*
|
||||
* @param g2
|
||||
* a {@link java.awt.Graphics2D} object.
|
||||
* @param info
|
||||
* a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
||||
* @param hints
|
||||
* a int.
|
||||
*/
|
||||
private void scaleWithGetScaledInstance(final Graphics2D g2, final ScalingInfo info, final int hints) {
|
||||
Image srcImage = getSourceImage(info);
|
||||
Image scaledImage = srcImage.getScaledInstance(info.targetWidth, info.targetHeight, hints);
|
||||
final Image srcImage = this.getSourceImage(info);
|
||||
final Image scaledImage = srcImage.getScaledInstance(info.targetWidth, info.targetHeight, hints);
|
||||
g2.drawImage(scaledImage, info.x, info.y, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>scaleWithDrawImage.</p>
|
||||
*
|
||||
* @param g2 a {@link java.awt.Graphics2D} object.
|
||||
* @param info a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
||||
* @param hint a {@link java.lang.Object} object.
|
||||
* <p>
|
||||
* scaleWithDrawImage.
|
||||
* </p>
|
||||
*
|
||||
* @param g2
|
||||
* a {@link java.awt.Graphics2D} object.
|
||||
* @param info
|
||||
* a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
||||
* @param hint
|
||||
* a {@link java.lang.Object} object.
|
||||
*/
|
||||
private void scaleWithDrawImage(final Graphics2D g2, final ScalingInfo info, final Object hint) {
|
||||
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
|
||||
@@ -198,30 +235,29 @@ public class ScaledImagePanel extends JPanel {
|
||||
tempDestHeight = info.targetHeight;
|
||||
}
|
||||
|
||||
Image srcImage = getSourceImage(info);
|
||||
final Image srcImage = this.getSourceImage(info);
|
||||
|
||||
// If not doing multipass or multipass only needs a single pass,
|
||||
// just scale it once directly to the panel surface.
|
||||
if (multiPassType == MultipassType.none
|
||||
|| (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight))
|
||||
{
|
||||
if ((this.multiPassType == MultipassType.none)
|
||||
|| ((tempDestWidth == info.targetWidth) && (tempDestHeight == info.targetHeight))) {
|
||||
g2.drawImage(srcImage, info.x, info.y, info.targetWidth, info.targetHeight, null);
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedImage tempImage = new BufferedImage(tempDestWidth, tempDestHeight, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g2temp = tempImage.createGraphics();
|
||||
switch (multiPassType) {
|
||||
case nearestNeighbor:
|
||||
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
||||
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
|
||||
break;
|
||||
case bilinear:
|
||||
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
break;
|
||||
case bicubic:
|
||||
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
||||
break;
|
||||
final BufferedImage tempImage = new BufferedImage(tempDestWidth, tempDestHeight, BufferedImage.TYPE_INT_RGB);
|
||||
final Graphics2D g2temp = tempImage.createGraphics();
|
||||
switch (this.multiPassType) {
|
||||
case nearestNeighbor:
|
||||
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
||||
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
|
||||
break;
|
||||
case bilinear:
|
||||
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
break;
|
||||
case bicubic:
|
||||
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -245,7 +281,7 @@ public class ScaledImagePanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
if (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight) {
|
||||
if ((tempDestWidth == info.targetWidth) && (tempDestHeight == info.targetHeight)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -257,87 +293,117 @@ public class ScaledImagePanel extends JPanel {
|
||||
g2temp.dispose();
|
||||
// Render last pass from temp to panel surface.
|
||||
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
|
||||
g2.drawImage(tempImage, info.x,
|
||||
info.y,
|
||||
info.x + info.targetWidth,
|
||||
info.y + info.targetHeight, 0, 0, tempSrcWidth,
|
||||
tempSrcHeight, null);
|
||||
g2.drawImage(tempImage, info.x, info.y, info.x + info.targetWidth, info.y + info.targetHeight, 0, 0,
|
||||
tempSrcWidth, tempSrcHeight, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getSourceImage.</p>
|
||||
*
|
||||
* @param info a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
||||
* <p>
|
||||
* getSourceImage.
|
||||
* </p>
|
||||
*
|
||||
* @param info
|
||||
* a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
||||
* @return a {@link java.awt.Image} object.
|
||||
*/
|
||||
private Image getSourceImage(final ScalingInfo info) {
|
||||
if (!blur || srcImageBlurred == null) {
|
||||
return srcImage;
|
||||
if (!this.blur || (this.getSrcImageBlurred() == null)) {
|
||||
return this.getSrcImage();
|
||||
}
|
||||
if (info.srcWidth / 2 < info.targetWidth || info.srcHeight / 2 < info.targetHeight) {
|
||||
return srcImage;
|
||||
if (((info.srcWidth / 2) < info.targetWidth) || ((info.srcHeight / 2) < info.targetHeight)) {
|
||||
return this.getSrcImage();
|
||||
}
|
||||
return srcImageBlurred;
|
||||
return this.getSrcImageBlurred();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the src image.
|
||||
*
|
||||
* @return the srcImage
|
||||
*/
|
||||
public Image getSrcImage() {
|
||||
return this.srcImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the src image.
|
||||
*
|
||||
* @param srcImage
|
||||
* the srcImage to set
|
||||
*/
|
||||
public void setSrcImage(final Image srcImage) {
|
||||
this.srcImage = srcImage; // TODO: Add 0 to parameter's name.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the src image blurred.
|
||||
*
|
||||
* @return the srcImageBlurred
|
||||
*/
|
||||
public Image getSrcImageBlurred() {
|
||||
return this.srcImageBlurred;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the src image blurred.
|
||||
*
|
||||
* @param srcImageBlurred
|
||||
* the srcImageBlurred to set
|
||||
*/
|
||||
public void setSrcImageBlurred(final Image srcImageBlurred) {
|
||||
this.srcImageBlurred = srcImageBlurred; // TODO: Add 0 to parameter's
|
||||
// name.
|
||||
}
|
||||
|
||||
private static class ScalingInfo {
|
||||
public int targetWidth;
|
||||
public int targetHeight;
|
||||
public int srcWidth;
|
||||
public int srcHeight;
|
||||
public int x;
|
||||
public int y;
|
||||
private int targetWidth;
|
||||
private int targetHeight;
|
||||
private int srcWidth;
|
||||
private int srcHeight;
|
||||
private int x;
|
||||
private int y;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* MultipassType.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static enum MultipassType {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/** The none. */
|
||||
none,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/** The nearest neighbor. */
|
||||
nearestNeighbor,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/** The bilinear. */
|
||||
bilinear,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/** The bicubic. */
|
||||
bicubic
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* ScalingType.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static enum ScalingType {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/** The nearest neighbor. */
|
||||
nearestNeighbor,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/** The replicate. */
|
||||
replicate,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/** The bilinear. */
|
||||
bilinear,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/** The bicubic. */
|
||||
bicubic,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/** The area averaging. */
|
||||
areaAveraging
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ import java.awt.BorderLayout;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
* <p>ViewPanel class.</p>
|
||||
*
|
||||
* <p>
|
||||
* ViewPanel class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
@@ -15,19 +17,22 @@ public class ViewPanel extends JPanel {
|
||||
private static final long serialVersionUID = 7016597023142963068L;
|
||||
|
||||
/**
|
||||
* <p>doLayout.</p>
|
||||
*
|
||||
* <p>
|
||||
* doLayout.
|
||||
* </p>
|
||||
*
|
||||
* @since 1.0.15
|
||||
*/
|
||||
@Override
|
||||
public final void doLayout() {
|
||||
if (getComponentCount() == 0) {
|
||||
if (this.getComponentCount() == 0) {
|
||||
return;
|
||||
}
|
||||
CardPanel panel = (CardPanel) getComponent(0);
|
||||
int viewWidth = getWidth();
|
||||
int viewHeight = getHeight();
|
||||
int srcWidth = viewWidth;
|
||||
int srcHeight = Math.round(viewWidth * CardPanel.ASPECT_RATIO);
|
||||
final CardPanel panel = (CardPanel) this.getComponent(0);
|
||||
final int viewWidth = this.getWidth();
|
||||
final int viewHeight = this.getHeight();
|
||||
final int srcWidth = viewWidth;
|
||||
final int srcHeight = Math.round(viewWidth * CardPanel.ASPECT_RATIO);
|
||||
int targetWidth = Math.round(viewHeight * (srcWidth / (float) srcHeight));
|
||||
int targetHeight;
|
||||
if (targetWidth > viewWidth) {
|
||||
@@ -36,21 +41,24 @@ public class ViewPanel extends JPanel {
|
||||
} else {
|
||||
targetHeight = viewHeight;
|
||||
}
|
||||
int x = viewWidth / 2 - targetWidth / 2;
|
||||
int y = viewHeight / 2 - targetHeight / 2;
|
||||
final int x = (viewWidth / 2) - (targetWidth / 2);
|
||||
final int y = (viewHeight / 2) - (targetHeight / 2);
|
||||
panel.setCardBounds(x, y, targetWidth, targetHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setCardPanel.</p>
|
||||
*
|
||||
* @param panel a {@link arcane.ui.CardPanel} object.
|
||||
* <p>
|
||||
* setCardPanel.
|
||||
* </p>
|
||||
*
|
||||
* @param panel
|
||||
* a {@link arcane.ui.CardPanel} object.
|
||||
*/
|
||||
public final void setCardPanel(final CardPanel panel) {
|
||||
//CardPanel newPanel = new CardPanel(panel.gameCard);
|
||||
//newPanel.setImage(panel);
|
||||
removeAll();
|
||||
add(panel, BorderLayout.CENTER);
|
||||
// CardPanel newPanel = new CardPanel(panel.gameCard);
|
||||
// newPanel.setImage(panel);
|
||||
this.removeAll();
|
||||
this.add(panel, BorderLayout.CENTER);
|
||||
panel.revalidate();
|
||||
panel.repaint();
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
/** Forge Card Game. */
|
||||
package arcane.ui;
|
||||
|
||||
|
||||
@@ -179,19 +179,19 @@ public abstract class Animation {
|
||||
public static void tapCardToggle(final CardPanel panel) {
|
||||
new Animation(200) {
|
||||
protected void start() {
|
||||
panel.tapped = !panel.tapped;
|
||||
panel.setTapped(!panel.isTapped());
|
||||
}
|
||||
|
||||
protected void update(final float percentage) {
|
||||
panel.tappedAngle = CardPanel.TAPPED_ANGLE * percentage;
|
||||
if (!panel.tapped) {
|
||||
panel.tappedAngle = CardPanel.TAPPED_ANGLE - panel.tappedAngle;
|
||||
panel.setTappedAngle(CardPanel.TAPPED_ANGLE * percentage);
|
||||
if (!panel.isTapped()) {
|
||||
panel.setTappedAngle(CardPanel.TAPPED_ANGLE - panel.getTappedAngle());
|
||||
}
|
||||
panel.repaint();
|
||||
}
|
||||
|
||||
protected void end() {
|
||||
panel.tappedAngle = panel.tapped ? CardPanel.TAPPED_ANGLE : 0;
|
||||
panel.setTappedAngle(panel.isTapped() ? CardPanel.TAPPED_ANGLE : 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -347,7 +347,7 @@ public abstract class Animation {
|
||||
if (placeholder != null) {
|
||||
placeholder.setDisplayEnabled(true);
|
||||
// placeholder.setImage(animationPanel);
|
||||
placeholder.setCard(placeholder.gameCard);
|
||||
placeholder.setCard(placeholder.getGameCard());
|
||||
}
|
||||
animationPanel.setVisible(false);
|
||||
animationPanel.repaint();
|
||||
@@ -376,7 +376,7 @@ public abstract class Animation {
|
||||
if (placeholder != null) {
|
||||
placeholder.setDisplayEnabled(true);
|
||||
// placeholder.setImage(imagePanel);
|
||||
placeholder.setCard(placeholder.gameCard);
|
||||
placeholder.setCard(placeholder.getGameCard());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -426,7 +426,7 @@ public abstract class Animation {
|
||||
currentX = Math.min(currentX, layeredPane.getWidth() - currentWidth);
|
||||
int currentY = Math.max(0, centerY - Math.round(currentHeight / 2f));
|
||||
currentY = Math.min(currentY, layeredPane.getHeight() - currentHeight);
|
||||
animationPanel.tappedAngle = overPanel.tappedAngle * percentage;
|
||||
animationPanel.setTappedAngle(overPanel.getTappedAngle() * percentage);
|
||||
animationPanel.setCardBounds(currentX, currentY, currentWidth, currentHeight);
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ public abstract class Animation {
|
||||
}
|
||||
final long thisDelayedTime = delayedTime;
|
||||
|
||||
final CardPanel animationPanel = new CardPanel(overPanel.gameCard);
|
||||
final CardPanel animationPanel = new CardPanel(overPanel.getGameCard());
|
||||
animationPanel.setImage(overPanel);
|
||||
|
||||
new Animation(200, delay) {
|
||||
@@ -518,7 +518,7 @@ public abstract class Animation {
|
||||
animationPanel.setCardBounds(startPos.x, startPos.y, startWidth, startHeight);
|
||||
}
|
||||
// clientFrame.clearArrows();
|
||||
animationPanel.tappedAngle = overPanel.tappedAngle;
|
||||
animationPanel.setTappedAngle(overPanel.getTappedAngle());
|
||||
try {
|
||||
Util.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
@@ -547,7 +547,7 @@ public abstract class Animation {
|
||||
currentX = Math.min(currentX, layeredPane.getWidth() - currentWidth);
|
||||
int currentY = Math.max(0, centerY - Math.round(currentHeight / 2f));
|
||||
currentY = Math.min(currentY, layeredPane.getHeight() - currentHeight);
|
||||
animationPanel.tappedAngle = overPanel.tappedAngle * (1 - percentage);
|
||||
animationPanel.setTappedAngle(overPanel.getTappedAngle() * (1 - percentage));
|
||||
animationPanel.setCardBounds(currentX, currentY, currentWidth, currentHeight);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -540,9 +540,10 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo
|
||||
if (c != null) {
|
||||
|
||||
if (c.isTapped()
|
||||
&& (inputControl.input instanceof Input_PayManaCost || inputControl.input instanceof Input_PayManaCost_Ability)) {
|
||||
&& (inputControl.input instanceof Input_PayManaCost
|
||||
|| inputControl.input instanceof Input_PayManaCost_Ability)) {
|
||||
arcane.ui.CardPanel cardPanel = playerPlayPanel.getCardPanel(c.getUniqueNumber());
|
||||
for (arcane.ui.CardPanel cp : cardPanel.attachedPanels) {
|
||||
for (arcane.ui.CardPanel cp : cardPanel.getAttachedPanels()) {
|
||||
if (cp.getCard().isUntapped()) {
|
||||
break;
|
||||
}
|
||||
@@ -553,7 +554,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo
|
||||
if ((c.isTapped() || c.hasSickness() || ((c.hasKeyword("Vigilance")) && att.contains(c)))
|
||||
&& (inputControl.input instanceof Input_Attack)) {
|
||||
arcane.ui.CardPanel cardPanel = playerPlayPanel.getCardPanel(c.getUniqueNumber());
|
||||
for (arcane.ui.CardPanel cp : cardPanel.attachedPanels) {
|
||||
for (arcane.ui.CardPanel cp : cardPanel.getAttachedPanels()) {
|
||||
if (cp.getCard().isUntapped() && !cp.getCard().hasSickness()) {
|
||||
break;
|
||||
}
|
||||
@@ -775,12 +776,12 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo
|
||||
|
||||
List<Card> tmp, diff;
|
||||
tmp = new ArrayList<Card>();
|
||||
for (arcane.ui.CardPanel cpa : p.cardPanels) {
|
||||
tmp.add(cpa.gameCard);
|
||||
for (arcane.ui.CardPanel cpa : p.getCardPanels()) {
|
||||
tmp.add(cpa.getGameCard());
|
||||
}
|
||||
diff = new ArrayList<Card>(tmp);
|
||||
diff.removeAll(Arrays.asList(c));
|
||||
if (diff.size() == p.cardPanels.size()) {
|
||||
if (diff.size() == p.getCardPanels().size()) {
|
||||
p.clear();
|
||||
} else {
|
||||
for (Card card : diff) {
|
||||
|
||||
@@ -1137,12 +1137,12 @@ public final class GuiDisplayUtil implements NewConstants {
|
||||
public static void setupPlayZone(final PlayArea p, final Card[] c) {
|
||||
List<Card> tmp, diff;
|
||||
tmp = new ArrayList<Card>();
|
||||
for (arcane.ui.CardPanel cpa : p.cardPanels) {
|
||||
tmp.add(cpa.gameCard);
|
||||
for (arcane.ui.CardPanel cpa : p.getCardPanels()) {
|
||||
tmp.add(cpa.getGameCard());
|
||||
}
|
||||
diff = new ArrayList<Card>(tmp);
|
||||
diff.removeAll(Arrays.asList(c));
|
||||
if (diff.size() == p.cardPanels.size()) {
|
||||
if (diff.size() == p.getCardPanels().size()) {
|
||||
p.clear();
|
||||
} else {
|
||||
for (Card card : diff) {
|
||||
@@ -1161,19 +1161,19 @@ public final class GuiDisplayUtil implements NewConstants {
|
||||
for (Card card : c) {
|
||||
toPanel = p.getCardPanel(card.getUniqueNumber());
|
||||
if (card.isTapped()) {
|
||||
toPanel.tapped = true;
|
||||
toPanel.tappedAngle = arcane.ui.CardPanel.TAPPED_ANGLE;
|
||||
toPanel.setTapped(true);
|
||||
toPanel.setTappedAngle(arcane.ui.CardPanel.TAPPED_ANGLE);
|
||||
} else {
|
||||
toPanel.tapped = false;
|
||||
toPanel.tappedAngle = 0;
|
||||
toPanel.setTapped(false);
|
||||
toPanel.setTappedAngle(0);
|
||||
}
|
||||
toPanel.attachedPanels.clear();
|
||||
toPanel.getAttachedPanels().clear();
|
||||
if (card.isEnchanted()) {
|
||||
ArrayList<Card> enchants = card.getEnchantedBy();
|
||||
for (Card e : enchants) {
|
||||
arcane.ui.CardPanel cardE = p.getCardPanel(e.getUniqueNumber());
|
||||
if (cardE != null) {
|
||||
toPanel.attachedPanels.add(cardE);
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1183,20 +1183,20 @@ public final class GuiDisplayUtil implements NewConstants {
|
||||
for (Card e : enchants) {
|
||||
arcane.ui.CardPanel cardE = p.getCardPanel(e.getUniqueNumber());
|
||||
if (cardE != null) {
|
||||
toPanel.attachedPanels.add(cardE);
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (card.isEnchantingCard()) {
|
||||
toPanel.attachedToPanel = p.getCardPanel(card.getEnchantingCard().getUniqueNumber());
|
||||
toPanel.setAttachedToPanel(p.getCardPanel(card.getEnchantingCard().getUniqueNumber()));
|
||||
} else if (card.isEquipping()) {
|
||||
toPanel.attachedToPanel = p.getCardPanel(card.getEquipping().get(0).getUniqueNumber());
|
||||
toPanel.setAttachedToPanel(p.getCardPanel(card.getEquipping().get(0).getUniqueNumber()));
|
||||
} else {
|
||||
toPanel.attachedToPanel = null;
|
||||
toPanel.setAttachedToPanel(null);
|
||||
}
|
||||
|
||||
toPanel.setCard(toPanel.gameCard);
|
||||
toPanel.setCard(toPanel.getGameCard());
|
||||
}
|
||||
p.invalidate();
|
||||
p.repaint();
|
||||
|
||||
Reference in New Issue
Block a user