View Javadoc

1   package nl.tudelft.pogamut.ut2004.agent.module.shooting.util;
2   
3   import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
4   import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
5   
6   /**
7    * The focus point for a given location. Will self update.
8    * 
9    * @author mpkorstanje
10   * 
11   */
12  public final class FocusProvider implements ILocated {
13  
14  	private ILocated focus;
15  
16  	/**
17  	 * Creates a FocusProvider with a given location
18  	 * 
19  	 * @param focus
20  	 *            the focus for this FocusProvider
21  	 */
22  	public FocusProvider(ILocated focus) {
23  		super();
24  		this.focus = focus;
25  	}
26  
27  	/**
28  	 * Creates a FocusProvider with no focus.
29  	 */
30  	public FocusProvider() {
31  		this(null);
32  	}
33  
34  	/**
35  	 * @return the focus
36  	 */
37  	public ILocated getFocus() {
38  		return focus;
39  	}
40  
41  	/**
42  	 * @param focus
43  	 *            the focus to set
44  	 */
45  	public void setFocus(ILocated focus) {		
46  		this.focus = focus;
47  	}
48  
49  	/**
50  	 * The location this focus is focused on.
51  	 */
52  	@Override
53  	public Location getLocation() {
54  		if(focus == null){
55  			return null;
56  		}
57  		
58  		return focus.getLocation();
59  	}
60  
61  	/*
62  	 * (non-Javadoc)
63  	 * 
64  	 * @see java.lang.Object#toString()
65  	 */
66  	@Override
67  	public String toString() {
68  		return "FocusProvider [focus=" + focus + "]";
69  	}
70  
71  	public void clearFocus() {
72  		focus = null;
73  	}
74  
75  }