예제 #1
0
        /// <summary>
        /// Constructs a chunk containing an Image.
        /// </summary>
        /// <param name="image">the image</param>
        /// <param name="offsetX">the image offset in the x direction</param>
        /// <param name="offsetY">the image offset in the y direction</param>
        public Chunk(Image image, float offsetX, float offsetY) : this(OBJECT_REPLACEMENT_CHARACTER, new Font())
        {
            Image copyImage = Image.getInstance(image);

            copyImage.setAbsolutePosition(float.NaN, float.NaN);
            setAttribute(IMAGE, new Object[] { copyImage, offsetX, offsetY, false });
        }
예제 #2
0
        /// <summary>
        /// Returns an Image that has been constructed taking in account
        /// the value of some attributes.
        /// </summary>
        /// <param name="attributes">Some attributes</param>
        /// <returns>an Image</returns>
        public static Image getInstance(Properties attributes)
        {
            string value = attributes.Remove(ElementTags.URL);

            if (value == null)
            {
                throw new Exception("The URL of the image is missing.");
            }
            Image image = Image.getInstance(value);
            int   align = Element.ALIGN_LEFT;

            if ((value = attributes.Remove(ElementTags.ALIGN)) != null)
            {
                if (ElementTags.ALIGN_LEFT.ToLower().Equals(value))
                {
                    align |= Image.LEFT;
                }
                else if (ElementTags.ALIGN_RIGHT.ToLower().Equals(value))
                {
                    align |= Image.RIGHT;
                }
                else if (ElementTags.ALIGN_MIDDLE.ToLower().Equals(value))
                {
                    align |= Image.MIDDLE;
                }
            }
            if ((value = attributes.Remove(ElementTags.UNDERLYING)) != null)
            {
                if (bool.Parse(value))
                {
                    align |= Image.UNDERLYING;
                }
            }
            if ((value = attributes.Remove(ElementTags.TEXTWRAP)) != null)
            {
                if (bool.Parse(value))
                {
                    align |= Image.TEXTWRAP;
                }
            }
            image.alignment = align;
            if ((value = attributes.Remove(ElementTags.ALT)) != null)
            {
                image.Alt = value;
            }
            string x;
            string y;

            if (((x = attributes.Remove(ElementTags.ABSOLUTEX)) != null) &&
                ((y = attributes.Remove(ElementTags.ABSOLUTEY)) != null))
            {
                image.setAbsolutePosition(float.Parse(x), float.Parse(y));
            }
            if ((value = attributes.Remove(ElementTags.PLAINWIDTH)) != null)
            {
                image.scaleAbsoluteWidth(float.Parse(value));
            }
            if ((value = attributes.Remove(ElementTags.PLAINHEIGHT)) != null)
            {
                image.scaleAbsoluteHeight(float.Parse(value));
            }
            if ((value = attributes.Remove(ElementTags.ROTATION)) != null)
            {
                image.setRotation(float.Parse(value));
            }
            if (attributes.Count > 0)
            {
                image.MarkupAttributes = attributes;
            }
            return(image);
        }