Esempio n. 1
0
 /**
  * Fetches the attributes to use when rendering. This is implemented to multiplex the attributes
  * specified in the model with a StyleSheet.
  */
 public AttributeSet getAttributes() {
   if (attr == null) {
     StyleSheet sheet = getStyleSheet();
     attr = sheet.getViewAttributes(this);
   }
   return attr;
 }
Esempio n. 2
0
 /**
  * Outputs the styles as a single element. Styles are not stored as elements, but part of the
  * document. For the time being styles are written out as a comment, inside a style tag.
  */
 void writeStyles(StyleSheet sheet) throws IOException {
   if (sheet != null) {
     Enumeration styles = sheet.getStyleNames();
     if (styles != null) {
       boolean outputStyle = false;
       while (styles.hasMoreElements()) {
         String name = (String) styles.nextElement();
         // Don't write out the default style.
         if (!StyleContext.DEFAULT_STYLE.equals(name)
             && writeStyle(name, sheet.getStyle(name), outputStyle)) {
           outputStyle = true;
         }
       }
       if (outputStyle) {
         writeStyleEndTag();
       }
     }
   }
 }
Esempio n. 3
0
  /** Update any cached values that come from attributes. */
  protected void setPropertiesFromAttributes() {

    // update attributes
    StyleSheet sheet = getStyleSheet();
    attr = sheet.getViewAttributes(this);

    // Reset the painter
    painter = sheet.getBoxPainter(attr);
    if (attr != null) {
      setInsets(
          (short) painter.getInset(TOP, this),
          (short) painter.getInset(LEFT, this),
          (short) painter.getInset(BOTTOM, this),
          (short) painter.getInset(RIGHT, this));
    }

    // Get the width/height
    cssWidth = (CSS.LengthValue) attr.getAttribute(CSS.Attribute.WIDTH);
    cssHeight = (CSS.LengthValue) attr.getAttribute(CSS.Attribute.HEIGHT);
  }
 /**
  * Creates a new view that represents an IMG element.
  *
  * @param elem the element to create a view for
  */
 public MyImageView(Element elem) {
   super(elem);
   initialize(elem);
   StyleSheet sheet = getStyleSheet();
   attr = sheet.getViewAttributes(this);
 }