[Collection viewer] Drawing set name on the tabs (vertical for selected and normal for tabs without images).

This commit is contained in:
magenoxx 2011-04-10 11:25:25 +04:00
parent 48142926dd
commit b42e056750
3 changed files with 390 additions and 344 deletions

View file

@ -15,161 +15,198 @@ import java.awt.font.FontRenderContext;
*/
public class HoverButton extends JPanel implements MouseListener {
private Image image;
private Image hoverImage;
private Image disabledImage;
private Image selectedImage;
private Image overlayImage;
private Rectangle imageSize;
private Rectangle buttonSize;
private String text;
private int textOffsetY = 0;
private int textOffsetX = -1;
private Dimension overlayImageSize;
private Image image;
private Image hoverImage;
private Image disabledImage;
private Image selectedImage;
protected Image overlayImage;
private Rectangle imageSize;
private Rectangle buttonSize;
private String text;
private int textOffsetY = 0;
private int textOffsetX = -1;
private Dimension overlayImageSize;
private boolean isHovered = false;
private boolean isSelected = false;
private boolean isHovered = false;
private boolean isSelected = false;
private boolean drawSet = false;
private String set = null;
private Command observer = null;
private Command onHover = null;
private Color textColor = Color.white;
private Command observer = null;
private Command onHover = null;
private Color textColor = Color.white;
final static Font textFont = new Font("Arial", Font.PLAIN, 12);
final static Font textFontMini = new Font("Arial", Font.PLAIN, 11);
private boolean useMiniFont = false;
final static Font textFont = new Font("Arial", Font.PLAIN, 12);
final static Font textFontMini = new Font("Arial", Font.PLAIN, 11);
final static Font textSetFontBoldMini = new Font("Arial", Font.BOLD, 12);
final static Font textSetFontBold = new Font("Arial", Font.BOLD, 14);
private boolean useMiniFont = false;
public HoverButton(String text, Image image, Image hover, Image disabled, Rectangle size) {
this(text, image, hover, null, disabled, size);
}
public HoverButton(String text, Image image, Image hover, Image disabled, Rectangle size) {
this(text, image, hover, null, disabled, size);
}
public HoverButton(String text, Image image, Image hover, Image selected, Image disabled, Rectangle size) {
this.image = image;
this.hoverImage = hover;
this.selectedImage = selected;
this.disabledImage = disabled;
this.imageSize = size;
this.text = text;
setOpaque(false);
addMouseListener(this);
}
public HoverButton(String text, Image image, Image hover, Image selected, Image disabled, Rectangle size) {
this.image = image;
this.hoverImage = hover;
this.selectedImage = selected;
this.disabledImage = disabled;
this.imageSize = size;
this.text = text;
setOpaque(false);
addMouseListener(this);
}
@Override
public void paintComponent(Graphics g) {
if (isEnabled()) {
if (isHovered) {
g.drawImage(hoverImage, 0, 0, imageSize.width, imageSize.height, this);
if (text != null) {
Graphics2D g2d = (Graphics2D) g;
if (textColor != null) g2d.setColor(textColor);
if (useMiniFont) g2d.setFont(textFontMini);
else g2d.setFont(textFont);
if (textOffsetX == -1) { // calculate once
FontRenderContext frc = g2d.getFontRenderContext();
int textWidth = (int) textFont.getStringBounds(text, frc).getWidth();
if (textWidth > buttonSize.width) {
g2d.setFont(textFontMini);
useMiniFont = true;
frc = g2d.getFontRenderContext();
textWidth = (int) textFontMini.getStringBounds(text, frc).getWidth();
}
textOffsetX = (int) ((imageSize.width - textWidth) / 2);
}
g2d.drawString(text, textOffsetX, textOffsetY);
}
} else {
g.drawImage(image, 0, 0, imageSize.width, imageSize.height, this);
}
if (isSelected) {
if (selectedImage != null) {
g.drawImage(selectedImage, 0, 0, imageSize.width, imageSize.height, this);
} else {
System.err.println("No selectedImage for button.");
}
}
} else {
g.drawImage(disabledImage, 0, 0, imageSize.width, imageSize.height, this);
}
if (overlayImage != null) {
g.drawImage(overlayImage, (imageSize.width - overlayImageSize.width) / 2, 10, this);
}
}
public HoverButton(HoverButton button) {
this(button.text, button.image, button.hoverImage, button.selectedImage, button.disabledImage, button.imageSize);
}
public void setTextColor(Color textColor) {
this.textColor = textColor;
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
if (isEnabled()) {
if (isHovered) {
g.drawImage(hoverImage, 0, 0, imageSize.width, imageSize.height, this);
if (text != null) {
if (textColor != null) g2d.setColor(textColor);
if (useMiniFont) g2d.setFont(textFontMini);
else g2d.setFont(textFont);
textOffsetX = calculateOffset(g2d);
g2d.drawString(text, textOffsetX, textOffsetY);
}
} else {
g.drawImage(image, 0, 0, imageSize.width, imageSize.height, this);
}
if (isSelected) {
if (selectedImage != null) {
g.drawImage(selectedImage, 0, 0, imageSize.width, imageSize.height, this);
} else {
System.err.println("No selectedImage for button.");
}
}
} else {
g.drawImage(disabledImage, 0, 0, imageSize.width, imageSize.height, this);
}
if (overlayImage != null) {
g.drawImage(overlayImage, (imageSize.width - overlayImageSize.width) / 2, 10, this);
} else if (set != null) {
// draw only if it is not current tab
if (!drawSet) {
g2d.setFont(textSetFontBoldMini);
g2d.drawString(set, 5, 25);
}
}
public void setOverlayImage(Image image) {
this.overlayImage = image;
this.overlayImageSize = new Dimension(image.getWidth(null), image.getHeight(null));
}
if (drawSet && set != null) {
g2d.setFont(textSetFontBold);
int w = (int) (getWidth() / 2.0);
int h = (int) (getHeight() / 2.0);
int dy = overlayImage == null ? 15 : 25;
g2d.translate(w + 5, h + dy);
g2d.rotate(-Math.PI / 2.0);
g2d.drawString(set, 0, 0);
}
}
@Override
public void mouseClicked(MouseEvent e) {
}
private int calculateOffset(Graphics2D g2d) {
if (textOffsetX == -1) { // calculate once
FontRenderContext frc = g2d.getFontRenderContext();
int textWidth = (int) textFont.getStringBounds(text, frc).getWidth();
if (textWidth > buttonSize.width) {
g2d.setFont(textFontMini);
useMiniFont = true;
frc = g2d.getFontRenderContext();
textWidth = (int) textFontMini.getStringBounds(text, frc).getWidth();
}
textOffsetX = (int) ((imageSize.width - textWidth) / 2);
}
return textOffsetX;
}
@Override
public void mouseEntered(MouseEvent e) {
isHovered = true;
this.repaint();
if (onHover != null) {
onHover.execute();
}
}
public void setTextColor(Color textColor) {
this.textColor = textColor;
}
@Override
public void mouseExited(MouseEvent e) {
isHovered = false;
this.repaint();
}
public void setOverlayImage(Image image) {
this.overlayImage = image;
this.overlayImageSize = new Dimension(image.getWidth(null), image.getHeight(null));
}
@Override
public void mousePressed(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
if (isEnabled() && observer != null) {
observer.execute();
}
}
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
isHovered = true;
this.repaint();
if (onHover != null) {
onHover.execute();
}
}
public void setObserver(Command observer) {
this.observer = observer;
}
@Override
public void mouseExited(MouseEvent e) {
isHovered = false;
this.repaint();
}
public void setOnHover(Command onHover) {
this.onHover = onHover;
}
@Override
public void mousePressed(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
if (isEnabled() && observer != null) {
observer.execute();
}
}
}
@Override
public void setBounds(Rectangle r) {
super.setBounds(r);
this.textOffsetY = r.height - 2;
this.buttonSize = r;
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void setBounds(int x, int y, int width, int height) {
super.setBounds(x, y, width, height);
this.textOffsetY = height - 2;
this.buttonSize = new Rectangle(x, y, width, height);
}
public void setObserver(Command observer) {
this.observer = observer;
}
public boolean isSelected() {
return isSelected;
}
public void setOnHover(Command onHover) {
this.onHover = onHover;
}
public void setSelected(boolean isSelected) {
this.isSelected = isSelected;
}
@Override
public void setBounds(Rectangle r) {
super.setBounds(r);
this.textOffsetY = r.height - 2;
this.buttonSize = r;
}
public void changeSelected() {
this.isSelected = !this.isSelected;
}
@Override
public void setBounds(int x, int y, int width, int height) {
super.setBounds(x, y, width, height);
this.textOffsetY = height - 2;
this.buttonSize = new Rectangle(x, y, width, height);
}
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean isSelected) {
this.isSelected = isSelected;
}
public void changeSelected() {
this.isSelected = !this.isSelected;
}
public void setText(String text) {
this.text = text;
}
public void setSet(String set) {
this.set = set;
}
public void drawSet() {
this.drawSet = true;
}
}

