📄 paragraphprimitive.java
字号:
package com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.ContentElements;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Core.*;import java.util.*;/** The ParagraphPrimitive class encapsulates the logic for * creating a paragraph that encloses text, links, spans, * and images. */public class ParagraphPrimitive implements IHtmlPrimitive{ private List primitives = new ArrayList(); private Style style; /** Construct a ParagraphPrimitive with the specified style and text.*/ public ParagraphPrimitive(Style style, String text) { this.style = style; addText(text); } /** add the specified text to this ParagraphPrimitive*/ public void addText(String text) { primitives.add(new TextPrimitive(text)); } /** add the specified text with the specified style*/ public void addText(Style style, String text) { primitives.add(new SpanPrimitive(style, text)); } /** Add the specified primitive to this ParagraphPrimitive */ public void addImage(ImagePrimitive primitive) { primitives.add(primitive); } /** Add the specified primitive to this ParagraphPrimitive */ public void addLink(LinkPrimitive primitive) { primitives.add(primitive); } /** Add the specified primitive to this ParagraphPrimitive */ public void addSpan(SpanPrimitive primitive) { primitives.add(primitive); } /** Add the specified primitive to this ParagraphPrimitive */ public void addText(TextPrimitive primitive) { primitives.add(primitive); } /** Add the a line break to this ParagraphPrimitive */ public void addLineBreak() { TextPrimitive text = new TextPrimitive(); text.addLineBreak(); primitives.add(text); } /** Build the content for this primitive and append it to * the specified buffer.*/ public void buildContent(StringBuffer buffer) { String style_string = Formatting.convertToAttribute("class", style); buffer.append("<p " +style_string+ ">"); Iterator it = primitives.iterator(); while (it.hasNext()) { IHtmlPrimitive primitive = (IHtmlPrimitive) it.next(); primitive.buildContent(buffer); } buffer.append("</p>\n"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -