Changeset 6036 for trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs
- Timestamp:
- 04/21/11 17:16:50 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs
r6031 r6036 22 22 using System.Collections.Generic; 23 23 using System.Drawing; 24 using System.Linq;25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using Netron.Diagramming.Core;28 26 29 27 namespace HeuristicLab.Operators.Views.GraphVisualization { 30 28 [StorableClass] 31 internalclass OperatorShapeInfo : ShapeInfo, IOperatorShapeInfo {29 public class OperatorShapeInfo : ShapeInfo, IOperatorShapeInfo { 32 30 [Storable] 33 31 private List<string> labels; 32 public IEnumerable<string> Labels { 33 get { return labels; } 34 } 34 35 35 36 private object lockObject = new object(); … … 61 62 62 63 public OperatorShapeInfo() 63 : base( typeof(OperatorShape)) {64 : base() { 64 65 this.connectorNames = new List<string>(); 65 66 this.labels = new List<string>(); … … 173 174 } 174 175 } 175 176 public override IShape CreateShape() {177 OperatorShape shape = (OperatorShape)base.CreateShape();178 shape.Title = this.Title;179 shape.Color = this.Color;180 shape.LineColor = this.LineColor;181 shape.LineWidth = this.LineWidth;182 shape.Icon = this.Icon;183 shape.Collapsed = this.Collapsed;184 foreach (string connectorName in this.connectorNames)185 if (connectorName != OperatorShapeInfoFactory.SuccessorConnector && connectorName != OperatorShapeInfoFactory.PredecessorConnector)186 shape.AddConnector(connectorName);187 188 shape.UpdateLabels(this.labels);189 return shape;190 }191 192 public override void UpdateShape(IShape shape) {193 base.UpdateShape(shape);194 OperatorShape operatorShape = (OperatorShape)shape;195 operatorShape.Title = this.Title;196 operatorShape.Color = this.Color;197 operatorShape.LineColor = this.LineColor;198 operatorShape.LineWidth = this.LineWidth;199 operatorShape.Icon = this.Icon;200 operatorShape.Collapsed = this.Collapsed;201 202 int i = 0;203 int j = 0;204 //remove old connectors and skip correct connectors205 List<string> oldConnectorNames = operatorShape.AdditionalConnectorNames.ToList();206 while (i < this.connectorNames.Count && j < oldConnectorNames.Count) {207 if (connectorNames[i] == OperatorShapeInfoFactory.SuccessorConnector ||208 connectorNames[i] == OperatorShapeInfoFactory.PredecessorConnector)209 i++;210 else if (oldConnectorNames[j] == OperatorShapeInfoFactory.SuccessorConnector ||211 oldConnectorNames[j] == OperatorShapeInfoFactory.PredecessorConnector)212 j++;213 else if (this.connectorNames[i] != oldConnectorNames[j]) {214 operatorShape.RemoveConnector(oldConnectorNames[j]);215 j++;216 } else {217 i++;218 j++;219 }220 }221 //remove remaining old connectors222 for (; j < oldConnectorNames.Count; j++)223 operatorShape.RemoveConnector(oldConnectorNames[j]);224 225 //add new connectors except successor and connector226 for (; i < this.connectorNames.Count; i++)227 if (this.connectorNames[i] != OperatorShapeInfoFactory.SuccessorConnector && this.connectorNames[i] != OperatorShapeInfoFactory.PredecessorConnector)228 operatorShape.AddConnector(this.connectorNames[i]);229 230 operatorShape.UpdateLabels(this.labels);231 }232 233 public override void UpdateShapeInfo(IShape shape) {234 base.UpdateShapeInfo(shape);235 OperatorShape operatorShape = (OperatorShape)shape;236 this.Title = operatorShape.Title;237 this.Color = operatorShape.Color;238 this.LineColor = operatorShape.LineColor;239 this.LineWidth = operatorShape.LineWidth;240 this.Icon = operatorShape.Icon;241 this.Collapsed = operatorShape.Collapsed;242 }243 176 } 244 177 }
Note: See TracChangeset
for help on using the changeset viewer.