View Javadoc

1   /*
2    *   Magic-Project is a turn based strategy simulator
3    *   Copyright (C) 2003-2007 Fabrice Daugan
4    *
5    *   This program is free software; you can redistribute it and/or modify it 
6    * under the terms of the GNU General Public License as published by the Free 
7    * Software Foundation; either version 2 of the License, or (at your option) any
8    * later version.
9    *
10   *   This program is distributed in the hope that it will be useful, but WITHOUT 
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
13   * details.
14   *
15   *   You should have received a copy of the GNU General Public License along  
16   * with this program; if not, write to the Free Software Foundation, Inc., 
17   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   * 
19   */
20  package net.sf.magicproject.zone;
21  
22  import java.awt.FlowLayout;
23  import java.awt.event.HierarchyBoundsListener;
24  import java.awt.event.HierarchyEvent;
25  
26  import javax.swing.JScrollPane;
27  
28  import net.sf.magicproject.clickable.targetable.card.DelayedCard;
29  import net.sf.magicproject.clickable.targetable.card.MCard;
30  import net.sf.magicproject.token.IdZones;
31  import net.sf.magicproject.token.Visibility;
32  import net.sf.magicproject.ui.component.TableTop;
33  
34  /***
35   * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
36   * @since 0.80
37   */
38  public class DelayedBuffer extends MZone {
39  
40  	/***
41  	 * The zone name.
42  	 */
43  	public static final String ZONE_NAME = "dbz";
44  
45  	/***
46  	 * create a new instance of DelayedBuffer
47  	 * 
48  	 * @param superPanel
49  	 *          scroll panel containing this panel
50  	 * @param you
51  	 *          is this zone is controlled by you.
52  	 * @since 0.3 feature "reverseImage" implemented
53  	 * @since 0.80 feature "reverseImage" removed, since this panel has been moved
54  	 *        in a JTabbedPanel with the stack
55  	 * @see IdZones
56  	 */
57  	DelayedBuffer(JScrollPane superPanel, boolean you) {
58  		super(IdZones.DELAYED, new FlowLayout(FlowLayout.LEFT, 2, 2), superPanel,
59  				!you, ZONE_NAME);
60  		this.you = you;
61  		this.reverseImage = false;
62  		addHierarchyBoundsListener(new HierarchyBoundsListener() {
63  
64  			public void ancestorMoved(HierarchyEvent evt) {
65  				// Ignore this event
66  			}
67  
68  			public void ancestorResized(HierarchyEvent evt) {
69  				updatePanel();
70  			}
71  		});
72  		visibility = Visibility.PUBLIC;
73  	}
74  
75  	@Override
76  	public void updatePanel() {
77  		// superPanel.setViewportView(this);
78  		// setPreferredSize(getLayout().preferredLayoutSize(this));
79  	}
80  
81  	/***
82  	 * Add a delayed ability to this zone
83  	 * 
84  	 * @param delayed
85  	 *          the delayed to add
86  	 */
87  	public void add(DelayedCard delayed) {
88  		super.add(delayed);
89  		updatePanel();
90  	}
91  
92  	@Override
93  	public int getControllerIdPlayer() {
94  		return you ? 0 : 1;
95  	}
96  
97  	@Override
98  	public void disHighLight() {
99  		TableTop.getInstance().tabbedPane.setBackgroundAt(
100 				TableTop.getInstance().tabbedPane.indexOfComponent(superPanel), null);
101 	}
102 
103 	@Override
104 	public boolean isMustBePaintedReversed(MCard card) {
105 		return false;
106 	}
107 
108 	/***
109 	 * is this zone is controlled by you.
110 	 */
111 	private boolean you;
112 }