Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7226 for trunk/sources


Ignore:
Timestamp:
12/21/11 23:26:30 (12 years ago)
Author:
mkommend
Message:

#1715: Corrected display of type names in OperatorShapes.

Location:
trunk/sources
Files:
4 edited

Legend:

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

    r7199 r7226  
    7979    }
    8080
    81     public string TypeName { get; set; }
     81    public string Subtitle { get; set; }
    8282
    8383    private IconMaterial iconMaterial;
     
    218218      g.SmoothingMode = SmoothingMode.HighQuality;
    219219
    220       Pen pen = new Pen(lineColor, lineWidth);
    221 
    222       SizeF titleSize = g.MeasureString(this.Title, ArtPalette.DefaultBoldFont, Rectangle.Width - 45);
    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;
    230         this.UpdateLabels();
    231       }
    232 
    233       GraphicsPath path = new GraphicsPath();
    234       path.AddArc(Rectangle.X, Rectangle.Y, 20, 20, -180, 90);
    235       path.AddLine(Rectangle.X + 10, Rectangle.Y, Rectangle.X + Rectangle.Width - 10, Rectangle.Y);
    236       path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y, 20, 20, -90, 90);
    237       path.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + 10, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 10);
    238       path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y + Rectangle.Height - 20, 20, 20, 0, 90);
    239       path.AddLine(Rectangle.X + Rectangle.Width - 10, Rectangle.Y + Rectangle.Height, Rectangle.X + 10, Rectangle.Y + Rectangle.Height);
    240       path.AddArc(Rectangle.X, Rectangle.Y + Rectangle.Height - 20, 20, 20, 90, 90);
    241       path.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height - 10, Rectangle.X, Rectangle.Y + 10);
    242       //shadow
    243       if (ArtPalette.EnableShadows) {
    244         Region darkRegion = new Region(path);
    245         darkRegion.Translate(5, 5);
    246         g.FillRegion(ArtPalette.ShadowBrush, darkRegion);
    247       }
    248       //background
    249       g.FillPath(Brush, path);
    250 
    251       using (LinearGradientBrush gradientBrush = new LinearGradientBrush(Rectangle.Location, new Point(Rectangle.X + Rectangle.Width, Rectangle.Y), this.Color, Color.White)) {
    252         Region gradientRegion = new Region(path);
    253         g.FillRegion(gradientBrush, gradientRegion);
    254       }
    255 
    256       if (!this.Collapsed) {
    257         TextStyle textStyle = new TextStyle(Color.Black, new Font("Arial", 7), StringAlignment.Near, StringAlignment.Near);
    258         StringFormat stringFormat = textStyle.StringFormat;
    259         stringFormat.Trimming = StringTrimming.EllipsisWord;
    260         stringFormat.FormatFlags = StringFormatFlags.LineLimit;
    261         Rectangle rect;
    262 
    263         for (int i = 0; i < this.labels.Count; i++) {
    264           rect = new Rectangle(Rectangle.X + 25, Rectangle.Y + headerHeight + i * (LABEL_HEIGHT + LABEL_SPACING), LABEL_WIDTH, LABEL_HEIGHT);
    265           g.DrawString(textStyle.GetFormattedText(this.labels[i]), textStyle.Font, textStyle.GetBrush(), rect, stringFormat);
    266         }
    267       }
    268 
    269       //the border
    270       g.DrawPath(pen, path);
    271 
    272       //the title
    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       }
    283 
    284 
    285       //the material
    286       foreach (IPaintable material in Children)
    287         material.Paint(g);
    288 
    289       //the connectors
    290       if (this.ShowConnectors) {
    291         for (int k = 0; k < Connectors.Count; k++)
    292           Connectors[k].Paint(g);
     220      using (Pen pen = new Pen(lineColor, lineWidth)) {
     221
     222        SizeF titleSize = g.MeasureString(this.Title, ArtPalette.DefaultBoldFont, Rectangle.Width - 45);
     223        titleSize.Height += 10; //add spacing
     224        SizeF subtitleSize = g.MeasureString(this.Subtitle, ArtPalette.DefaultFont, Rectangle.Width - 45);
     225        subtitleSize.Height += 5; //add spacing
     226        if (this.Title == this.Subtitle || string.IsNullOrEmpty(this.Subtitle)) subtitleSize = new SizeF(0, 0);
     227
     228        if ((int)titleSize.Height + (int)subtitleSize.Height != Rectangle.Height) {
     229          headerHeight = (int)titleSize.Height + (int)subtitleSize.Height;
     230          this.UpdateLabels();
     231        }
     232
     233        GraphicsPath path = new GraphicsPath();
     234        path.AddArc(Rectangle.X, Rectangle.Y, 20, 20, -180, 90);
     235        path.AddLine(Rectangle.X + 10, Rectangle.Y, Rectangle.X + Rectangle.Width - 10, Rectangle.Y);
     236        path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y, 20, 20, -90, 90);
     237        path.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + 10, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 10);
     238        path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y + Rectangle.Height - 20, 20, 20, 0, 90);
     239        path.AddLine(Rectangle.X + Rectangle.Width - 10, Rectangle.Y + Rectangle.Height, Rectangle.X + 10, Rectangle.Y + Rectangle.Height);
     240        path.AddArc(Rectangle.X, Rectangle.Y + Rectangle.Height - 20, 20, 20, 90, 90);
     241        path.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height - 10, Rectangle.X, Rectangle.Y + 10);
     242        //shadow
     243        if (ArtPalette.EnableShadows) {
     244          Region darkRegion = new Region(path);
     245          darkRegion.Translate(5, 5);
     246          g.FillRegion(ArtPalette.ShadowBrush, darkRegion);
     247        }
     248        //background
     249        g.FillPath(Brush, path);
     250
     251        using (LinearGradientBrush gradientBrush = new LinearGradientBrush(Rectangle.Location, new Point(Rectangle.X + Rectangle.Width, Rectangle.Y), this.Color, Color.White)) {
     252          Region gradientRegion = new Region(path);
     253          g.FillRegion(gradientBrush, gradientRegion);
     254        }
     255
     256        if (!this.Collapsed) {
     257          TextStyle textStyle = new TextStyle(Color.Black, new Font("Arial", 7), StringAlignment.Near, StringAlignment.Near);
     258          StringFormat stringFormat = textStyle.StringFormat;
     259          stringFormat.Trimming = StringTrimming.EllipsisWord;
     260          stringFormat.FormatFlags = StringFormatFlags.LineLimit;
     261          Rectangle rect;
     262
     263          const int verticalHeaderSpacing = 5;
     264          Point separationLineStart = new Point(Rectangle.X + 25, Rectangle.Y + headerHeight - verticalHeaderSpacing);
     265          Point separationLineEnd = new Point(Rectangle.X + Rectangle.Width - 25, Rectangle.Y + headerHeight - verticalHeaderSpacing);
     266          using (LinearGradientBrush brush = new LinearGradientBrush(separationLineStart, separationLineEnd, Color.Black, Color.White)) {
     267            using (Pen separationLinePen = new Pen(brush)) {
     268              g.DrawLine(separationLinePen, separationLineStart, separationLineEnd);
     269            }
     270          }
     271
     272
     273          for (int i = 0; i < this.labels.Count; i++) {
     274            rect = new Rectangle(Rectangle.X + 25, Rectangle.Y + headerHeight + i * (LABEL_HEIGHT + LABEL_SPACING), LABEL_WIDTH, LABEL_HEIGHT);
     275            g.DrawString(textStyle.GetFormattedText(this.labels[i]), textStyle.Font, textStyle.GetBrush(), rect, stringFormat);
     276          }
     277        }
     278
     279        //the border
     280        g.DrawPath(pen, path);
     281
     282        //the title
     283        g.DrawString(this.Title, ArtPalette.DefaultBoldFont, Brushes.Black,
     284                     new Rectangle(Rectangle.X + 25, Rectangle.Y + 5,
     285                                   Rectangle.Width - 45, Rectangle.Height - 5 - (int)subtitleSize.Height));
     286
     287        //the subtitle
     288        if (this.Title != this.Subtitle || string.IsNullOrEmpty(this.Subtitle)) {
     289          g.DrawString(this.Subtitle, ArtPalette.DefaultFont, Brushes.Black,
     290                       new Rectangle(Rectangle.X + 25, Rectangle.Y + (int)titleSize.Height -5 ,
     291                                     Rectangle.Width - 45, Rectangle.Height - 5));
     292        }
     293
     294
     295        //the material
     296        foreach (IShapeMaterial material in Children)
     297          material.Paint(g);
     298
     299        //the connectors
     300        if (this.ShowConnectors) {
     301          foreach (IConnector t in Connectors)
     302            t.Paint(g);
     303        }
    293304      }
    294305    }
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization.Views/3.3/ShapeInfoExtensions.cs

    r7199 r7226  
    5050      shape.Location = shapeInfo.Location;
    5151      shape.Title = shapeInfo.Title;
    52       shape.TypeName = shapeInfo.TypeName;
     52      shape.Subtitle = shapeInfo.TypeName;
    5353      shape.Color = shapeInfo.Color;
    5454      shape.LineColor = shapeInfo.LineColor;
     
    6666    public static void UpdateShape(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape) {
    6767      operatorShape.Title = operatorShapeInfo.Title;
    68       operatorShape.TypeName = operatorShapeInfo.TypeName;
     68      operatorShape.Subtitle = operatorShapeInfo.TypeName;
    6969      operatorShape.Color = operatorShapeInfo.Color;
    7070      operatorShape.LineColor = operatorShapeInfo.LineColor;
     
    107107    public static void UpdateShapeInfo(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape) {
    108108      operatorShapeInfo.Title = operatorShape.Title;
    109       operatorShapeInfo.TypeName = operatorShape.TypeName;
     109      operatorShapeInfo.TypeName = operatorShape.Subtitle;
    110110      operatorShapeInfo.Color = operatorShape.Color;
    111111      operatorShapeInfo.LineColor = operatorShape.LineColor;
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphVisualizationInfo.cs

    r6572 r7226  
    121121        }
    122122      }
     123
     124      foreach (IOperatorShapeInfo shapeInfo2 in this.operatorShapeInfoMapping.SecondValues)
     125        if (string.IsNullOrEmpty(shapeInfo2.TypeName)) shapeInfo2.TypeName = this.operatorShapeInfoMapping.GetBySecond(shapeInfo2).GetType().GetPrettyName();
    123126    }
    124127
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs

    r7199 r7226  
    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     }
     40
    4541    protected OperatorShapeInfo(OperatorShapeInfo original, Cloner cloner)
    4642      : base(original, cloner) {
Note: See TracChangeset for help on using the changeset viewer.