Changeset 6046 for branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs
- Timestamp:
- 04/23/11 10:00:31 (13 years ago)
- Location:
- branches/histogram
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/histogram
- Property svn:ignore
-
old new 10 10 protoc.exe 11 11 HeuristicLab 3.3.5.1.ReSharper.user 12 *.psess 13 *.vsp
-
- Property svn:mergeinfo changed
/trunk/sources merged: 6026,6029-6031,6035-6037,6042-6045
- Property svn:ignore
-
branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs
r5445 r6046 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 } 35 36 private object lockObject = new object(); 34 37 35 38 [StorableConstructor] … … 42 45 lineWidth = original.lineWidth; 43 46 title = original.title; 44 if (original.icon != null) icon = (Bitmap)original.icon.Clone(); 47 48 //mkommend: necessary because cloning a Bitmap is not threadsafe 49 //see http://stackoverflow.com/questions/1851292/invalidoperationexception-object-is-currently-in-use-elsewhere for further information 50 if (original.icon != null) { 51 lock (original.lockObject) { 52 icon = (Bitmap)original.icon.Clone(); 53 } 54 } 45 55 46 56 connectorNames = new List<string>(original.connectorNames); … … 52 62 53 63 public OperatorShapeInfo() 54 : base( typeof(OperatorShape)) {64 : base() { 55 65 this.connectorNames = new List<string>(); 56 66 this.labels = new List<string>(); … … 164 174 } 165 175 } 166 167 public override IShape CreateShape() {168 OperatorShape shape = (OperatorShape)base.CreateShape();169 shape.Title = this.Title;170 shape.Color = this.Color;171 shape.LineColor = this.LineColor;172 shape.LineWidth = this.LineWidth;173 shape.Icon = this.Icon;174 shape.Collapsed = this.Collapsed;175 foreach (string connectorName in this.connectorNames)176 if (connectorName != OperatorShapeInfoFactory.SuccessorConnector && connectorName != OperatorShapeInfoFactory.PredecessorConnector)177 shape.AddConnector(connectorName);178 179 shape.UpdateLabels(this.labels);180 return shape;181 }182 183 public override void UpdateShape(IShape shape) {184 base.UpdateShape(shape);185 OperatorShape operatorShape = (OperatorShape)shape;186 operatorShape.Title = this.Title;187 operatorShape.Color = this.Color;188 operatorShape.LineColor = this.LineColor;189 operatorShape.LineWidth = this.LineWidth;190 operatorShape.Icon = this.Icon;191 operatorShape.Collapsed = this.Collapsed;192 193 int i = 0;194 int j = 0;195 //remove old connectors and skip correct connectors196 List<string> oldConnectorNames = operatorShape.AdditionalConnectorNames.ToList();197 while (i < this.connectorNames.Count && j < oldConnectorNames.Count) {198 if (connectorNames[i] == OperatorShapeInfoFactory.SuccessorConnector ||199 connectorNames[i] == OperatorShapeInfoFactory.PredecessorConnector)200 i++;201 else if (oldConnectorNames[j] == OperatorShapeInfoFactory.SuccessorConnector ||202 oldConnectorNames[j] == OperatorShapeInfoFactory.PredecessorConnector)203 j++;204 else if (this.connectorNames[i] != oldConnectorNames[j]) {205 operatorShape.RemoveConnector(oldConnectorNames[j]);206 j++;207 } else {208 i++;209 j++;210 }211 }212 //remove remaining old connectors213 for (; j < oldConnectorNames.Count; j++)214 operatorShape.RemoveConnector(oldConnectorNames[j]);215 216 //add new connectors except successor and connector217 for (; i < this.connectorNames.Count; i++)218 if (this.connectorNames[i] != OperatorShapeInfoFactory.SuccessorConnector && this.connectorNames[i] != OperatorShapeInfoFactory.PredecessorConnector)219 operatorShape.AddConnector(this.connectorNames[i]);220 221 operatorShape.UpdateLabels(this.labels);222 }223 224 public override void UpdateShapeInfo(IShape shape) {225 base.UpdateShapeInfo(shape);226 OperatorShape operatorShape = (OperatorShape)shape;227 this.Title = operatorShape.Title;228 this.Color = operatorShape.Color;229 this.LineColor = operatorShape.LineColor;230 this.LineWidth = operatorShape.LineWidth;231 this.Icon = operatorShape.Icon;232 this.Collapsed = operatorShape.Collapsed;233 234 //TODO update Connector and labels;235 }236 176 } 237 177 }
Note: See TracChangeset
for help on using the changeset viewer.