View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: Legend.java
13   * Created: 2009-07-27
14   * Author: cast
15   * $Id$
16   */
17  
18  package pl.edu.agh.cast.model.visual;
19  
20  import java.beans.PropertyChangeListener;
21  
22  import org.eclipse.draw2d.geometry.Point;
23  
24  import pl.edu.agh.cast.data.model.property.IPropertyChangeProvider;
25  import pl.edu.agh.cast.data.model.property.PropertyChangeProviderHelper;
26  
27  /**
28   * Diagram legend.
29   * 
30   * @author AGH CAST Team
31   */
32  public class Legend implements IPropertyChangeProvider {
33  
34  	/**
35  	 * The name of the location change event.
36  	 */
37  	public static final String LOCATION_EVENT = "Legend.Location"; //$NON-NLS-1$
38  
39  	private static final int POSITION_TOP = 10;
40  
41  	private static final int POSITION_RIGHT = 500;
42  
43  	/**
44  	 * Location of the legend.
45  	 */
46  	protected Point location = new Point(2, 2);
47  
48  	/**
49  	 * The property change helper.
50  	 */
51  	private PropertyChangeProviderHelper pcpHelper = new PropertyChangeProviderHelper(this);
52  
53  	/**
54  	 * Creates new Legend.
55  	 * 
56  	 */
57  	public Legend() {
58  		super();
59  		location = new Point(POSITION_RIGHT, POSITION_TOP);
60  	}
61  
62  	public Point getLocation() {
63  		return location;
64  	}
65  
66  	public void setLocation(Point newLocation) {
67  		Point oldLocation = location;
68  		location = newLocation;
69  		pcpHelper.firePropertyChange(Legend.LOCATION_EVENT, oldLocation, newLocation);
70  	}
71  
72  	/**
73  	 * {@inheritDoc}
74  	 * 
75  	 * @see pl.edu.agh.cast.data.model.property.IPropertyChangeProvider
76  	 *      #addPropertyChangeListener(java.beans.PropertyChangeListener)
77  	 */
78  	@Override
79  	public final void addPropertyChangeListener(PropertyChangeListener l) {
80  		pcpHelper.addPropertyChangeListener(l);
81  	}
82  
83  	/**
84  	 * {@inheritDoc}
85  	 * 
86  	 * @see pl.edu.agh.cast.data.model.property.IPropertyChangeProvider
87  	 *      #removePropertyChangeListener(java.beans.PropertyChangeListener)
88  	 */
89  	@Override
90  	public final void removePropertyChangeListener(PropertyChangeListener l) {
91  		pcpHelper.removePropertyChangeListener(l);
92  	}
93  
94  }