View Javadoc

1   /*
2    * jcurl java curling software framework http://www.jcurl.org Copyright (C)
3    * 2005-2009 M. Rohrmoser
4    * 
5    * This program is free software; you can redistribute it and/or modify it under
6    * the terms of the GNU General Public License as published by the Free Software
7    * Foundation; either version 2 of the License, or (at your option) any later
8    * 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 with
16   * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17   * Place, Suite 330, Boston, MA 02111-1307 USA
18   */
19  
20  package org.jcurl.demo.tactics;
21  
22  import java.awt.BorderLayout;
23  
24  import javax.swing.JComponent;
25  
26  import org.jcurl.demo.tactics.JCurlShotPlanner.ZoomHelper;
27  
28  import edu.umd.cs.piccolo.PCanvas;
29  import edu.umd.cs.piccolo.util.PPaintContext;
30  
31  /**
32   * Bird's eye view to {@link TrajectoryPiccoloBean}.
33   * <p>
34   * Uses {@link TrajectoryPiccoloBean#getIceLayer()}.
35   * </p>
36   * 
37   * @author <a href="mailto:m@jcurl.org">M. Rohrmoser </a>
38   * @version $Id$
39   */
40  public class BirdPiccoloBean extends JComponent {
41  
42  	private static final long serialVersionUID = -408035623675258196L;
43  	private TrajectoryPiccoloBean master;
44  	private PCanvas pc;
45  
46  	public BirdPiccoloBean() {
47  		setLayout(new BorderLayout());
48  		add(pc = new PCanvas(), BorderLayout.CENTER);
49  		pc.setAnimatingRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
50  		pc.setInteractingRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
51  		pc.setPanEventHandler(null);
52  		pc.setZoomEventHandler(null);
53  		// setEnabled(false);
54  	}
55  
56  	@Override
57  	public void doLayout() {
58  		super.doLayout();
59  		pc.getCamera().setViewBounds(ZoomHelper.HousePlus);
60  	}
61  
62  	public TrajectoryPiccoloBean getMaster() {
63  		return master;
64  	}
65  
66  	public void setMaster(final TrajectoryBean master) {
67  		if (master instanceof TrajectoryPiccoloBean) {
68  			this.master = (TrajectoryPiccoloBean) master;
69  			pc.getCamera().removeAllChildren();
70  			pc.getCamera().addLayer(this.master.getIceLayer());
71  		}
72  	}
73  }