Beispiel #1
0
        /**
         * Create the wptColors array when the mode is KmlColorMode.RAINBOW.
         *
         * @param kmlOptions
         */
        private static void createWptRainbowColors(KmlOptions kmlOptions,
                                                   GpxFileSetModel fileSetModel)
        {
            // Make a color for each waypoint
            int nColors = 0;
            List <GpxFileModel> fileModels = fileSetModel.Files;

            foreach (GpxFileModel fileModel in fileModels)
            {
                if (!fileModel.Checked)
                {
                    continue;
                }
                List <GpxWaypointModel> waypointModels = fileModel.Waypoints;
                foreach (GpxWaypointModel waypointModel in waypointModels)
                {
                    if (!waypointModel.Checked)
                    {
                        continue;
                    }
                    nColors++;
                }
            }
            wptColors = new String[nColors];

            // Calculate the wptColors
            Color  color;
            int    red, green, blue;
            String alpha = kmlOptions.WptAlpha;

            // Insure alpha has two characters
            if (alpha.Length == 0)
            {
                alpha = "00";
            }
            else if (alpha.Length == 1)
            {
                alpha = "0" + alpha;
            }
            else if (alpha.Length > 2)
            {
                alpha = alpha.Substring(0, 2);
            }
            for (int i = 0; i < nColors; i++)
            {
                color        = RainbowColorScheme.defineColor(i, nColors);
                red          = color.R;
                green        = color.G;
                blue         = color.B;
                wptColors[i] = String.Format("{0}{1:X2}{2:X2}{3:X2}", alpha, blue, green,
                                             red);
                // DEBUG
                // System.out.println(wptColors[i]);
            }
            // DEBUG
            // System.out.println("nColors=" + nColors);
        }
Beispiel #2
0
        /**
         * Create the trkColors array when the mode is KmlColorMode.RAINBOW.
         *
         * @param kmlOptions
         */
        private static void createTrkRainbowColors(KmlOptions kmlOptions,
                                                   GpxFileSetModel fileSetModel)
        {
            // Make a color for each track
            int nColors = 0;
            List <GpxFileModel> fileModels = fileSetModel.Files;

            foreach (GpxFileModel fileModel in fileModels)
            {
                if (!fileModel.Checked)
                {
                    continue;
                }
                List <GpxTrackModel> trackModels = fileModel.Tracks;
                foreach (GpxTrackModel trackModel in trackModels)
                {
                    if (!trackModel.Checked)
                    {
                        continue;
                    }
                    nColors++;
                }
            }
            trkColors = new String[nColors];

            // Calculate the trkColors
            Color  color;
            int    red, green, blue;
            String alpha = kmlOptions.TrkAlpha;

            // Insure alpha has two characters
            if (alpha.Length == 0)
            {
                alpha = "00";
            }
            else if (alpha.Length == 1)
            {
                alpha = "0" + alpha;
            }
            else if (alpha.Length > 2)
            {
                alpha = alpha.Substring(0, 2);
            }
            for (int i = 0; i < nColors; i++)
            {
                color        = RainbowColorScheme.defineColor(i, nColors);
                red          = color.R;
                green        = color.G;
                blue         = color.B;
                trkColors[i] = String.Format("{0}{1:X2}{2:X2}{3:X2}", alpha, blue, green,
                                             red);
            }
        }