From 231906701e8cf5b00058e23e6a666a2f9a3e566e Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Thu, 18 Jun 2015 18:11:31 +0200 Subject: GUI is under way, 1.0 release --- src/eu/equalparts/cardbase/gui/CardImageView.java | 18 ----- src/eu/equalparts/cardbase/gui/CardView.java | 29 ++++++++ src/eu/equalparts/cardbase/gui/CardbaseGUI.java | 83 +++++++++++++++++------ src/eu/equalparts/cardbase/utils/MTGUniverse.java | 4 +- 4 files changed, 94 insertions(+), 40 deletions(-) delete mode 100644 src/eu/equalparts/cardbase/gui/CardImageView.java create mode 100644 src/eu/equalparts/cardbase/gui/CardView.java (limited to 'src/eu/equalparts') diff --git a/src/eu/equalparts/cardbase/gui/CardImageView.java b/src/eu/equalparts/cardbase/gui/CardImageView.java deleted file mode 100644 index 7c79c6a..0000000 --- a/src/eu/equalparts/cardbase/gui/CardImageView.java +++ /dev/null @@ -1,18 +0,0 @@ -package eu.equalparts.cardbase.gui; - -import eu.equalparts.cardbase.data.Card; -import javafx.scene.image.ImageView; - -public class CardImageView extends ImageView { - - private static final String BASE_IMG_URL = "http://magiccards.info/scans/en/"; - - public CardImageView(Card card) { - super(makeUrl(card)); - } - - public static String makeUrl(Card card) { - return BASE_IMG_URL + card.imageCode + "/" + card.number + ".jpg"; - } - -} diff --git a/src/eu/equalparts/cardbase/gui/CardView.java b/src/eu/equalparts/cardbase/gui/CardView.java new file mode 100644 index 0000000..61504ee --- /dev/null +++ b/src/eu/equalparts/cardbase/gui/CardView.java @@ -0,0 +1,29 @@ +package eu.equalparts.cardbase.gui; + +import eu.equalparts.cardbase.data.Card; +import javafx.event.EventHandler; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; + +public class CardView extends ImageView { + + private static final String BASE_IMG_URL = "http://magiccards.info/scans/en/"; + + public CardView(Card card) { + super(makeUrl(card)); + + addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() { + + @Override + public void handle(MouseEvent event) { + setVisible(false); + } + }); + + } + + public static String makeUrl(Card card) { + return BASE_IMG_URL + card.imageCode + "/" + card.number + ".jpg"; + } + +} diff --git a/src/eu/equalparts/cardbase/gui/CardbaseGUI.java b/src/eu/equalparts/cardbase/gui/CardbaseGUI.java index 46d3c55..bbbb97c 100644 --- a/src/eu/equalparts/cardbase/gui/CardbaseGUI.java +++ b/src/eu/equalparts/cardbase/gui/CardbaseGUI.java @@ -1,14 +1,14 @@ package eu.equalparts.cardbase.gui; -import javafx.application.Application; -import javafx.scene.Scene; -import javafx.scene.image.ImageView; -import javafx.scene.layout.Pane; -import javafx.stage.Stage; -import eu.equalparts.cardbase.data.Card; -import eu.equalparts.cardbase.utils.MTGUniverse; +import java.awt.Button; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; -public class CardbaseGUI extends Application { + +@SuppressWarnings("serial") +public class CardbaseGUI extends Panel { /** * Run the GUI. @@ -16,21 +16,64 @@ public class CardbaseGUI extends Application { * @param args arguments passed down to {@code Application.launch()}. */ public static void main(String... args) { - launch(args); - } - - @Override - public void start(Stage primaryStage) throws Exception { - Card card = MTGUniverse.getCard("M15", "281"); - ImageView test = new ImageView(CardImageView.makeUrl(card)); + Frame f = new Frame("Test"); - Pane parent = new Pane(); + CardbaseGUI c = new CardbaseGUI(); - parent.getChildren().add(test); + f.add(c); + f.pack(); - primaryStage.setScene(new Scene(parent)); + f.addWindowListener(new WindowListener() { + @Override + public void windowOpened(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowIconified(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowDeiconified(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowDeactivated(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowClosing(WindowEvent e) { + System.exit(0); + } + + @Override + public void windowClosed(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowActivated(WindowEvent e) { + // TODO Auto-generated method stub + + } + }); - primaryStage.setTitle("Cardbase"); - primaryStage.show(); + f.setVisible(true); + } + + + public void init() { + add(new Button("one")); + add(new Button("two")); } + + } diff --git a/src/eu/equalparts/cardbase/utils/MTGUniverse.java b/src/eu/equalparts/cardbase/utils/MTGUniverse.java index 51959aa..b52c3e6 100644 --- a/src/eu/equalparts/cardbase/utils/MTGUniverse.java +++ b/src/eu/equalparts/cardbase/utils/MTGUniverse.java @@ -21,9 +21,9 @@ import eu.equalparts.cardbase.data.FullCardSet; * MTG universe. This class has a series of utility functions that * query remote databases to acquire card information. *
- * Conversely, {@code CardbaseManager}'s methods are used solely to + * Conversely, {@code Cardbase}'s methods are used solely to * acquire information regarding the loaded cardbase, which will - * most likely contain only a subset of the MTG universe. + * most likely contain only a subset of the MTG universe of cards. * * @author Eduardo Pedroni */ -- cgit v1.2.3