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/grouping-content.html#the-figure-element"><figure></a> 023 * element. 024 * 025 * <p> 026 * The figure element represents self-contained content, potentially with a caption, that is 027 * typically referenced as a single unit from the main flow of the document. It is used to 028 * group related content such as images, diagrams, code snippets, or other media that can 029 * be moved away from the main flow of the document without affecting the document's meaning. 030 * The figure element can contain a figcaption element to provide a caption for the content. 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 figure with image</jc> 037 * Figure <jv>simple</jv> = <jsm>figure</jsm>( 038 * <jsm>img</jsm>(<js>"/images/sunset.jpg"</js>, <js>"Sunset"</js>), 039 * <jsm>figcaption</jsm>(<js>"A beautiful sunset over the mountains."</js>) 040 * ); 041 * 042 * <jc>// Figure with code snippet</jc> 043 * Figure <jv>codeFigure</jv> = <jsm>figure</jsm>( 044 * <jsm>pre</jsm>(<jsm>code</jsm>(<js>"function hello() {\n return 'Hello World';\n}"</js>)), 045 * <jsm>figcaption</jsm>(<js>"A simple JavaScript function."</js>) 046 * ); 047 * 048 * <jc>// Figure with styling</jc> 049 * Figure <jv>styled</jv> = <jsm>figure</jsm>( 050 * <jsm>img</jsm>(<js>"/charts/sales.png"</js>, <js>"Sales Chart"</js>), 051 * <jsm>figcaption</jsm>(<js>"Monthly sales data for 2024."</js>) 052 * ).class_(<js>"chart-figure"</js>); 053 * 054 * <jc>// Figure with multiple elements</jc> 055 * Figure <jv>complex</jv> = <jsm>figure</jsm>( 056 * <jsm>img</jsm>(<js>"/images/diagram.png"</js>, <js>"Process Diagram"</js>), 057 * <jsm>p</jsm>(<js>"This diagram shows the complete workflow."</js>), 058 * <jsm>figcaption</jsm>(<js>"Figure 1: System Architecture Overview."</js>) 059 * ); 060 * 061 * <jc>// Figure with ID</jc> 062 * Figure <jv>withId</jv> = <jsm>figure</jsm>( 063 * <jsm>img</jsm>(<js>"/charts/main.png"</js>, <js>"Main Chart"</js>), 064 * <jsm>figcaption</jsm>(<js>"Primary performance metrics."</js>) 065 * ).id(<js>"main-chart"</js>); 066 * 067 * <jc>// Figure with styling</jc> 068 * Figure <jv>styled2</jv> = <jsm>figure</jsm>( 069 * <jsm>img</jsm>(<js>"/images/example.png"</js>, <js>"Example"</js>), 070 * <jsm>figcaption</jsm>(<js>"An example of the new feature."</js>) 071 * ).style(<js>"border: 1px solid #ccc; padding: 10px; margin: 20px 0;"</js>); 072 * 073 * <jc>// Figure with table</jc> 074 * Figure <jv>tableFigure</jv> = <jsm>figure</jsm>( 075 * <jsm>table</jsm>( 076 * <jsm>tr</jsm>( 077 * <jsm>th</jsm>(<js>"Name"</js>), 078 * <jsm>th</jsm>(<js>"Value"</js>) 079 * ), 080 * <jsm>tr</jsm>( 081 * <jsm>td</jsm>(<js>"Item 1"</js>), 082 * <jsm>td</jsm>(<js>"100"</js>) 083 * ) 084 * ), 085 * <jsm>figcaption</jsm>(<js>"Data summary table."</js>) 086 * ); 087 * </p> 088 * 089 * <p> 090 * The following convenience methods are provided for constructing instances of this bean: 091 * <ul class='javatree'> 092 * <li class='jc'>{@link HtmlBuilder} 093 * <ul class='javatree'> 094 * <li class='jm'>{@link HtmlBuilder#figure() figure()} 095 * <li class='jm'>{@link HtmlBuilder#figure(Object...) figure(Object...)} 096 * </ul> 097 * </ul> 098 * </p> 099 * 100 * <h5 class='section'>See Also:</h5><ul> 101 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 102 * </ul> 103 */ 104@Marshalled(typeName = "figure") 105public class Figure extends HtmlElementContainer<Figure> { 106 107 /** 108 * Creates an empty {@link Figure} element. 109 */ 110 public Figure() {} 111 112 /** 113 * Creates a {@link Figure} element with the specified child nodes. 114 * 115 * @param children The child nodes. 116 */ 117 public Figure(Object...children) { 118 children(children); 119 } 120 121}