Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/ConnectionInfo.cs @ 3580

Last change on this file since 3580 was 3386, checked in by mkommend, 15 years ago

completly refactored the graph visualization (ticket #867)

File size: 2.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Common;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7
8#region License Information
9/* HeuristicLab
10 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
11 *
12 * This file is part of HeuristicLab.
13 *
14 * HeuristicLab is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * HeuristicLab is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
26 */
27#endregion
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.