Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/23/11 10:00:31 (14 years ago)
Author:
abeham
Message:

#1465

  • updated branch with trunk changes
Location:
branches/histogram
Files:
4 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • branches/histogram

  • branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/IShapeInfo.cs

    r5445 r6046  
    2424using System.Drawing;
    2525using HeuristicLab.Common;
    26 using Netron.Diagramming.Core;
    2726
    2827namespace HeuristicLab.Operators.Views.GraphVisualization {
    2928  public interface IShapeInfo : IDeepCloneable {
    30     Type ShapeType { get; }
    3129    Point Location { get; set; }
    32 
    33     IShape CreateShape();
    3430    IEnumerable<string> Connectors { get; }
    35     void UpdateShape(IShape shape);
    36     void UpdateShapeInfo(IShape shape);
    3731
    3832    event EventHandler Changed;
  • branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/ShapeInfo.cs

    r5445 r6046  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using Netron.Diagramming.Core;
    2827
    2928namespace HeuristicLab.Operators.Views.GraphVisualization {
     
    3433    protected ShapeInfo(ShapeInfo original, Cloner cloner)
    3534      : base(original, cloner) {
    36       shapeType = original.shapeType;
    3735      location = original.location;
    3836    }
    3937
    40     protected ShapeInfo(Type shapeType) {
    41       if (!typeof(IShape).IsAssignableFrom(shapeType))
    42         throw new ArgumentException("The passed shape type " + shapeType + " must be derived from IShape.");
    43       this.shapeType = shapeType;
    44     }
    45 
    46     [Storable]
    47     private Type shapeType;
    48     public Type ShapeType {
    49       get { return this.shapeType; }
    50     }
     38    protected ShapeInfo() : base() { }
    5139
    5240    [Storable]
     
    6957      if (handler != null) this.Changed(this, EventArgs.Empty);
    7058    }
    71 
    72     public virtual IShape CreateShape() {
    73       IShape shape = (IShape)Activator.CreateInstance(this.shapeType);
    74       shape.Tag = this;
    75       shape.Location = this.Location;
    76       return shape;
    77     }
    78 
    79     public virtual void UpdateShape(IShape shape) {
    80       shape.Location = this.Location;
    81     }
    82 
    83     public virtual void UpdateShapeInfo(IShape shape) {
    84       this.Location = shape.Location;
    85     }
    8659  }
    8760}
  • branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/HeuristicLab.Operators.Views.GraphVisualization-3.3.csproj

    r5163 r6046  
    1212    <AssemblyName>HeuristicLab.Operators.Views.GraphVisualization-3.3</AssemblyName>
    1313    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    14     <TargetFrameworkProfile></TargetFrameworkProfile>
     14    <TargetFrameworkProfile>
     15    </TargetFrameworkProfile>
    1516    <FileAlignment>512</FileAlignment>
    1617    <SignAssembly>true</SignAssembly>
     
    112113  <ItemGroup>
    113114    <Compile Include="HeuristicLabOperatorsViewsGraphVisualizationPlugin.cs" />
     115    <Compile Include="OperatorGraphVisualization\OperatorShape.cs" />
     116    <Compile Include="OperatorGraphVisualization\OperatorShapeInfoFactory.cs" />
    114117    <Compile Include="Properties\AssemblyInfo.cs" />
    115118  </ItemGroup>
     
    119122    <None Include="Properties\AssemblyInfo.frame" />
    120123    <Compile Include="General\GraphVisualizationInfo.cs" />
    121     <Compile Include="General\GraphVisualizationInfoView.cs">
    122       <SubType>UserControl</SubType>
    123     </Compile>
    124     <Compile Include="General\GraphVisualizationInfoView.Designer.cs">
    125       <DependentUpon>GraphVisualizationInfoView.cs</DependentUpon>
    126     </Compile>
    127124    <Compile Include="General\ConnectionInfo.cs" />
    128125    <Compile Include="General\IConnectionInfo.cs" />
    129126    <Compile Include="General\IGraphVisualizationInfo.cs" />
    130127    <Compile Include="OperatorGraphVisualization\IOperatorShapeInfo.cs" />
    131     <Compile Include="OperatorGraphVisualization\OperatorGraphView.cs">
    132       <SubType>UserControl</SubType>
    133     </Compile>
    134     <Compile Include="OperatorGraphVisualization\OperatorGraphView.Designer.cs">
    135       <DependentUpon>OperatorGraphView.cs</DependentUpon>
    136     </Compile>
    137128    <Compile Include="OperatorGraphVisualization\OperatorGraphVisualizationInfo.cs">
    138129      <SubType>Code</SubType>
     
    141132    <Compile Include="BidirectionalLookup.cs" />
    142133    <Compile Include="General\IShapeInfo.cs" />
    143     <Compile Include="OperatorGraphVisualization\OperatorShape.cs" />
    144134    <Compile Include="General\ShapeInfo.cs">
    145135      <SubType>Code</SubType>
    146136    </Compile>
    147     <Compile Include="OperatorGraphVisualization\OperatorShapeInfoFactory.cs" />
    148137  </ItemGroup>
    149138  <ItemGroup>
     
    152141      <Name>HeuristicLab.Collections-3.3</Name>
    153142    </ProjectReference>
    154     <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
    155       <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
    156       <Name>HeuristicLab.Common.Resources-3.3</Name>
    157     </ProjectReference>
    158143    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    159144      <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    160145      <Name>HeuristicLab.Common-3.3</Name>
    161     </ProjectReference>
    162     <ProjectReference Include="..\..\HeuristicLab.Core.Views\3.3\HeuristicLab.Core.Views-3.3.csproj">
    163       <Project>{E226881D-315F-423D-B419-A766FE0D8685}</Project>
    164       <Name>HeuristicLab.Core.Views-3.3</Name>
    165146    </ProjectReference>
    166147    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
     
    168149      <Name>HeuristicLab.Core-3.3</Name>
    169150    </ProjectReference>
    170     <ProjectReference Include="..\..\HeuristicLab.ExtLibs\HeuristicLab.Netron\3.0.2672.12446\HeuristicLab.Netron-3.0.2672.12446\HeuristicLab.Netron-3.0.2672.12446.csproj">
    171       <Project>{BB994448-2B21-4564-BB2E-38D8FFF8CF18}</Project>
    172       <Name>HeuristicLab.Netron-3.0.2672.12446 %28HeuristicLab.ExtLibs\HeuristicLab.Netron\HeuristicLab.Netron-3.0.2672.12446\HeuristicLab.Netron-3.0.2672.12446%29</Name>
    173     </ProjectReference>
    174     <ProjectReference Include="..\..\HeuristicLab.ExtLibs\HeuristicLab.Netron\3.0.2672.12446\Netron.Diagramming.Core-3.0.2672.12446\Netron.Diagramming.Core-3.0.2672.12446.csproj">
    175       <Project>{96AEBBEE-4203-45F3-BCF5-7B73BF256BDA}</Project>
    176       <Name>Netron.Diagramming.Core-3.0.2672.12446</Name>
    177     </ProjectReference>
    178     <ProjectReference Include="..\..\HeuristicLab.MainForm.WindowsForms\3.3\HeuristicLab.MainForm.WindowsForms-3.3.csproj">
    179       <Project>{AB687BBE-1BFE-476B-906D-44237135431D}</Project>
    180       <Name>HeuristicLab.MainForm.WindowsForms-3.3</Name>
    181     </ProjectReference>
    182     <ProjectReference Include="..\..\HeuristicLab.MainForm\3.3\HeuristicLab.MainForm-3.3.csproj">
    183       <Project>{3BD61258-31DA-4B09-89C0-4F71FEF5F05A}</Project>
    184       <Name>HeuristicLab.MainForm-3.3</Name>
    185     </ProjectReference>
    186     <ProjectReference Include="..\..\HeuristicLab.Operators.Views\3.3\HeuristicLab.Operators.Views-3.3.csproj">
    187       <Project>{C49CB749-8B24-4628-8003-E86475749410}</Project>
    188       <Name>HeuristicLab.Operators.Views-3.3</Name>
    189     </ProjectReference>
    190151    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    191152      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    192153      <Name>HeuristicLab.Operators-3.3</Name>
    193     </ProjectReference>
    194     <ProjectReference Include="..\..\HeuristicLab.Optimizer\3.3\HeuristicLab.Optimizer-3.3.csproj">
    195       <Project>{C664305E-497C-4533-A140-967DEDB05C19}</Project>
    196       <Name>HeuristicLab.Optimizer-3.3</Name>
    197     </ProjectReference>
    198     <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    199       <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
    200       <Name>HeuristicLab.Parameters-3.3</Name>
    201154    </ProjectReference>
    202155    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
  • branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/HeuristicLabOperatorsViewsGraphVisualizationPlugin.cs.frame

    r5446 r6046  
    3333  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3434  [PluginDependency("HeuristicLab.Common", "3.3")]
    35   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    3635  [PluginDependency("HeuristicLab.Core", "3.3")]
    37   [PluginDependency("HeuristicLab.MainForm", "3.3")]
    38   [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
    39   [PluginDependency("HeuristicLab.Netron", "3.0")]
    4036  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    4137  public class HeuristicLabOperatorsViewsGraphVisualizationPlugin : PluginBase {
  • branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/IOperatorShapeInfo.cs

    r5445 r6046  
    3535    void RemoveConnector(string connectorName);
    3636
     37    IEnumerable<string> Labels { get; }
    3738    void UpdateLabels(IEnumerable<string> labels);
    3839  }
  • branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphVisualizationInfo.cs

    r5445 r6046  
    128128    }
    129129
    130     internal IOperator GetOperatorForShapeInfo(IOperatorShapeInfo shapeInfo) {
     130    public IOperator GetOperatorForShapeInfo(IOperatorShapeInfo shapeInfo) {
    131131      return this.operatorShapeInfoMapping.GetBySecond(shapeInfo);
    132132    }
     
    192192
    193193    #region methods to manipulate operatorgraph by the shape info
    194     internal void AddShapeInfo(IOperator op, IOperatorShapeInfo shapeInfo) {
     194    public void AddShapeInfo(IOperator op, IOperatorShapeInfo shapeInfo) {
    195195      this.RegisterOperatorEvents(op);
    196196      this.operatorParameterCollectionMapping.Add(op, op.Parameters);
  • branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShape.cs

    r5445 r6046  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Drawing;
    25 using System.Drawing.Drawing2D;
    26 using System.Linq;
    27 using HeuristicLab.Netron;
    28 using Netron.Diagramming.Core;
    2922
    3023
    3124namespace HeuristicLab.Operators.Views.GraphVisualization {
    32   public class OperatorShape : ComplexShapeBase {
    33     private static int LABEL_HEIGHT = 16;
    34     private static int LABEL_WIDTH = 180;
    35     private static int LABEL_SPACING = 3;
    36     private int headerHeight = 30;
    37 
    38     private ExpandableIconMaterial expandIconMaterial;
    39     public OperatorShape()
    40       : base() {
    41       this.Resizable = false;
    42       this.additionalConnectors = new List<IConnector>();
    43       this.labels = new List<string>();
    44     }
    45 
    46     public override string EntityName {
    47       get { return "Operator Shape"; }
    48     }
    49 
    50     public bool Collapsed {
    51       get { return this.expandIconMaterial.Collapsed; }
    52       set {
    53         if (this.expandIconMaterial.Collapsed != value)
    54           this.expandIconMaterial.Collapsed = value;
    55       }
    56     }
    57 
    58     private Color lineColor;
    59     public Color LineColor {
    60       get { return this.lineColor; }
    61       set { this.lineColor = value; }
    62     }
    63 
    64     private float lineWidth;
    65     public float LineWidth {
    66       get { return this.lineWidth; }
    67       set { this.lineWidth = value; }
    68     }
    69 
    70     private Color color;
    71     public Color Color {
    72       get { return this.color; }
    73       set { this.color = value; }
    74     }
    75 
    76     private string title;
    77     public string Title {
    78       get { return title; }
    79       set { title = value; }
    80     }
    81 
    82     private IconMaterial iconMaterial;
    83     public Bitmap Icon {
    84       get { return this.iconMaterial.Icon; }
    85       set {
    86         this.iconMaterial.Icon = value;
    87         this.iconMaterial.Transform(new Rectangle(new Point(Rectangle.X + 5, Rectangle.Y + 5), this.iconMaterial.Icon.Size));
    88       }
    89     }
    90 
    91     #region additional connectors
    92     private List<IConnector> additionalConnectors;
    93     public IEnumerable<string> AdditionalConnectorNames {
    94       get { return this.additionalConnectors.Select(c => c.Name); }
    95     }
    96 
    97     private IConnector predecessor;
    98     public IConnector Predecessor {
    99       get { return this.predecessor; }
    100     }
    101 
    102     private IConnector successor;
    103     public IConnector Successor {
    104       get { return this.successor; }
    105     }
    106 
    107     private IConnector CreateConnector(string connectorName, Point location) {
    108       Connector connector = new Connector(location, this.Model);
    109       connector.ConnectorStyle = ConnectorStyle.Square;
    110       connector.Parent = this;
    111       connector.Name = connectorName;
    112       return connector;
    113     }
    114 
    115     public void AddConnector(string connectorName) {
    116       IConnector connector = this.CreateConnector(connectorName, this.BottomRightCorner);
    117 
    118       this.additionalConnectors.Add(connector);
    119       this.Connectors.Add(connector);
    120       this.UpdateConnectorLocation();
    121     }
    122 
    123     public void RemoveConnector(string connectorName) {
    124       IConnector connector = this.additionalConnectors.Where(c => c.Name == connectorName).FirstOrDefault();
    125       if (connector != null) {
    126         this.additionalConnectors.Remove(connector);
    127         this.Connectors.Remove(connector);
    128         this.UpdateConnectorLocation();
    129       }
    130     }
    131 
    132     private void UpdateConnectorLocation() {
    133       if (this.additionalConnectors.Count == 0)
    134         return;
    135 
    136       int spacing = this.Rectangle.Width / this.additionalConnectors.Count;
    137       int margin = spacing / 2;
    138       int posX = margin + this.Rectangle.X;
    139       for (int i = 0; i < this.additionalConnectors.Count; i++) {
    140         this.additionalConnectors[i].MoveBy(new Point(posX - this.additionalConnectors[i].Point.X, 0));
    141         posX += spacing;
    142       }
    143     }
    144     #endregion
    145 
    146     #region label material
    147     private List<string> labels;
    148     public IEnumerable<string> Labels {
    149       get { return this.labels; }
    150     }
    151 
    152     public void UpdateLabels(IEnumerable<string> labels) {
    153       this.labels = new List<string>(labels);
    154       this.expandIconMaterial.Visible = this.labels.Count != 0;
    155       this.UpdateLabels();
    156     }
    157     #endregion
    158 
    159     private void expandIconMaterial_OnExpand(object sender, EventArgs e) {
    160       this.UpdateLabels();
    161     }
    162 
    163     private void expandIconMaterial_OnCollapse(object sender, EventArgs e) {
    164       this.UpdateLabels();
    165     }
    166 
    167     private Size CalculateSize() {
    168       int width = this.Rectangle.Width;
    169       int height = headerHeight;
    170       if (!Collapsed)
    171         height += this.labels.Count * (LABEL_HEIGHT + LABEL_SPACING);
    172       return new Size(width, height);
    173     }
    174 
    175     private void UpdateLabels() {
    176       Size newSize = CalculateSize();
    177       if (this.Rectangle.Size != newSize) {
    178         foreach (IConnector connector in this.additionalConnectors)
    179           connector.MoveBy(new Point(0, newSize.Height - this.Rectangle.Height));
    180         this.mRectangle = new Rectangle(this.Rectangle.Location, newSize);
    181         this.Invalidate();
    182         this.RaiseOnChange(this, new EntityEventArgs(this));
    183       }
    184     }
    185 
    186     protected override void Initialize() {
    187       base.Initialize();
    188 
    189       //the initial size
    190       this.Transform(0, 0, 200, headerHeight);
    191       this.color = Color.LightBlue;
    192 
    193       this.iconMaterial = new IconMaterial();
    194       this.iconMaterial.Gliding = false;
    195       this.Children.Add(iconMaterial);
    196 
    197       Bitmap expandBitmap = new Bitmap(HeuristicLab.Common.Resources.VSImageLibrary.Expand);
    198       Bitmap collapseBitmap = new Bitmap(HeuristicLab.Common.Resources.VSImageLibrary.Collapse);
    199       this.expandIconMaterial = new ExpandableIconMaterial(expandBitmap, collapseBitmap);
    200       this.expandIconMaterial.Gliding = false;
    201       this.expandIconMaterial.Transform(new Rectangle(new Point(Rectangle.Right - 20, Rectangle.Y + 7), expandIconMaterial.Icon.Size));
    202       this.expandIconMaterial.Visible = false;
    203       this.expandIconMaterial.OnExpand += new EventHandler(expandIconMaterial_OnExpand);
    204       this.expandIconMaterial.OnCollapse += new EventHandler(expandIconMaterial_OnCollapse);
    205       this.Children.Add(expandIconMaterial);
    206 
    207       this.predecessor = this.CreateConnector(OperatorShapeInfoFactory.PredecessorConnector, new Point(Rectangle.Left, Center.Y));
    208       this.Connectors.Add(predecessor);
    209 
    210       this.successor = this.CreateConnector(OperatorShapeInfoFactory.SuccessorConnector, (new Point(Rectangle.Right, Center.Y)));
    211       this.Connectors.Add(successor);
    212     }
    213 
    214     public override void Paint(Graphics g) {
    215       base.Paint(g);
    216 
    217       g.SmoothingMode = SmoothingMode.HighQuality;
    218 
    219       Pen pen = new Pen(lineColor, lineWidth);
    220 
    221       SizeF titleSize = g.MeasureString(this.Title, ArtPalette.DefaultBoldFont, Rectangle.Width - 45);
    222       if (titleSize.Height + 10 > Rectangle.Height) {
    223         headerHeight = (int)titleSize.Height + 10;
    224         this.UpdateLabels();
    225       }
    226 
    227       GraphicsPath path = new GraphicsPath();
    228       path.AddArc(Rectangle.X, Rectangle.Y, 20, 20, -180, 90);
    229       path.AddLine(Rectangle.X + 10, Rectangle.Y, Rectangle.X + Rectangle.Width - 10, Rectangle.Y);
    230       path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y, 20, 20, -90, 90);
    231       path.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + 10, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 10);
    232       path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y + Rectangle.Height - 20, 20, 20, 0, 90);
    233       path.AddLine(Rectangle.X + Rectangle.Width - 10, Rectangle.Y + Rectangle.Height, Rectangle.X + 10, Rectangle.Y + Rectangle.Height);
    234       path.AddArc(Rectangle.X, Rectangle.Y + Rectangle.Height - 20, 20, 20, 90, 90);
    235       path.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height - 10, Rectangle.X, Rectangle.Y + 10);
    236       //shadow
    237       if (ArtPalette.EnableShadows) {
    238         Region darkRegion = new Region(path);
    239         darkRegion.Translate(5, 5);
    240         g.FillRegion(ArtPalette.ShadowBrush, darkRegion);
    241       }
    242       //background
    243       g.FillPath(Brush, path);
    244 
    245       using (LinearGradientBrush gradientBrush = new LinearGradientBrush(Rectangle.Location, new Point(Rectangle.X + Rectangle.Width, Rectangle.Y), this.Color, Color.White)) {
    246         Region gradientRegion = new Region(path);
    247         g.FillRegion(gradientBrush, gradientRegion);
    248       }
    249 
    250       if (!this.Collapsed) {
    251         TextStyle textStyle = new TextStyle(Color.Black, new Font("Arial", 7), StringAlignment.Near, StringAlignment.Near);
    252         StringFormat stringFormat = textStyle.StringFormat;
    253         stringFormat.Trimming = StringTrimming.EllipsisWord;
    254         stringFormat.FormatFlags = StringFormatFlags.LineLimit;
    255         Rectangle rect;
    256 
    257         for (int i = 0; i < this.labels.Count; i++) {
    258           rect = new Rectangle(Rectangle.X + 25, Rectangle.Y + headerHeight + i * (LABEL_HEIGHT + LABEL_SPACING), LABEL_WIDTH, LABEL_HEIGHT);
    259           g.DrawString(textStyle.GetFormattedText(this.labels[i]), textStyle.Font, textStyle.GetBrush(), rect, stringFormat);
    260         }
    261       }
    262 
    263       //the border
    264       g.DrawPath(pen, path);
    265 
    266       //the title
    267       g.DrawString(this.Title, ArtPalette.DefaultBoldFont, Brushes.Black, new Rectangle(Rectangle.X + 25, Rectangle.Y + 5, Rectangle.Width - 45, Rectangle.Height - 5));
    268 
    269 
    270       //the material
    271       foreach (IPaintable material in Children)
    272         material.Paint(g);
    273 
    274       //the connectors
    275       if (this.ShowConnectors) {
    276         for (int k = 0; k < Connectors.Count; k++)
    277           Connectors[k].Paint(g);
    278       }
    279     }
     25  internal class OperatorShape {
     26    //21.04.2011 mkommend
     27    //Do not delete this empty class, because this type was moved in to the plugin GraphVisualiation.Views
     28    //But it is referenced in persisted ShapeInfo objects and thus these files could not be loaded without this type
     29    //Should be removed with HL 3.4
    28030  }
    28131}
  • branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs

    r5445 r6046  
    2222using System.Collections.Generic;
    2323using System.Drawing;
    24 using System.Linq;
    2524using HeuristicLab.Common;
    2625using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using Netron.Diagramming.Core;
    2826
    2927namespace HeuristicLab.Operators.Views.GraphVisualization {
    3028  [StorableClass]
    31   internal class OperatorShapeInfo : ShapeInfo, IOperatorShapeInfo {
     29  public class OperatorShapeInfo : ShapeInfo, IOperatorShapeInfo {
    3230    [Storable]
    3331    private List<string> labels;
     32    public IEnumerable<string> Labels {
     33      get { return labels; }
     34    }
     35
     36    private object lockObject = new object();
    3437
    3538    [StorableConstructor]
     
    4245      lineWidth = original.lineWidth;
    4346      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      }
    4555
    4656      connectorNames = new List<string>(original.connectorNames);
     
    5262
    5363    public OperatorShapeInfo()
    54       : base(typeof(OperatorShape)) {
     64      : base() {
    5565      this.connectorNames = new List<string>();
    5666      this.labels = new List<string>();
     
    164174      }
    165175    }
    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 connectors
    196       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 connectors
    213       for (; j < oldConnectorNames.Count; j++)
    214         operatorShape.RemoveConnector(oldConnectorNames[j]);
    215 
    216       //add new connectors except successor and connector
    217       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     }
    236176  }
    237177}
  • branches/histogram/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfoFactory.cs

    r5445 r6046  
    2626
    2727namespace HeuristicLab.Operators.Views.GraphVisualization {
    28   internal static class OperatorShapeInfoFactory {
     28  public static class OperatorShapeInfoFactory {
    2929    public const string PredecessorConnector = "Predecessor";
    3030    public const string SuccessorConnector = "Successor";
Note: See TracChangeset for help on using the changeset viewer.