mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
checkstyle
This commit is contained in:
@@ -1,30 +1,39 @@
|
|||||||
package arcane.ui;
|
package arcane.ui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLayeredPane;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import arcane.ui.util.Animation;
|
import arcane.ui.util.Animation;
|
||||||
import arcane.ui.util.CardPanelMouseListener;
|
import arcane.ui.util.CardPanelMouseListener;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>CardArea class.</p>
|
* <p>CardArea class.</p>
|
||||||
*
|
*
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class CardArea extends CardPanelContainer
|
public class CardArea extends CardPanelContainer implements CardPanelMouseListener
|
||||||
implements CardPanelMouseListener {
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -5836122075999621592L;
|
private static final long serialVersionUID = -5836122075999621592L;
|
||||||
/**
|
/**
|
||||||
* Constant <code>GUTTER_Y=5</code>
|
* Constant <code>GUTTER_Y=5</code>.
|
||||||
*/
|
*/
|
||||||
public static final int GUTTER_Y = 5;
|
public static final int GUTTER_Y = 5;
|
||||||
/**
|
/**
|
||||||
* Constant <code>GUTTER_X=5</code>
|
* Constant <code>GUTTER_X=5</code>.
|
||||||
*/
|
*/
|
||||||
public static final int GUTTER_X = 5;
|
public static final int GUTTER_X = 5;
|
||||||
/**
|
/**
|
||||||
@@ -60,13 +69,13 @@ public class CardArea extends CardPanelContainer
|
|||||||
*
|
*
|
||||||
* @param scrollPane a {@link javax.swing.JScrollPane} object.
|
* @param scrollPane a {@link javax.swing.JScrollPane} object.
|
||||||
*/
|
*/
|
||||||
public CardArea(JScrollPane scrollPane) {
|
public CardArea(final JScrollPane scrollPane) {
|
||||||
super(scrollPane);
|
super(scrollPane);
|
||||||
setBackground(Color.white);
|
setBackground(Color.white);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public CardPanel getCardPanel(int x, int y) {
|
public final CardPanel getCardPanel(final int x, final int y) {
|
||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
for (int i = cardPanels.size() - 1; i >= 0; i--) {
|
for (int i = cardPanels.size() - 1; i >= 0; i--) {
|
||||||
CardPanel panel = cardPanels.get(i);
|
CardPanel panel = cardPanels.get(i);
|
||||||
@@ -76,7 +85,9 @@ public class CardArea extends CardPanelContainer
|
|||||||
int panelHeight = panel.getCardHeight();
|
int panelHeight = panel.getCardHeight();
|
||||||
if (x > panelX && x < panelX + panelWidth) {
|
if (x > panelX && x < panelX + panelWidth) {
|
||||||
if (y > panelY && y < panelY + panelHeight) {
|
if (y > panelY && y < panelY + panelHeight) {
|
||||||
if (!panel.isDisplayEnabled()) return null;
|
if (!panel.isDisplayEnabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +101,9 @@ public class CardArea extends CardPanelContainer
|
|||||||
int panelHeight = panel.getCardHeight();
|
int panelHeight = panel.getCardHeight();
|
||||||
if (x > panelX && x < panelX + panelWidth) {
|
if (x > panelX && x < panelX + panelWidth) {
|
||||||
if (y > panelY && y < panelY + panelHeight) {
|
if (y > panelY && y < panelY + panelHeight) {
|
||||||
if (!panel.isDisplayEnabled()) return null;
|
if (!panel.isDisplayEnabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,8 +117,10 @@ public class CardArea extends CardPanelContainer
|
|||||||
*
|
*
|
||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public void doLayout() {
|
public final void doLayout() {
|
||||||
if (cardPanels.isEmpty()) return;
|
if (cardPanels.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle rect = scrollPane.getVisibleRect();
|
Rectangle rect = scrollPane.getVisibleRect();
|
||||||
Insets insets = scrollPane.getInsets();
|
Insets insets = scrollPane.getInsets();
|
||||||
@@ -126,11 +141,16 @@ public class CardArea extends CardPanelContainer
|
|||||||
cardHeight = Math.round(cardWidth * CardPanel.ASPECT_RATIO);
|
cardHeight = Math.round(cardWidth * CardPanel.ASPECT_RATIO);
|
||||||
cardSpacingX = Math.round(cardWidth * VERT_CARD_SPACING_X);
|
cardSpacingX = Math.round(cardWidth * VERT_CARD_SPACING_X);
|
||||||
cardSpacingY = cardHeight + Math.round(cardWidth * VERT_CARD_SPACING_Y);
|
cardSpacingY = cardHeight + Math.round(cardWidth * VERT_CARD_SPACING_Y);
|
||||||
int maxRows = (int) Math.floor((cardAreaWidth - GUTTER_X * 2 + cardSpacingX) / (cardWidth + cardSpacingX));
|
int maxRows =
|
||||||
if (this.maxRows > 0) maxRows = Math.min(this.maxRows, maxRows);
|
(int) Math.floor((cardAreaWidth - GUTTER_X * 2 + cardSpacingX) / (cardWidth + cardSpacingX));
|
||||||
|
if (this.maxRows > 0) {
|
||||||
|
maxRows = Math.min(this.maxRows, maxRows);
|
||||||
|
}
|
||||||
int availableRowHeight = cardAreaHeight - GUTTER_Y * 2;
|
int availableRowHeight = cardAreaHeight - GUTTER_Y * 2;
|
||||||
int availableCardsPerRow = (int) Math.floor((availableRowHeight - (cardHeight - cardSpacingY)) / (double) cardSpacingY);
|
int availableCardsPerRow =
|
||||||
actualCardsPerRow = Math.max(availableCardsPerRow, (int) Math.ceil(cardPanels.size() / (float) maxRows));
|
(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);
|
int actualRowHeight = (int) Math.floor((actualCardsPerRow - 1) * cardSpacingY + cardHeight);
|
||||||
float overflow = actualRowHeight - availableRowHeight;
|
float overflow = actualRowHeight - availableRowHeight;
|
||||||
if (overflow > 0) {
|
if (overflow > 0) {
|
||||||
@@ -139,16 +159,22 @@ public class CardArea extends CardPanelContainer
|
|||||||
cardSpacingY -= offsetY;
|
cardSpacingY -= offsetY;
|
||||||
}
|
}
|
||||||
actualRowHeight = (int) Math.floor((actualCardsPerRow - 1) * cardSpacingY + cardHeight);
|
actualRowHeight = (int) Math.floor((actualCardsPerRow - 1) * cardSpacingY + cardHeight);
|
||||||
if (actualRowHeight >= 0 && actualRowHeight <= availableRowHeight) break;
|
if (actualRowHeight >= 0 && actualRowHeight <= availableRowHeight) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
cardWidth--;
|
cardWidth--;
|
||||||
if (cardWidth == cardWidthMin) break;
|
if (cardWidth == cardWidthMin) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float x = GUTTER_X;
|
float x = GUTTER_X;
|
||||||
int y = GUTTER_Y;
|
int y = GUTTER_Y;
|
||||||
int zOrder = cardPanels.size() - 1, rowCount = 0;
|
int zOrder = cardPanels.size() - 1, rowCount = 0;
|
||||||
for (CardPanel panel : cardPanels) {
|
for (CardPanel panel : cardPanels) {
|
||||||
if (panel != mouseDragPanel) panel.setCardBounds((int) Math.floor(x), y, cardWidth, cardHeight);
|
if (panel != mouseDragPanel) {
|
||||||
|
panel.setCardBounds((int) Math.floor(x), y, cardWidth, cardHeight);
|
||||||
|
}
|
||||||
y += cardSpacingY;
|
y += cardSpacingY;
|
||||||
maxWidth = Math.round(x) + cardWidth + GUTTER_X;
|
maxWidth = Math.round(x) + cardWidth + GUTTER_X;
|
||||||
maxHeight = Math.max(maxHeight, (y + (cardHeight - cardSpacingY) + GUTTER_Y));
|
maxHeight = Math.max(maxHeight, (y + (cardHeight - cardSpacingY) + GUTTER_Y));
|
||||||
@@ -167,11 +193,17 @@ public class CardArea extends CardPanelContainer
|
|||||||
int extraCardSpacingX = Math.round(cardWidth * HORIZ_CARD_SPACING_X);
|
int extraCardSpacingX = Math.round(cardWidth * HORIZ_CARD_SPACING_X);
|
||||||
cardSpacingY = Math.round(cardHeight * HORIZ_CARD_SPACING_Y);
|
cardSpacingY = Math.round(cardHeight * HORIZ_CARD_SPACING_Y);
|
||||||
cardSpacingX = cardWidth + extraCardSpacingX;
|
cardSpacingX = cardWidth + extraCardSpacingX;
|
||||||
int maxRows = (int) Math.floor((cardAreaHeight - GUTTER_Y * 2 + cardSpacingY) / (double) (cardHeight + cardSpacingY));
|
int maxRows =
|
||||||
if (this.maxRows > 0) maxRows = Math.min(this.maxRows, maxRows);
|
(int) Math.floor((cardAreaHeight - GUTTER_Y * 2 + cardSpacingY) /
|
||||||
|
(double) (cardHeight + cardSpacingY));
|
||||||
|
if (this.maxRows > 0) {
|
||||||
|
maxRows = Math.min(this.maxRows, maxRows);
|
||||||
|
}
|
||||||
int availableRowWidth = cardAreaWidth - GUTTER_X * 2;
|
int availableRowWidth = cardAreaWidth - GUTTER_X * 2;
|
||||||
int availableCardsPerRow = (int) Math.floor((availableRowWidth - (cardWidth - cardSpacingX)) / cardSpacingX);
|
int availableCardsPerRow =
|
||||||
actualCardsPerRow = Math.max(availableCardsPerRow, (int) Math.ceil(cardPanels.size() / (float) maxRows));
|
(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);
|
int actualRowWidth = (int) Math.floor((actualCardsPerRow - 1) * cardSpacingX + cardWidth);
|
||||||
float overflow = actualRowWidth - availableRowWidth;
|
float overflow = actualRowWidth - availableRowWidth;
|
||||||
if (overflow > 0) {
|
if (overflow > 0) {
|
||||||
@@ -180,16 +212,22 @@ public class CardArea extends CardPanelContainer
|
|||||||
cardSpacingX -= offsetX;
|
cardSpacingX -= offsetX;
|
||||||
}
|
}
|
||||||
actualRowWidth = (int) Math.floor((actualCardsPerRow - 1) * cardSpacingX + cardWidth);
|
actualRowWidth = (int) Math.floor((actualCardsPerRow - 1) * cardSpacingX + cardWidth);
|
||||||
if (actualRowWidth <= availableRowWidth) break;
|
if (actualRowWidth <= availableRowWidth) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
cardWidth--;
|
cardWidth--;
|
||||||
if (cardWidth == cardWidthMin) break;
|
if (cardWidth == cardWidthMin) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float x = GUTTER_X;
|
float x = GUTTER_X;
|
||||||
int y = GUTTER_Y;
|
int y = GUTTER_Y;
|
||||||
int zOrder = 0, rowCount = 0;
|
int zOrder = 0, rowCount = 0;
|
||||||
for (CardPanel panel : cardPanels) {
|
for (CardPanel panel : cardPanels) {
|
||||||
if (panel != mouseDragPanel) panel.setCardBounds((int) Math.floor(x), y, cardWidth, cardHeight);
|
if (panel != mouseDragPanel) {
|
||||||
|
panel.setCardBounds((int) Math.floor(x), y, cardWidth, cardHeight);
|
||||||
|
}
|
||||||
x += cardSpacingX;
|
x += cardSpacingX;
|
||||||
maxWidth = Math.max(maxWidth, Math.round(x + (cardWidth - cardSpacingX) + GUTTER_X) - 1);
|
maxWidth = Math.max(maxWidth, Math.round(x + (cardWidth - cardSpacingX) + GUTTER_X) - 1);
|
||||||
maxHeight = Math.max(maxHeight, y + (cardHeight - cardSpacingY) + GUTTER_Y);
|
maxHeight = Math.max(maxHeight, y + (cardHeight - cardSpacingY) + GUTTER_Y);
|
||||||
@@ -213,16 +251,18 @@ public class CardArea extends CardPanelContainer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void paint(Graphics g) {
|
public final void paint(final Graphics g) {
|
||||||
boolean hasScrollbars = scrollPane.getVerticalScrollBar().isVisible();
|
boolean hasScrollbars = scrollPane.getVerticalScrollBar().isVisible();
|
||||||
if (hasScrollbars != this.hasScrollbars) revalidate();
|
if (hasScrollbars != this.hasScrollbars) {
|
||||||
|
revalidate();
|
||||||
|
}
|
||||||
this.hasScrollbars = hasScrollbars;
|
this.hasScrollbars = hasScrollbars;
|
||||||
|
|
||||||
super.paint(g);
|
super.paint(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void mouseDragStart(CardPanel dragPanel, MouseEvent evt) {
|
public final void mouseDragStart(final CardPanel dragPanel, final MouseEvent evt) {
|
||||||
super.mouseDragStart(dragPanel, evt);
|
super.mouseDragStart(dragPanel, evt);
|
||||||
|
|
||||||
mouseDragStartX = dragPanel.getCardX();
|
mouseDragStartX = dragPanel.getCardX();
|
||||||
@@ -240,7 +280,9 @@ public class CardArea extends CardPanelContainer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void mouseDragged(CardPanel dragPanel, int dragOffsetX, int dragOffsetY, MouseEvent evt) {
|
public final void mouseDragged(final CardPanel dragPanel,
|
||||||
|
final int dragOffsetX, final int dragOffsetY, final MouseEvent evt)
|
||||||
|
{
|
||||||
super.mouseDragged(dragPanel, dragOffsetX, dragOffsetY, evt);
|
super.mouseDragged(dragPanel, dragOffsetX, dragOffsetY, evt);
|
||||||
|
|
||||||
int mouseX = evt.getX();
|
int mouseX = evt.getX();
|
||||||
@@ -251,10 +293,15 @@ public class CardArea extends CardPanelContainer
|
|||||||
CardPanel.dragAnimationPanel.setLocation(p.x, p.y);
|
CardPanel.dragAnimationPanel.setLocation(p.x, p.y);
|
||||||
|
|
||||||
CardPanel panel = getCardPanel(mouseX, mouseY);
|
CardPanel panel = getCardPanel(mouseX, mouseY);
|
||||||
if (panel == null || panel == dragPanel) return;
|
if (panel == null || panel == dragPanel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int index = cardPanels.size();
|
int index = cardPanels.size();
|
||||||
while (--index >= 0)
|
while (--index >= 0) {
|
||||||
if (cardPanels.get(index) == panel) break;
|
if (cardPanels.get(index) == panel) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
cardPanels.remove(dragPanel);
|
cardPanels.remove(dragPanel);
|
||||||
cardPanels.add(index, dragPanel);
|
cardPanels.add(index, dragPanel);
|
||||||
mouseDragStartX = panel.getCardX();
|
mouseDragStartX = panel.getCardX();
|
||||||
@@ -263,7 +310,7 @@ public class CardArea extends CardPanelContainer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void mouseDragEnd(CardPanel dragPanel, MouseEvent evt) {
|
public final void mouseDragEnd(final CardPanel dragPanel, final MouseEvent evt) {
|
||||||
super.mouseDragEnd(dragPanel, evt);
|
super.mouseDragEnd(dragPanel, evt);
|
||||||
doLayout();
|
doLayout();
|
||||||
JLayeredPane layeredPane = SwingUtilities.getRootPane(CardPanel.dragAnimationPanel).getLayeredPane();
|
JLayeredPane layeredPane = SwingUtilities.getRootPane(CardPanel.dragAnimationPanel).getLayeredPane();
|
||||||
@@ -272,8 +319,8 @@ public class CardArea extends CardPanelContainer
|
|||||||
int startWidth = CardPanel.dragAnimationPanel.getCardWidth();
|
int startWidth = CardPanel.dragAnimationPanel.getCardWidth();
|
||||||
Point endPos = SwingUtilities.convertPoint(this, dragPanel.getCardLocation(), layeredPane);
|
Point endPos = SwingUtilities.convertPoint(this, dragPanel.getCardLocation(), layeredPane);
|
||||||
int endWidth = dragPanel.getCardWidth();
|
int endWidth = dragPanel.getCardWidth();
|
||||||
Animation.moveCard(startX, startY, startWidth, endPos.x, endPos.y, endWidth, CardPanel.dragAnimationPanel, dragPanel,
|
Animation.moveCard(startX, startY, startWidth, endPos.x, endPos.y, endWidth,
|
||||||
layeredPane, 200);
|
CardPanel.dragAnimationPanel, dragPanel, layeredPane, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -281,7 +328,7 @@ public class CardArea extends CardPanelContainer
|
|||||||
*
|
*
|
||||||
* @return a float.
|
* @return a float.
|
||||||
*/
|
*/
|
||||||
public float getMaxCoverage() {
|
public final float getMaxCoverage() {
|
||||||
return maxCoverage;
|
return maxCoverage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +337,7 @@ public class CardArea extends CardPanelContainer
|
|||||||
*
|
*
|
||||||
* @param maxCoverage a float.
|
* @param maxCoverage a float.
|
||||||
*/
|
*/
|
||||||
public void setMaxCoverage(float maxCoverage) {
|
public final void setMaxCoverage(float maxCoverage) {
|
||||||
this.maxCoverage = maxCoverage;
|
this.maxCoverage = maxCoverage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +346,7 @@ public class CardArea extends CardPanelContainer
|
|||||||
*
|
*
|
||||||
* @param maxRows a int.
|
* @param maxRows a int.
|
||||||
*/
|
*/
|
||||||
public void setMaxRows(int maxRows) {
|
public final void setMaxRows(int maxRows) {
|
||||||
this.maxRows = maxRows;
|
this.maxRows = maxRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +355,7 @@ public class CardArea extends CardPanelContainer
|
|||||||
*
|
*
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public int getMaxRows() {
|
public final int getMaxRows() {
|
||||||
return maxRows;
|
return maxRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +364,7 @@ public class CardArea extends CardPanelContainer
|
|||||||
*
|
*
|
||||||
* @param isVertical a boolean.
|
* @param isVertical a boolean.
|
||||||
*/
|
*/
|
||||||
public void setVertical(boolean isVertical) {
|
public final void setVertical(final boolean isVertical) {
|
||||||
this.isVertical = isVertical;
|
this.isVertical = isVertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,7 +373,7 @@ public class CardArea extends CardPanelContainer
|
|||||||
*
|
*
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean isVertical() {
|
public final boolean isVertical() {
|
||||||
return isVertical;
|
return isVertical;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,42 +21,60 @@ import java.util.List;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class CardPanel extends JPanel implements CardContainer {
|
public class CardPanel extends JPanel implements CardContainer {
|
||||||
/** Constant <code>serialVersionUID=2361907095724263295L</code> */
|
/** Constant <code>serialVersionUID=2361907095724263295L</code>. */
|
||||||
private static final long serialVersionUID = 2361907095724263295L;
|
private static final long serialVersionUID = 2361907095724263295L;
|
||||||
/**
|
/**
|
||||||
* Constant <code>TAPPED_ANGLE=Math.PI / 2</code>
|
* Constant <code>TAPPED_ANGLE=Math.PI / 2</code>.
|
||||||
*/
|
*/
|
||||||
public static final double TAPPED_ANGLE = Math.PI / 2;
|
public static final double TAPPED_ANGLE = Math.PI / 2;
|
||||||
/**
|
/**
|
||||||
* Constant <code>ASPECT_RATIO=3.5f / 2.5f</code>
|
* Constant <code>ASPECT_RATIO=3.5f / 2.5f</code>.
|
||||||
*/
|
*/
|
||||||
public static final float ASPECT_RATIO = 3.5f / 2.5f;
|
public static final float ASPECT_RATIO = 3.5f / 2.5f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant <code>dragAnimationPanel</code>
|
* Constant <code>dragAnimationPanel</code>.
|
||||||
*/
|
*/
|
||||||
public static CardPanel dragAnimationPanel;
|
public static CardPanel dragAnimationPanel;
|
||||||
|
|
||||||
/** Constant <code>ROUNDED_CORNER_SIZE=0.1f</code> */
|
/** Constant <code>ROUNDED_CORNER_SIZE=0.1f</code>. */
|
||||||
private static final float ROUNDED_CORNER_SIZE = 0.1f;
|
private static final float ROUNDED_CORNER_SIZE = 0.1f;
|
||||||
/** Constant <code>SELECTED_BORDER_SIZE=0.01f</code> */
|
/** Constant <code>SELECTED_BORDER_SIZE=0.01f</code>. */
|
||||||
private static final float SELECTED_BORDER_SIZE = 0.01f;
|
private static final float SELECTED_BORDER_SIZE = 0.01f;
|
||||||
/** Constant <code>BLACK_BORDER_SIZE=0.03f</code> */
|
/** Constant <code>BLACK_BORDER_SIZE=0.03f</code>. */
|
||||||
private static final float BLACK_BORDER_SIZE = 0.03f;
|
private static final float BLACK_BORDER_SIZE = 0.03f;
|
||||||
/** Constant <code>TEXT_GLOW_SIZE=6</code> */
|
/** Constant <code>TEXT_GLOW_SIZE=6</code>. */
|
||||||
private static final int TEXT_GLOW_SIZE = 6;
|
private static final int TEXT_GLOW_SIZE = 6;
|
||||||
/** Constant <code>TEXT_GLOW_INTENSITY=3f</code> */
|
/** Constant <code>TEXT_GLOW_INTENSITY=3f</code>. */
|
||||||
private static final float TEXT_GLOW_INTENSITY = 3f;
|
private static final float TEXT_GLOW_INTENSITY = 3f;
|
||||||
/** Constant <code>rotCenterToTopCorner=1.0295630140987000315797369464196f</code> */
|
/** Constant <code>rotCenterToTopCorner=1.0295630140987000315797369464196f</code>. */
|
||||||
private static final float rotCenterToTopCorner = 1.0295630140987000315797369464196f;
|
private static final float rotCenterToTopCorner = 1.0295630140987000315797369464196f;
|
||||||
/** Constant <code>rotCenterToBottomCorner=0.7071067811865475244008443621048f</code> */
|
/** Constant <code>rotCenterToBottomCorner=0.7071067811865475244008443621048f</code>. */
|
||||||
private static final float rotCenterToBottomCorner = 0.7071067811865475244008443621048f;
|
private static final float rotCenterToBottomCorner = 0.7071067811865475244008443621048f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public Card gameCard;
|
public Card gameCard;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public CardPanel attachedToPanel;
|
public CardPanel attachedToPanel;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public List<CardPanel> attachedPanels = new ArrayList<CardPanel>();
|
public List<CardPanel> attachedPanels = new ArrayList<CardPanel>();
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public boolean tapped;
|
public boolean tapped;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public double tappedAngle = 0;
|
public double tappedAngle = 0;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public ScaledImagePanel imagePanel;
|
public ScaledImagePanel imagePanel;
|
||||||
|
|
||||||
private GlowText titleText;
|
private GlowText titleText;
|
||||||
@@ -73,7 +91,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @param newGameCard a {@link forge.Card} object.
|
* @param newGameCard a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public CardPanel(Card newGameCard) {
|
public CardPanel(final Card newGameCard) {
|
||||||
this.gameCard = newGameCard;
|
this.gameCard = newGameCard;
|
||||||
|
|
||||||
setBackground(Color.black);
|
setBackground(Color.black);
|
||||||
@@ -101,12 +119,12 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
|
|
||||||
addComponentListener(new ComponentAdapter() {
|
addComponentListener(new ComponentAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void componentShown(ComponentEvent e) {
|
public void componentShown(final ComponentEvent e) {
|
||||||
setCard(gameCard);
|
setCard(gameCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentResized(ComponentEvent e) {
|
public void componentResized(final ComponentEvent e) {
|
||||||
setCard(gameCard);
|
setCard(gameCard);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -121,7 +139,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
* @param srcImageBlurred a {@link java.awt.Image} object.
|
* @param srcImageBlurred a {@link java.awt.Image} object.
|
||||||
* @param srcImageBlurred a {@link java.awt.Image} object.
|
* @param srcImageBlurred a {@link java.awt.Image} object.
|
||||||
*/
|
*/
|
||||||
private void setImage(Image srcImage, Image srcImageBlurred) {
|
private void setImage(final Image srcImage, final Image srcImageBlurred) {
|
||||||
synchronized (imagePanel) {
|
synchronized (imagePanel) {
|
||||||
imagePanel.setImage(srcImage, srcImageBlurred);
|
imagePanel.setImage(srcImage, srcImageBlurred);
|
||||||
repaint();
|
repaint();
|
||||||
@@ -139,12 +157,13 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @param panel a {@link arcane.ui.CardPanel} object.
|
* @param panel a {@link arcane.ui.CardPanel} object.
|
||||||
*/
|
*/
|
||||||
public void setImage(final CardPanel panel) {
|
public final void setImage(final CardPanel panel) {
|
||||||
synchronized (panel.imagePanel) {
|
synchronized (panel.imagePanel) {
|
||||||
if (panel.imagePanel.hasImage())
|
if (panel.imagePanel.hasImage()) {
|
||||||
setImage(panel.imagePanel.srcImage, panel.imagePanel.srcImageBlurred);
|
setImage(panel.imagePanel.srcImage, panel.imagePanel.srcImageBlurred);
|
||||||
else
|
} else {
|
||||||
panel.imageLoadListeners.add(this);
|
panel.imageLoadListeners.add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +172,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @param scalingType a {@link arcane.ui.ScaledImagePanel.ScalingType} object.
|
* @param scalingType a {@link arcane.ui.ScaledImagePanel.ScalingType} object.
|
||||||
*/
|
*/
|
||||||
public void setScalingType(ScalingType scalingType) {
|
public final void setScalingType(final ScalingType scalingType) {
|
||||||
imagePanel.setScalingType(scalingType);
|
imagePanel.setScalingType(scalingType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +181,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @param displayEnabled a boolean.
|
* @param displayEnabled a boolean.
|
||||||
*/
|
*/
|
||||||
public void setDisplayEnabled(boolean displayEnabled) {
|
public final void setDisplayEnabled(final boolean displayEnabled) {
|
||||||
this.displayEnabled = displayEnabled;
|
this.displayEnabled = displayEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +190,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean isDisplayEnabled() {
|
public final boolean isDisplayEnabled() {
|
||||||
return displayEnabled;
|
return displayEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +199,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @param isAnimationPanel a boolean.
|
* @param isAnimationPanel a boolean.
|
||||||
*/
|
*/
|
||||||
public void setAnimationPanel(boolean isAnimationPanel) {
|
public final void setAnimationPanel(final boolean isAnimationPanel) {
|
||||||
this.isAnimationPanel = isAnimationPanel;
|
this.isAnimationPanel = isAnimationPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +208,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @param isSelected a boolean.
|
* @param isSelected a boolean.
|
||||||
*/
|
*/
|
||||||
public void setSelected(boolean isSelected) {
|
public final void setSelected(final boolean isSelected) {
|
||||||
this.isSelected = isSelected;
|
this.isSelected = isSelected;
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
@@ -199,14 +218,18 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @param showCastingCost a boolean.
|
* @param showCastingCost a boolean.
|
||||||
*/
|
*/
|
||||||
public void setShowCastingCost(boolean showCastingCost) {
|
public final void setShowCastingCost(final boolean showCastingCost) {
|
||||||
this.showCastingCost = showCastingCost;
|
this.showCastingCost = showCastingCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void paint(Graphics g) {
|
public final void paint(final Graphics g) {
|
||||||
if (!displayEnabled) return;
|
if (!displayEnabled) {
|
||||||
if (!isValid()) super.validate();
|
return;
|
||||||
|
}
|
||||||
|
if (!isValid()) {
|
||||||
|
super.validate();
|
||||||
|
}
|
||||||
Graphics2D g2d = (Graphics2D) g;
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
if (tappedAngle > 0) {
|
if (tappedAngle > 0) {
|
||||||
g2d = (Graphics2D) g2d.create();
|
g2d = (Graphics2D) g2d.create();
|
||||||
@@ -217,7 +240,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
protected void paintComponent(Graphics g) {
|
protected final void paintComponent(final Graphics g) {
|
||||||
Graphics2D g2d = (Graphics2D) g;
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
@@ -226,24 +249,27 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
|
|
||||||
if (this.gameCard != null) {
|
if (this.gameCard != null) {
|
||||||
if ((!this.gameCard.getImageFilename().equals("none")) && (!this.gameCard.getName().equals("Morph"))) {
|
if ((!this.gameCard.getImageFilename().equals("none")) && (!this.gameCard.getName().equals("Morph"))) {
|
||||||
if ((this.gameCard.getCurSetCode().equals("2ED")) ||
|
if ((this.gameCard.getCurSetCode().equals("2ED"))
|
||||||
(this.gameCard.getCurSetCode().equals("3ED")) ||
|
|| (this.gameCard.getCurSetCode().equals("3ED"))
|
||||||
(this.gameCard.getCurSetCode().equals("4ED")) ||
|
|| (this.gameCard.getCurSetCode().equals("4ED"))
|
||||||
(this.gameCard.getCurSetCode().equals("5ED")) ||
|
|| (this.gameCard.getCurSetCode().equals("5ED"))
|
||||||
(this.gameCard.getCurSetCode().equals("6ED")) ||
|
|| (this.gameCard.getCurSetCode().equals("6ED"))
|
||||||
(this.gameCard.getCurSetCode().equals("7ED")) ||
|
|| (this.gameCard.getCurSetCode().equals("7ED"))
|
||||||
(this.gameCard.getCurSetCode().equals("8ED")) ||
|
|| (this.gameCard.getCurSetCode().equals("8ED"))
|
||||||
(this.gameCard.getCurSetCode().equals("9ED")) ||
|
|| (this.gameCard.getCurSetCode().equals("9ED"))
|
||||||
(this.gameCard.getCurSetCode().equals("CHR")) ||
|
|| (this.gameCard.getCurSetCode().equals("CHR"))
|
||||||
(this.gameCard.getCurSetCode().equals("S99")) ||
|
|| (this.gameCard.getCurSetCode().equals("S99"))
|
||||||
(this.gameCard.getCurSetCode().equals("PTK")) ||
|
|| (this.gameCard.getCurSetCode().equals("PTK"))
|
||||||
(this.gameCard.getCurSetCode().equals("S00"))) {
|
|| (this.gameCard.getCurSetCode().equals("S00")))
|
||||||
|
{
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
g2d.setColor(Color.black);
|
g2d.setColor(Color.black);
|
||||||
int offset = tapped ? 1 : 0;
|
int offset = tapped ? 1 : 0;
|
||||||
for (int i = 1, n = Math.max(1, Math.round(cardWidth * SELECTED_BORDER_SIZE)); i <= n; i++)
|
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,
|
g2d.drawRoundRect(cardXOffset - i, cardYOffset - i + offset,
|
||||||
|
cardWidth + i * 2 - 1, cardHeight + i * 2 - 1,
|
||||||
cornerSize, cornerSize);
|
cornerSize, cornerSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g2d.setColor(Color.white);
|
g2d.setColor(Color.white);
|
||||||
} else {
|
} else {
|
||||||
@@ -257,71 +283,88 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
g2d.setColor(Color.green);
|
g2d.setColor(Color.green);
|
||||||
int offset = tapped ? 1 : 0;
|
int offset = tapped ? 1 : 0;
|
||||||
for (int i = 1, n = Math.max(1, Math.round(cardWidth * SELECTED_BORDER_SIZE)); i <= n; i++)
|
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,
|
g2d.drawRoundRect(cardXOffset - i, cardYOffset - i + offset,
|
||||||
|
cardWidth + i * 2 - 1, cardHeight + i * 2 - 1,
|
||||||
cornerSize, cornerSize);
|
cornerSize, cornerSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
protected void paintChildren(Graphics g) {
|
protected final void paintChildren(final Graphics g) {
|
||||||
super.paintChildren(g);
|
super.paintChildren(g);
|
||||||
|
|
||||||
boolean canDrawOverCard = showCastingCost && !isAnimationPanel;
|
boolean canDrawOverCard = showCastingCost && !isAnimationPanel;
|
||||||
|
|
||||||
if (!canDrawOverCard)
|
if (!canDrawOverCard) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int width = ManaSymbols.getWidth(gameCard.getManaCost());
|
int width = ManaSymbols.getWidth(gameCard.getManaCost());
|
||||||
if(cardWidth < 200)
|
if (cardWidth < 200) {
|
||||||
ManaSymbols.draw(g, gameCard.getManaCost(), cardXOffset + cardWidth / 2 - width / 2, cardYOffset + cardHeight / 2);
|
ManaSymbols.draw(g, gameCard.getManaCost(),
|
||||||
|
cardXOffset + cardWidth / 2 - width / 2, cardYOffset + cardHeight / 2);
|
||||||
|
}
|
||||||
|
|
||||||
int counters = getCard().getNumberOfCounters();
|
int counters = getCard().getNumberOfCounters();
|
||||||
|
|
||||||
if(counters == 1) {
|
if (counters == 1) {
|
||||||
ManaSymbols.drawSymbol("counters1", g, cardXOffset - 15, cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
ManaSymbols.drawSymbol("counters1", g, cardXOffset - 15,
|
||||||
} else if(counters == 2) {
|
cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
||||||
ManaSymbols.drawSymbol("counters2", g, cardXOffset - 15, cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
} else if (counters == 2) {
|
||||||
} else if(counters == 3) {
|
ManaSymbols.drawSymbol("counters2", g, cardXOffset - 15,
|
||||||
ManaSymbols.drawSymbol("counters3", g, cardXOffset - 15, cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
||||||
} else if(counters > 3) {
|
} else if (counters == 3) {
|
||||||
ManaSymbols.drawSymbol("countersMulti", g, cardXOffset - 15, cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
ManaSymbols.drawSymbol("counters3", g, cardXOffset - 15,
|
||||||
|
cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
||||||
|
} else if (counters > 3) {
|
||||||
|
ManaSymbols.drawSymbol("countersMulti", g, cardXOffset - 15,
|
||||||
|
cardYOffset + cardHeight - (cardHeight / 3) - 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
//int yOff = (cardHeight/4) + 2;
|
//int yOff = (cardHeight/4) + 2;
|
||||||
if (getCard().isAttacking()) {
|
if (getCard().isAttacking()) {
|
||||||
ManaSymbols.drawSymbol("attack", g, cardXOffset + cardWidth / 4 - 16, cardYOffset + cardHeight - (cardHeight / 8) - 16);
|
ManaSymbols.drawSymbol("attack", g, cardXOffset + cardWidth / 4 - 16,
|
||||||
|
cardYOffset + cardHeight - (cardHeight / 8) - 16);
|
||||||
} else if (getCard().isBlocking()) {
|
} else if (getCard().isBlocking()) {
|
||||||
ManaSymbols.drawSymbol("defend", g, cardXOffset + cardWidth / 4 - 16, cardYOffset + cardHeight - (cardHeight / 8) - 16);
|
ManaSymbols.drawSymbol("defend", g, cardXOffset + cardWidth / 4 - 16,
|
||||||
|
cardYOffset + cardHeight - (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 (getCard().isPhasedOut()) {
|
||||||
|
ManaSymbols.drawSymbol("phasing", g, cardXOffset + cardWidth / 2 - 16,
|
||||||
|
cardYOffset + cardHeight - (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 (getCard().isPhasedOut())
|
|
||||||
ManaSymbols.drawSymbol("phasing", g, cardXOffset + cardWidth / 2 - 16, cardYOffset + cardHeight - (cardHeight / 8) - 16);
|
|
||||||
|
|
||||||
if (getCard() != null) {
|
if (getCard() != null) {
|
||||||
if (this.gameCard.getFoil() > 0) {
|
if (this.gameCard.getFoil() > 0) {
|
||||||
String fl = String.format("foil%02d", getCard().getFoil());
|
String fl = String.format("foil%02d", getCard().getFoil());
|
||||||
int z = Math.round(cardWidth * BLACK_BORDER_SIZE);
|
int z = Math.round(cardWidth * BLACK_BORDER_SIZE);
|
||||||
ManaSymbols.draw(g, fl, cardXOffset + z, cardYOffset + z, cardWidth - (2*z), cardHeight - (2*z));
|
ManaSymbols.draw(g, fl, cardXOffset + z, cardYOffset + z, cardWidth - (2 * z), cardHeight - (2 * z));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCard().getName().equals("Mana Pool") && !isAnimationPanel) {
|
if (getCard().getName().equals("Mana Pool") && !isAnimationPanel) {
|
||||||
|
|
||||||
if (AllZone.getHumanPlayer().getManaPool() != null) {
|
if (AllZone.getHumanPlayer().getManaPool() != null) {
|
||||||
String s = AllZone.getHumanPlayer().getManaPool().getManaList();
|
String s = AllZone.getHumanPlayer().getManaPool().getManaList();
|
||||||
if (!s.equals("|||||||||||")) {
|
if (!s.equals("|||||||||||")) {
|
||||||
|
|
||||||
String mList[] = s.split("\\|", 12);
|
String[] mList = s.split("\\|", 12);
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
for (int j = 0; j < 6; j++) {
|
for (int j = 0; j < 6; j++) {
|
||||||
if (!mList[n].equals("")) {
|
if (!mList[n].equals("")) {
|
||||||
width = ManaSymbols.getWidth(mList[n]);
|
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],
|
||||||
|
cardXOffset + ((i + 1) * (cardWidth / 3)) - width / 2,
|
||||||
|
cardYOffset + ((j + 1) * (cardHeight / 7)));
|
||||||
}
|
}
|
||||||
|
|
||||||
n++;
|
n++;
|
||||||
@@ -338,7 +381,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public void doLayout() {
|
public final void doLayout() {
|
||||||
int borderSize = Math.round(cardWidth * BLACK_BORDER_SIZE);
|
int borderSize = Math.round(cardWidth * BLACK_BORDER_SIZE);
|
||||||
imagePanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
|
imagePanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
|
||||||
imagePanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
|
imagePanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
|
||||||
@@ -358,10 +401,11 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
int ptY = Math.round(cardHeight * (675f / 680)) - ptSize.height;
|
int ptY = Math.round(cardHeight * (675f / 680)) - ptSize.height;
|
||||||
ptText.setLocation(cardXOffset + ptX - TEXT_GLOW_SIZE / 2, cardYOffset + ptY - TEXT_GLOW_SIZE / 2);
|
ptText.setLocation(cardXOffset + ptX - TEXT_GLOW_SIZE / 2, cardYOffset + ptY - TEXT_GLOW_SIZE / 2);
|
||||||
|
|
||||||
if (isAnimationPanel || cardWidth < 200)
|
if (isAnimationPanel || cardWidth < 200) {
|
||||||
imagePanel.setScalingType(ScalingType.nearestNeighbor);
|
imagePanel.setScalingType(ScalingType.nearestNeighbor);
|
||||||
else
|
} else {
|
||||||
imagePanel.setScalingType(ScalingType.bilinear);
|
imagePanel.setScalingType(ScalingType.bilinear);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -369,7 +413,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public final String toString() {
|
||||||
return gameCard.getName();
|
return gameCard.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +425,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
* @param width a int.
|
* @param width a int.
|
||||||
* @param height a int.
|
* @param height a int.
|
||||||
*/
|
*/
|
||||||
public void setCardBounds(int x, int y, int width, int height) {
|
public final void setCardBounds(final int x, final int y, int width, int height) {
|
||||||
cardWidth = width;
|
cardWidth = width;
|
||||||
cardHeight = height;
|
cardHeight = height;
|
||||||
int rotCenterX = Math.round(width / 2f);
|
int rotCenterX = Math.round(width / 2f);
|
||||||
@@ -400,10 +444,12 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
/**
|
/**
|
||||||
* <p>repaint.</p>
|
* <p>repaint.</p>
|
||||||
*/
|
*/
|
||||||
public void repaint() {
|
public final void repaint() {
|
||||||
Rectangle b = getBounds();
|
Rectangle b = getBounds();
|
||||||
JRootPane rootPane = SwingUtilities.getRootPane(this);
|
JRootPane rootPane = SwingUtilities.getRootPane(this);
|
||||||
if (rootPane == null) return;
|
if (rootPane == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Point p = SwingUtilities.convertPoint(getParent(), b.x, b.y, rootPane);
|
Point p = SwingUtilities.convertPoint(getParent(), b.x, b.y, rootPane);
|
||||||
rootPane.repaint(p.x, p.y, b.width, b.height);
|
rootPane.repaint(p.x, p.y, b.width, b.height);
|
||||||
}
|
}
|
||||||
@@ -413,7 +459,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public int getCardX() {
|
public final int getCardX() {
|
||||||
return getX() + cardXOffset;
|
return getX() + cardXOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,7 +468,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public int getCardY() {
|
public final int getCardY() {
|
||||||
return getY() + cardYOffset;
|
return getY() + cardYOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +477,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public int getCardWidth() {
|
public final int getCardWidth() {
|
||||||
return cardWidth;
|
return cardWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,7 +486,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public int getCardHeight() {
|
public final int getCardHeight() {
|
||||||
return cardHeight;
|
return cardHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +495,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a {@link java.awt.Point} object.
|
* @return a {@link java.awt.Point} object.
|
||||||
*/
|
*/
|
||||||
public Point getCardLocation() {
|
public final Point getCardLocation() {
|
||||||
Point p = getLocation();
|
Point p = getLocation();
|
||||||
p.x += cardXOffset;
|
p.x += cardXOffset;
|
||||||
p.y += cardYOffset;
|
p.y += cardYOffset;
|
||||||
@@ -461,10 +507,11 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @param card a {@link forge.Card} object.
|
* @param card a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public void setText(Card card) {
|
public final void setText(final Card card) {
|
||||||
if (card == null || !Singletons.getModel().getPreferences().cardOverlay)
|
if (card == null || !Singletons.getModel().getPreferences().cardOverlay) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (card.isFaceDown()) {
|
if (card.isFaceDown()) {
|
||||||
titleText.setText("");
|
titleText.setText("");
|
||||||
showCastingCost = false;
|
showCastingCost = false;
|
||||||
@@ -474,7 +521,9 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (card.isCreature() && card.isPlaneswalker()) {
|
if (card.isCreature() && card.isPlaneswalker()) {
|
||||||
ptText.setText(card.getNetAttack() + "/" + card.getNetDefense() + " (" + String.valueOf(card.getCounters(Counters.LOYALTY)) + ")");
|
ptText.setText(card.getNetAttack() + "/"
|
||||||
|
+ card.getNetDefense()
|
||||||
|
+ " (" + String.valueOf(card.getCounters(Counters.LOYALTY)) + ")");
|
||||||
} else if (card.isCreature()) {
|
} else if (card.isCreature()) {
|
||||||
ptText.setText(card.getNetAttack() + "/" + card.getNetDefense());
|
ptText.setText(card.getNetAttack() + "/" + card.getNetDefense());
|
||||||
} else if (card.isPlaneswalker()) {
|
} else if (card.isPlaneswalker()) {
|
||||||
@@ -489,15 +538,19 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public Card getCard() {
|
public final Card getCard() {
|
||||||
return gameCard;
|
return gameCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void setCard(Card card) {
|
public final void setCard(final Card card) {
|
||||||
if (gameCard != null && gameCard.equals(card) && isAnimationPanel && imagePanel.hasImage()) return;
|
if (gameCard != null && gameCard.equals(card) && isAnimationPanel && imagePanel.hasImage()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.gameCard = card;
|
this.gameCard = card;
|
||||||
if (!isShowing()) return;
|
if (!isShowing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Insets i = getInsets();
|
Insets i = getInsets();
|
||||||
Image image = card == null ? null : ImageCache.getImage(card, getWidth() - i.left - i.right, getHeight()
|
Image image = card == null ? null : ImageCache.getImage(card, getWidth() - i.left - i.right, getHeight()
|
||||||
- i.top - i.bottom);
|
- i.top - i.bottom);
|
||||||
|
|||||||
@@ -1,34 +1,51 @@
|
|||||||
package arcane.ui;
|
package arcane.ui;
|
||||||
|
|
||||||
import arcane.ui.util.CardPanelMouseListener;
|
import java.awt.Dimension;
|
||||||
import arcane.ui.util.UI;
|
import java.awt.Rectangle;
|
||||||
import forge.Card;
|
|
||||||
import forge.Constant;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import arcane.ui.util.CardPanelMouseListener;
|
||||||
|
import arcane.ui.util.UI;
|
||||||
|
import forge.Card;
|
||||||
|
import forge.Constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages mouse events and common funcitonality for CardPanel containing components.
|
* Manages mouse events and common functionality for CardPanel containing
|
||||||
*
|
* components.
|
||||||
|
*
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
abstract public class CardPanelContainer extends JPanel {
|
public abstract class CardPanelContainer extends JPanel {
|
||||||
/** Constant <code>serialVersionUID=-6400018234895548306L</code> */
|
/** Constant <code>serialVersionUID=-6400018234895548306L</code>. */
|
||||||
private static final long serialVersionUID = -6400018234895548306L;
|
private static final long serialVersionUID = -6400018234895548306L;
|
||||||
|
|
||||||
/** Constant <code>DRAG_SMUDGE=10</code> */
|
/** Constant <code>DRAG_SMUDGE=10</code>. */
|
||||||
private final static int DRAG_SMUDGE = 10;
|
private static final int DRAG_SMUDGE = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
public List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected JScrollPane scrollPane;
|
protected JScrollPane scrollPane;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected int cardWidthMin = 50, cardWidthMax = Constant.Runtime.width[0];
|
protected int cardWidthMin = 50, cardWidthMax = Constant.Runtime.width[0];
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected CardPanel mouseOverPanel, mouseDownPanel, mouseDragPanel;
|
protected CardPanel mouseOverPanel, mouseDownPanel, mouseDragPanel;
|
||||||
|
|
||||||
private List<CardPanelMouseListener> listeners = new ArrayList<CardPanelMouseListener>(2);
|
private List<CardPanelMouseListener> listeners = new ArrayList<CardPanelMouseListener>(2);
|
||||||
@@ -38,17 +55,20 @@ abstract public class CardPanelContainer extends JPanel {
|
|||||||
private int zoneID;
|
private int zoneID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructor for CardPanelContainer.</p>
|
* <p>
|
||||||
*
|
* Constructor for CardPanelContainer.
|
||||||
* @param scrollPane a {@link javax.swing.JScrollPane} object.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param scrollPane
|
||||||
|
* a {@link javax.swing.JScrollPane} object.
|
||||||
*/
|
*/
|
||||||
public CardPanelContainer(JScrollPane scrollPane) {
|
public CardPanelContainer(final JScrollPane scrollPane) {
|
||||||
this.scrollPane = scrollPane;
|
this.scrollPane = scrollPane;
|
||||||
|
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
|
|
||||||
addMouseMotionListener(new MouseMotionListener() {
|
addMouseMotionListener(new MouseMotionListener() {
|
||||||
public void mouseDragged(MouseEvent evt) {
|
public void mouseDragged(final MouseEvent evt) {
|
||||||
if (!dragEnabled) {
|
if (!dragEnabled) {
|
||||||
mouseOutPanel(evt);
|
mouseOutPanel(evt);
|
||||||
return;
|
return;
|
||||||
@@ -60,15 +80,20 @@ abstract public class CardPanelContainer extends JPanel {
|
|||||||
int x = evt.getX();
|
int x = evt.getX();
|
||||||
int y = evt.getY();
|
int y = evt.getY();
|
||||||
CardPanel panel = getCardPanel(x, y);
|
CardPanel panel = getCardPanel(x, y);
|
||||||
if (panel == null) return;
|
if (panel == null) {
|
||||||
if (panel != mouseDownPanel) return;
|
return;
|
||||||
|
}
|
||||||
|
if (panel != mouseDownPanel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (intialMouseDragX == -1) {
|
if (intialMouseDragX == -1) {
|
||||||
intialMouseDragX = x;
|
intialMouseDragX = x;
|
||||||
intialMouseDragY = y;
|
intialMouseDragY = y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Math.abs(x - intialMouseDragX) < DRAG_SMUDGE && Math.abs(y - intialMouseDragY) < DRAG_SMUDGE)
|
if (Math.abs(x - intialMouseDragX) < DRAG_SMUDGE && Math.abs(y - intialMouseDragY) < DRAG_SMUDGE) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
mouseDownPanel = null;
|
mouseDownPanel = null;
|
||||||
mouseDragPanel = panel;
|
mouseDragPanel = panel;
|
||||||
mouseDragOffsetX = panel.getX() - intialMouseDragX;
|
mouseDragOffsetX = panel.getX() - intialMouseDragX;
|
||||||
@@ -76,10 +101,14 @@ abstract public class CardPanelContainer extends JPanel {
|
|||||||
CardPanelContainer.this.mouseDragStart(mouseDragPanel, evt);
|
CardPanelContainer.this.mouseDragStart(mouseDragPanel, evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseMoved(MouseEvent evt) {
|
public void mouseMoved(final MouseEvent evt) {
|
||||||
CardPanel panel = getCardPanel(evt.getX(), evt.getY());
|
CardPanel panel = getCardPanel(evt.getX(), evt.getY());
|
||||||
if (mouseOverPanel != null && mouseOverPanel != panel) CardPanelContainer.this.mouseOutPanel(evt);
|
if (mouseOverPanel != null && mouseOverPanel != panel) {
|
||||||
if (panel == null) return;
|
CardPanelContainer.this.mouseOutPanel(evt);
|
||||||
|
}
|
||||||
|
if (panel == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mouseOverPanel = panel;
|
mouseOverPanel = panel;
|
||||||
mouseOverPanel.setSelected(true);
|
mouseOverPanel.setSelected(true);
|
||||||
CardPanelContainer.this.mouseOver(panel, evt);
|
CardPanelContainer.this.mouseOver(panel, evt);
|
||||||
@@ -89,16 +118,20 @@ abstract public class CardPanelContainer extends JPanel {
|
|||||||
addMouseListener(new MouseAdapter() {
|
addMouseListener(new MouseAdapter() {
|
||||||
private boolean[] buttonsDown = new boolean[4];
|
private boolean[] buttonsDown = new boolean[4];
|
||||||
|
|
||||||
public void mousePressed(MouseEvent evt) {
|
public void mousePressed(final MouseEvent evt) {
|
||||||
int button = evt.getButton();
|
int button = evt.getButton();
|
||||||
if (button < 1 || button > 3) return;
|
if (button < 1 || button > 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
buttonsDown[button] = true;
|
buttonsDown[button] = true;
|
||||||
mouseDownPanel = getCardPanel(evt.getX(), evt.getY());
|
mouseDownPanel = getCardPanel(evt.getX(), evt.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseReleased(MouseEvent evt) {
|
public void mouseReleased(final MouseEvent evt) {
|
||||||
int button = evt.getButton();
|
int button = evt.getButton();
|
||||||
if (button < 1 || button > 3) return;
|
if (button < 1 || button > 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (dragEnabled) {
|
if (dragEnabled) {
|
||||||
intialMouseDragX = -1;
|
intialMouseDragX = -1;
|
||||||
@@ -109,7 +142,9 @@ abstract public class CardPanelContainer extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buttonsDown[button]) return;
|
if (!buttonsDown[button]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
buttonsDown[button] = false;
|
buttonsDown[button] = false;
|
||||||
|
|
||||||
CardPanel panel = getCardPanel(evt.getX(), evt.getY());
|
CardPanel panel = getCardPanel(evt.getX(), evt.getY());
|
||||||
@@ -133,76 +168,95 @@ abstract public class CardPanelContainer extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseExited(MouseEvent evt) {
|
public void mouseExited(final MouseEvent evt) {
|
||||||
mouseOutPanel(evt);
|
mouseOutPanel(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(final MouseEvent e) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>mouseOutPanel.</p>
|
* <p>
|
||||||
*
|
* mouseOutPanel.
|
||||||
* @param evt a {@link java.awt.event.MouseEvent} object.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param evt
|
||||||
|
* a {@link java.awt.event.MouseEvent} object.
|
||||||
*/
|
*/
|
||||||
private void mouseOutPanel(MouseEvent evt) {
|
private void mouseOutPanel(final MouseEvent evt) {
|
||||||
if (mouseOverPanel == null) return;
|
if (mouseOverPanel == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mouseOverPanel.setSelected(false);
|
mouseOverPanel.setSelected(false);
|
||||||
mouseOut(mouseOverPanel, evt);
|
mouseOut(mouseOverPanel, evt);
|
||||||
mouseOverPanel = null;
|
mouseOverPanel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public void resetDrag(){
|
/*
|
||||||
mouseDragPanel = null;
|
* public void resetDrag(){ mouseDragPanel = null; invalidate(); };
|
||||||
invalidate();
|
*/
|
||||||
};*/
|
|
||||||
/**
|
/**
|
||||||
* <p>getCardPanel.</p>
|
* <p>
|
||||||
*
|
* getCardPanel.
|
||||||
* @param x a int.
|
* </p>
|
||||||
* @param y a int.
|
*
|
||||||
|
* @param x
|
||||||
|
* a int.
|
||||||
|
* @param y
|
||||||
|
* a int.
|
||||||
* @return a {@link arcane.ui.CardPanel} object.
|
* @return a {@link arcane.ui.CardPanel} object.
|
||||||
*/
|
*/
|
||||||
abstract protected CardPanel getCardPanel(int x, int y);
|
protected abstract CardPanel getCardPanel(int x, int y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must call from the Swing event thread.
|
* Must call from the Swing event thread.
|
||||||
*
|
*
|
||||||
* @param card a {@link forge.Card} object.
|
* @param card
|
||||||
|
* a {@link forge.Card} object.
|
||||||
* @return a {@link arcane.ui.CardPanel} object.
|
* @return a {@link arcane.ui.CardPanel} object.
|
||||||
*/
|
*/
|
||||||
public CardPanel addCard(Card card) {
|
public final CardPanel addCard(final Card card) {
|
||||||
final CardPanel placeholder = new CardPanel(card);
|
final CardPanel placeholder = new CardPanel(card);
|
||||||
placeholder.setDisplayEnabled(false);
|
placeholder.setDisplayEnabled(false);
|
||||||
cardPanels.add(placeholder);
|
cardPanels.add(placeholder);
|
||||||
add(placeholder);
|
add(placeholder);
|
||||||
doLayout();
|
doLayout();
|
||||||
// int y = Math.min(placeholder.getHeight(), scrollPane.getVisibleRect().height);
|
// int y = Math.min(placeholder.getHeight(),
|
||||||
scrollRectToVisible(new Rectangle(placeholder.getCardX(), placeholder.getCardY(), placeholder.getCardWidth(), placeholder
|
// scrollPane.getVisibleRect().height);
|
||||||
.getCardHeight()));
|
scrollRectToVisible(new Rectangle(placeholder.getCardX(), placeholder.getCardY(), placeholder.getCardWidth(),
|
||||||
|
placeholder.getCardHeight()));
|
||||||
return placeholder;
|
return placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>getCardPanel.</p>
|
* <p>
|
||||||
*
|
* getCardPanel.
|
||||||
* @param gameCardID a int.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param gameCardID
|
||||||
|
* a int.
|
||||||
* @return a {@link arcane.ui.CardPanel} object.
|
* @return a {@link arcane.ui.CardPanel} object.
|
||||||
*/
|
*/
|
||||||
public CardPanel getCardPanel(int gameCardID) {
|
public final CardPanel getCardPanel(final int gameCardID) {
|
||||||
for (CardPanel panel : cardPanels)
|
for (CardPanel panel : cardPanels) {
|
||||||
if (panel.gameCard.getUniqueNumber() == gameCardID) return panel;
|
if (panel.gameCard.getUniqueNumber() == gameCardID) {
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>removeCardPanel.</p>
|
* <p>
|
||||||
*
|
* removeCardPanel.
|
||||||
* @param fromPanel a {@link arcane.ui.CardPanel} object.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param fromPanel
|
||||||
|
* a {@link arcane.ui.CardPanel} object.
|
||||||
*/
|
*/
|
||||||
public void removeCardPanel(final CardPanel fromPanel) {
|
public final void removeCardPanel(final CardPanel fromPanel) {
|
||||||
UI.invokeAndWait(new Runnable() {
|
UI.invokeAndWait(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mouseDragPanel != null) {
|
if (mouseDragPanel != null) {
|
||||||
@@ -222,9 +276,11 @@ abstract public class CardPanelContainer extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>clear.</p>
|
* <p>
|
||||||
|
* clear.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public void clear() {
|
public final void clear() {
|
||||||
UI.invokeAndWait(new Runnable() {
|
UI.invokeAndWait(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
cardPanels.clear();
|
cardPanels.clear();
|
||||||
@@ -238,194 +294,265 @@ abstract public class CardPanelContainer extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Getter for the field <code>scrollPane</code>.</p>
|
* <p>
|
||||||
*
|
* Getter for the field <code>scrollPane</code>.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @return a {@link javax.swing.JScrollPane} object.
|
* @return a {@link javax.swing.JScrollPane} object.
|
||||||
*/
|
*/
|
||||||
public JScrollPane getScrollPane() {
|
public final JScrollPane getScrollPane() {
|
||||||
return scrollPane;
|
return scrollPane;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Getter for the field <code>cardWidthMin</code>.</p>
|
* <p>
|
||||||
*
|
* Getter for the field <code>cardWidthMin</code>.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public int getCardWidthMin() {
|
public final int getCardWidthMin() {
|
||||||
return cardWidthMin;
|
return cardWidthMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Setter for the field <code>cardWidthMin</code>.</p>
|
* <p>
|
||||||
*
|
* Setter for the field <code>cardWidthMin</code>.
|
||||||
* @param cardWidthMin a int.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cardWidthMin
|
||||||
|
* a int.
|
||||||
*/
|
*/
|
||||||
public void setCardWidthMin(int cardWidthMin) {
|
public final void setCardWidthMin(int cardWidthMin) {
|
||||||
this.cardWidthMin = cardWidthMin;
|
this.cardWidthMin = cardWidthMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Getter for the field <code>cardWidthMax</code>.</p>
|
* <p>
|
||||||
*
|
* Getter for the field <code>cardWidthMax</code>.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public int getCardWidthMax() {
|
public final int getCardWidthMax() {
|
||||||
return cardWidthMax;
|
return cardWidthMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Setter for the field <code>cardWidthMax</code>.</p>
|
* <p>
|
||||||
*
|
* Setter for the field <code>cardWidthMax</code>.
|
||||||
* @param cardWidthMax a int.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cardWidthMax
|
||||||
|
* a int.
|
||||||
*/
|
*/
|
||||||
public void setCardWidthMax(int cardWidthMax) {
|
public final void setCardWidthMax(int cardWidthMax) {
|
||||||
this.cardWidthMax = cardWidthMax;
|
this.cardWidthMax = cardWidthMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>isDragEnabled.</p>
|
* <p>
|
||||||
*
|
* isDragEnabled.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean isDragEnabled() {
|
public final boolean isDragEnabled() {
|
||||||
return dragEnabled;
|
return dragEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Setter for the field <code>dragEnabled</code>.</p>
|
* <p>
|
||||||
*
|
* Setter for the field <code>dragEnabled</code>.
|
||||||
* @param dragEnabled a boolean.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param dragEnabled
|
||||||
|
* a boolean.
|
||||||
*/
|
*/
|
||||||
public void setDragEnabled(boolean dragEnabled) {
|
public final void setDragEnabled(boolean dragEnabled) {
|
||||||
this.dragEnabled = dragEnabled;
|
this.dragEnabled = dragEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>addCardPanelMouseListener.</p>
|
* <p>
|
||||||
*
|
* addCardPanelMouseListener.
|
||||||
* @param listener a {@link arcane.ui.util.CardPanelMouseListener} object.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
* a {@link arcane.ui.util.CardPanelMouseListener} object.
|
||||||
*/
|
*/
|
||||||
public void addCardPanelMouseListener(CardPanelMouseListener listener) {
|
public final void addCardPanelMouseListener(final CardPanelMouseListener listener) {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>mouseLeftClicked.</p>
|
* <p>
|
||||||
*
|
* mouseLeftClicked.
|
||||||
* @param panel a {@link arcane.ui.CardPanel} object.
|
* </p>
|
||||||
* @param evt a {@link java.awt.event.MouseEvent} object.
|
*
|
||||||
|
* @param panel
|
||||||
|
* a {@link arcane.ui.CardPanel} object.
|
||||||
|
* @param evt
|
||||||
|
* a {@link java.awt.event.MouseEvent} object.
|
||||||
*/
|
*/
|
||||||
public void mouseLeftClicked(CardPanel panel, MouseEvent evt) {
|
public void mouseLeftClicked(final CardPanel panel, final MouseEvent evt) {
|
||||||
for (CardPanelMouseListener listener : listeners)
|
for (CardPanelMouseListener listener : listeners) {
|
||||||
listener.mouseLeftClicked(panel, evt);
|
listener.mouseLeftClicked(panel, evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>mouseRightClicked.</p>
|
* <p>
|
||||||
*
|
* mouseRightClicked.
|
||||||
* @param panel a {@link arcane.ui.CardPanel} object.
|
* </p>
|
||||||
* @param evt a {@link java.awt.event.MouseEvent} object.
|
*
|
||||||
|
* @param panel
|
||||||
|
* a {@link arcane.ui.CardPanel} object.
|
||||||
|
* @param evt
|
||||||
|
* a {@link java.awt.event.MouseEvent} object.
|
||||||
*/
|
*/
|
||||||
public void mouseRightClicked(CardPanel panel, MouseEvent evt) {
|
public final void mouseRightClicked(final CardPanel panel, final MouseEvent evt) {
|
||||||
for (CardPanelMouseListener listener : listeners)
|
for (CardPanelMouseListener listener : listeners) {
|
||||||
listener.mouseRightClicked(panel, evt);
|
listener.mouseRightClicked(panel, evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>mouseMiddleClicked.</p>
|
* <p>
|
||||||
*
|
* mouseMiddleClicked.
|
||||||
* @param panel a {@link arcane.ui.CardPanel} object.
|
* </p>
|
||||||
* @param evt a {@link java.awt.event.MouseEvent} object.
|
*
|
||||||
|
* @param panel
|
||||||
|
* a {@link arcane.ui.CardPanel} object.
|
||||||
|
* @param evt
|
||||||
|
* a {@link java.awt.event.MouseEvent} object.
|
||||||
*/
|
*/
|
||||||
public void mouseMiddleClicked(CardPanel panel, MouseEvent evt) {
|
public final void mouseMiddleClicked(final CardPanel panel, final MouseEvent evt) {
|
||||||
for (CardPanelMouseListener listener : listeners)
|
for (CardPanelMouseListener listener : listeners) {
|
||||||
listener.mouseMiddleClicked(panel, evt);
|
listener.mouseMiddleClicked(panel, evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>mouseDragEnd.</p>
|
* <p>
|
||||||
*
|
* mouseDragEnd.
|
||||||
* @param dragPanel a {@link arcane.ui.CardPanel} object.
|
* </p>
|
||||||
* @param evt a {@link java.awt.event.MouseEvent} object.
|
*
|
||||||
|
* @param dragPanel
|
||||||
|
* a {@link arcane.ui.CardPanel} object.
|
||||||
|
* @param evt
|
||||||
|
* a {@link java.awt.event.MouseEvent} object.
|
||||||
*/
|
*/
|
||||||
public void mouseDragEnd(CardPanel dragPanel, MouseEvent evt) {
|
public void mouseDragEnd(final CardPanel dragPanel, final MouseEvent evt) {
|
||||||
for (CardPanelMouseListener listener : listeners)
|
for (CardPanelMouseListener listener : listeners) {
|
||||||
listener.mouseDragEnd(dragPanel, evt);
|
listener.mouseDragEnd(dragPanel, evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>mouseDragged.</p>
|
* <p>
|
||||||
*
|
* mouseDragged.
|
||||||
* @param dragPanel a {@link arcane.ui.CardPanel} object.
|
* </p>
|
||||||
* @param dragOffsetX a int.
|
*
|
||||||
* @param dragOffsetY a int.
|
* @param dragPanel
|
||||||
* @param evt a {@link java.awt.event.MouseEvent} object.
|
* a {@link arcane.ui.CardPanel} object.
|
||||||
|
* @param dragOffsetX
|
||||||
|
* a int.
|
||||||
|
* @param dragOffsetY
|
||||||
|
* a int.
|
||||||
|
* @param evt
|
||||||
|
* a {@link java.awt.event.MouseEvent} object.
|
||||||
*/
|
*/
|
||||||
public void mouseDragged(CardPanel dragPanel, int dragOffsetX, int dragOffsetY, MouseEvent evt) {
|
public void mouseDragged(final CardPanel dragPanel, final int dragOffsetX, final int dragOffsetY,
|
||||||
for (CardPanelMouseListener listener : listeners)
|
final MouseEvent evt) {
|
||||||
|
for (CardPanelMouseListener listener : listeners) {
|
||||||
listener.mouseDragged(mouseDragPanel, mouseDragOffsetX, mouseDragOffsetY, evt);
|
listener.mouseDragged(mouseDragPanel, mouseDragOffsetX, mouseDragOffsetY, evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>mouseDragStart.</p>
|
* <p>
|
||||||
*
|
* mouseDragStart.
|
||||||
* @param dragPanel a {@link arcane.ui.CardPanel} object.
|
* </p>
|
||||||
* @param evt a {@link java.awt.event.MouseEvent} object.
|
*
|
||||||
|
* @param dragPanel
|
||||||
|
* a {@link arcane.ui.CardPanel} object.
|
||||||
|
* @param evt
|
||||||
|
* a {@link java.awt.event.MouseEvent} object.
|
||||||
*/
|
*/
|
||||||
public void mouseDragStart(CardPanel dragPanel, MouseEvent evt) {
|
public void mouseDragStart(final CardPanel dragPanel, final MouseEvent evt) {
|
||||||
for (CardPanelMouseListener listener : listeners)
|
for (CardPanelMouseListener listener : listeners) {
|
||||||
listener.mouseDragStart(mouseDragPanel, evt);
|
listener.mouseDragStart(mouseDragPanel, evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>mouseOut.</p>
|
* <p>
|
||||||
*
|
* mouseOut.
|
||||||
* @param panel a {@link arcane.ui.CardPanel} object.
|
* </p>
|
||||||
* @param evt a {@link java.awt.event.MouseEvent} object.
|
*
|
||||||
|
* @param panel
|
||||||
|
* a {@link arcane.ui.CardPanel} object.
|
||||||
|
* @param evt
|
||||||
|
* a {@link java.awt.event.MouseEvent} object.
|
||||||
*/
|
*/
|
||||||
public void mouseOut(CardPanel panel, MouseEvent evt) {
|
public final void mouseOut(final CardPanel panel, final MouseEvent evt) {
|
||||||
for (CardPanelMouseListener listener : listeners)
|
for (CardPanelMouseListener listener : listeners) {
|
||||||
listener.mouseOut(mouseOverPanel, evt);
|
listener.mouseOut(mouseOverPanel, evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>mouseOver.</p>
|
* <p>
|
||||||
*
|
* mouseOver.
|
||||||
* @param panel a {@link arcane.ui.CardPanel} object.
|
* </p>
|
||||||
* @param evt a {@link java.awt.event.MouseEvent} object.
|
*
|
||||||
|
* @param panel
|
||||||
|
* a {@link arcane.ui.CardPanel} object.
|
||||||
|
* @param evt
|
||||||
|
* a {@link java.awt.event.MouseEvent} object.
|
||||||
*/
|
*/
|
||||||
public void mouseOver(CardPanel panel, MouseEvent evt) {
|
public final void mouseOver(final CardPanel panel, final MouseEvent evt) {
|
||||||
for (CardPanelMouseListener listener : listeners)
|
for (CardPanelMouseListener listener : listeners) {
|
||||||
listener.mouseOver(panel, evt);
|
listener.mouseOver(panel, evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>getCardFromMouseOverPanel.</p>
|
* <p>
|
||||||
*
|
* getCardFromMouseOverPanel.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public Card getCardFromMouseOverPanel() {
|
public final Card getCardFromMouseOverPanel() {
|
||||||
if (mouseOverPanel != null)
|
if (mouseOverPanel != null) {
|
||||||
return mouseOverPanel.gameCard;
|
return mouseOverPanel.gameCard;
|
||||||
else
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Getter for the field <code>zoneID</code>.</p>
|
* <p>
|
||||||
*
|
* Getter for the field <code>zoneID</code>.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public int getZoneID() {
|
public final int getZoneID() {
|
||||||
return zoneID;
|
return zoneID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Setter for the field <code>zoneID</code>.</p>
|
* <p>
|
||||||
*
|
* Setter for the field <code>zoneID</code>.
|
||||||
* @param zoneID a int.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param zoneID
|
||||||
|
* a int.
|
||||||
*/
|
*/
|
||||||
public void setZoneID(int zoneID) {
|
public void setZoneID(final int zoneID) {
|
||||||
this.zoneID = zoneID;
|
this.zoneID = zoneID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.awt.event.MouseEvent;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class HandArea extends CardArea {
|
public class HandArea extends CardArea {
|
||||||
/** Constant <code>serialVersionUID=7488132628637407745L</code> */
|
/** Constant <code>serialVersionUID=7488132628637407745L</code>. */
|
||||||
private static final long serialVersionUID = 7488132628637407745L;
|
private static final long serialVersionUID = 7488132628637407745L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,36 +22,40 @@ public class HandArea extends CardArea {
|
|||||||
* @param scrollPane a {@link javax.swing.JScrollPane} object.
|
* @param scrollPane a {@link javax.swing.JScrollPane} object.
|
||||||
* @param frame a {@link java.awt.Frame} object.
|
* @param frame a {@link java.awt.Frame} object.
|
||||||
*/
|
*/
|
||||||
public HandArea(JScrollPane scrollPane, final Frame frame) {
|
public HandArea(final JScrollPane scrollPane, final Frame frame) {
|
||||||
super(scrollPane);
|
super(scrollPane);
|
||||||
|
|
||||||
setDragEnabled(true);
|
setDragEnabled(true);
|
||||||
setVertical(true);
|
setVertical(true);
|
||||||
|
|
||||||
addCardPanelMouseListener(new CardPanelMouseListener() {
|
addCardPanelMouseListener(new CardPanelMouseListener() {
|
||||||
public void mouseRightClicked(CardPanel panel, MouseEvent evt) {
|
public void mouseRightClicked(final CardPanel panel, final MouseEvent evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseOver(CardPanel panel, MouseEvent evt) {
|
public void mouseOver(final CardPanel panel, final MouseEvent evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseOut(CardPanel panel, MouseEvent evt) {
|
public void mouseOut(final CardPanel panel, final MouseEvent evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseMiddleClicked(CardPanel panel, MouseEvent evt) {
|
public void mouseMiddleClicked(final CardPanel panel, final MouseEvent evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseLeftClicked(CardPanel panel, MouseEvent evt) {
|
public void mouseLeftClicked(final CardPanel panel, final MouseEvent evt) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseDragged(CardPanel dragPanel, int dragOffsetX, int dragOffsetY, MouseEvent evt) {
|
public void mouseDragged(final CardPanel dragPanel,
|
||||||
|
final int dragOffsetX,
|
||||||
|
final int dragOffsetY,
|
||||||
|
final MouseEvent evt)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseDragStart(CardPanel dragPanel, MouseEvent evt) {
|
public void mouseDragStart(final CardPanel dragPanel, final MouseEvent evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseDragEnd(CardPanel dragPanel, MouseEvent evt) {
|
public void mouseDragEnd(final CardPanel dragPanel, final MouseEvent evt) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,41 @@
|
|||||||
package arcane.ui;
|
package arcane.ui;
|
||||||
|
|
||||||
import arcane.ui.util.CardPanelMouseListener;
|
import java.awt.Color;
|
||||||
import forge.Card;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
|
import arcane.ui.util.CardPanelMouseListener;
|
||||||
|
import forge.Card;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>PlayArea class.</p>
|
* <p>
|
||||||
*
|
* PlayArea class.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class PlayArea extends CardPanelContainer implements CardPanelMouseListener {
|
public class PlayArea extends CardPanelContainer implements CardPanelMouseListener {
|
||||||
/** Constant <code>serialVersionUID=8333013579724492513L</code> */
|
/** Constant <code>serialVersionUID=8333013579724492513L</code>. */
|
||||||
private static final long serialVersionUID = 8333013579724492513L;
|
private static final long serialVersionUID = 8333013579724492513L;
|
||||||
/** Constant <code>GUTTER_Y=5</code> */
|
/** Constant <code>GUTTER_Y=5</code>. */
|
||||||
static private final int GUTTER_Y = 5;
|
private static final int GUTTER_Y = 5;
|
||||||
/** Constant <code>GUTTER_X=5</code> */
|
/** Constant <code>GUTTER_X=5</code>. */
|
||||||
static private final int GUTTER_X = 5;
|
private static final int GUTTER_X = 5;
|
||||||
/** Constant <code>EXTRA_CARD_SPACING_X=0.04f</code> */
|
/** Constant <code>EXTRA_CARD_SPACING_X=0.04f</code>. */
|
||||||
static final float EXTRA_CARD_SPACING_X = 0.04f;
|
static final float EXTRA_CARD_SPACING_X = 0.04f;
|
||||||
/** Constant <code>CARD_SPACING_Y=0.06f</code> */
|
/** Constant <code>CARD_SPACING_Y=0.06f</code>. */
|
||||||
static private final float CARD_SPACING_Y = 0.06f;
|
private static final float CARD_SPACING_Y = 0.06f;
|
||||||
/** Constant <code>STACK_SPACING_X=0.07f</code> */
|
/** Constant <code>STACK_SPACING_X=0.07f</code>. */
|
||||||
static private final float STACK_SPACING_X = 0.07f;
|
private static final float STACK_SPACING_X = 0.07f;
|
||||||
/** Constant <code>STACK_SPACING_Y=0.07f</code> */
|
/** Constant <code>STACK_SPACING_Y=0.07f</code>. */
|
||||||
static private final float STACK_SPACING_Y = 0.07f;
|
private static final float STACK_SPACING_Y = 0.07f;
|
||||||
|
|
||||||
private int landStackMax = 5;
|
private int landStackMax = 5;
|
||||||
|
|
||||||
@@ -45,20 +50,26 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
private int stackSpacingX, stackSpacingY;
|
private int stackSpacingX, stackSpacingY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructor for PlayArea.</p>
|
* <p>
|
||||||
*
|
* Constructor for PlayArea.
|
||||||
* @param scrollPane a {@link javax.swing.JScrollPane} object.
|
* </p>
|
||||||
* @param mirror a boolean.
|
*
|
||||||
|
* @param scrollPane
|
||||||
|
* a {@link javax.swing.JScrollPane} object.
|
||||||
|
* @param mirror
|
||||||
|
* a boolean.
|
||||||
*/
|
*/
|
||||||
public PlayArea(JScrollPane scrollPane, boolean mirror) {
|
public PlayArea(final JScrollPane scrollPane, final boolean mirror) {
|
||||||
super(scrollPane);
|
super(scrollPane);
|
||||||
setBackground(Color.white);
|
setBackground(Color.white);
|
||||||
this.mirror = mirror;
|
this.mirror = mirror;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>doLayout.</p>
|
* <p>
|
||||||
*
|
* doLayout.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public void doLayout() {
|
public void doLayout() {
|
||||||
@@ -68,7 +79,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
outerLoop:
|
outerLoop:
|
||||||
//
|
//
|
||||||
for (CardPanel panel : cardPanels) {
|
for (CardPanel panel : cardPanels) {
|
||||||
if (!panel.gameCard.isLand() || panel.gameCard.isCreature()) continue;
|
if (!panel.gameCard.isLand() || panel.gameCard.isCreature()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int insertIndex = -1;
|
int insertIndex = -1;
|
||||||
|
|
||||||
@@ -76,15 +89,18 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
for (int i = 0, n = allLands.size(); i < n; i++) {
|
for (int i = 0, n = allLands.size(); i < n; i++) {
|
||||||
Stack stack = allLands.get(i);
|
Stack stack = allLands.get(i);
|
||||||
CardPanel firstPanel = stack.get(0);
|
CardPanel firstPanel = stack.get(0);
|
||||||
if (firstPanel.gameCard.getName().equals(panel.gameCard.getName()) ) {
|
if (firstPanel.gameCard.getName().equals(panel.gameCard.getName())) {
|
||||||
if (!firstPanel.attachedPanels.isEmpty() || firstPanel.gameCard.isEnchanted()) {
|
if (!firstPanel.attachedPanels.isEmpty() || firstPanel.gameCard.isEnchanted()) {
|
||||||
// Put this land to the left of lands with the same name and attachments.
|
// Put this land to the left of lands with the same name
|
||||||
|
// and attachments.
|
||||||
insertIndex = i;
|
insertIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!panel.attachedPanels.isEmpty() || !panel.gameCard.getCounters().equals(firstPanel.gameCard.getCounters())
|
if (!panel.attachedPanels.isEmpty()
|
||||||
|
|| !panel.gameCard.getCounters().equals(firstPanel.gameCard.getCounters())
|
||||||
|| firstPanel.gameCard.isEnchanted() || stack.size() == landStackMax) {
|
|| firstPanel.gameCard.isEnchanted() || stack.size() == landStackMax) {
|
||||||
// If this land has attachments or the stack is full, put it to the right.
|
// If this land has attachments or the stack is full,
|
||||||
|
// put it to the right.
|
||||||
insertIndex = i + 1;
|
insertIndex = i + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -92,7 +108,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
stack.add(0, panel);
|
stack.add(0, panel);
|
||||||
continue outerLoop;
|
continue outerLoop;
|
||||||
}
|
}
|
||||||
if (insertIndex != -1) break;
|
if (insertIndex != -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Stack stack = new Stack();
|
Stack stack = new Stack();
|
||||||
@@ -105,7 +123,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
outerLoop:
|
outerLoop:
|
||||||
//
|
//
|
||||||
for (CardPanel panel : cardPanels) {
|
for (CardPanel panel : cardPanels) {
|
||||||
if (!panel.gameCard.isToken()) continue;
|
if (!panel.gameCard.isToken()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int insertIndex = -1;
|
int insertIndex = -1;
|
||||||
|
|
||||||
@@ -115,16 +135,19 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
CardPanel firstPanel = stack.get(0);
|
CardPanel firstPanel = stack.get(0);
|
||||||
if (firstPanel.gameCard.getName().equals(panel.gameCard.getName())) {
|
if (firstPanel.gameCard.getName().equals(panel.gameCard.getName())) {
|
||||||
if (!firstPanel.attachedPanels.isEmpty()) {
|
if (!firstPanel.attachedPanels.isEmpty()) {
|
||||||
// Put this token to the left of tokens with the same name and attachments.
|
// Put this token to the left of tokens with the same
|
||||||
|
// name and attachments.
|
||||||
insertIndex = i;
|
insertIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!panel.attachedPanels.isEmpty() || !panel.gameCard.getCounters().equals(firstPanel.gameCard.getCounters())
|
if (!panel.attachedPanels.isEmpty()
|
||||||
|
|| !panel.gameCard.getCounters().equals(firstPanel.gameCard.getCounters())
|
||||||
|| panel.gameCard.isSick() != firstPanel.gameCard.isSick()
|
|| panel.gameCard.isSick() != firstPanel.gameCard.isSick()
|
||||||
|| panel.gameCard.getNetAttack() != firstPanel.gameCard.getNetAttack()
|
|| panel.gameCard.getNetAttack() != firstPanel.gameCard.getNetAttack()
|
||||||
|| panel.gameCard.getNetDefense() != firstPanel.gameCard.getNetDefense()
|
|| panel.gameCard.getNetDefense() != firstPanel.gameCard.getNetDefense()
|
||||||
|| stack.size() == tokenStackMax) {
|
|| stack.size() == tokenStackMax) {
|
||||||
// If this token has attachments or the stack is full, put it to the right.
|
// If this token has attachments or the stack is full,
|
||||||
|
// put it to the right.
|
||||||
insertIndex = i + 1;
|
insertIndex = i + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -132,7 +155,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
stack.add(0, panel);
|
stack.add(0, panel);
|
||||||
continue outerLoop;
|
continue outerLoop;
|
||||||
}
|
}
|
||||||
if (insertIndex != -1) break;
|
if (insertIndex != -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Stack stack = new Stack();
|
Stack stack = new Stack();
|
||||||
@@ -175,22 +200,30 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
}
|
}
|
||||||
// Store the current rows and others.
|
// Store the current rows and others.
|
||||||
List<Row> storedRows = new ArrayList<Row>(rows.size());
|
List<Row> storedRows = new ArrayList<Row>(rows.size());
|
||||||
for (Row row : rows)
|
for (Row row : rows) {
|
||||||
storedRows.add((Row) row.clone());
|
storedRows.add((Row) row.clone());
|
||||||
|
}
|
||||||
Row storedOthers = (Row) others.clone();
|
Row storedOthers = (Row) others.clone();
|
||||||
// Fill in all rows with others.
|
// Fill in all rows with others.
|
||||||
for (Row row : rows)
|
for (Row row : rows) {
|
||||||
fillRow(others, rows, row);
|
fillRow(others, rows, row);
|
||||||
// Stop if everything fits, otherwise revert back to the stored values.
|
}
|
||||||
if (creatures.isEmpty() && tokens.isEmpty() && lands.isEmpty() && others.isEmpty()) break;
|
// Stop if everything fits, otherwise revert back to the stored
|
||||||
|
// values.
|
||||||
|
if (creatures.isEmpty() && tokens.isEmpty() && lands.isEmpty() && others.isEmpty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
rows = storedRows;
|
rows = storedRows;
|
||||||
others = storedOthers;
|
others = storedOthers;
|
||||||
// Try to put others on their own row(s) and fill in the rest.
|
// Try to put others on their own row(s) and fill in the rest.
|
||||||
wrap(others, rows, afterFirstRow);
|
wrap(others, rows, afterFirstRow);
|
||||||
for (Row row : rows)
|
for (Row row : rows) {
|
||||||
fillRow(others, rows, row);
|
fillRow(others, rows, row);
|
||||||
|
}
|
||||||
// If that still doesn't fit, scale down.
|
// If that still doesn't fit, scale down.
|
||||||
if (creatures.isEmpty() && tokens.isEmpty() && lands.isEmpty() && others.isEmpty()) break;
|
if (creatures.isEmpty() && tokens.isEmpty() && lands.isEmpty() && others.isEmpty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
cardWidth--;
|
cardWidth--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,8 +255,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
// Align others to the right.
|
// Align others to the right.
|
||||||
if (RowType.other.isType(stack.get(0).gameCard)) {
|
if (RowType.other.isType(stack.get(0).gameCard)) {
|
||||||
x = playAreaWidth - GUTTER_X + extraCardSpacingX;
|
x = playAreaWidth - GUTTER_X + extraCardSpacingX;
|
||||||
for (int i = stackIndex, n = row.size(); i < n; i++)
|
for (int i = stackIndex, n = row.size(); i < n; i++) {
|
||||||
x -= row.get(i).getWidth();
|
x -= row.get(i).getWidth();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (int panelIndex = 0, panelCount = stack.size(); panelIndex < panelCount; panelIndex++) {
|
for (int panelIndex = 0, panelCount = stack.size(); panelIndex < panelCount; panelIndex++) {
|
||||||
CardPanel panel = stack.get(panelIndex);
|
CardPanel panel = stack.get(panelIndex);
|
||||||
@@ -241,15 +275,21 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>wrap.</p>
|
* <p>
|
||||||
*
|
* wrap.
|
||||||
* @param sourceRow a {@link arcane.ui.PlayArea.Row} object.
|
* </p>
|
||||||
* @param rows a {@link java.util.List} object.
|
*
|
||||||
* @param insertIndex a int.
|
* @param sourceRow
|
||||||
|
* a {@link arcane.ui.PlayArea.Row} object.
|
||||||
|
* @param rows
|
||||||
|
* a {@link java.util.List} object.
|
||||||
|
* @param insertIndex
|
||||||
|
* a int.
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
private int wrap(Row sourceRow, List<Row> rows, int insertIndex) {
|
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.
|
// The cards are sure to fit (with vertical scrolling) at the minimum
|
||||||
|
// card width.
|
||||||
boolean allowHeightOverflow = cardWidth == cardWidthMin;
|
boolean allowHeightOverflow = cardWidth == cardWidthMin;
|
||||||
|
|
||||||
Row currentRow = new Row();
|
Row currentRow = new Row();
|
||||||
@@ -259,8 +299,12 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
int rowWidth = currentRow.getWidth();
|
int rowWidth = currentRow.getWidth();
|
||||||
if (!currentRow.isEmpty() && rowWidth + stack.getWidth() > playAreaWidth) {
|
if (!currentRow.isEmpty() && rowWidth + stack.getWidth() > playAreaWidth) {
|
||||||
// Stop processing if the row is too wide or tall.
|
// Stop processing if the row is too wide or tall.
|
||||||
if (!allowHeightOverflow && rowWidth > playAreaWidth) break;
|
if (!allowHeightOverflow && rowWidth > playAreaWidth) {
|
||||||
if (!allowHeightOverflow && getRowsHeight(rows) + sourceRow.getHeight() > playAreaHeight) break;
|
break;
|
||||||
|
}
|
||||||
|
if (!allowHeightOverflow && getRowsHeight(rows) + sourceRow.getHeight() > playAreaHeight) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
rows.add(insertIndex == -1 ? rows.size() : insertIndex, currentRow);
|
rows.add(insertIndex == -1 ? rows.size() : insertIndex, currentRow);
|
||||||
currentRow = new Row();
|
currentRow = new Row();
|
||||||
}
|
}
|
||||||
@@ -276,48 +320,64 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Remove the wrapped stacks from the source row.
|
// Remove the wrapped stacks from the source row.
|
||||||
for (Row row : rows)
|
for (Row row : rows) {
|
||||||
for (Stack stack : row)
|
for (Stack stack : row) {
|
||||||
sourceRow.remove(stack);
|
sourceRow.remove(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
return insertIndex;
|
return insertIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>fillRow.</p>
|
* <p>
|
||||||
*
|
* fillRow.
|
||||||
* @param sourceRow a {@link arcane.ui.PlayArea.Row} object.
|
* </p>
|
||||||
* @param rows a {@link java.util.List} object.
|
*
|
||||||
* @param rows a {@link java.util.List} object.
|
* @param sourceRow
|
||||||
* @param row a {@link arcane.ui.PlayArea.Row} object.
|
* a {@link arcane.ui.PlayArea.Row} object.
|
||||||
|
* @param rows
|
||||||
|
* a {@link java.util.List} object.
|
||||||
|
* @param rows
|
||||||
|
* a {@link java.util.List} object.
|
||||||
|
* @param row
|
||||||
|
* a {@link arcane.ui.PlayArea.Row} object.
|
||||||
*/
|
*/
|
||||||
private void fillRow(Row sourceRow, List<Row> rows, Row row) {
|
private void fillRow(final Row sourceRow, final List<Row> rows, Row row) {
|
||||||
int rowWidth = row.getWidth();
|
int rowWidth = row.getWidth();
|
||||||
while (!sourceRow.isEmpty()) {
|
while (!sourceRow.isEmpty()) {
|
||||||
Stack stack = sourceRow.get(0);
|
Stack stack = sourceRow.get(0);
|
||||||
rowWidth += stack.getWidth();
|
rowWidth += stack.getWidth();
|
||||||
if (rowWidth > playAreaWidth) break;
|
if (rowWidth > playAreaWidth) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (stack.getHeight() > row.getHeight()) {
|
if (stack.getHeight() > row.getHeight()) {
|
||||||
if (getRowsHeight(rows) - row.getHeight() + stack.getHeight() > playAreaHeight) break;
|
if (getRowsHeight(rows) - row.getHeight() + stack.getHeight() > playAreaHeight) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
row.add(sourceRow.remove(0));
|
row.add(sourceRow.remove(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>getRowsHeight.</p>
|
* <p>
|
||||||
*
|
* getRowsHeight.
|
||||||
* @param rows a {@link java.util.List} object.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param rows
|
||||||
|
* a {@link java.util.List} object.
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
private int getRowsHeight(List<Row> rows) {
|
private int getRowsHeight(List<Row> rows) {
|
||||||
int height = 0;
|
int height = 0;
|
||||||
for (Row row : rows)
|
for (Row row : rows) {
|
||||||
height += row.getHeight();
|
height += row.getHeight();
|
||||||
|
}
|
||||||
return height - cardSpacingY + GUTTER_Y * 2;
|
return height - cardSpacingY + GUTTER_Y * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public CardPanel getCardPanel(int x, int y) {
|
public final CardPanel getCardPanel(final int x, final int y) {
|
||||||
for (Row row : rows) {
|
for (Row row : rows) {
|
||||||
for (Stack stack : row) {
|
for (Stack stack : row) {
|
||||||
for (CardPanel panel : stack) {
|
for (CardPanel panel : stack) {
|
||||||
@@ -334,7 +394,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
}
|
}
|
||||||
if (x > panelX && x < panelX + panelWidth) {
|
if (x > panelX && x < panelX + panelWidth) {
|
||||||
if (y > panelY && y < panelY + panelHeight) {
|
if (y > panelY && y < panelY + panelHeight) {
|
||||||
if (!panel.isDisplayEnabled()) return null;
|
if (!panel.isDisplayEnabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,62 +407,74 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void mouseLeftClicked(CardPanel panel, MouseEvent evt) {
|
public final void mouseLeftClicked(final CardPanel panel, final MouseEvent evt) {
|
||||||
if (panel.tappedAngle != 0 && panel.tappedAngle != CardPanel.TAPPED_ANGLE) return;
|
if (panel.tappedAngle != 0 && panel.tappedAngle != CardPanel.TAPPED_ANGLE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
super.mouseLeftClicked(panel, evt);
|
super.mouseLeftClicked(panel, evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Getter for the field <code>landStackMax</code>.</p>
|
* <p>
|
||||||
*
|
* Getter for the field <code>landStackMax</code>.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public int getLandStackMax() {
|
public final int getLandStackMax() {
|
||||||
return landStackMax;
|
return landStackMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Setter for the field <code>landStackMax</code>.</p>
|
* <p>
|
||||||
*
|
* Setter for the field <code>landStackMax</code>.
|
||||||
* @param landStackMax a int.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param landStackMax
|
||||||
|
* a int.
|
||||||
*/
|
*/
|
||||||
public void setLandStackMax(int landStackMax) {
|
public final void setLandStackMax(int landStackMax) {
|
||||||
this.landStackMax = landStackMax;
|
this.landStackMax = landStackMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Getter for the field <code>stackVertical</code>.</p>
|
* <p>
|
||||||
*
|
* Getter for the field <code>stackVertical</code>.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean getStackVertical() {
|
public final boolean getStackVertical() {
|
||||||
return stackVertical;
|
return stackVertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Setter for the field <code>stackVertical</code>.</p>
|
* <p>
|
||||||
*
|
* Setter for the field <code>stackVertical</code>.
|
||||||
* @param stackVertical a boolean.
|
* </p>
|
||||||
|
*
|
||||||
|
* @param stackVertical
|
||||||
|
* a boolean.
|
||||||
*/
|
*/
|
||||||
public void setStackVertical(boolean stackVertical) {
|
public final void setStackVertical(boolean stackVertical) {
|
||||||
this.stackVertical = stackVertical;
|
this.stackVertical = stackVertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private enum RowType {
|
private static enum RowType {
|
||||||
land, creature, creatureNonToken, other;
|
land, creature, creatureNonToken, other;
|
||||||
|
|
||||||
public boolean isType(Card card) {
|
public boolean isType(final Card card) {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case land:
|
case land:
|
||||||
return card.isLand();
|
return card.isLand();
|
||||||
case creature:
|
case creature:
|
||||||
return card.isCreature();
|
return card.isCreature();
|
||||||
case creatureNonToken:
|
case creatureNonToken:
|
||||||
return card.isCreature() && !card.isToken();
|
return card.isCreature() && !card.isToken();
|
||||||
case other:
|
case other:
|
||||||
return !card.isLand() && !card.isCreature();
|
return !card.isLand() && !card.isCreature();
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unhandled type: " + this);
|
throw new RuntimeException("Unhandled type: " + this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,39 +486,47 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
super(16);
|
super(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Row(List<CardPanel> cardPanels, RowType type) {
|
public Row(final List<CardPanel> cardPanels, final RowType type) {
|
||||||
this();
|
this();
|
||||||
addAll(cardPanels, type);
|
addAll(cardPanels, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAll(List<CardPanel> cardPanels, RowType type) {
|
private void addAll(final List<CardPanel> cardPanels, final RowType type) {
|
||||||
for (CardPanel panel : cardPanels) {
|
for (CardPanel panel : cardPanels) {
|
||||||
if (!type.isType(panel.gameCard) || panel.attachedToPanel != null) continue;
|
if (!type.isType(panel.gameCard) || panel.attachedToPanel != null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Stack stack = new Stack();
|
Stack stack = new Stack();
|
||||||
stack.add(panel);
|
stack.add(panel);
|
||||||
add(stack);
|
add(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addAll(Collection<? extends Stack> c) {
|
public boolean addAll(final Collection<? extends Stack> c) {
|
||||||
boolean changed = super.addAll(c);
|
boolean changed = super.addAll(c);
|
||||||
c.clear();
|
c.clear();
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getWidth() {
|
private int getWidth() {
|
||||||
if (isEmpty()) return 0;
|
if (isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
int width = 0;
|
int width = 0;
|
||||||
for (Stack stack : this)
|
for (Stack stack : this) {
|
||||||
width += stack.getWidth();
|
width += stack.getWidth();
|
||||||
|
}
|
||||||
return width + GUTTER_X * 2 - extraCardSpacingX;
|
return width + GUTTER_X * 2 - extraCardSpacingX;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getHeight() {
|
private int getHeight() {
|
||||||
if (isEmpty()) return 0;
|
if (isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
int height = 0;
|
int height = 0;
|
||||||
for (Stack stack : this)
|
for (Stack stack : this) {
|
||||||
height = Math.max(height, stack.getHeight());
|
height = Math.max(height, stack.getHeight());
|
||||||
|
}
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -456,10 +538,11 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
super(8);
|
super(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(CardPanel panel) {
|
public boolean add(final CardPanel panel) {
|
||||||
boolean appended = super.add(panel);
|
boolean appended = super.add(panel);
|
||||||
for (CardPanel attachedPanel : panel.attachedPanels)
|
for (CardPanel attachedPanel : panel.attachedPanels) {
|
||||||
add(attachedPanel);
|
add(attachedPanel);
|
||||||
|
}
|
||||||
return appended;
|
return appended;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package arcane.ui;
|
package arcane.ui;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.Graphics;
|
||||||
import java.awt.*;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>ScaledImagePanel class.</p>
|
* <p>ScaledImagePanel class.</p>
|
||||||
*
|
*
|
||||||
@@ -12,9 +16,15 @@ import java.awt.image.BufferedImage;
|
|||||||
*/
|
*/
|
||||||
public class ScaledImagePanel extends JPanel {
|
public class ScaledImagePanel extends JPanel {
|
||||||
|
|
||||||
/** Constant <code>serialVersionUID=-5691107238620895385L</code> */
|
/** Constant <code>serialVersionUID=-5691107238620895385L</code>. */
|
||||||
private static final long serialVersionUID = -5691107238620895385L;
|
private static final long serialVersionUID = -5691107238620895385L;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public volatile Image srcImage;
|
public volatile Image srcImage;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public volatile Image srcImageBlurred;
|
public volatile Image srcImageBlurred;
|
||||||
|
|
||||||
private ScalingType scalingType = ScalingType.bilinear;
|
private ScalingType scalingType = ScalingType.bilinear;
|
||||||
@@ -37,7 +47,7 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
* @param srcImageBlurred a {@link java.awt.Image} object.
|
* @param srcImageBlurred a {@link java.awt.Image} object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setImage(Image srcImage, Image srcImageBlurred) {
|
public final void setImage(final Image srcImage, Image srcImageBlurred) {
|
||||||
this.srcImage = srcImage;
|
this.srcImage = srcImage;
|
||||||
this.srcImageBlurred = srcImageBlurred;
|
this.srcImageBlurred = srcImageBlurred;
|
||||||
}
|
}
|
||||||
@@ -45,7 +55,7 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
/**
|
/**
|
||||||
* <p>clearImage.</p>
|
* <p>clearImage.</p>
|
||||||
*/
|
*/
|
||||||
public void clearImage() {
|
public final void clearImage() {
|
||||||
srcImage = null;
|
srcImage = null;
|
||||||
srcImageBlurred = null;
|
srcImageBlurred = null;
|
||||||
repaint();
|
repaint();
|
||||||
@@ -56,7 +66,7 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
*
|
*
|
||||||
* @param multiPassType a {@link arcane.ui.ScaledImagePanel.MultipassType} object.
|
* @param multiPassType a {@link arcane.ui.ScaledImagePanel.MultipassType} object.
|
||||||
*/
|
*/
|
||||||
public void setScalingMultiPassType(MultipassType multiPassType) {
|
public final void setScalingMultiPassType(final MultipassType multiPassType) {
|
||||||
this.multiPassType = multiPassType;
|
this.multiPassType = multiPassType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +75,7 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
*
|
*
|
||||||
* @param scalingType a {@link arcane.ui.ScaledImagePanel.ScalingType} object.
|
* @param scalingType a {@link arcane.ui.ScaledImagePanel.ScalingType} object.
|
||||||
*/
|
*/
|
||||||
public void setScalingType(ScalingType scalingType) {
|
public final void setScalingType(final ScalingType scalingType) {
|
||||||
this.scalingType = scalingType;
|
this.scalingType = scalingType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +84,7 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
*
|
*
|
||||||
* @param blur a boolean.
|
* @param blur a boolean.
|
||||||
*/
|
*/
|
||||||
public void setScalingBlur(boolean blur) {
|
public final void setScalingBlur(final boolean blur) {
|
||||||
this.blur = blur;
|
this.blur = blur;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +93,7 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
*
|
*
|
||||||
* @param scaleLarger a boolean.
|
* @param scaleLarger a boolean.
|
||||||
*/
|
*/
|
||||||
public void setScaleLarger(boolean scaleLarger) {
|
public final void setScaleLarger(final boolean scaleLarger) {
|
||||||
this.scaleLarger = scaleLarger;
|
this.scaleLarger = scaleLarger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +102,7 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
*
|
*
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean hasImage() {
|
public final boolean hasImage() {
|
||||||
return srcImage != null;
|
return srcImage != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,8 +123,9 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
if (targetWidth > panelWidth) {
|
if (targetWidth > panelWidth) {
|
||||||
targetHeight = Math.round(panelWidth * (srcHeight / (float) srcWidth));
|
targetHeight = Math.round(panelWidth * (srcHeight / (float) srcWidth));
|
||||||
targetWidth = panelWidth;
|
targetWidth = panelWidth;
|
||||||
} else
|
} else {
|
||||||
targetHeight = panelHeight;
|
targetHeight = panelHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ScalingInfo info = new ScalingInfo();
|
ScalingInfo info = new ScalingInfo();
|
||||||
info.targetWidth = targetWidth;
|
info.targetWidth = targetWidth;
|
||||||
@@ -127,8 +138,10 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void paint(Graphics g) {
|
public final void paint(final Graphics g) {
|
||||||
if (srcImage == null) return;
|
if (srcImage == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Graphics2D g2 = (Graphics2D) g.create();
|
Graphics2D g2 = (Graphics2D) g.create();
|
||||||
ScalingInfo info = getScalingInfo();
|
ScalingInfo info = getScalingInfo();
|
||||||
@@ -149,6 +162,8 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
case replicate:
|
case replicate:
|
||||||
scaleWithGetScaledInstance(g2, info, Image.SCALE_REPLICATE);
|
scaleWithGetScaledInstance(g2, info, Image.SCALE_REPLICATE);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +174,7 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
* @param info a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
* @param info a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
||||||
* @param hints a int.
|
* @param hints a int.
|
||||||
*/
|
*/
|
||||||
private void scaleWithGetScaledInstance(Graphics2D g2, ScalingInfo info, int hints) {
|
private void scaleWithGetScaledInstance(final Graphics2D g2, final ScalingInfo info, final int hints) {
|
||||||
Image srcImage = getSourceImage(info);
|
Image srcImage = getSourceImage(info);
|
||||||
Image scaledImage = srcImage.getScaledInstance(info.targetWidth, info.targetHeight, hints);
|
Image scaledImage = srcImage.getScaledInstance(info.targetWidth, info.targetHeight, hints);
|
||||||
g2.drawImage(scaledImage, info.x, info.y, null);
|
g2.drawImage(scaledImage, info.x, info.y, null);
|
||||||
@@ -172,17 +187,24 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
* @param info a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
* @param info a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
||||||
* @param hint a {@link java.lang.Object} object.
|
* @param hint a {@link java.lang.Object} object.
|
||||||
*/
|
*/
|
||||||
private void scaleWithDrawImage(Graphics2D g2, ScalingInfo info, Object hint) {
|
private void scaleWithDrawImage(final Graphics2D g2, final ScalingInfo info, final Object hint) {
|
||||||
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
|
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
|
||||||
|
|
||||||
int tempDestWidth = info.srcWidth / 2, tempDestHeight = info.srcHeight / 2;
|
int tempDestWidth = info.srcWidth / 2, tempDestHeight = info.srcHeight / 2;
|
||||||
if (tempDestWidth < info.targetWidth) tempDestWidth = info.targetWidth;
|
if (tempDestWidth < info.targetWidth) {
|
||||||
if (tempDestHeight < info.targetHeight) tempDestHeight = info.targetHeight;
|
tempDestWidth = info.targetWidth;
|
||||||
|
}
|
||||||
|
if (tempDestHeight < info.targetHeight) {
|
||||||
|
tempDestHeight = info.targetHeight;
|
||||||
|
}
|
||||||
|
|
||||||
Image srcImage = getSourceImage(info);
|
Image srcImage = getSourceImage(info);
|
||||||
|
|
||||||
// If not doing multipass or multipass only needs a single pass, just scale it once directly to the panel surface.
|
// If not doing multipass or multipass only needs a single pass,
|
||||||
if (multiPassType == MultipassType.none || (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight)) {
|
// just scale it once directly to the panel surface.
|
||||||
|
if (multiPassType == MultipassType.none
|
||||||
|
|| (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight))
|
||||||
|
{
|
||||||
g2.drawImage(srcImage, info.x, info.y, info.targetWidth, info.targetHeight, null);
|
g2.drawImage(srcImage, info.x, info.y, info.targetWidth, info.targetHeight, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -191,7 +213,8 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
Graphics2D g2temp = tempImage.createGraphics();
|
Graphics2D g2temp = tempImage.createGraphics();
|
||||||
switch (multiPassType) {
|
switch (multiPassType) {
|
||||||
case nearestNeighbor:
|
case nearestNeighbor:
|
||||||
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
|
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
||||||
|
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
|
||||||
break;
|
break;
|
||||||
case bilinear:
|
case bilinear:
|
||||||
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||||
@@ -199,6 +222,8 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
case bicubic:
|
case bicubic:
|
||||||
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// Render first pass from image to temp.
|
// Render first pass from image to temp.
|
||||||
g2temp.drawImage(srcImage, 0, 0, tempDestWidth, tempDestHeight, null);
|
g2temp.drawImage(srcImage, 0, 0, tempDestWidth, tempDestHeight, null);
|
||||||
@@ -208,15 +233,21 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
while (true) {
|
while (true) {
|
||||||
if (tempDestWidth > info.targetWidth) {
|
if (tempDestWidth > info.targetWidth) {
|
||||||
tempDestWidth = tempDestWidth / 2;
|
tempDestWidth = tempDestWidth / 2;
|
||||||
if (tempDestWidth < info.targetWidth) tempDestWidth = info.targetWidth;
|
if (tempDestWidth < info.targetWidth) {
|
||||||
|
tempDestWidth = info.targetWidth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempDestHeight > info.targetHeight) {
|
if (tempDestHeight > info.targetHeight) {
|
||||||
tempDestHeight = tempDestHeight / 2;
|
tempDestHeight = tempDestHeight / 2;
|
||||||
if (tempDestHeight < info.targetHeight) tempDestHeight = info.targetHeight;
|
if (tempDestHeight < info.targetHeight) {
|
||||||
|
tempDestHeight = info.targetHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight) break;
|
if (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
g2temp.drawImage(tempImage, 0, 0, tempDestWidth, tempDestHeight, 0, 0, tempSrcWidth, tempSrcHeight, null);
|
g2temp.drawImage(tempImage, 0, 0, tempDestWidth, tempDestHeight, 0, 0, tempSrcWidth, tempSrcHeight, null);
|
||||||
|
|
||||||
@@ -226,7 +257,10 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
g2temp.dispose();
|
g2temp.dispose();
|
||||||
// Render last pass from temp to panel surface.
|
// Render last pass from temp to panel surface.
|
||||||
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
|
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
|
||||||
g2.drawImage(tempImage, info.x, info.y, info.x + info.targetWidth, info.y + info.targetHeight, 0, 0, tempSrcWidth,
|
g2.drawImage(tempImage, info.x,
|
||||||
|
info.y,
|
||||||
|
info.x + info.targetWidth,
|
||||||
|
info.y + info.targetHeight, 0, 0, tempSrcWidth,
|
||||||
tempSrcHeight, null);
|
tempSrcHeight, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,13 +270,17 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
* @param info a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
* @param info a {@link arcane.ui.ScaledImagePanel.ScalingInfo} object.
|
||||||
* @return a {@link java.awt.Image} object.
|
* @return a {@link java.awt.Image} object.
|
||||||
*/
|
*/
|
||||||
private Image getSourceImage(ScalingInfo info) {
|
private Image getSourceImage(final ScalingInfo info) {
|
||||||
if (!blur || srcImageBlurred == null) return srcImage;
|
if (!blur || srcImageBlurred == null) {
|
||||||
if (info.srcWidth / 2 < info.targetWidth || info.srcHeight / 2 < info.targetHeight) return srcImage;
|
return srcImage;
|
||||||
|
}
|
||||||
|
if (info.srcWidth / 2 < info.targetWidth || info.srcHeight / 2 < info.targetHeight) {
|
||||||
|
return srcImage;
|
||||||
|
}
|
||||||
return srcImageBlurred;
|
return srcImageBlurred;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private class ScalingInfo {
|
private static class ScalingInfo {
|
||||||
public int targetWidth;
|
public int targetWidth;
|
||||||
public int targetHeight;
|
public int targetHeight;
|
||||||
public int srcWidth;
|
public int srcWidth;
|
||||||
@@ -251,11 +289,55 @@ public class ScaledImagePanel extends JPanel {
|
|||||||
public int y;
|
public int y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public enum MultipassType {
|
/**
|
||||||
none, nearestNeighbor, bilinear, bicubic
|
*
|
||||||
|
* MultipassType.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static enum MultipassType {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
none,
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
nearestNeighbor,
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bilinear,
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bicubic
|
||||||
}
|
}
|
||||||
|
|
||||||
static public enum ScalingType {
|
/**
|
||||||
nearestNeighbor, replicate, bilinear, bicubic, areaAveraging
|
*
|
||||||
|
* ScalingType.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static enum ScalingType {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
nearestNeighbor,
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
replicate,
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bilinear,
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bicubic,
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
areaAveraging
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package arcane.ui;
|
package arcane.ui;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.*;
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>ViewPanel class.</p>
|
* <p>ViewPanel class.</p>
|
||||||
@@ -10,7 +11,7 @@ import java.awt.*;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class ViewPanel extends JPanel {
|
public class ViewPanel extends JPanel {
|
||||||
/** Constant <code>serialVersionUID=7016597023142963068L</code> */
|
/** Constant <code>serialVersionUID=7016597023142963068L</code>. */
|
||||||
private static final long serialVersionUID = 7016597023142963068L;
|
private static final long serialVersionUID = 7016597023142963068L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,8 +19,10 @@ public class ViewPanel extends JPanel {
|
|||||||
*
|
*
|
||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public void doLayout() {
|
public final void doLayout() {
|
||||||
if (getComponentCount() == 0) return;
|
if (getComponentCount() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
CardPanel panel = (CardPanel) getComponent(0);
|
CardPanel panel = (CardPanel) getComponent(0);
|
||||||
int viewWidth = getWidth();
|
int viewWidth = getWidth();
|
||||||
int viewHeight = getHeight();
|
int viewHeight = getHeight();
|
||||||
@@ -30,8 +33,9 @@ public class ViewPanel extends JPanel {
|
|||||||
if (targetWidth > viewWidth) {
|
if (targetWidth > viewWidth) {
|
||||||
targetHeight = Math.round(viewWidth * (srcHeight / (float) srcWidth));
|
targetHeight = Math.round(viewWidth * (srcHeight / (float) srcWidth));
|
||||||
targetWidth = viewWidth;
|
targetWidth = viewWidth;
|
||||||
} else
|
} else {
|
||||||
targetHeight = viewHeight;
|
targetHeight = viewHeight;
|
||||||
|
}
|
||||||
int x = viewWidth / 2 - targetWidth / 2;
|
int x = viewWidth / 2 - targetWidth / 2;
|
||||||
int y = viewHeight / 2 - targetHeight / 2;
|
int y = viewHeight / 2 - targetHeight / 2;
|
||||||
panel.setCardBounds(x, y, targetWidth, targetHeight);
|
panel.setCardBounds(x, y, targetWidth, targetHeight);
|
||||||
@@ -42,7 +46,7 @@ public class ViewPanel extends JPanel {
|
|||||||
*
|
*
|
||||||
* @param panel a {@link arcane.ui.CardPanel} object.
|
* @param panel a {@link arcane.ui.CardPanel} object.
|
||||||
*/
|
*/
|
||||||
public void setCardPanel(CardPanel panel) {
|
public final void setCardPanel(final CardPanel panel) {
|
||||||
//CardPanel newPanel = new CardPanel(panel.gameCard);
|
//CardPanel newPanel = new CardPanel(panel.gameCard);
|
||||||
//newPanel.setImage(panel);
|
//newPanel.setImage(panel);
|
||||||
removeAll();
|
removeAll();
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
/** Forge Card Game */
|
/** Forge Card Game. */
|
||||||
package arcane.ui;
|
package arcane.ui;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import net.slightlymagic.braids.util.lambda.Lambda1;
|
|||||||
*
|
*
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id: CardPoolView.java 9708 2011-08-09 19:34:12Z jendave $
|
* @version $Id: CardPoolView.java 9708 2011-08-09 19:34:12Z jendave $
|
||||||
|
* @param <T> an InventoryItem
|
||||||
*/
|
*/
|
||||||
public class ItemPoolView<T extends InventoryItem> implements Iterable<Entry<T, Integer>> {
|
public class ItemPoolView<T extends InventoryItem> implements Iterable<Entry<T, Integer>> {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user