View file

@ -60,107 +60,109 @@ import java.util.UUID;
*/
public class MageBook extends JComponent {
public MageBook(BigCard bigCard) {
super();
this.bigCard = bigCard;
initComponents();
}
public MageBook(BigCard bigCard) {
super();
this.bigCard = bigCard;
initComponents();
}
private void initComponents() {
setOpaque(false);
setSize(WIDTH, HEIGHT);
setPreferredSize(new Dimension(WIDTH, HEIGHT));
setMinimumSize(new Dimension(WIDTH, HEIGHT));
//setBorder(BorderFactory.createLineBorder(Color.green));
private void initComponents() {
setOpaque(false);
setSize(WIDTH, HEIGHT);
setPreferredSize(new Dimension(WIDTH, HEIGHT));
setMinimumSize(new Dimension(WIDTH, HEIGHT));
//setBorder(BorderFactory.createLineBorder(Color.green));
jPanelLeft = getImagePanel(LEFT_PANEL_IMAGE_PATH, ImagePanel.TILED);
jPanelLeft.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0));
jPanelLeft.setLayout(null);
jPanelCenter = getImagePanel(CENTER_PANEL_IMAGE_PATH, ImagePanel.SCALED);
jPanelCenter.setLayout(new BorderLayout());
jPanelRight = getImagePanel(RIGHT_PANEL_IMAGE_PATH, ImagePanel.TILED);
jPanelRight.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0));
jPanelRight.setLayout(null);
jPanelLeft = getImagePanel(LEFT_PANEL_IMAGE_PATH, ImagePanel.TILED);
jPanelLeft.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0));
jPanelLeft.setLayout(null);
jPanelCenter = getImagePanel(CENTER_PANEL_IMAGE_PATH, ImagePanel.SCALED);
jPanelCenter.setLayout(new BorderLayout());
jPanelRight = getImagePanel(RIGHT_PANEL_IMAGE_PATH, ImagePanel.TILED);
jPanelRight.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0));
jPanelRight.setLayout(null);
jLayeredPane = new JLayeredPane();
jPanelCenter.add(jLayeredPane, BorderLayout.CENTER);
jLayeredPane = new JLayeredPane();
jPanelCenter.add(jLayeredPane, BorderLayout.CENTER);
Image image = ImageHelper.loadImage(LEFT_PAGE_BUTTON_IMAGE_PATH);
pageLeft = new HoverButton(null, image, image, image, new Rectangle(64, 64));
pageLeft.setBounds(0, 0, 64, 64);
pageLeft.setVisible(false);
pageLeft.setObserver(new Command() {
public void execute() {
currentPage--;
if (currentPage == 0) {
pageLeft.setVisible(false);
}
pageRight.setVisible(true);
AudioManager.playPrevPage();
showCards();
}
});
Image image = ImageHelper.loadImage(LEFT_PAGE_BUTTON_IMAGE_PATH);
pageLeft = new HoverButton(null, image, image, image, new Rectangle(64, 64));
pageLeft.setBounds(0, 0, 64, 64);
pageLeft.setVisible(false);
pageLeft.setObserver(new Command() {
public void execute() {
currentPage--;
if (currentPage == 0) {
pageLeft.setVisible(false);
}
pageRight.setVisible(true);
AudioManager.playPrevPage();
showCards();
}
});
image = ImageHelper.loadImage(RIGHT_PAGE_BUTTON_IMAGE_PATH);
pageRight = new HoverButton(null, image, image, image, new Rectangle(64, 64));
pageRight.setBounds(WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH - 64, 0, 64, 64);
pageRight.setVisible(false);
pageRight.setObserver(new Command() {
public void execute() {
currentPage++;
pageLeft.setVisible(true);
pageRight.setVisible(false);
AudioManager.playNextPage();
showCards();
}
});
image = ImageHelper.loadImage(RIGHT_PAGE_BUTTON_IMAGE_PATH);
pageRight = new HoverButton(null, image, image, image, new Rectangle(64, 64));
pageRight.setBounds(WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH - 64, 0, 64, 64);
pageRight.setVisible(false);
pageRight.setObserver(new Command() {
public void execute() {
currentPage++;
pageLeft.setVisible(true);
pageRight.setVisible(false);
AudioManager.playNextPage();
showCards();
}
});
addSetTabs();
addSetTabs();
setLayout(new BorderLayout());
add(jPanelLeft, BorderLayout.LINE_START);
add(jPanelCenter, BorderLayout.CENTER);
add(jPanelRight, BorderLayout.LINE_END);
setLayout(new BorderLayout());
add(jPanelLeft, BorderLayout.LINE_START);
add(jPanelCenter, BorderLayout.CENTER);
add(jPanelRight, BorderLayout.LINE_END);
cardDimensions = new CardDimensions(0.45d);
cardDimensions = new CardDimensions(0.45d);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
showCards();
}
});
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
showCards();
}
});
}
private void addLeftRightPageButtons() {
jLayeredPane.add(pageLeft, JLayeredPane.DEFAULT_LAYER, 0);
jLayeredPane.add(pageRight, JLayeredPane.DEFAULT_LAYER, 1);
}
private void addLeftRightPageButtons() {
jLayeredPane.add(pageLeft, JLayeredPane.DEFAULT_LAYER, 0);
jLayeredPane.add(pageRight, JLayeredPane.DEFAULT_LAYER, 1);
}
private void addSetTabs() {
jPanelLeft.removeAll();
jPanelRight.removeAll();
Image image = ImageHelper.loadImage(LEFT_TAB_IMAGE_PATH);
Image imageRight = ImageHelper.loadImage(RIGHT_TAB_IMAGE_PATH);
int y = 0;
int dy = 0;
if (CardsStorage.getSetCodes().size() > 1) {
dy = (HEIGHT - 120) / (CardsStorage.getSetCodes().size() - 1) + 1;
}
int count = 0;
JPanel currentPanel = jPanelLeft;
for (String set : CardsStorage.getSetCodes()) {
HoverButton tab = new HoverButton(null, image, image, image, new Rectangle(39, 120));
Image setImage = ManaSymbols.getSetSymbolImage(set);
if (setImage != null) {
tab.setOverlayImage(setImage);
} else {
System.out.println("Couldn't find: " + "/plugins/images/sets/" + set + "-C.jpg");
}
tab.setBounds(0, y, 39, 120);
final String _set = set;
tab.setObserver(new Command() {
public void execute() {
private void addSetTabs() {
jPanelLeft.removeAll();
jPanelRight.removeAll();
Image image = ImageHelper.loadImage(LEFT_TAB_IMAGE_PATH);
Image imageRight = ImageHelper.loadImage(RIGHT_TAB_IMAGE_PATH);
int y = 0;
int dy = 0;
if (CardsStorage.getSetCodes().size() > 1) {
dy = (HEIGHT - 120) / (CardsStorage.getSetCodes().size() - 1) + 1;
}
int count = 0;
JPanel currentPanel = jPanelLeft;
HoverButton currentTab = null;
for (String set : CardsStorage.getSetCodes()) {
HoverButton tab = new HoverButton(null, image, image, image, new Rectangle(39, 120));
Image setImage = ManaSymbols.getSetSymbolImage(set);
if (setImage != null) {
tab.setOverlayImage(setImage);
} else {
System.out.println("Couldn't find: " + "/plugins/images/sets/" + set + "-C.jpg");
}
tab.setSet(set);
tab.setBounds(0, y, 39, 120);
final String _set = set;
tab.setObserver(new Command() {
public void execute() {
if (currentSet != _set || currentPage != 0) {
AudioManager.playAnotherTab();
currentPage = 0;
@ -170,149 +172,154 @@ public class MageBook extends JComponent {
addSetTabs();
showCards();
}
}
});
currentPanel.add(tab, JLayeredPane.DEFAULT_LAYER + count++, 0);
y += dy;
if (set.equals(currentSet)) {
currentPanel = jPanelRight;
image = imageRight;
}
}
jPanelLeft.revalidate();
jPanelLeft.repaint();
jPanelRight.revalidate();
jPanelRight.repaint();
}
}
});
currentPanel.add(tab, JLayeredPane.DEFAULT_LAYER + count++, 0);
y += dy;
if (set.equals(currentSet)) {
currentPanel = jPanelRight;
image = imageRight;
currentTab = tab;
}
}
jPanelLeft.revalidate();
jPanelLeft.repaint();
jPanelRight.revalidate();
jPanelRight.repaint();
if (currentTab != null) {
currentTab.drawSet();
currentTab.repaint();
}
}
private void showCards() {
jLayeredPane.removeAll();
addLeftRightPageButtons();
private void showCards() {
jLayeredPane.removeAll();
addLeftRightPageButtons();
java.util.List<Card> cards = getCards(currentPage, currentSet);
int size = cards.size();
java.util.List<Card> cards = getCards(currentPage, currentSet);
int size = cards.size();
Rectangle rectangle = new Rectangle();
rectangle.translate(OFFSET_X, OFFSET_Y);
for (int i = 0; i < Math.min(CARDS_PER_PAGE / 2, size); i++) {
addCard(new CardView(cards.get(i)), bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i, rectangle);
}
Rectangle rectangle = new Rectangle();
rectangle.translate(OFFSET_X, OFFSET_Y);
for (int i = 0; i < Math.min(CARDS_PER_PAGE / 2, size); i++) {
addCard(new CardView(cards.get(i)), bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i, rectangle);
}
// calculate the x offset of the second (right) page
int second_page_x = (WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH) -
(cardDimensions.frameWidth + CardPosition.GAP_X) * 3 + CardPosition.GAP_X - OFFSET_X;
// calculate the x offset of the second (right) page
int second_page_x = (WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH) -
(cardDimensions.frameWidth + CardPosition.GAP_X) * 3 + CardPosition.GAP_X - OFFSET_X;
rectangle.setLocation(second_page_x, OFFSET_Y);
for (int i = CARDS_PER_PAGE / 2; i < Math.min(CARDS_PER_PAGE, size); i++) {
addCard(new CardView(cards.get(i)), bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i - CARDS_PER_PAGE / 2, rectangle);
}
rectangle.setLocation(second_page_x, OFFSET_Y);
for (int i = CARDS_PER_PAGE / 2; i < Math.min(CARDS_PER_PAGE, size); i++) {
addCard(new CardView(cards.get(i)), bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i - CARDS_PER_PAGE / 2, rectangle);
}
jLayeredPane.repaint();
}
jLayeredPane.repaint();
}
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
}
final MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, false);
cardImg.setBounds(rectangle);
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
cardImg.update(card);
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight);
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
}
final MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, false);
cardImg.setBounds(rectangle);
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
cardImg.update(card);
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight);
boolean implemented = !card.getRarity().equals(mage.Constants.Rarity.NA);
boolean implemented = !card.getRarity().equals(mage.Constants.Rarity.NA);
GlowText label = new GlowText();
label.setGlow(implemented ? Color.green : NOT_IMPLEMENTED, 12, 0.0f);
label.setText(implemented ? "Implemented" : "Not implemented");
int dx = implemented ? 15 : 5;
label.setBounds(rectangle.x + dx, rectangle.y + cardDimensions.frameHeight + 7, 110, 30);
jLayeredPane.add(label);
}
GlowText label = new GlowText();
label.setGlow(implemented ? Color.green : NOT_IMPLEMENTED, 12, 0.0f);
label.setText(implemented ? "Implemented" : "Not implemented");
int dx = implemented ? 15 : 5;
label.setBounds(rectangle.x + dx, rectangle.y + cardDimensions.frameHeight + 7, 110, 30);
jLayeredPane.add(label);
}
private java.util.List<Card> getCards(int page, String set) {
int start = page * CARDS_PER_PAGE;
int end = (page + 1) * CARDS_PER_PAGE;
java.util.List<Card> cards = CardsStorage.getAllCards(start, end, currentSet, false);
if (cards.size() > CARDS_PER_PAGE) {
pageRight.setVisible(true);
}
return cards;
}
private java.util.List<Card> getCards(int page, String set) {
int start = page * CARDS_PER_PAGE;
int end = (page + 1) * CARDS_PER_PAGE;
java.util.List<Card> cards = CardsStorage.getAllCards(start, end, currentSet, false);
if (cards.size() > CARDS_PER_PAGE) {
pageRight.setVisible(true);
}
return cards;
}
private ImagePanel getImagePanel(String filename, int type) {
try {
InputStream is = this.getClass().getResourceAsStream(filename);
private ImagePanel getImagePanel(String filename, int type) {
try {
InputStream is = this.getClass().getResourceAsStream(filename);
if (is == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
}
if (is == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
}
BufferedImage background = ImageIO.read(is);
BufferedImage background = ImageIO.read(is);
if (background == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
}
if (background == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
}
return new ImagePanel(background, type);
return new ImagePanel(background, type);
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}
}
/**
* Defines the position of the next card on the mage book
*/
private static class CardPosition {
private CardPosition() {
}
/**
* Defines the position of the next card on the mage book
*/
private static class CardPosition {
private CardPosition() {
}
public static Rectangle translatePosition(int index, Rectangle r) {
Rectangle rect = new Rectangle(r);
rect.translate((cardDimensions.frameWidth + GAP_X) * dx[index],
(cardDimensions.frameHeight + GAP_Y) * dy[index]);
return rect;
}
public static Rectangle translatePosition(int index, Rectangle r) {
Rectangle rect = new Rectangle(r);
rect.translate((cardDimensions.frameWidth + GAP_X) * dx[index],
(cardDimensions.frameHeight + GAP_Y) * dy[index]);
return rect;
}
private static final int[] dx = {1, 1, -2, 1, 1, -2, 1, 1, 2, 1, -2, 1, 1, -2, 1, 1};
private static final int[] dy = {0, 0, 1, 0, 0, 1, 0, 0, -2, 0, 1, 0, 0, 1, 0, 0};
public static final int GAP_X = 17;
public static final int GAP_Y = 45;
private static int cardWidth;
private static int cardHeight;
}
private static final int[] dx = {1, 1, -2, 1, 1, -2, 1, 1, 2, 1, -2, 1, 1, -2, 1, 1};
private static final int[] dy = {0, 0, 1, 0, 0, 1, 0, 0, -2, 0, 1, 0, 0, 1, 0, 0};
public static final int GAP_X = 17;
public static final int GAP_Y = 45;
private static int cardWidth;
private static int cardHeight;
}
private JPanel jPanelLeft;
private ImagePanel jPanelCenter;
private JPanel jPanelRight;
private JLayeredPane jLayeredPane;
private BigCard bigCard;
private HoverButton pageLeft;
private HoverButton pageRight;
private JPanel jPanelLeft;
private ImagePanel jPanelCenter;
private JPanel jPanelRight;
private JLayeredPane jLayeredPane;
private BigCard bigCard;
private HoverButton pageLeft;
private HoverButton pageRight;
private int currentPage = 0;
private String currentSet = "MBS";
private int currentPage = 0;
private String currentSet = "MBS";
private static CardDimensions cardDimensions = new CardDimensions(1.2d);
private static final Logger log = Logger.getLogger(MageBook.class);
private static CardDimensions cardDimensions = new CardDimensions(1.2d);
private static final Logger log = Logger.getLogger(MageBook.class);
private Dimension cardDimension;
static private final String CENTER_PANEL_IMAGE_PATH = "/book_bg.jpg";
static private final String RIGHT_PANEL_IMAGE_PATH = "/book_right.jpg";
static private final String LEFT_PANEL_IMAGE_PATH = "/book_left.jpg";
static private final String LEFT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_left.png";
static private final String RIGHT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_right.png";
static private final String LEFT_TAB_IMAGE_PATH = "/tab_left.png";
static private final String RIGHT_TAB_IMAGE_PATH = "/tab_right.png";
static private final int CARDS_PER_PAGE = 18;
static private final int WIDTH = 950;
static private final int HEIGHT = 650;
static private final int OFFSET_X = 25;
static private final int OFFSET_Y = 20;
static private final int LEFT_RIGHT_PAGES_WIDTH = 40;
static private final Color NOT_IMPLEMENTED = new Color(220, 220, 220, 150);
static private final String CENTER_PANEL_IMAGE_PATH = "/book_bg.jpg";
static private final String RIGHT_PANEL_IMAGE_PATH = "/book_right.jpg";
static private final String LEFT_PANEL_IMAGE_PATH = "/book_left.jpg";
static private final String LEFT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_left.png";
static private final String RIGHT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_right.png";
static private final String LEFT_TAB_IMAGE_PATH = "/tab_left.png";
static private final String RIGHT_TAB_IMAGE_PATH = "/tab_right.png";
static private final int CARDS_PER_PAGE = 18;
static private final int WIDTH = 950;
static private final int HEIGHT = 650;
static private final int OFFSET_X = 25;
static private final int OFFSET_Y = 20;
static private final int LEFT_RIGHT_PAGES_WIDTH = 40;
static private final Color NOT_IMPLEMENTED = new Color(220, 220, 220, 150);
}