diff options
author | Bennet Gerlach <bennet_gerlach@web.de> | 2011-05-03 20:39:21 +0200 |
---|---|---|
committer | Bennet Gerlach <bennet_gerlach@web.de> | 2011-05-03 20:39:21 +0200 |
commit | 344d63598afa6aea19e1975d4253bb11dfef6182 (patch) | |
tree | 9f1cddaf52635cbc49e1efde8b810c59c9ad9fe4 /src/jrummikub/view/impl/StoneCollectionPanel.java | |
parent | e7613bfd930290025b4c5abaf4acf63683efd5f2 (diff) | |
download | JRummikub-344d63598afa6aea19e1975d4253bb11dfef6182.tar JRummikub-344d63598afa6aea19e1975d4253bb11dfef6182.zip |
Added connector click events
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@94 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/StoneCollectionPanel.java')
-rw-r--r-- | src/jrummikub/view/impl/StoneCollectionPanel.java | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/src/jrummikub/view/impl/StoneCollectionPanel.java b/src/jrummikub/view/impl/StoneCollectionPanel.java index 8729170..9548b3b 100644 --- a/src/jrummikub/view/impl/StoneCollectionPanel.java +++ b/src/jrummikub/view/impl/StoneCollectionPanel.java @@ -20,70 +20,70 @@ import jrummikub.view.IStoneCollectionPanel; */ @SuppressWarnings("serial") class StoneCollectionPanel extends AbstractStonePanel implements - IStoneCollectionPanel { - private final static int INSET = 7; - private final static float STONE_SCALE = 1.1f; - - private Collection<Stone> selectedStones = Collections.emptyList(); - - /** - * Creates a new StoneCollection instance - */ - StoneCollectionPanel() { - super(STONE_SCALE); - - setOpaque(false); - setVisible(false); - setBorder(new EmptyBorder(INSET, INSET, INSET, INSET)); - } - - /** - * Sets the stones to be shown in the collection - * - * @param selectedStones - * the selected stones - */ - void setSelectedStones(Collection<Stone> selectedStones) { - this.selectedStones = selectedStones; - - Map<Stone, Position> stones = new HashMap<Stone, Position>(); - float x = 0; - - for (Stone stone : selectedStones) { - stones.put(stone, new Position(x, 0)); - x += stone.getWidth(); - } - - setStones(stones); - - if (selectedStones.isEmpty()) { - setVisible(false); - } else { - setSize(getStonePainter().getStoneWidth() * selectedStones.size() + 2 - * INSET, getStonePainter().getStoneHeight() + 2 * INSET); - setVisible(true); - - repaint(); - } - } - - @Override - public void paintComponent(Graphics g1) { - Insets insets = getInsets(); - int x = insets.left, y = insets.top, width = getWidth() - insets.left - - insets.right, height = getHeight() - insets.top - insets.bottom; - Graphics2D g = (Graphics2D) g1.create(x, y, width, height); - - if (!selectedStones.isEmpty()) { - g1.setColor(new Color(0, 0, 0, 0.25f)); - g1.fillRoundRect(0, 0, getWidth(), getHeight(), INSET, INSET); - - float xpos = 0; - - for (Stone stone : selectedStones) { - getStonePainter().paintStone(g, stone, new Position(xpos, 0), false); - xpos++; - } - } - } + IStoneCollectionPanel { + private final static int INSET = 7; + private final static float STONE_SCALE = 1.1f; + + private Collection<Stone> selectedStones = Collections.emptyList(); + + /** + * Creates a new StoneCollection instance + */ + StoneCollectionPanel() { + super(STONE_SCALE); + + setOpaque(false); + setVisible(false); + setBorder(new EmptyBorder(INSET, INSET, INSET, INSET)); + } + + /** + * Sets the stones to be shown in the collection + * + * @param selectedStones + * the selected stones + */ + void setSelectedStones(Collection<Stone> selectedStones) { + this.selectedStones = selectedStones; + + Map<Stone, Position> stones = new HashMap<Stone, Position>(); + float x = 0; + + for (Stone stone : selectedStones) { + stones.put(stone, new Position(x, 0)); + x++; + } + + setStones(stones); + + if (selectedStones.isEmpty()) { + setVisible(false); + } else { + setSize(getStonePainter().getStoneWidth() * selectedStones.size() + 2 + * INSET, getStonePainter().getStoneHeight() + 2 * INSET); + setVisible(true); + + repaint(); + } + } + + @Override + public void paintComponent(Graphics g1) { + Insets insets = getInsets(); + int x = insets.left, y = insets.top, width = getWidth() - insets.left + - insets.right, height = getHeight() - insets.top - insets.bottom; + Graphics2D g = (Graphics2D) g1.create(x, y, width, height); + + if (!selectedStones.isEmpty()) { + g1.setColor(new Color(0, 0, 0, 0.25f)); + g1.fillRoundRect(0, 0, getWidth(), getHeight(), INSET, INSET); + + float xpos = 0; + + for (Stone stone : selectedStones) { + getStonePainter().paintStone(g, stone, new Position(xpos, 0), false); + xpos++; + } + } + } } |