Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7199


Ignore:
Timestamp:
12/16/11 18:25:47 (12 years ago)
Author:
mkommend
Message:

#1715: Added type name to operator shapes.

Location:
trunk/sources
Files:
5 edited

Legend:

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

    r6036 r7199  
    7878      set { title = value; }
    7979    }
     80
     81    public string TypeName { get; set; }
    8082
    8183    private IconMaterial iconMaterial;
     
    219221
    220222      SizeF titleSize = g.MeasureString(this.Title, ArtPalette.DefaultBoldFont, Rectangle.Width - 45);
    221       if (titleSize.Height + 10 > Rectangle.Height) {
    222         headerHeight = (int)titleSize.Height + 10;
     223      titleSize.Height += 10; //add spacing
     224      SizeF typeNameSize = g.MeasureString(this.TypeName, ArtPalette.DefaultFont, Rectangle.Width - 45);
     225      typeNameSize.Height += 10;  //add spacing
     226      if (this.Title == this.TypeName) typeNameSize = new SizeF(0, 0);
     227
     228      if (titleSize.Height + typeNameSize.Height > Rectangle.Height) {
     229        headerHeight = (int)titleSize.Height + (int)typeNameSize.Height;
    223230        this.UpdateLabels();
    224231      }
     
    264271
    265272      //the title
    266       g.DrawString(this.Title, ArtPalette.DefaultBoldFont, Brushes.Black, new Rectangle(Rectangle.X + 25, Rectangle.Y + 5, Rectangle.Width - 45, Rectangle.Height - 5));
     273      g.DrawString(this.Title, ArtPalette.DefaultBoldFont, Brushes.Black,
     274        new Rectangle(Rectangle.X + 25, Rectangle.Y + 5,
     275                      Rectangle.Width - 45, Rectangle.Height - 5 - (int)typeNameSize.Height));
     276
     277      //the typeName
     278      if (this.Title != this.TypeName) {
     279        g.DrawString(this.TypeName, ArtPalette.DefaultFont, Brushes.Black,
     280          new Rectangle(Rectangle.X + 25, Rectangle.Y + (int)titleSize.Height,
     281                        Rectangle.Width - 45, Rectangle.Height - 5));
     282      }
    267283
    268284
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization.Views/3.3/ShapeInfoExtensions.cs

    r6036 r7199  
    5050      shape.Location = shapeInfo.Location;
    5151      shape.Title = shapeInfo.Title;
     52      shape.TypeName = shapeInfo.TypeName;
    5253      shape.Color = shapeInfo.Color;
    5354      shape.LineColor = shapeInfo.LineColor;
     
    6566    public static void UpdateShape(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape) {
    6667      operatorShape.Title = operatorShapeInfo.Title;
     68      operatorShape.TypeName = operatorShapeInfo.TypeName;
    6769      operatorShape.Color = operatorShapeInfo.Color;
    6870      operatorShape.LineColor = operatorShapeInfo.LineColor;
     
    105107    public static void UpdateShapeInfo(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape) {
    106108      operatorShapeInfo.Title = operatorShape.Title;
     109      operatorShapeInfo.TypeName = operatorShape.TypeName;
    107110      operatorShapeInfo.Color = operatorShape.Color;
    108111      operatorShapeInfo.LineColor = operatorShape.LineColor;
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/IOperatorShapeInfo.cs

    r6036 r7199  
    2727    bool Collapsed { get; set; }
    2828    string Title { get; set; }
     29    string TypeName { get; set; }
    2930    Color Color { get; set; }
    3031    Color LineColor { get; set; }
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs

    r6036 r7199  
    3838    [StorableConstructor]
    3939    protected OperatorShapeInfo(bool deserializing) : base(deserializing) { }
     40    [StorableHook(HookType.AfterDeserialization)]
     41    private void AfterDeserialization() {
     42      if (string.IsNullOrEmpty(this.typeName))
     43        typeName = title;
     44    }
    4045    protected OperatorShapeInfo(OperatorShapeInfo original, Cloner cloner)
    4146      : base(original, cloner) {
     
    4550      lineWidth = original.lineWidth;
    4651      title = original.title;
     52      typeName = original.typeName;
    4753
    4854      //mkommend: necessary because cloning a Bitmap is not threadsafe
     
    129135
    130136    [Storable]
     137    private string typeName;
     138    public string TypeName {
     139      get { return this.typeName; }
     140      set {
     141        if (this.typeName != value) {
     142          this.typeName = value;
     143          this.OnChanged();
     144        }
     145      }
     146    }
     147
     148    [Storable]
    131149    private Color color;
    132150    public Color Color {
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfoFactory.cs

    r6036 r7199  
    2323using System.Drawing;
    2424using System.Linq;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627
     
    3738      operatorShapeInfo.Collapsed = true;
    3839      operatorShapeInfo.Title = op.Name;
     40      operatorShapeInfo.TypeName = op.GetType().GetPrettyName();
    3941      operatorShapeInfo.Color = Color.LightBlue;
    4042      operatorShapeInfo.LineWidth = 1;
Note: See TracChangeset for help on using the changeset viewer.