/**
  * Sets up the paragraph from css attributes instead of the values found in StyleConstants (i.e.
  * which are used by the superclass). Since
  */
 protected void setPropertiesFromAttributes() {
   StyleSheet sheet = getStyleSheet();
   attr = sheet.getViewAttributes(this);
   painter = sheet.getBoxPainter(attr);
   if (attr != null) {
     super.setPropertiesFromAttributes();
     setInsets(
         (short) painter.getInset(TOP, this),
         (short) painter.getInset(LEFT, this),
         (short) painter.getInset(BOTTOM, this),
         (short) painter.getInset(RIGHT, this));
     Object o = attr.getAttribute(CSS.Attribute.TEXT_ALIGN);
     if (o != null) {
       // set horizontal alignment
       String ta = o.toString();
       if (ta.equals("left")) {
         setJustification(StyleConstants.ALIGN_LEFT);
       } else if (ta.equals("center")) {
         setJustification(StyleConstants.ALIGN_CENTER);
       } else if (ta.equals("right")) {
         setJustification(StyleConstants.ALIGN_RIGHT);
       } else if (ta.equals("justify")) {
         setJustification(StyleConstants.ALIGN_JUSTIFIED);
       }
     }
     // Get the width/height
     cssWidth = (CSS.LengthValue) attr.getAttribute(CSS.Attribute.WIDTH);
     cssHeight = (CSS.LengthValue) attr.getAttribute(CSS.Attribute.HEIGHT);
   }
 }
Example #2
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);
  }