View Javadoc

1   /*
2    * jcurl java curling software framework https://JCurl.mro.name 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  import java.awt.geom.AffineTransform;
24  
25  import javax.swing.JComponent;
26  
27  import org.jcurl.demo.tactics.JCurlShotPlanner.ZoomHelper;
28  import org.jcurl.demo.tactics.sg.AnimateAffine;
29  
30  import com.sun.scenario.scenegraph.JSGPanel;
31  import com.sun.scenario.scenegraph.SGGroup;
32  import com.sun.scenario.scenegraph.SGTransform;
33  import com.sun.scenario.scenegraph.SGTransform.Affine;
34  
35  /**
36   * Bird's eye view to {@link TrajectoryPiccoloBean}.
37   * <p>
38   * Uses {@link TrajectoryPiccoloBean#getIceLayer()}.
39   * </p>
40   * 
41   * @author <a href="mailto:JCurl@mro.name">M. Rohrmoser </a>
42   * @version $Id$
43   */
44  public class BirdScenarioBean extends JComponent {
45  
46  	private static final long serialVersionUID = -408035623675258196L;
47  	private TrajectoryScenarioBean master;
48  	private final JSGPanel pc;
49  	private final SGGroup scene = new SGGroup();
50  	private final Affine zoom = SGTransform.createAffine(new AffineTransform(),
51  			scene);
52  
53  	public BirdScenarioBean() {
54  		pc = new JSGPanel();
55  		setLayout(new BorderLayout());
56  		add(pc, BorderLayout.CENTER);
57  		pc.setScene(zoom);
58  		// setEnabled(false);
59  	}
60  
61  	/** keep the recent viewport visible */
62  	@Override
63  	public void doLayout() {
64  	// super.doLayout();
65  	}
66  
67  	public TrajectoryScenarioBean getMaster() {
68  		return master;
69  	}
70  
71  	public void setMaster(final TrajectoryBean master) {
72  		if (master instanceof TrajectoryScenarioBean) {
73  			this.master = (TrajectoryScenarioBean) master;
74  			for (int i = scene.getChildren().size() - 1; i >= 0; i--)
75  				scene.remove(i);
76  			// scene.add(this.master.getDc2Wc());
77  
78  			zoom.setAffine(AnimateAffine.map(ZoomHelper.HousePlus, this
79  					.getBounds(), zoom.getAffine()));
80  		}
81  	}
82  }