forked from External/mage
* UI: fixed graveyard and other cards window size (removed unnecessary scrolls, #5659);
This commit is contained in:
parent
893e9384b1
commit
16efc350b4
4 changed files with 323 additions and 358 deletions
|
|
@ -1,349 +1,339 @@
|
|||
|
||||
|
||||
/*
|
||||
* Cards.java
|
||||
*
|
||||
* Created on Dec 18, 2009, 10:40:12 AM
|
||||
*/
|
||||
package mage.client.cards;
|
||||
* Cards.java
|
||||
*
|
||||
* Created on Dec 18, 2009, 10:40:12 AM
|
||||
*/
|
||||
package mage.client.cards;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.CardsViewUtil;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
import mage.view.PermanentView;
|
||||
import mage.view.SimpleCardsView;
|
||||
import mage.view.StackAbilityView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.CardsViewUtil;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.view.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Cards extends javax.swing.JPanel {
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(Cards.class);
|
||||
private static final Border EMPTY_BORDER = new EmptyBorder(0, 0, 0, 0);
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Cards extends javax.swing.JPanel {
|
||||
|
||||
private final Map<UUID, MageCard> cards = new LinkedHashMap<>();
|
||||
private boolean dontDisplayTapped = false;
|
||||
private static final int GAP_X = 5; // needed for marking cards with coloured fram (e.g. on hand)
|
||||
private String zone;
|
||||
private static final Logger LOGGER = Logger.getLogger(Cards.class);
|
||||
private static final Border EMPTY_BORDER = new EmptyBorder(0, 0, 0, 0);
|
||||
|
||||
private int minOffsetY = 0;
|
||||
private final Map<UUID, MageCard> cards = new LinkedHashMap<>();
|
||||
private boolean dontDisplayTapped = false;
|
||||
private static final int GAP_X = 5; // needed for marking cards with coloured fram (e.g. on hand)
|
||||
private String zone;
|
||||
|
||||
/**
|
||||
* Defines whether component should be visible whenever there is no objects
|
||||
* within. True by default.
|
||||
*/
|
||||
private boolean isVisibleIfEmpty = true;
|
||||
private int minOffsetY = 0;
|
||||
|
||||
private Dimension cardDimension;
|
||||
/**
|
||||
* Defines whether component should be visible whenever there is no objects
|
||||
* within. True by default.
|
||||
*/
|
||||
private boolean isVisibleIfEmpty = true;
|
||||
|
||||
/**
|
||||
* Creates new form Cards
|
||||
*/
|
||||
public Cards() {
|
||||
this(false);
|
||||
}
|
||||
private Dimension cardDimension;
|
||||
|
||||
public Cards(boolean skipAddingScrollPane) {
|
||||
initComponents(skipAddingScrollPane);
|
||||
setOpaque(false);
|
||||
//cardArea.setOpaque(false);
|
||||
setBackgroundColor(new Color(0, 0, 0, 100));
|
||||
if (!skipAddingScrollPane) {
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
jScrollPane1.setBorder(EMPTY_BORDER);
|
||||
}
|
||||
if (Plugins.instance.isCardPluginLoaded()) {
|
||||
cardArea.setLayout(null);
|
||||
}
|
||||
cardArea.setBorder(EMPTY_BORDER);
|
||||
setGUISize();
|
||||
}
|
||||
/**
|
||||
* Creates new form Cards
|
||||
*/
|
||||
public Cards() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public void cleanUp() {
|
||||
}
|
||||
public Cards(boolean skipAddingScrollPane) {
|
||||
initComponents(skipAddingScrollPane);
|
||||
setOpaque(false);
|
||||
//cardArea.setOpaque(false);
|
||||
setBackgroundColor(new Color(0, 0, 0, 100));
|
||||
if (!skipAddingScrollPane) {
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
jScrollPane1.setBorder(EMPTY_BORDER);
|
||||
}
|
||||
if (Plugins.instance.isCardPluginLoaded()) {
|
||||
cardArea.setLayout(null);
|
||||
}
|
||||
cardArea.setBorder(EMPTY_BORDER);
|
||||
setGUISize();
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
for (MageCard mageCard : cards.values()) {
|
||||
mageCard.setCardBounds(0, 0, getCardDimension().width, getCardDimension().height);
|
||||
mageCard.updateArtImage();
|
||||
mageCard.doLayout();
|
||||
}
|
||||
layoutCards();
|
||||
sizeCards(cardDimension);
|
||||
}
|
||||
public void cleanUp() {
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
||||
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
||||
}
|
||||
}
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
for (MageCard mageCard : cards.values()) {
|
||||
mageCard.setCardBounds(0, 0, getCardDimension().width, getCardDimension().height);
|
||||
mageCard.updateArtImage();
|
||||
mageCard.doLayout();
|
||||
}
|
||||
layoutCards();
|
||||
sizeCards(getCardDimension());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets components background color
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
public void setBackgroundColor(Color color) {
|
||||
setBackground(color);
|
||||
cardArea.setOpaque(true);
|
||||
cardArea.setBackground(color);
|
||||
}
|
||||
private void setGUISize() {
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
||||
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisibleIfEmpty(boolean isVisibleIfEmpty) {
|
||||
this.isVisibleIfEmpty = isVisibleIfEmpty;
|
||||
}
|
||||
/**
|
||||
* Sets components background color
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
public void setBackgroundColor(Color color) {
|
||||
setBackground(color);
|
||||
cardArea.setOpaque(true);
|
||||
cardArea.setBackground(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorder(Border border) {
|
||||
super.setBorder(border);
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.setViewportBorder(border);
|
||||
jScrollPane1.setBorder(border);
|
||||
}
|
||||
}
|
||||
public void setVisibleIfEmpty(boolean isVisibleIfEmpty) {
|
||||
this.isVisibleIfEmpty = isVisibleIfEmpty;
|
||||
}
|
||||
|
||||
public boolean loadCards(SimpleCardsView cardsView, BigCard bigCard, UUID gameId) {
|
||||
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId, true);
|
||||
}
|
||||
@Override
|
||||
public void setBorder(Border border) {
|
||||
super.setBorder(border);
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.setViewportBorder(border);
|
||||
jScrollPane1.setBorder(border);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId, boolean revertOrder) {
|
||||
boolean changed = false;
|
||||
public boolean loadCards(SimpleCardsView cardsView, BigCard bigCard, UUID gameId) {
|
||||
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId, true);
|
||||
}
|
||||
|
||||
// remove objects no longer on the stack from display
|
||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||
Entry<UUID, MageCard> entry = i.next();
|
||||
if (!cardsView.containsKey(entry.getKey())) {
|
||||
removeCard(entry.getKey());
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId, boolean revertOrder) {
|
||||
boolean changed = false;
|
||||
|
||||
// Workaround for bug leaving display of objects on the stack (issue #213 https://github.com/magefree/mage/issues/213)
|
||||
if (cardsView.isEmpty() && countCards() > 0) {
|
||||
// problem happens with transformable cards
|
||||
LOGGER.fatal("Card object on the cards panel was not removed");
|
||||
for (Component comp : cardArea.getComponents()) {
|
||||
if (comp instanceof Card) {
|
||||
Card card = (Card) comp;
|
||||
LOGGER.fatal("Card name:" + card.getName() + " type:" + card.getType(null));
|
||||
} else if (comp instanceof MageCard) {
|
||||
MageCard mageCard = (MageCard) comp;
|
||||
LOGGER.fatal("MageCard name:" + mageCard.getName() + " toolTiptext:" + mageCard.getToolTipText());
|
||||
} else {
|
||||
LOGGER.fatal("Unknown object:" + comp.getName() + " className:" + comp.getClass().getName());
|
||||
}
|
||||
cardArea.remove(comp);
|
||||
}
|
||||
}
|
||||
// remove objects no longer on the stack from display
|
||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext(); ) {
|
||||
Entry<UUID, MageCard> entry = i.next();
|
||||
if (!cardsView.containsKey(entry.getKey())) {
|
||||
removeCard(entry.getKey());
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
java.util.List<CardView> orderedList = new ArrayList<>();
|
||||
if (revertOrder) {
|
||||
// order objects for display
|
||||
for (CardView card : cardsView.values()) {
|
||||
orderedList.add(0, card);
|
||||
}
|
||||
} else {
|
||||
orderedList.addAll(cardsView.values());
|
||||
}
|
||||
// Workaround for bug leaving display of objects on the stack (issue #213 https://github.com/magefree/mage/issues/213)
|
||||
if (cardsView.isEmpty() && countCards() > 0) {
|
||||
// problem happens with transformable cards
|
||||
LOGGER.fatal("Card object on the cards panel was not removed");
|
||||
for (Component comp : cardArea.getComponents()) {
|
||||
if (comp instanceof Card) {
|
||||
Card card = (Card) comp;
|
||||
LOGGER.fatal("Card name:" + card.getName() + " type:" + card.getType(null));
|
||||
} else if (comp instanceof MageCard) {
|
||||
MageCard mageCard = (MageCard) comp;
|
||||
LOGGER.fatal("MageCard name:" + mageCard.getName() + " toolTiptext:" + mageCard.getToolTipText());
|
||||
} else {
|
||||
LOGGER.fatal("Unknown object:" + comp.getName() + " className:" + comp.getClass().getName());
|
||||
}
|
||||
cardArea.remove(comp);
|
||||
}
|
||||
}
|
||||
|
||||
// add objects to the panel
|
||||
for (CardView card : orderedList) {
|
||||
if (dontDisplayTapped) {
|
||||
if (card instanceof PermanentView) {
|
||||
((PermanentView) card).overrideTapped(false);
|
||||
}
|
||||
}
|
||||
if (card instanceof StackAbilityView) {
|
||||
CardView tmp = ((StackAbilityView) card).getSourceCard();
|
||||
tmp.overrideRules(card.getRules());
|
||||
tmp.setIsAbility(true);
|
||||
tmp.overrideTargets(card.getTargets());
|
||||
tmp.overrideId(card.getId());
|
||||
tmp.setAbilityType(card.getAbilityType());
|
||||
card = tmp;
|
||||
} else {
|
||||
card.setAbilityType(null);
|
||||
}
|
||||
if (!cards.containsKey(card.getId())) {
|
||||
addCard(card, bigCard, gameId);
|
||||
changed = true;
|
||||
}
|
||||
cards.get(card.getId()).update(card);
|
||||
}
|
||||
java.util.List<CardView> orderedList = new ArrayList<>();
|
||||
if (revertOrder) {
|
||||
// order objects for display
|
||||
for (CardView card : cardsView.values()) {
|
||||
orderedList.add(0, card);
|
||||
}
|
||||
} else {
|
||||
orderedList.addAll(cardsView.values());
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
layoutCards();
|
||||
}
|
||||
// add objects to the panel
|
||||
for (CardView card : orderedList) {
|
||||
if (dontDisplayTapped) {
|
||||
if (card instanceof PermanentView) {
|
||||
((PermanentView) card).overrideTapped(false);
|
||||
}
|
||||
}
|
||||
if (card instanceof StackAbilityView) {
|
||||
CardView tmp = ((StackAbilityView) card).getSourceCard();
|
||||
tmp.overrideRules(card.getRules());
|
||||
tmp.setIsAbility(true);
|
||||
tmp.overrideTargets(card.getTargets());
|
||||
tmp.overrideId(card.getId());
|
||||
tmp.setAbilityType(card.getAbilityType());
|
||||
card = tmp;
|
||||
} else {
|
||||
card.setAbilityType(null);
|
||||
}
|
||||
if (!cards.containsKey(card.getId())) {
|
||||
addCard(card, bigCard, gameId);
|
||||
changed = true;
|
||||
}
|
||||
cards.get(card.getId()).update(card);
|
||||
}
|
||||
|
||||
if (!isVisibleIfEmpty) {
|
||||
cardArea.setVisible(!cards.isEmpty());
|
||||
}
|
||||
if (changed) {
|
||||
layoutCards();
|
||||
}
|
||||
|
||||
sizeCards(getCardDimension());
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
if (!isVisibleIfEmpty) {
|
||||
cardArea.setVisible(!cards.isEmpty());
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
sizeCards(getCardDimension());
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
|
||||
public void sizeCards(Dimension cardDimension) {
|
||||
cardArea.setPreferredSize(new Dimension((int) ((cards.size()) * (cardDimension.getWidth() + GAP_X)) + 20, (int) (cardDimension.getHeight()) + 20));
|
||||
cardArea.revalidate();
|
||||
cardArea.repaint();
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
public int getNumberOfCards() {
|
||||
return cards.size();
|
||||
}
|
||||
public void sizeCards(Dimension cardDimension) {
|
||||
cardArea.setPreferredSize(new Dimension((int) ((cards.size()) * (cardDimension.getWidth() + GAP_X)) + 20, (int) (cardDimension.getHeight()) + 20));
|
||||
cardArea.revalidate();
|
||||
cardArea.repaint();
|
||||
}
|
||||
|
||||
private Dimension getCardDimension() {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||
}
|
||||
return cardDimension;
|
||||
}
|
||||
public int getNumberOfCards() {
|
||||
return cards.size();
|
||||
}
|
||||
|
||||
public void setCardDimension(Dimension dimension) {
|
||||
this.cardDimension = dimension;
|
||||
for (Component component : cardArea.getComponents()) {
|
||||
if (component instanceof CardPanel) {
|
||||
component.setBounds(0, 0, dimension.width, dimension.height);
|
||||
}
|
||||
}
|
||||
layoutCards();
|
||||
}
|
||||
private Dimension getCardDimension() {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||
}
|
||||
return cardDimension;
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||
MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
|
||||
if (zone != null) {
|
||||
mageCard.setZone(zone);
|
||||
}
|
||||
cards.put(card.getId(), mageCard);
|
||||
cardArea.add(mageCard);
|
||||
definePosition(mageCard);
|
||||
mageCard.setCardAreaRef(cardArea);
|
||||
}
|
||||
public void setCardDimension(Dimension dimension) {
|
||||
this.cardDimension = dimension;
|
||||
for (Component component : cardArea.getComponents()) {
|
||||
if (component instanceof CardPanel) {
|
||||
component.setBounds(0, 0, dimension.width, dimension.height);
|
||||
}
|
||||
}
|
||||
layoutCards();
|
||||
}
|
||||
|
||||
private void definePosition(MageCard card) {
|
||||
int dx = 0;
|
||||
for (Component comp : cardArea.getComponents()) {
|
||||
if (!comp.equals(card)) {
|
||||
dx = Math.max(dx, (int) comp.getLocation().getX());
|
||||
}
|
||||
}
|
||||
dx += ((CardPanel) card).getCardWidth() + GAP_X;
|
||||
card.setLocation(dx, (int) card.getLocation().getY());
|
||||
}
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||
MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
|
||||
if (zone != null) {
|
||||
mageCard.setZone(zone);
|
||||
}
|
||||
cards.put(card.getId(), mageCard);
|
||||
cardArea.add(mageCard);
|
||||
definePosition(mageCard);
|
||||
mageCard.setCardAreaRef(cardArea);
|
||||
}
|
||||
|
||||
private void removeCard(UUID cardId) {
|
||||
for (Component comp : cardArea.getComponents()) {
|
||||
if (comp instanceof Card) {
|
||||
if (((Card) comp).getCardId().equals(cardId)) {
|
||||
cardArea.remove(comp);
|
||||
}
|
||||
} else if (comp instanceof MageCard) {
|
||||
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
|
||||
cardArea.remove(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void definePosition(MageCard card) {
|
||||
int dx = 0;
|
||||
for (Component comp : cardArea.getComponents()) {
|
||||
if (!comp.equals(card)) {
|
||||
dx = Math.max(dx, (int) comp.getLocation().getX());
|
||||
}
|
||||
}
|
||||
dx += ((CardPanel) card).getCardWidth() + GAP_X;
|
||||
card.setLocation(dx, (int) card.getLocation().getY());
|
||||
}
|
||||
|
||||
private int countCards() {
|
||||
return cardArea.getComponentCount();
|
||||
}
|
||||
private void removeCard(UUID cardId) {
|
||||
for (Component comp : cardArea.getComponents()) {
|
||||
if (comp instanceof Card) {
|
||||
if (((Card) comp).getCardId().equals(cardId)) {
|
||||
cardArea.remove(comp);
|
||||
}
|
||||
} else if (comp instanceof MageCard) {
|
||||
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
|
||||
cardArea.remove(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents(boolean skipAddingScrollPane) {
|
||||
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0, 0)));
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
private int countCards() {
|
||||
return cardArea.getComponentCount();
|
||||
}
|
||||
|
||||
cardArea = new javax.swing.JPanel();
|
||||
cardArea.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents(boolean skipAddingScrollPane) {
|
||||
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0, 0)));
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
if (skipAddingScrollPane) {
|
||||
add(cardArea, java.awt.BorderLayout.CENTER);
|
||||
} else{
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
jScrollPane1.setViewportView(cardArea);
|
||||
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||
add(jScrollPane1, java.awt.BorderLayout.CENTER);
|
||||
}
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
cardArea = new javax.swing.JPanel();
|
||||
cardArea.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel cardArea;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
if (skipAddingScrollPane) {
|
||||
add(cardArea, java.awt.BorderLayout.CENTER);
|
||||
} else {
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||
jScrollPane1.setViewportView(cardArea);
|
||||
add(jScrollPane1, java.awt.BorderLayout.CENTER);
|
||||
}
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
public void setDontDisplayTapped(boolean dontDisplayTapped) {
|
||||
this.dontDisplayTapped = dontDisplayTapped;
|
||||
}
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel cardArea;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
public void setHScrollSpeed(int unitIncrement) {
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(unitIncrement);
|
||||
}
|
||||
}
|
||||
public void setDontDisplayTapped(boolean dontDisplayTapped) {
|
||||
this.dontDisplayTapped = dontDisplayTapped;
|
||||
}
|
||||
|
||||
public void setVScrollSpeed(int unitIncrement) {
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.getVerticalScrollBar().setUnitIncrement(unitIncrement);
|
||||
}
|
||||
}
|
||||
public void setHScrollSpeed(int unitIncrement) {
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(unitIncrement);
|
||||
}
|
||||
}
|
||||
|
||||
private void layoutCards() {
|
||||
java.util.List<CardPanel> cardsToLayout = new ArrayList<>();
|
||||
// get all the card panels
|
||||
for (Component component : cardArea.getComponents()) {
|
||||
if (component instanceof CardPanel) {
|
||||
cardsToLayout.add((CardPanel) component);
|
||||
}
|
||||
}
|
||||
// sort the cards
|
||||
cardsToLayout.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
|
||||
// relocate the cards
|
||||
int dx = 0;
|
||||
for (Component component : cardsToLayout) {
|
||||
component.setLocation(dx, Math.max(component.getLocation().y, minOffsetY));
|
||||
dx += ((CardPanel) component).getCardWidth() + GAP_X;
|
||||
}
|
||||
}
|
||||
public void setVScrollSpeed(int unitIncrement) {
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.getVerticalScrollBar().setUnitIncrement(unitIncrement);
|
||||
}
|
||||
}
|
||||
|
||||
public void setZone(String zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
private void layoutCards() {
|
||||
java.util.List<CardPanel> cardsToLayout = new ArrayList<>();
|
||||
// get all the card panels
|
||||
for (Component component : cardArea.getComponents()) {
|
||||
if (component instanceof CardPanel) {
|
||||
cardsToLayout.add((CardPanel) component);
|
||||
}
|
||||
}
|
||||
// sort the cards
|
||||
cardsToLayout.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
|
||||
// relocate the cards
|
||||
int dx = 0;
|
||||
for (Component component : cardsToLayout) {
|
||||
component.setLocation(dx, Math.max(component.getLocation().y, minOffsetY));
|
||||
dx += ((CardPanel) component).getCardWidth() + GAP_X;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMinOffsetY(int minOffsetY) {
|
||||
this.minOffsetY = minOffsetY;
|
||||
}
|
||||
}
|
||||
public void setZone(String zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
public void setMinOffsetY(int minOffsetY) {
|
||||
this.minOffsetY = minOffsetY;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue