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: Diagram.java
13   * Created: 2009-04-21
14   * Author: kpietak
15   * $Id$
16   */
17  
18  package pl.edu.agh.cast.model.visual;
19  
20  import java.util.ArrayList;
21  import java.util.List;
22  
23  import pl.edu.agh.cast.data.model.IDataSet;
24  import pl.edu.agh.cast.data.model.IElement;
25  import pl.edu.agh.cast.data.model.presentation.IPresentationDataSet;
26  import pl.edu.agh.cast.data.model.presentation.IPresentationElement;
27  import pl.edu.agh.cast.data.model.visual.IVisualDataSet;
28  import pl.edu.agh.cast.data.model.visual.IVisualElement;
29  
30  /**
31   * Abstract implementation of {@link IDiagram}. For more details see {@link IDiagram}.
32   *
33   * @param <M>
34   *            type of presentation data set which can be hold by this diagram
35   * @param <V>
36   *            type of visual data set which can be hold by this diagram
37   *
38   * @author AGH CAST Team
39   */
40  public abstract class Diagram<M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>, V extends IVisualDataSet<? extends IVisualElement<? extends IPresentationElement<? extends IElement>>, M>>
41          implements IDiagram<M, V> {
42  
43  	/**
44  	 * Presentation data set which represents diagram's model.
45  	 */
46  	protected M model;
47  
48  	private List<IDataSet<? extends IElement>> dataSets;
49  
50  	private Legend legend;
51  
52  	/**
53  	 * Constructor.
54  	 *
55  	 * @param model
56  	 *            presentation data set
57  	 */
58  	public Diagram(M model) {
59  		this.model = model;
60  		dataSets = new ArrayList<IDataSet<? extends IElement>>(2);
61  		dataSets.add(0, model);
62  		dataSets.add(1, model.getVisualDataSet());
63  		legend = new Legend();
64  	}
65  
66  	/**
67  	 *
68  	 * {@inheritDoc}
69  	 *
70  	 * @see pl.edu.agh.cast.model.visual.IDiagram#getModel()
71  	 */
72  	@Override
73  	public M getModel() {
74  		return model;
75  	}
76  
77  	/**
78  	 *
79  	 * {@inheritDoc}
80  	 *
81  	 * @see pl.edu.agh.cast.model.visual.IDiagram#getDataSets()
82  	 */
83  	public List<IDataSet<? extends IElement>> getDataSets() {
84  		return dataSets;
85  	}
86  
87  	/**
88  	 *
89  	 * {@inheritDoc}
90  	 *
91  	 * @see pl.edu.agh.cast.model.visual.IDiagram#getName()
92  	 */
93  	public String getName() {
94  		return getModel().getName();
95  	}
96  
97  	/**
98       * {@inheritDoc}
99       *
100      * @see pl.edu.agh.cast.model.visual.IDiagram#getLegend()
101      */
102     @Override
103     public Legend getLegend() {
104 	    return legend;
105     }
106 
107 }