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