001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.dto.html5;
014
015import java.net.*;
016import java.net.URI;
017
018import org.apache.juneau.*;
019import org.apache.juneau.annotation.*;
020
021/**
022 * DTO for an HTML {@doc ExtHTML5.embedded-content-0#the-img-element <img>}
023 * element.
024 *
025 * <ul class='seealso'>
026 *    <li class='link'>{@doc DtoHtml5}
027 * </ul>
028 */
029@Bean(typeName="img")
030public class Img extends HtmlElementVoid {
031
032   /**
033    * Creates an empty {@link Img} element.
034    */
035   public Img() {}
036
037   /**
038    * Creates an {@link Img} element with the specified {@link Img#src(Object)} attribute.
039    *
040    * @param src The {@link Img#src(Object)} attribute.
041    */
042   public Img(Object src) {
043      src(src);
044   }
045
046   /**
047    * {@doc ExtHTML5.embedded-content-0#attr-img-alt alt} attribute.
048    *
049    * <p>
050    * Replacement text for use when images are not available.
051    *
052    * @param alt The new value for this attribute.
053    * @return This object (for method chaining).
054    */
055   public final Img alt(String alt) {
056      attr("alt", alt);
057      return this;
058   }
059
060   /**
061    * {@doc ExtHTML5.embedded-content-0#attr-img-crossorigin crossorigin}
062    * attribute.
063    *
064    * <p>
065    * How the element handles cross-origin requests.
066    *
067    * @param crossorigin The new value for this attribute.
068    * @return This object (for method chaining).
069    */
070   public final Img crossorigin(String crossorigin) {
071      attr("crossorigin", crossorigin);
072      return this;
073   }
074
075   /**
076    * {@doc ExtHTML5.embedded-content-0#attr-dim-height height}
077    * attribute.
078    *
079    * <p>
080    * Vertical dimension.
081    *
082    * @param height
083    *    The new value for this attribute.
084    *    Typically a {@link Number} or {@link String}.
085    * @return This object (for method chaining).
086    */
087   public final Img height(Object height) {
088      attr("height", height);
089      return this;
090   }
091
092   /**
093    * {@doc ExtHTML5.embedded-content-0#attr-img-ismap ismap} attribute.
094    *
095    * <p>
096    * Whether the image is a server-side image map.
097    *
098    * @param ismap
099    *    The new value for this attribute.
100    *    Typically a {@link Boolean} or {@link String}.
101    * @return This object (for method chaining).
102    */
103   public final Img ismap(Object ismap) {
104      attr("ismap", deminimize(ismap, "ismap"));
105      return this;
106   }
107
108   /**
109    * {@doc ExtHTML5.embedded-content-0#attr-img-src src} attribute.
110    *
111    * <p>
112    * Address of the resource.
113    *
114    * <p>
115    * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
116    * Strings must be valid URIs.
117    *
118    * <p>
119    * URIs defined by {@link UriResolver} can be used for values.
120    *
121    * @param src
122    *    The new value for this attribute.
123    *    Typically a {@link URL} or {@link String}.
124    * @return This object (for method chaining).
125    */
126   public final Img src(Object src) {
127      attrUri("src", src);
128      return this;
129   }
130
131   /**
132    * {@doc ExtHTML5.embedded-content-0#attr-hyperlink-usemap usemap}
133    * attribute.
134    *
135    * <p>
136    * Name of image map to use.
137    *
138    * @param usemap The new value for this attribute.
139    * @return This object (for method chaining).
140    */
141   public final Img usemap(String usemap) {
142      attr("usemap", usemap);
143      return this;
144   }
145
146   /**
147    * {@doc ExtHTML5.embedded-content-0#attr-dim-width width} attribute.
148    *
149    * <p>
150    * Horizontal dimension.
151    *
152    * @param width
153    *    The new value for this attribute.
154    *    Typically a {@link Number} or {@link String}.
155    * @return This object (for method chaining).
156    */
157   public final Img width(Object width) {
158      attr("width", width);
159      return this;
160   }
161
162
163   //-----------------------------------------------------------------------------------------------------------------
164   // Overridden methods
165   //-----------------------------------------------------------------------------------------------------------------
166
167   @Override /* HtmlElement */
168   public final Img _class(String _class) {
169      super._class(_class);
170      return this;
171   }
172
173   @Override /* HtmlElement */
174   public final Img id(String id) {
175      super.id(id);
176      return this;
177   }
178
179   @Override /* HtmlElement */
180   public final Img style(String style) {
181      super.style(style);
182      return this;
183   }
184}