- Timestamp:
- 11/06/10 01:56:04 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/CloningRefactoring (added) merged: 4656-4693,4696-4697,4711-4714,4718-4719
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/BidirectionalLookup.cs
r4068 r4722 31 31 [Storable] 32 32 private Dictionary<TSecond, TFirst> secondToFirst; 33 34 [StorableConstructor] 35 protected BidirectionalLookup(bool deserializing) : base() { } 33 36 34 37 public BidirectionalLookup() { -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/ConnectionInfo.cs
r4068 r4722 28 28 [StorableClass] 29 29 public class ConnectionInfo : DeepCloneable, IConnectionInfo { 30 private ConnectionInfo() { 30 [StorableConstructor] 31 protected ConnectionInfo(bool deserializing) : base() { } 32 protected ConnectionInfo(ConnectionInfo original, Cloner cloner) 33 : base(original, cloner) { 34 from = cloner.Clone(original.from); 35 connectorFrom = original.ConnectorFrom; 36 to = cloner.Clone(original.To); 37 connectorTo = original.ConnectorTo; 38 } 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new ConnectionInfo(this, cloner); 31 41 } 32 42 public ConnectionInfo(IShapeInfo from, string connectorFrom, IShapeInfo to, string connectorTo) 33 : this() {43 : base() { 34 44 if (from == to) 35 45 throw new ArgumentException("Could not create connections between the same shape info."); … … 70 80 protected virtual void OnChanged() { 71 81 EventHandler handler = this.Changed; 72 if (handler != null) 73 this.Changed(this, EventArgs.Empty); 74 } 75 76 public override IDeepCloneable Clone(Cloner cloner) { 77 ConnectionInfo clone = (ConnectionInfo)base.Clone(cloner); 78 clone.from = (IShapeInfo)cloner.Clone(this.from); 79 clone.connectorFrom = this.ConnectorFrom; 80 clone.to = (IShapeInfo)cloner.Clone(this.To); 81 clone.connectorTo = this.ConnectorTo; 82 return clone; 82 if (handler != null) this.Changed(this, EventArgs.Empty); 83 83 } 84 84 } -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/GraphVisualizationInfo.cs
r4068 r4722 30 30 [StorableClass] 31 31 public class GraphVisualizationInfo : DeepCloneable, IGraphVisualizationInfo { 32 public GraphVisualizationInfo() { 32 [StorableConstructor] 33 protected GraphVisualizationInfo(bool deserializing) : base() { } 34 protected GraphVisualizationInfo(GraphVisualizationInfo original, Cloner cloner) 35 : base(original, cloner) { 36 shapeInfos = new ObservableSet<IShapeInfo>(original.shapeInfos.Select(x => cloner.Clone(x))); 37 connectionInfos = new ObservableSet<IConnectionInfo>(original.connectionInfos.Select(x => cloner.Clone(x))); 38 initialShape = cloner.Clone(original.initialShape); 39 } 40 public override IDeepCloneable Clone(Cloner cloner) { 41 return new GraphVisualizationInfo(this, cloner); 42 } 43 public GraphVisualizationInfo() 44 : base() { 33 45 this.shapeInfos = new ObservableSet<IShapeInfo>(); 34 46 this.connectionInfos = new ObservableSet<IConnectionInfo>(); … … 96 108 } 97 109 #endregion 98 99 public override IDeepCloneable Clone(Cloner cloner) {100 GraphVisualizationInfo clone = (GraphVisualizationInfo)base.Clone(cloner);101 clone.shapeInfos = new ObservableSet<IShapeInfo>(this.shapeInfos.Select(x => (IShapeInfo)cloner.Clone(x)));102 clone.connectionInfos = new ObservableSet<IConnectionInfo>(this.connectionInfos.Select(x => (IConnectionInfo)cloner.Clone(x)));103 if (this.initialShape != null)104 clone.initialShape = (IShapeInfo)this.initialShape.Clone(cloner);105 return clone;106 }107 110 } 108 111 } -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/ShapeInfo.cs
r4068 r4722 30 30 [StorableClass] 31 31 public abstract class ShapeInfo : DeepCloneable, IShapeInfo { 32 private ShapeInfo() { 32 [StorableConstructor] 33 protected ShapeInfo(bool deserializing) : base() { } 34 protected ShapeInfo(ShapeInfo original, Cloner cloner) 35 : base(original, cloner) { 36 shapeType = original.shapeType; 37 location = original.location; 33 38 } 34 39 … … 62 67 protected virtual void OnChanged() { 63 68 EventHandler handler = this.Changed; 64 if (handler != null) 65 this.Changed(this, EventArgs.Empty); 69 if (handler != null) this.Changed(this, EventArgs.Empty); 66 70 } 67 71 … … 80 84 this.Location = shape.Location; 81 85 } 82 83 public override IDeepCloneable Clone(Cloner cloner) {84 ShapeInfo clone = (ShapeInfo)base.Clone(cloner);85 clone.shapeType = this.shapeType;86 clone.location = this.location;87 return clone;88 }89 86 } 90 87 } -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphVisualizationInfo.cs
r4068 r4722 46 46 [StorableConstructor] 47 47 private OperatorGraphVisualizationInfo(bool deserializing) 48 : base( ) {48 : base(deserializing) { 49 49 this.operatorParameterCollectionMapping = new BidirectionalLookup<IOperator, IKeyedItemCollection<string, IParameter>>(); 50 50 this.parameterOperatorMapping = new Dictionary<IParameter, IOperator>(); 51 } 52 private OperatorGraphVisualizationInfo(OperatorGraphVisualizationInfo original, Cloner cloner) 53 : base(original, cloner) { 54 operatorShapeInfoMapping = new BidirectionalLookup<IOperator, IOperatorShapeInfo>(); 55 operatorParameterCollectionMapping = new BidirectionalLookup<IOperator, IKeyedItemCollection<string, IParameter>>(); 56 parameterOperatorMapping = new Dictionary<IParameter, IOperator>(); 57 58 operatorGraph = cloner.Clone(original.operatorGraph); 59 RegisterOperatorGraphEvents(); 60 oldInitialShape = cloner.Clone(original.oldInitialShape); 61 oldInitialShapeColor = original.oldInitialShapeColor; 62 63 foreach (KeyValuePair<IOperator, IOperatorShapeInfo> pair in original.operatorShapeInfoMapping.FirstEnumerable) { 64 IOperator op = cloner.Clone(pair.Key); 65 IOperatorShapeInfo shapeInfo = cloner.Clone(pair.Value); 66 RegisterOperatorEvents(op); 67 operatorParameterCollectionMapping.Add(op, pair.Key.Parameters); 68 operatorShapeInfoMapping.Add(op, shapeInfo); 69 } 70 71 foreach (IOperator oper in operatorShapeInfoMapping.FirstValues) { 72 foreach (IParameter param in oper.Parameters) { 73 parameterOperatorMapping.Add(param, oper); 74 IValueParameter opParam = param as IValueParameter; 75 if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) 76 RegisterOperatorParameterEvents(opParam); 77 else 78 RegisterParameterEvents(param); 79 } 80 } 81 if (original.operatorGraph.InitialOperator != null) { 82 IOperatorShapeInfo newInitialShapeInfo = original.operatorShapeInfoMapping.GetByFirst(original.operatorGraph.InitialOperator); 83 if (newInitialShapeInfo != null) { 84 oldInitialShapeColor = newInitialShapeInfo.Color; 85 newInitialShapeInfo.Color = Color.LightGreen; 86 } 87 oldInitialShape = InitialShape; 88 OnInitialShapeChanged(); 89 } 90 } 91 public override IDeepCloneable Clone(Cloner cloner) { 92 return new OperatorGraphVisualizationInfo(this, cloner); 51 93 } 52 94 … … 64 106 65 107 [StorableHook(HookType.AfterDeserialization)] 66 private void DeserializationHook() {108 private void AfterDeserialization() { 67 109 this.operatorGraph.DeserializationFinished += new EventHandler(operatorGraph_DeserializationFinished); 68 110 … … 101 143 } 102 144 this.operatorGraph.DeserializationFinished -= new EventHandler(operatorGraph_DeserializationFinished); 103 }104 105 public override IDeepCloneable Clone(Cloner cloner) {106 OperatorGraphVisualizationInfo clone = (OperatorGraphVisualizationInfo)base.Clone(cloner);107 clone.operatorGraph = (OperatorGraph)cloner.Clone(this.operatorGraph);108 clone.RegisterOperatorGraphEvents();109 clone.oldInitialShape = (IOperatorShapeInfo)cloner.Clone(this.oldInitialShape);110 clone.oldInitialShapeColor = this.oldInitialShapeColor;111 112 IOperator op;113 IOperatorShapeInfo shapeInfo;114 foreach (KeyValuePair<IOperator, IOperatorShapeInfo> pair in this.operatorShapeInfoMapping.FirstEnumerable) {115 op = (IOperator)cloner.Clone(pair.Key);116 shapeInfo = (IOperatorShapeInfo)cloner.Clone(pair.Value);117 clone.RegisterOperatorEvents(op);118 clone.operatorParameterCollectionMapping.Add(op, pair.Key.Parameters);119 clone.operatorShapeInfoMapping.Add(op, shapeInfo);120 }121 122 foreach (IOperator oper in clone.operatorShapeInfoMapping.FirstValues) {123 foreach (IParameter param in oper.Parameters) {124 clone.parameterOperatorMapping.Add(param, oper);125 IValueParameter opParam = param as IValueParameter;126 if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType))127 clone.RegisterOperatorParameterEvents(opParam);128 else129 clone.RegisterParameterEvents(param);130 }131 }132 if (this.operatorGraph.InitialOperator != null) {133 IOperatorShapeInfo newInitialShapeInfo = this.operatorShapeInfoMapping.GetByFirst(this.operatorGraph.InitialOperator);134 if (newInitialShapeInfo != null) {135 oldInitialShapeColor = newInitialShapeInfo.Color;136 newInitialShapeInfo.Color = Color.LightGreen;137 }138 oldInitialShape = this.InitialShape;139 this.OnInitialShapeChanged();140 }141 return clone;142 145 } 143 146 -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs
r4068 r4722 32 32 [Storable] 33 33 private List<string> labels; 34 35 [StorableConstructor] 36 protected OperatorShapeInfo(bool deserializing) : base(deserializing) { } 37 protected OperatorShapeInfo(OperatorShapeInfo original, Cloner cloner) 38 : base(original, cloner) { 39 collapsed = original.collapsed; 40 color = original.color; 41 lineColor = original.lineColor; 42 lineWidth = original.lineWidth; 43 title = original.title; 44 if (original.icon != null) icon = (Bitmap)original.icon.Clone(); 45 46 connectorNames = new List<string>(original.connectorNames); 47 labels = new List<string>(original.labels); 48 } 49 public override IDeepCloneable Clone(Cloner cloner) { 50 return new OperatorShapeInfo(this, cloner); 51 } 34 52 35 53 public OperatorShapeInfo() … … 216 234 //TODO update Connector and labels; 217 235 } 218 219 public override IDeepCloneable Clone(Cloner cloner) {220 OperatorShapeInfo clone = (OperatorShapeInfo)base.Clone(cloner);221 clone.collapsed = this.collapsed;222 clone.color = this.color;223 clone.lineColor = this.lineColor;224 clone.lineWidth = this.lineWidth;225 clone.title = this.title;226 clone.icon = (Bitmap)this.icon.Clone();227 228 clone.connectorNames = new List<string>(this.connectorNames);229 clone.labels = new List<string>(this.labels);230 231 return clone;232 }233 236 } 234 237 }
Note: See TracChangeset
for help on using the changeset viewer.