Ejemplo n.º 1
0
        //Overloaded operator used for comparisons in the set
        public override bool Equals(Object a)
        {
            Style aS = (Style)this;
            Style bS = (Style)a;

            if (aS.getStyleName().Equals(bS.getStyleName()))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a style to the KML file. Requires the icon ID and color.
        /// </summary>
        /// <param name="ic">Icon --> needed to retrieve icon ID and icon location</param>
        /// <param name="color">String --> color of the overlay </param>
        /// <param name="styleName">String --> associated styleName</param>
        public void addStyle(Style style)
        {
            if (style.getStyleColor() == 0) //Don't add a color
            {
                if (style.getStyleIcon().getLocation() == "")
                {
                    formattedKML +=
                        "";
                }
                else
                {
                    formattedKML +=
                        "\t<Style id='" + style.getStyleName() + "'>\n" +
                        "\t<IconStyle>\n" +
                        "\t\t<Icon>\n" +
                        "\t\t\t<href>" + style.getStyleIcon().getLocation() + "</href>\n" +
                        "\t\t</Icon>\n" +
                        "\t</IconStyle>\n" +
                        "\t</Style>\n";
                }
            }
            else //Add a color
            {
                if (style.getStyleIcon().getLocation() == "")
                {
                    Char[] colorHandler = style.getStyleColor().ToString("X").ToCharArray();

                    //Swap the RGB to BGR, if not, google will not interpret the colors correctly
                    Char temp = colorHandler[2];
                    colorHandler[2] = colorHandler[6];
                    colorHandler[6] = temp;

                    temp            = colorHandler[3];
                    colorHandler[3] = colorHandler[7];
                    colorHandler[7] = temp;

                    //Set color
                    String color = new String(colorHandler);
                    colorHandler = null;

                    formattedKML +=
                        "\t<Style id='" + style.getStyleName() + "'>\n" +
                        "\t<IconStyle>\n" +
                        "\t\t<color>" + color + "</color>\n" +
                        "\t</IconStyle>\n" +
                        "\t</Style>\n";
                }
                else
                {
                    Char[] colorHandler = style.getStyleColor().ToString("X").ToCharArray();

                    //Swap the RGB to BGR, if not, google will not interpret the colors correctly
                    Char temp = colorHandler[2];
                    colorHandler[2] = colorHandler[6];
                    colorHandler[6] = temp;

                    temp            = colorHandler[3];
                    colorHandler[3] = colorHandler[7];
                    colorHandler[7] = temp;


                    //Set color
                    String color = new String(colorHandler);
                    colorHandler = null;


                    formattedKML +=
                        "\t<Style id='" + style.getStyleName() + "'>\n" +
                        "\t<IconStyle>\n" +
                        "\t\t<color>" + color + "</color>\n" +
                        "\t\t<Icon>\n" +
                        "\t\t\t<href>" + style.getStyleIcon().getLocation() + "</href>\n" +
                        "\t\t</Icon>\n" +
                        "\t</IconStyle>\n" +
                        "\t</Style>\n";
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a style to the KML file. Requires the icon ID and color. 
        /// </summary>
        /// <param name="ic">Icon --> needed to retrieve icon ID and icon location</param>
        /// <param name="color">String --> color of the overlay </param>
        /// <param name="styleName">String --> associated styleName</param>
        public void addStyle(Style style)
        {
            if (style.getStyleColor() == 0) //Don't add a color
            {
                if (style.getStyleIcon().getLocation() == "")
                {
                    formattedKML +=
                       "";
                }
                else
                {
                    formattedKML +=
                        "\t<Style id='" + style.getStyleName() + "'>\n" +
                        "\t<IconStyle>\n" +
                        "\t\t<Icon>\n" +
                        "\t\t\t<href>" + style.getStyleIcon().getLocation() + "</href>\n" +
                        "\t\t</Icon>\n" +
                        "\t</IconStyle>\n" +
                        "\t</Style>\n";
                }
            }
            else //Add a color
            {
                if (style.getStyleIcon().getLocation() == "")
                {
                    Char[] colorHandler = style.getStyleColor().ToString("X").ToCharArray();

                    //Swap the RGB to BGR, if not, google will not interpret the colors correctly
                    Char temp = colorHandler[2];
                    colorHandler[2] = colorHandler[6];
                    colorHandler[6] = temp;

                    temp = colorHandler[3];
                    colorHandler[3] = colorHandler[7];
                    colorHandler[7] = temp;

                    //Set color
                    String color = new String(colorHandler);
                    colorHandler = null;

                    formattedKML +=
                        "\t<Style id='" + style.getStyleName() + "'>\n" +
                        "\t<IconStyle>\n" +
                        "\t\t<color>" + color + "</color>\n" +
                        "\t</IconStyle>\n" +
                        "\t</Style>\n";
                }
                else
                {
                    Char[] colorHandler = style.getStyleColor().ToString("X").ToCharArray();

                    //Swap the RGB to BGR, if not, google will not interpret the colors correctly
                    Char temp = colorHandler[2];
                    colorHandler[2] = colorHandler[6];
                    colorHandler[6] = temp;

                    temp = colorHandler[3];
                    colorHandler[3] = colorHandler[7];
                    colorHandler[7] = temp;

                    //Set color
                    String color = new String(colorHandler);
                    colorHandler = null;

                    formattedKML +=
                        "\t<Style id='" + style.getStyleName() + "'>\n" +
                        "\t<IconStyle>\n" +
                        "\t\t<color>" + color + "</color>\n" +
                        "\t\t<Icon>\n" +
                        "\t\t\t<href>" + style.getStyleIcon().getLocation() + "</href>\n" +
                        "\t\t</Icon>\n" +
                        "\t</IconStyle>\n" +
                        "\t</Style>\n";
                }
            }
        }