Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/17/10 23:50:05 (14 years ago)
Author:
mkommend
Message:

completly refactored the graph visualization (ticket #867)

Location:
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs

    r3374 r3386  
    2929using System.Windows.Forms;
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.Common;
    3132
    3233namespace HeuristicLab.Operators.Views.GraphVisualization {
    3334  [StorableClass]
    3435  internal class OperatorShapeInfo : ShapeInfo, IOperatorShapeInfo {
    35     [Storable]
    36     private List<string> connectorNames;
    3736    [Storable]
    3837    private List<string> labels;
     
    5756
    5857    public void AddConnector(string connectorName) {
    59       if (!this.connectorNames.Contains(connectorName) && connectorName != "Successor") {
     58      if (!this.connectorNames.Contains(connectorName)) {
    6059        this.connectorNames.Add(connectorName);
    6160        this.OnChanged();
     
    7372      this.labels = new List<string>(labels);
    7473      this.OnChanged();
     74    }
     75
     76    [Storable]
     77    private List<string> connectorNames;
     78    public override IEnumerable<string> Connectors {
     79      get { return this.connectorNames; }
    7580    }
    7681
     
    163168    public override void UpdateShape(IShape shape) {
    164169      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]) {
    187184          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;
    195211    }
    196212
    197213    public override IDeepCloneable Clone(Cloner cloner) {
    198       OperatorShapeInfo clone = (OperatorShapeInfo) base.Clone(cloner);
     214      OperatorShapeInfo clone = (OperatorShapeInfo)base.Clone(cloner);
    199215      clone.collapsed = this.collapsed;
    200216      clone.color = this.color;
     
    202218      clone.lineWidth = this.lineWidth;
    203219      clone.title = this.title;
    204       clone.icon = (Bitmap) this.icon.Clone();
     220      clone.icon = (Bitmap)this.icon.Clone();
    205221
    206222      clone.connectorNames = new List<string>(this.connectorNames);
Note: See TracChangeset for help on using the changeset viewer.