/// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (Axis != null)
         {
             hashCode = hashCode * 59 + Axis.GetHashCode();
         }
         if (Label != null)
         {
             hashCode = hashCode * 59 + Label.GetHashCode();
         }
         if (Color != null)
         {
             hashCode = hashCode * 59 + Color.GetHashCode();
         }
         if (Format != null)
         {
             hashCode = hashCode * 59 + Format.GetHashCode();
         }
         if (Minimum != null)
         {
             hashCode = hashCode * 59 + Minimum.GetHashCode();
         }
         if (Maximum != null)
         {
             hashCode = hashCode * 59 + Maximum.GetHashCode();
         }
         if (Position != null)
         {
             hashCode = hashCode * 59 + Position.GetHashCode();
         }
         if (MajorColor != null)
         {
             hashCode = hashCode * 59 + MajorColor.GetHashCode();
         }
         if (MajorWidth != null)
         {
             hashCode = hashCode * 59 + MajorWidth.GetHashCode();
         }
         if (MajorStyle != null)
         {
             hashCode = hashCode * 59 + MajorStyle.GetHashCode();
         }
         if (MinorColor != null)
         {
             hashCode = hashCode * 59 + MinorColor.GetHashCode();
         }
         if (MinorWidth != null)
         {
             hashCode = hashCode * 59 + MinorWidth.GetHashCode();
         }
         if (MinorStyle != null)
         {
             hashCode = hashCode * 59 + MinorStyle.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 2
0
    void Start()
    {
        //AppFactory.instances.Todo(new Observer( Cmd.DeleteMinScore));
        //for(int i=0;i< StudentProxy.instances().getmodellist().Count; i++) {
        //    Debug.Log(StudentProxy.instances().getmodellist()[i].name);
        //}
        if (!File.Exists(Application.streamingAssetsPath + "\\Json\\" + "json.json"))
        {
            List <string> majorColorList = new List <string>();

            MajorColor majorColor0 = new MajorColor();
            majorColor0.colorName = "red";
            majorColor0.major     = Major.Chemical;
            majorColorList.Add(JsonMapper.ToJson(majorColor0));
            MajorColor majorColor1 = new MajorColor();
            majorColor1.colorName = "blue";
            majorColor1.major     = Major.Math;
            majorColorList.Add(JsonMapper.ToJson(majorColor1));
            MajorColor majorColor2 = new MajorColor();
            majorColor2.colorName = "yellow";
            majorColor2.major     = Major.Chinese;
            majorColorList.Add(JsonMapper.ToJson(majorColor2));
            MajorColor majorColor3 = new MajorColor();
            majorColor3.colorName = "green";
            majorColor3.major     = Major.Geographic;
            majorColorList.Add(JsonMapper.ToJson(majorColor3));
            MajorColor majorColor4 = new MajorColor();
            majorColor4.colorName = "black";
            majorColor4.major     = Major.Physical;
            majorColorList.Add(JsonMapper.ToJson(majorColor4));
            File.WriteAllLines(Application.streamingAssetsPath + "\\Json\\" + "json.json", majorColorList);
        }
    }
        /// <summary>
        /// Returns true if ChartAxisConfigBean instances are equal
        /// </summary>
        /// <param name="input">Instance of ChartAxisConfigBean to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ChartAxisConfigBean input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Axis == input.Axis ||
                     (Axis != null &&
                      Axis.Equals(input.Axis))
                     ) &&
                 (
                     Label == input.Label ||
                     (Label != null &&
                      Label.Equals(input.Label))
                 ) &&
                 (
                     Color == input.Color ||
                     (Color != null &&
                      Color.Equals(input.Color))
                 ) &&
                 (
                     Format == input.Format ||
                     (Format != null &&
                      Format.Equals(input.Format))
                 ) &&
                 (
                     Minimum == input.Minimum ||
                     (Minimum != null &&
                      Minimum.Equals(input.Minimum))
                 ) &&
                 (
                     Maximum == input.Maximum ||
                     (Maximum != null &&
                      Maximum.Equals(input.Maximum))
                 ) &&
                 (
                     Position == input.Position ||
                     (Position != null &&
                      Position.Equals(input.Position))
                 ) &&
                 (
                     MajorColor == input.MajorColor ||
                     (MajorColor != null &&
                      MajorColor.Equals(input.MajorColor))
                 ) &&
                 (
                     MajorWidth == input.MajorWidth ||
                     (MajorWidth != null &&
                      MajorWidth.Equals(input.MajorWidth))
                 ) &&
                 (
                     MajorStyle == input.MajorStyle ||
                     (MajorStyle != null &&
                      MajorStyle.Equals(input.MajorStyle))
                 ) &&
                 (
                     MinorColor == input.MinorColor ||
                     (MinorColor != null &&
                      MinorColor.Equals(input.MinorColor))
                 ) &&
                 (
                     MinorWidth == input.MinorWidth ||
                     (MinorWidth != null &&
                      MinorWidth.Equals(input.MinorWidth))
                 ) &&
                 (
                     MinorStyle == input.MinorStyle ||
                     (MinorStyle != null &&
                      MinorStyle.Equals(input.MinorStyle))
                 ));
        }
