Esempio n. 1
0
 /**
  * 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);
   }
 }
Esempio n. 2
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. 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);
 }