Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/13/17 14:01:44 (7 years ago)
Author:
mkommend
Message:

#2765: Implemented tags for data points in ScatterPlot.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Common/3.3/Point2D.cs

    r14185 r14860  
    2626namespace HeuristicLab.Common {
    2727  [Serializable]
    28   public struct Point2D<T> where T : struct {
     28  public struct Point2D<T> where T : struct, IEquatable<T> {
    2929    public static readonly Point2D<T> Empty = new Point2D<T>();
    3030
     
    3838    }
    3939
     40    private object tag;
     41    public object Tag {
     42      get { return tag; }
     43    }
     44
    4045    [Browsable(false)]
    4146    public bool IsEmpty {
     
    4348    }
    4449
    45     public Point2D(T x, T y) {
     50    public Point2D(T x, T y, object tag = null) {
    4651      this.x = x;
    4752      this.y = y;
     53      this.tag = tag;
    4854    }
    4955
    5056    public static bool operator ==(Point2D<T> left, Point2D<T> right) {
    51       return left.x.Equals(right.x) && left.y.Equals(right.y);
     57      return left.x.Equals(right.x) && left.y.Equals(right.y) && left.tag == right.tag;
    5258    }
    5359    public static bool operator !=(Point2D<T> left, Point2D<T> right) {
     
    5965        return false;
    6066      Point2D<T> point = (Point2D<T>)obj;
    61       return x.Equals(point.x) && y.Equals(point.y) && GetType().Equals(point.GetType());
     67      return GetType() == point.GetType() && x.Equals(point.x) && y.Equals(point.y) &&
     68             ((tag != null && tag.Equals(point.tag)) || tag == point.tag);
    6269    }
    6370    public override int GetHashCode() {
Note: See TracChangeset for help on using the changeset viewer.