1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Common;
|
---|
6 | using 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 |
|
---|
29 | namespace 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 | }
|
---|