View Javadoc

1   /*
2    * @(#)ProgressDataAndTime.java Jun 8, 2004
3    * 
4    * 
5    * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
6    * Delft, the Netherlands. All rights reserved.
7    * 
8    * See for project information <a href="http://www.simulation.tudelft.nl/">
9    * www.simulation.tudelft.nl </a>.
10   * 
11   * The source code and binary code of this software is proprietary information
12   * of Delft University of Technology.
13   */
14  
15  package org.gscg.common.interactionlayer.timecontrol;
16  
17  import java.rmi.RemoteException;
18  
19  import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
20  import nl.tudelft.simulation.event.Event;
21  import nl.tudelft.simulation.event.EventListenerInterface;
22  import nl.tudelft.simulation.event.EventProducer;
23  import nl.tudelft.simulation.event.EventType;
24  import nl.tudelft.simulation.logger.Logger;
25  
26  import org.gscg.common.interactionlayer.AnnounceInterface;
27  import org.gscg.common.interactionlayer.dataobjects.ProgressionData;
28  import org.gscg.singleuser.interactionlayer.SingleUserInteractionLayerInterface;
29  
30  /***
31   * The ProgressDataAndTime object manages the client-side ProgressPanel and
32   * ProgressIndicator panels.
33   * 
34   * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
35   * Delft, the Netherlands. All rights reserved.
36   * 
37   * See for project information <a href="http://www.simulation.tudelft.nl/">
38   * www.simulation.tudelft.nl </a>.
39   * 
40   * The source code and binary code of this software is proprietary information
41   * of Delft University of Technology.
42   * 
43   * @author <a
44   *         href="http://www.tbm.tudelft.nl/webstaf/stijnh/index.htm">Stijn-Pieter
45   *         van Houten </a>
46   * @version $Revision: 1.2 $ $Date: 2005/08/09 15:43:42 $
47   * @since 1.1.1
48   * 
49   */
50  public class ProgressDateAndTime extends EventProducer implements
51  		AnnounceInterface
52  {
53  	/*** the serial version uid */
54  	private static final long serialVersionUID = 11L;
55  
56  	/*** the owner */
57  	private EventListenerInterface owner = null;
58  
59  	/***
60  	 * constructs a new SimulationDateTime
61  	 * 
62  	 * @param owner the owner
63  	 */
64  	public ProgressDateAndTime(final EventListenerInterface owner)
65  	{
66  		super();
67  		this.owner = owner;
68  
69  		GlobalProgressDateAndTime.getStaticProgressDateAndTime()
70  				.getCustomEventProducer().addListener(owner,
71  						SimulatorInterface.TIME_CHANGED_EVENT);
72  
73  		// add the announce event
74  		if (SingleUserInteractionLayerInterface.class.isAssignableFrom(owner
75  				.getClass()))
76  		{
77  			try
78  			{
79  				((SingleUserInteractionLayerInterface) this.owner)
80  						.addEventType(SimulatorInterface.TIME_CHANGED_EVENT);
81  				((SingleUserInteractionLayerInterface) this.owner)
82  						.addEventTypeToAnnounceList(
83  								SimulatorInterface.TIME_CHANGED_EVENT, this);
84  			} catch (RemoteException remoteException)
85  			{
86  				Logger.severe(this, "<init>", remoteException);
87  			}
88  		}
89  	}
90  
91  	/***
92  	 * @see org.gscg.common.interactionlayer.AnnounceInterface#announce(nl.tudelft.simulation.event.EventType,
93  	 *      boolean)
94  	 */
95  	public void announce(final EventType eventType, final boolean announce)
96  	{
97  		ProgressionData data = new ProgressionData(GlobalProgressDateAndTime
98  				.getDate(), GlobalProgressDateAndTime.getTime(),
99  				GlobalProgressDateAndTime.getStopTime(),
100 				GlobalProgressDateAndTime.getProgress(),
101 				GlobalProgressDateAndTime.getProgressTime());
102 		try
103 		{
104 			((SingleUserInteractionLayerInterface) this.owner)
105 					.notifyAnnounced(new Event(
106 							SimulatorInterface.TIME_CHANGED_EVENT, this, data));
107 		} catch (RemoteException remoteException)
108 		{
109 			Logger.severe(this, "announce", remoteException);
110 		}
111 	}
112 }