Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.0/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/ConnectionInfo.cs @ 6368

Last change on this file since 6368 was 3742, checked in by gkronber, 14 years ago

Fixed GPL license headers and deleted files which are not referenced by projects. #893

File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Common;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Operators.Views.GraphVisualization {
30  [StorableClass]
31  public class ConnectionInfo : DeepCloneable, IConnectionInfo {
32    private ConnectionInfo() {
33    }
34    public ConnectionInfo(IShapeInfo from, string connectorFrom, IShapeInfo to, string connectorTo)
35      : this() {
36      if (from == to)
37        throw new ArgumentException("Could not create connections between the same shape info.");
38      if (!from.Connectors.Contains(connectorFrom) || !to.Connectors.Contains(connectorTo))
39        throw new ArgumentException("Could not create connection between not existent connectors.");
40
41      this.from = from;
42      this.connectorFrom = connectorFrom;
43      this.to = to;
44      this.connectorTo = connectorTo;
45    }
46
47    [Storable]
48    private IShapeInfo from;
49    public IShapeInfo From {
50      get { return from; }
51    }
52
53    [Storable]
54    private string connectorFrom;
55    public string ConnectorFrom {
56      get { return this.connectorFrom; }
57    }
58
59    [Storable]
60    private IShapeInfo to;
61    public IShapeInfo To {
62      get { return this.to; }
63    }
64
65    [Storable]
66    private string connectorTo;
67    public string ConnectorTo {
68      get { return this.connectorTo; }
69    }
70
71    public event EventHandler Changed;
72    protected virtual void OnChanged() {
73      EventHandler handler = this.Changed;
74      if (handler != null)
75        this.Changed(this, EventArgs.Empty);
76    }
77
78    public override  IDeepCloneable Clone(Cloner cloner) {
79      ConnectionInfo clone = (ConnectionInfo)base.Clone(cloner);
80      clone.from = (IShapeInfo)cloner.Clone(this.from);
81      clone.connectorFrom = this.ConnectorFrom;
82      clone.to = (IShapeInfo)cloner.Clone(this.To);
83      clone.connectorTo = this.ConnectorTo;
84      return clone;
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.