aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/equalparts/cardbase/gui/CardView.java
blob: 2ec7576120b919dbec76682432b655db77950cf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package eu.equalparts.cardbase.gui;

import eu.equalparts.cardbase.cards.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<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				setVisible(false);
			}
		});
		
	}

	public static String makeUrl(Card card) {
		return BASE_IMG_URL + card.imageCode + "/" + card.number + ".jpg";
	}
	
}