imageprimitive.java

来自「考勤管理系统源码」· Java 代码 · 共 56 行

JAVA
56
字号
package com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.ContentElements;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Core.*;import java.util.*;/** * The ImagePrimitive class encapsulates the details of building * the HTML for an img tag.. */public class ImagePrimitive implements IHtmlPrimitive{  private String source;  private String alternateText;  private Style style;  private int width = -1;  private int height = -1;  /** Construct an ImagePrimitive with the specified source url. */  public ImagePrimitive(String source)  {    this.source = source;  }  /** Specifies the text to use if the image is not displayed or   *  to display to augment the image in a tooltip.*/  public void setAlternateText(String alternateText)  {    this.alternateText = alternateText;  }  /** Specifies the size in pixels of the image. */  public void setSize(int width, int height)  {    this.width = width;    this.height = height;  }  /** Specify the style class that is applied to the image. */  public void setStyle(Style style)  {    this.style = style;  }  /** Build the content for this primitive and append it to   *  the specified buffer.*/  public void buildContent(StringBuffer buffer)  {    String width_string = Formatting.convertToAttribute("width", width);    String height_string = Formatting.convertToAttribute("height", height);    String src_string = Formatting.convertToAttribute("src", source);    String alt_string = Formatting.convertToAttribute("alt", alternateText);    String class_string = Formatting.convertToAttribute("class", style);    buffer.append("<img" +src_string+width_string+height_string+alt_string+class_string+ "></img>");  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?