Changeset 3386 for trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization
- Timestamp:
- 04/17/10 23:50:05 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization
- Files:
-
- 1 added
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphView.cs
r3374 r3386 66 66 bool createdVisualizationInfo = false; 67 67 if (this.VisualizationInfo == null) { 68 this.VisualizationInfo = new GraphVisualizationInfo(this.Content);68 this.VisualizationInfo = new OperatorGraphVisualizationInfo(this.Content); 69 69 createdVisualizationInfo = true; 70 70 } … … 108 108 } 109 109 110 private GraphVisualizationInfo VisualizationInfo {111 get { return Content.VisualizationInfo as GraphVisualizationInfo; }110 private OperatorGraphVisualizationInfo VisualizationInfo { 111 get { return Content.VisualizationInfo as OperatorGraphVisualizationInfo; } 112 112 set { this.Content.VisualizationInfo = value; } 113 113 } … … 228 228 if (e.Effect != DragDropEffects.None) { 229 229 IOperator op = e.Data.GetData("Value") as IOperator; 230 IOperatorShapeInfo shapeInfo = Factory.CreateOperatorShapeInfo(op);230 IOperatorShapeInfo shapeInfo = OperatorShapeInfoFactory.CreateOperatorShapeInfo(op); 231 231 Point mouse = new Point(MousePosition.X, MousePosition.Y); 232 232 Point screen = this.graphVisualizationInfoView.PointToScreen(new Point(0, 0)); -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphVisualizationInfo.cs
r3374 r3386 29 29 using HeuristicLab.Collections; 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Common; 31 32 32 33 namespace HeuristicLab.Operators.Views.GraphVisualization { 33 34 [StorableClass] 34 public sealed class GraphVisualizationInfo : DeepCloneable { 35 public sealed class OperatorGraphVisualizationInfo : GraphVisualizationInfo { 36 [Storable] 35 37 private BidirectionalLookup<IOperator, IOperatorShapeInfo> operatorShapeInfoMapping; 36 [Storable]37 private BidirectionalLookup<IOperator, IOperatorShapeInfo> OperatorShapeInfoMappingStore {38 get { return this.operatorShapeInfoMapping; }39 set {40 IOperator op;41 IOperatorShapeInfo shapeInfo;42 foreach (KeyValuePair<IOperator, IOperatorShapeInfo> pair in value.FirstEnumerable) {43 op = pair.Key;44 shapeInfo = pair.Value;45 shapeInfo.Icon = new Bitmap(op.ItemImage);46 this.RegisterOperatorEvents(op);47 this.operatorParameterCollectionMapping.Add(op, pair.Key.Parameters);48 this.operatorShapeInfoMapping.Add(op, shapeInfo);49 this.shapeInfos.Add(shapeInfo);50 }51 52 foreach (IOperator oper in value.FirstValues) {53 foreach (IParameter param in oper.Parameters) {54 this.parameterOperatorMapping.Add(param, oper);55 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;56 if (opParam != null) {57 this.RegisterOperatorParameterEvents(opParam);58 shapeInfo = this.operatorShapeInfoMapping.GetByFirst(oper);59 if (opParam.Value != null) {60 this.connections.Add(new KeyValuePair<IOperatorShapeInfo, string>(shapeInfo, param.Name), this.operatorShapeInfoMapping.GetByFirst(opParam.Value));61 }62 } else63 this.RegisterParameterEvents(param);64 }65 }66 }67 }68 69 38 private BidirectionalLookup<IOperator, IObservableKeyedCollection<string, IParameter>> operatorParameterCollectionMapping; 70 39 private Dictionary<IParameter, IOperator> parameterOperatorMapping; 71 40 72 private GraphVisualizationInfo() { 41 private OperatorGraphVisualizationInfo() 42 : base() { 73 43 this.operatorShapeInfoMapping = new BidirectionalLookup<IOperator, IOperatorShapeInfo>(); 74 44 this.operatorParameterCollectionMapping = new BidirectionalLookup<IOperator, IObservableKeyedCollection<string, IParameter>>(); 75 45 this.parameterOperatorMapping = new Dictionary<IParameter, IOperator>(); 76 77 this.shapeInfos = new ObservableSet<IOperatorShapeInfo>(); 78 this.connections = new ObservableDictionary<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>(); 79 } 80 81 public GraphVisualizationInfo(OperatorGraph operatorGraph) 46 } 47 48 [StorableConstructor] 49 private OperatorGraphVisualizationInfo(bool deserializing) 50 : base() { 51 this.operatorParameterCollectionMapping = new BidirectionalLookup<IOperator, IObservableKeyedCollection<string, IParameter>>(); 52 this.parameterOperatorMapping = new Dictionary<IParameter, IOperator>(); 53 } 54 55 public OperatorGraphVisualizationInfo(OperatorGraph operatorGraph) 82 56 : this() { 83 this.OperatorGraph = operatorGraph; 57 this.operatorGraph = operatorGraph; 58 this.RegisterOperatorGraphEvents(); 84 59 85 60 foreach (IOperator op in operatorGraph.Operators) 86 if (!this.operatorShapeInfoMapping.ContainsFirst(op)) 61 if (!this.operatorShapeInfoMapping.ContainsFirst(op)) //could be added by referencing parameters 87 62 this.AddOperator(op); 88 63 … … 90 65 } 91 66 67 [StorableHook(HookType.AfterDeserialization)] 68 private void DeserializationHook() { 69 this.operatorGraph.DeserializationFinished += new EventHandler(operatorGraph_DeserializationFinished); 70 71 IOperator op; 72 IOperatorShapeInfo shapeInfo; 73 foreach (KeyValuePair<IOperator, IOperatorShapeInfo> pair in this.operatorShapeInfoMapping.FirstEnumerable) { 74 op = pair.Key; 75 shapeInfo = pair.Value; 76 shapeInfo.Icon = new Bitmap(op.ItemImage); 77 this.RegisterOperatorEvents(op); 78 this.operatorParameterCollectionMapping.Add(op, op.Parameters); 79 } 80 81 foreach (IOperator oper in this.operatorShapeInfoMapping.FirstValues) { 82 foreach (IParameter param in oper.Parameters) { 83 this.parameterOperatorMapping.Add(param, oper); 84 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 85 if (opParam != null) 86 this.RegisterOperatorParameterEvents(opParam); 87 else 88 this.RegisterParameterEvents(param); 89 } 90 } 91 } 92 93 private void operatorGraph_DeserializationFinished(object sender, EventArgs e) { 94 this.RegisterOperatorGraphEvents(); 95 if (this.operatorGraph.InitialOperator != null) { 96 IOperatorShapeInfo newInitialShapeInfo = this.operatorShapeInfoMapping.GetByFirst(this.operatorGraph.InitialOperator); 97 if (newInitialShapeInfo != null) { 98 oldInitialShapeColor = newInitialShapeInfo.Color; 99 newInitialShapeInfo.Color = Color.LightGreen; 100 } 101 oldInitialShape = this.InitialShape; 102 this.OnInitialShapeChanged(); 103 } 104 this.operatorGraph.DeserializationFinished -= new EventHandler(operatorGraph_DeserializationFinished); 105 } 106 92 107 public override IDeepCloneable Clone(Cloner cloner) { 93 GraphVisualizationInfo clone = new GraphVisualizationInfo(); 94 cloner.RegisterClonedObject(this, clone); 108 OperatorGraphVisualizationInfo clone = (OperatorGraphVisualizationInfo)base.Clone(cloner); 95 109 clone.operatorGraph = (OperatorGraph)cloner.Clone(this.operatorGraph); 110 clone.RegisterOperatorGraphEvents(); 96 111 clone.oldInitialShape = (IOperatorShapeInfo)cloner.Clone(this.oldInitialShape); 97 112 clone.oldInitialShapeColor = this.oldInitialShapeColor; … … 105 120 clone.operatorParameterCollectionMapping.Add(op, pair.Key.Parameters); 106 121 clone.operatorShapeInfoMapping.Add(op, shapeInfo); 107 clone.shapeInfos.Add(shapeInfo);108 122 } 109 123 … … 112 126 clone.parameterOperatorMapping.Add(param, oper); 113 127 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 114 if (opParam != null) {128 if (opParam != null) 115 129 clone.RegisterOperatorParameterEvents(opParam); 116 shapeInfo = clone.operatorShapeInfoMapping.GetByFirst(oper); 117 if (opParam.Value != null) { 118 clone.connections.Add(new KeyValuePair<IOperatorShapeInfo, string>(shapeInfo, param.Name), clone.operatorShapeInfoMapping.GetByFirst(opParam.Value)); 119 } 120 } else 130 else 121 131 clone.RegisterParameterEvents(param); 122 132 } 123 133 } 124 134 if (this.operatorGraph.InitialOperator != null) { 135 IOperatorShapeInfo newInitialShapeInfo = this.operatorShapeInfoMapping.GetByFirst(this.operatorGraph.InitialOperator); 136 if (newInitialShapeInfo != null) { 137 oldInitialShapeColor = newInitialShapeInfo.Color; 138 newInitialShapeInfo.Color = Color.LightGreen; 139 } 140 oldInitialShape = this.InitialShape; 141 this.OnInitialShapeChanged(); 142 } 125 143 return clone; 126 144 } 127 145 128 public event EventHandler InitialShapeChanged; 146 internal IOperator GetOperatorForShapeInfo(IOperatorShapeInfo shapeInfo) { 147 return this.operatorShapeInfoMapping.GetBySecond(shapeInfo); 148 } 149 129 150 private void operatorGraph_InitialOperatorChanged(object sender, EventArgs e) { 130 151 this.UpdateInitialShape(); … … 143 164 144 165 oldInitialShape = this.InitialShape; 145 if (this.InitialShapeChanged != null) 146 this.InitialShapeChanged(this, new EventArgs()); 147 } 148 149 [Storable] 150 private IOperatorShapeInfo oldInitialShape; 151 [Storable] 166 this.OnInitialShapeChanged(); 167 } 168 169 private IShapeInfo oldInitialShape; 152 170 private Color oldInitialShapeColor; 153 public IOperatorShapeInfo InitialShape {171 public override IShapeInfo InitialShape { 154 172 get { 155 173 IOperator op = this.operatorGraph.InitialOperator; … … 161 179 if (value == null) 162 180 this.OperatorGraph.InitialOperator = null; 163 else 164 this.OperatorGraph.InitialOperator = this.operatorShapeInfoMapping.GetBySecond(value); 165 } 166 } 167 168 181 else { 182 IOperatorShapeInfo shapeInfo = (IOperatorShapeInfo)value; 183 this.OperatorGraph.InitialOperator = this.operatorShapeInfoMapping.GetBySecond(shapeInfo); 184 } 185 } 186 } 187 188 [Storable] 169 189 private OperatorGraph operatorGraph; 170 [Storable]171 190 public OperatorGraph OperatorGraph { 172 191 get { return this.operatorGraph; } 173 private set { 174 if (this.operatorGraph != null || value == null) 175 throw new InvalidOperationException("Could not set OperatorGraph"); 176 177 this.operatorGraph = value; 178 this.operatorGraph.InitialOperatorChanged += new EventHandler(operatorGraph_InitialOperatorChanged); 179 this.operatorGraph.Operators.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsAdded); 180 this.operatorGraph.Operators.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsRemoved); 181 this.operatorGraph.Operators.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_CollectionReset); 182 } 183 } 184 185 private ObservableSet<IOperatorShapeInfo> shapeInfos; 186 public INotifyObservableCollectionItemsChanged<IOperatorShapeInfo> ObserveableShapeInfos { 187 get { return this.shapeInfos; } 188 } 189 public IEnumerable<IOperatorShapeInfo> OperatorShapeInfos { 190 get { return this.shapeInfos; } 191 } 192 public IOperator GetOperatorForShapeInfo(IOperatorShapeInfo shapeInfo) { 193 return this.operatorShapeInfoMapping.GetBySecond(shapeInfo); 194 } 195 196 private ObservableDictionary<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> connections; 197 public INotifyObservableDictionaryItemsChanged<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> ObservableConnections { 198 get { return this.connections; } 199 } 200 public IEnumerable<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>> Connections { 201 get { return this.connections; } 192 } 193 194 private void RegisterOperatorGraphEvents() { 195 this.operatorGraph.InitialOperatorChanged += new EventHandler(operatorGraph_InitialOperatorChanged); 196 this.operatorGraph.Operators.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsAdded); 197 this.operatorGraph.Operators.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsRemoved); 198 this.operatorGraph.Operators.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_CollectionReset); 199 } 200 201 private void DeregisterOperatorGraphEvents() { 202 this.operatorGraph.InitialOperatorChanged -= new EventHandler(operatorGraph_InitialOperatorChanged); 203 this.operatorGraph.Operators.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsAdded); 204 this.operatorGraph.Operators.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsRemoved); 205 this.operatorGraph.Operators.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_CollectionReset); 202 206 } 203 207 … … 215 219 } 216 220 217 internal void RemoveShapeInfo(IOperatorShapeInfo shapeInfo) { 221 public override void RemoveShapeInfo(IShapeInfo shapeInfo) { 222 IOperatorShapeInfo opShapeInfo = (IOperatorShapeInfo)shapeInfo; 223 if (this.operatorShapeInfoMapping.ContainsSecond(opShapeInfo)) { 224 IOperator op = this.operatorShapeInfoMapping.GetBySecond(opShapeInfo); 225 this.operatorGraph.Operators.Remove(op); 226 } 227 } 228 229 public override void RemoveConnectionInfo(IConnectionInfo connectionInfo) { 230 IOperatorShapeInfo shapeInfo = (IOperatorShapeInfo)connectionInfo.From; 218 231 IOperator op = this.operatorShapeInfoMapping.GetBySecond(shapeInfo); 219 this.operatorGraph.Operators.Remove(op); 220 } 221 222 internal void AddConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName, IOperatorShapeInfo shapeInfoTo) { 223 IOperator opFrom = this.operatorShapeInfoMapping.GetBySecond(shapeInfoFrom); 224 IOperator opTo = this.operatorShapeInfoMapping.GetBySecond(shapeInfoTo); 225 226 IValueParameter<IOperator> param = (IValueParameter<IOperator>)opFrom.Parameters[connectorName]; 227 param.Value = opTo; 228 } 229 230 internal void ChangeConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName, IOperatorShapeInfo shapeInfoTo) { 231 IOperator opFrom = this.operatorShapeInfoMapping.GetBySecond(shapeInfoFrom); 232 IOperator opTo = this.operatorShapeInfoMapping.GetBySecond(shapeInfoTo); 233 234 IValueParameter<IOperator> param = (IValueParameter<IOperator>)opFrom.Parameters[connectorName]; 235 param.Value = opTo; 236 } 237 238 internal void RemoveConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName) { 239 IOperator opFrom = this.operatorShapeInfoMapping.GetBySecond(shapeInfoFrom); 240 IValueParameter<IOperator> param = (IValueParameter<IOperator>)opFrom.Parameters[connectorName]; 232 IValueParameter<IOperator> param = (IValueParameter<IOperator>)op.Parameters[connectionInfo.ConnectorFrom]; 241 233 param.Value = null; 242 234 } … … 247 239 if (!this.operatorShapeInfoMapping.ContainsFirst(op)) { 248 240 this.RegisterOperatorEvents(op); 249 IOperatorShapeInfo shapeInfo = Factory.CreateOperatorShapeInfo(op);241 IOperatorShapeInfo shapeInfo = OperatorShapeInfoFactory.CreateOperatorShapeInfo(op); 250 242 this.operatorParameterCollectionMapping.Add(op, op.Parameters); 251 243 this.operatorShapeInfoMapping.Add(op, shapeInfo); … … 255 247 } 256 248 } 257 258 249 private void RemoveOperator(IOperator op) { 259 250 this.DeregisterOperatorEvents(op); … … 333 324 if (opParam != null) { 334 325 this.RegisterOperatorParameterEvents(opParam); 335 IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op);336 shapeInfo .AddConnector(param.Name);326 IOperatorShapeInfo shapeInfoFrom = this.operatorShapeInfoMapping.GetByFirst(op); 327 shapeInfoFrom.AddConnector(param.Name); 337 328 338 329 if (opParam.Value != null) { 339 330 if (!this.operatorShapeInfoMapping.ContainsFirst(opParam.Value)) 340 331 this.AddOperator(opParam.Value); 341 this.connections.Add(new KeyValuePair<IOperatorShapeInfo, string>(shapeInfo, param.Name), this.operatorShapeInfoMapping.GetByFirst(opParam.Value)); 332 IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst(opParam.Value); 333 this.connectionInfos.Add(new ConnectionInfo(shapeInfoFrom, param.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector)); 342 334 } 343 335 } else … … 350 342 this.DeregisterOperatorParameterEvents(opParam); 351 343 IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op); 352 this.connections.Remove(new KeyValuePair<IOperatorShapeInfo, string>(shapeInfo, param.Name)); 344 this.connectionInfos.RemoveWhere(c => c.From == shapeInfo && c.ConnectorFrom == param.Name); 345 this.connectionInfos.RemoveWhere(c => c.To == shapeInfo && c.ConnectorTo == param.Name); 353 346 shapeInfo.RemoveConnector(param.Name); 354 347 } else … … 360 353 private void opParam_ValueChanged(object sender, EventArgs e) { 361 354 IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)sender; 362 if (opParam != null) { 363 IOperator op = this.parameterOperatorMapping[opParam]; 364 IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op); 365 KeyValuePair<IOperatorShapeInfo, string> connectionFrom = new KeyValuePair<IOperatorShapeInfo, string>(shapeInfo, opParam.Name); 366 367 if (opParam.Value == null) 368 this.connections.Remove(connectionFrom); 369 else { 370 if (!this.operatorShapeInfoMapping.ContainsFirst(opParam.Value)) 371 this.AddOperator(opParam.Value); 372 this.connections[connectionFrom] = this.operatorShapeInfoMapping.GetByFirst(opParam.Value); 373 } 355 IOperator op = this.parameterOperatorMapping[opParam]; 356 IOperatorShapeInfo shapeInfoFrom = this.operatorShapeInfoMapping.GetByFirst(op); 357 KeyValuePair<IOperatorShapeInfo, string> connectionFrom = new KeyValuePair<IOperatorShapeInfo, string>(shapeInfoFrom, opParam.Name); 358 359 this.connectionInfos.RemoveWhere(c => c.From == shapeInfoFrom && c.ConnectorFrom == opParam.Name); 360 if (opParam.Value != null) { 361 if (!this.operatorShapeInfoMapping.ContainsFirst(opParam.Value)) 362 this.AddOperator(opParam.Value); 363 IShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst(opParam.Value); 364 this.AddConnectionInfo(new ConnectionInfo(shapeInfoFrom, opParam.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector)); 374 365 } 375 366 } -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs
r3374 r3386 29 29 using System.Windows.Forms; 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Common; 31 32 32 33 namespace HeuristicLab.Operators.Views.GraphVisualization { 33 34 [StorableClass] 34 35 internal class OperatorShapeInfo : ShapeInfo, IOperatorShapeInfo { 35 [Storable]36 private List<string> connectorNames;37 36 [Storable] 38 37 private List<string> labels; … … 57 56 58 57 public void AddConnector(string connectorName) { 59 if (!this.connectorNames.Contains(connectorName) && connectorName != "Successor") {58 if (!this.connectorNames.Contains(connectorName)) { 60 59 this.connectorNames.Add(connectorName); 61 60 this.OnChanged(); … … 73 72 this.labels = new List<string>(labels); 74 73 this.OnChanged(); 74 } 75 76 [Storable] 77 private List<string> connectorNames; 78 public override IEnumerable<string> Connectors { 79 get { return this.connectorNames; } 75 80 } 76 81 … … 163 168 public override void UpdateShape(IShape shape) { 164 169 base.UpdateShape(shape); 165 OperatorShape operatorShape = shape as OperatorShape; 166 if (operatorShape != null) { 167 operatorShape.Title = this.Title; 168 operatorShape.Color = this.Color; 169 operatorShape.LineColor = this.LineColor; 170 operatorShape.LineWidth = this.LineWidth; 171 operatorShape.Icon = this.Icon; 172 operatorShape.Collapsed = this.Collapsed; 173 174 int i = 0; 175 int j = 0; 176 //remove old connectors and skip correct connectors 177 List<string> oldConnectorNames = operatorShape.AdditionalConnectorNames.ToList(); 178 while (i < this.connectorNames.Count && j < oldConnectorNames.Count) { 179 if (this.connectorNames[i] != oldConnectorNames[j]) { 180 operatorShape.RemoveConnector(oldConnectorNames[j]); 181 } else 182 i++; 183 j++; 184 } 185 //remove remaining old connectors 186 for (; j < oldConnectorNames.Count; j++) 170 OperatorShape operatorShape = (OperatorShape)shape; 171 operatorShape.Title = this.Title; 172 operatorShape.Color = this.Color; 173 operatorShape.LineColor = this.LineColor; 174 operatorShape.LineWidth = this.LineWidth; 175 operatorShape.Icon = this.Icon; 176 operatorShape.Collapsed = this.Collapsed; 177 178 int i = 0; 179 int j = 0; 180 //remove old connectors and skip correct connectors 181 List<string> oldConnectorNames = operatorShape.AdditionalConnectorNames.ToList(); 182 while (i < this.connectorNames.Count && j < oldConnectorNames.Count) { 183 if (this.connectorNames[i] != oldConnectorNames[j]) { 187 184 operatorShape.RemoveConnector(oldConnectorNames[j]); 188 189 //add new connectors 190 for (; i < this.connectorNames.Count; i++) 191 operatorShape.AddConnector(this.connectorNames[i]); 192 193 operatorShape.UpdateLabels(this.labels); 194 } 185 } else 186 i++; 187 j++; 188 } 189 //remove remaining old connectors 190 for (; j < oldConnectorNames.Count; j++) 191 operatorShape.RemoveConnector(oldConnectorNames[j]); 192 193 //add new connectors 194 for (; i < this.connectorNames.Count; i++) 195 operatorShape.AddConnector(this.connectorNames[i]); 196 197 operatorShape.UpdateLabels(this.labels); 198 } 199 200 public override void UpdateShapeInfo(IShape shape) { 201 base.UpdateShapeInfo(shape); 202 OperatorShape operatorShape = (OperatorShape)shape; 203 this.Title = operatorShape.Title; 204 this.Color = operatorShape.Color; 205 this.LineColor = operatorShape.LineColor; 206 this.LineWidth = operatorShape.LineWidth; 207 this.Icon = operatorShape.Icon; 208 this.Collapsed = operatorShape.Collapsed; 209 210 //TODO update Connector and labels; 195 211 } 196 212 197 213 public override IDeepCloneable Clone(Cloner cloner) { 198 OperatorShapeInfo clone = (OperatorShapeInfo) 214 OperatorShapeInfo clone = (OperatorShapeInfo)base.Clone(cloner); 199 215 clone.collapsed = this.collapsed; 200 216 clone.color = this.color; … … 202 218 clone.lineWidth = this.lineWidth; 203 219 clone.title = this.title; 204 clone.icon = (Bitmap) 220 clone.icon = (Bitmap)this.icon.Clone(); 205 221 206 222 clone.connectorNames = new List<string>(this.connectorNames); -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfoFactory.cs
r3374 r3386 30 30 31 31 namespace HeuristicLab.Operators.Views.GraphVisualization { 32 public static class Factory { 33 private static LinePenStyle connectionPenStyle; 34 35 static Factory() { 36 connectionPenStyle = new LinePenStyle(); 37 connectionPenStyle.EndCap = LineCap.ArrowAnchor; 38 } 39 32 internal static class OperatorShapeInfoFactory { 33 public const string PredecessorConnector = "Predecessor"; 40 34 public static IOperatorShapeInfo CreateOperatorShapeInfo(IOperator op) { 41 IEnumerable<string> operatorParameterNames = op.Parameters.Where(p => p is IValueParameter<IOperator> && p.Name != "Successor").Select(p => p.Name);35 IEnumerable<string> operatorParameterNames = op.Parameters.Where(p => p is IValueParameter<IOperator>).Select(p => p.Name); 42 36 IEnumerable<string> paramaterNameValues = op.Parameters.Where(p => !(p is IValueParameter<IOperator>)).Select(p => p.ToString()); 43 37 44 OperatorShapeInfo operatorShapeInfo = new OperatorShapeInfo(operatorParameterNames,paramaterNameValues); 38 OperatorShapeInfo operatorShapeInfo = new OperatorShapeInfo(operatorParameterNames, paramaterNameValues); 39 operatorShapeInfo.AddConnector(PredecessorConnector); 45 40 operatorShapeInfo.Collapsed = true; 46 41 operatorShapeInfo.Title = op.Name; … … 52 47 return operatorShapeInfo; 53 48 } 54 55 public static IConnection CreateConnection(IConnector from, IConnector to) {56 Connection connection = new Connection(from.Point, to.Point);57 connection.From.AllowMove = false;58 connection.To.AllowMove = false;59 from.AttachConnector(connection.From);60 61 to.AttachConnector(connection.To);62 connection.PenStyle = connectionPenStyle;63 return connection;64 }65 49 } 66 50 }
Note: See TracChangeset
for help on using the changeset viewer.