Ejemplo n.º 4
0
        // http://www.coolphptools.com/color_extract
        // http://www.wookmark.com/image/268753/30-inspiring-examples-of-levitation-photography-inspirationfeed-com
        public static List <MajorColor> PrincipalColorAnalysis(Bitmap Bmp, int PCAAmount, int Delta = 24)
        {
            List <MajorColor> MC = new List <MajorColor>();

            int        X, Y, Width, Height, Stride, Index, TotalColorAmount = 0;
            int        HalfDelta;
            byte *     Pointer, Scan0;
            BitmapData BmpData = Bmp.LockBits(new Rectangle(0, 0, Bmp.Width, Bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            Height = Bmp.Height; Width = Bmp.Width; Stride = BmpData.Stride; Scan0 = (byte *)BmpData.Scan0;

            int[] Table   = new int[256 * 256 * 256];
            int[] NonZero = new int[Width * Height];
            int[] Map     = new int[256];

            if (Delta > 2)
            {
                HalfDelta = Delta / 2 - 1;
            }
            else
            {
                HalfDelta = 0;
            }

            for (Y = 0; Y < 256; Y++)
            {
                Map[Y] = ((Y + HalfDelta) / Delta) * Delta;
                if (Map[Y] > 255)
                {
                    Map[Y] = 255;
                }
            }
            for (Y = 0; Y < Height; Y++)
            {
                Pointer = Scan0 + Stride * Y;
                for (X = 0; X < Width; X++)
                {
                    Index = (Map[*Pointer] << 16) + (Map[*(Pointer + 1)] << 8) + Map[*(Pointer + 2)];
                    if (Table[Index] == 0)                 //      还没有出现过该颜色
                    {
                        NonZero[TotalColorAmount] = Index; //      记录下有颜色的位置,同时也记录下了该颜色
                        TotalColorAmount++;                //      颜色总数+1
                    }
                    Table[Index]++;                        //      对应的颜色数加1
                    Pointer += 3;                          //      移动到下一个像素
                }
            }
            MajorColor[] Result = new MajorColor[TotalColorAmount];
            for (Y = 0; Y < TotalColorAmount; Y++)
            {
                Result[Y].Amount = Table[NonZero[Y]];
                Result[Y].Color  = NonZero[Y];
            }
            Array.Sort(Result);                             // 系统自带的这个排序算法比一般自己写的都要快
            Array.Reverse(Result);

            for (Y = 0; Y < PCAAmount && Y < Result.Length; Y++)
            {
                MC.Add(new MajorColor(Result[Y].Color, Result[Y].Amount));
            }
            Bmp.UnlockBits(BmpData);
            GC.Collect();                                   // 立即释放掉分配的64MB的内存
            return(MC);
        }
Ejemplo n.º 5
0
        // http://www.coolphptools.com/color_extract
        // http://www.wookmark.com/image/268753/30-inspiring-examples-of-levitation-photography-inspirationfeed-com
        public static List <MajorColor> PrincipalColorAnalysis(Bitmap Bmp, int PCAAmount, int Delta = 24)
        {
            List <MajorColor> MC = new List <MajorColor>();

            int        X, Y, Width, Height, Stride, Index, TotalColorAmount = 0;
            int        HalfDelta;
            byte *     Pointer, Scan0;
            BitmapData BmpData = Bmp.LockBits(new Rectangle(0, 0, Bmp.Width, Bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            Height = Bmp.Height; Width = Bmp.Width; Stride = BmpData.Stride; Scan0 = (byte *)BmpData.Scan0;

            int[] Table   = new int[256 * 256 * 256];
            int[] NonZero = new int[Width * Height];
            int[] Map     = new int[256];

            if (Delta > 2)
            {
                HalfDelta = Delta / 2 - 1;
            }
            else
            {
                HalfDelta = 0;
            }

            for (Y = 0; Y < 256; Y++)
            {
                Map[Y] = ((Y + HalfDelta) / Delta) * Delta;
                if (Map[Y] > 255)
                {
                    Map[Y] = 255;
                }
            }
            for (Y = 0; Y < Height; Y++)
            {
                Pointer = Scan0 + Stride * Y;
                for (X = 0; X < Width; X++)
                {
                    Index = (Map[*Pointer] << 16) + (Map[*(Pointer + 1)] << 8) + Map[*(Pointer + 2)];
                    if (Table[Index] == 0)                  //      No color has ever appeared
                    {
                        NonZero[TotalColorAmount] = Index;  //      The location of the color is recorded and the color is recorded.
                        TotalColorAmount++;                 //      Total number of colors +1
                    }
                    Table[Index]++;                         //      The number of corresponding colors plus 1
                    Pointer += 3;                           //      Move to the next pixel
                }
            }
            MajorColor[] Result = new MajorColor[TotalColorAmount];
            for (Y = 0; Y < TotalColorAmount; Y++)
            {
                Result[Y].Amount = Table[NonZero[Y]];
                Result[Y].Color  = NonZero[Y];
            }
            Array.Sort(Result);                             // The sort algorithm that the system takes is faster than the usual one.
            Array.Reverse(Result);

            for (Y = 0; Y < PCAAmount; Y++)
            {
                MC.Add(new MajorColor(Result[Y].Color, Result[Y].Amount));
            }
            Bmp.UnlockBits(BmpData);
            GC.Collect();                                   // Immediately release the allocated 64MB memory
            return(MC);
        }