View Javadoc

1   /*
2    * @(#) AddColumnAction.java Oct 29, 2003
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.dsol.gui.statistics.actions;
11  
12  import java.awt.event.ActionEvent;
13  
14  import javax.swing.AbstractAction;
15  import javax.swing.Action;
16  import javax.swing.ImageIcon;
17  
18  import nl.tudelft.simulation.dsol.gui.statistics.ChartPanel;
19  import nl.tudelft.simulation.language.io.URLResource;
20  
21  /***
22   * AddColumnAction <br>
23   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
24   * University of Technology </a>, the Netherlands. <br>
25   * See for project information <a href="http://www.simulation.tudelft.nl">
26   * www.simulation.tudelft.nl </a> <br>
27   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
28   * License (GPL) </a>, no warranty <br>
29   * 
30   * @version 1.1 05.11.2003 <br>
31   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
32   *         Jacobs </a>
33   */
34  public class AddColumnAction extends AbstractAction
35  {
36  	/*** target of the chartpanel */
37  	private ChartPanel target = null;
38  
39  	/***
40  	 * constructs a new AddColumnAction
41  	 * 
42  	 * @param target the target
43  	 */
44  	public AddColumnAction(final ChartPanel target)
45  	{
46  		super("AddColumn");
47  		this.target = target;
48  		this
49  				.putValue(
50  						Action.SMALL_ICON,
51  						new ImageIcon(
52  								URLResource
53  										.getResource("/toolbarButtonGraphics/table/ColumnInsertAfter24.gif")));
54  		this.setEnabled(true);
55  	}
56  
57  	/***
58  	 * @see java.awt.event.ActionListener
59  	 *      #actionPerformed(java.awt.event.ActionEvent)
60  	 */
61  	public void actionPerformed(final ActionEvent actionEvent)
62  	{
63  		new Worker(this.target).start();
64  	}
65  
66  	/*** SimulatorRunThread extends Thread */
67  	private class Worker extends Thread
68  	{
69  		/*** the source */
70  		private ChartPanel target = null;
71  
72  		/***
73  		 * constructs a new
74  		 * 
75  		 * @param target the target
76  		 */
77  		public Worker(final ChartPanel target)
78  		{
79  			this.target = target;
80  		}
81  
82  		/***
83  		 * @see java.lang.Runnable#run()
84  		 */
85  		public void run()
86  		{
87  			synchronized (this.target)
88  			{
89  				this.target.addColumn();
90  			}
91  		}
92  	}
93  }