001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.html5; 018 019import org.apache.juneau.marshall.*; 020 021/** 022 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#the-meter-element"><meter></a> 023 * element. 024 * 025 * <p> 026 * The meter element represents a scalar measurement within a known range, or a fractional value. 027 * It is used to display a gauge or meter showing a value within a defined range, such as disk 028 * usage, memory usage, or progress. The meter element is not suitable for representing a range 029 * of values (use the input element with type="range" for that). It is typically rendered as a 030 * visual gauge or bar that shows the current value relative to the minimum and maximum values. 031 * 032 * <h5 class='section'>Examples:</h5> 033 * <p class='bcode w800'> 034 * <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*; 035 * 036 * <jc>// Simple meter</jc> 037 * Meter <jv>simple</jv> = <jsm>meter</jsm>() 038 * .value(50) 039 * .min(0) 040 * .max(100); 041 * 042 * <jc>// Meter with styling</jc> 043 * Meter <jv>styled</jv> = <jsm>meter</jsm>() 044 * .class_(<js>"progress-meter"</js>) 045 * .value(75) 046 * .min(0) 047 * .max(100); 048 * 049 * <jc>// Meter with complex content</jc> 050 * Meter <jv>complex</jv> = <jsm>meter</jsm>() 051 * .value(60) 052 * .min(0) 053 * .max(100) 054 * .low(25) 055 * .high(75) 056 * .optimum(50); 057 * 058 * <jc>// Meter with ID</jc> 059 * Meter <jv>withId</jv> = <jsm>meter</jsm>() 060 * .id(<js>"disk-usage"</js>) 061 * .value(80) 062 * .min(0) 063 * .max(100); 064 * 065 * <jc>// Meter with styling</jc> 066 * Meter <jv>styled2</jv> = <jsm>meter</jsm>() 067 * .style(<js>"width: 200px; height: 20px;"</js>) 068 * .value(40) 069 * .min(0) 070 * .max(100); 071 * 072 * <jc>// Meter with multiple attributes</jc> 073 * Meter <jv>multiple</jv> = <jsm>meter</jsm>() 074 * .value(85) 075 * .min(0) 076 * .max(100) 077 * .low(20) 078 * .high(80) 079 * .optimum(50) 080 * .title(<js>"Disk Usage: 85%"</js>); 081 * 082 * // Meter with form 083 * Meter withForm = new Meter() 084 * .form("usage-form") 085 * .value(30) 086 * .min(0) 087 * .max(100); 088 * </p> 089 * 090 * <h5 class='section'>See Also:</h5><ul> 091 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 092 * </ul> 093 */ 094@Marshalled(typeName = "meter") 095public class Meter extends HtmlElementMixed<Meter> { 096 097 /** 098 * Creates an empty {@link Meter} element. 099 */ 100 public Meter() {} 101 102 /** 103 * Creates a {@link Meter} element with the specified child nodes. 104 * 105 * @param children The child nodes. Must not be <jk>null</jk>. 106 */ 107 public Meter(Object...children) { 108 children(children); 109 } 110 111 /** 112 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-meter-high">high</a> attribute. 113 * 114 * <p> 115 * Low limit of high range. 116 * 117 * @param value 118 * The new value for this attribute. 119 * Typically a {@link Number} or {@link String}. 120 * Can be <jk>null</jk> to unset the attribute. 121 * @return This object. 122 */ 123 public Meter high(Object value) { 124 attr("high", value); 125 return this; 126 } 127 128 /** 129 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-meter-low">low</a> attribute. 130 * 131 * <p> 132 * High limit of low range. 133 * 134 * @param value 135 * The new value for this attribute. 136 * Typically a {@link Number} or {@link String}. 137 * Can be <jk>null</jk> to unset the attribute. 138 * @return This object. 139 */ 140 public Meter low(Object value) { 141 attr("low", value); 142 return this; 143 } 144 145 /** 146 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-meter-max">max</a> attribute. 147 * 148 * <p> 149 * Upper bound of range. 150 * 151 * @param value 152 * The new value for this attribute. 153 * Typically a {@link Number} or {@link String}. 154 * Can be <jk>null</jk> to unset the attribute. 155 * @return This object. 156 */ 157 public Meter max(Object value) { 158 attr("max", value); 159 return this; 160 } 161 162 /** 163 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-meter-min">min</a> attribute. 164 * 165 * <p> 166 * Lower bound of range. 167 * 168 * @param value 169 * The new value for this attribute. 170 * Typically a {@link Number} or {@link String}. 171 * Can be <jk>null</jk> to unset the attribute. 172 * @return This object. 173 */ 174 public Meter min(Object value) { 175 attr("min", value); 176 return this; 177 } 178 179 /** 180 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-meter-optimum">optimum</a> attribute. 181 * 182 * <p> 183 * Optimum value in gauge. 184 * 185 * @param value 186 * The new value for this attribute. 187 * Typically a {@link Number} or {@link String}. 188 * Can be <jk>null</jk> to unset the attribute. 189 * @return This object. 190 */ 191 public Meter optimum(Object value) { 192 attr("optimum", value); 193 return this; 194 } 195 196 /** 197 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-meter-value">value</a> attribute. 198 * 199 * <p> 200 * Current value of the element. 201 * 202 * @param value 203 * The new value for this attribute. 204 * Typically a {@link Number} or {@link String}. 205 * Can be <jk>null</jk> to unset the attribute. 206 * @return This object. 207 */ 208 public Meter value(Object value) { 209 attr("value", value); 210 return this; 211 } 212}