Ejemplo 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);
   }
 }
Ejemplo n.º 2
0
  /**
   * Renders using the given rendering surface and area on that surface. This is implemented to
   * delgate to the superclass after stashing the base coordinate for tab calculations.
   *
   * @param g the rendering surface to use
   * @param a the allocated region to render into
   * @see View#paint
   */
  public void paint(Graphics g, Shape a) {
    if (a == null) {
      return;
    }

    Rectangle r;
    if (a instanceof Rectangle) {
      r = (Rectangle) a;
    } else {
      r = a.getBounds();
    }
    painter.paint(g, r.x, r.y, r.width, r.height, this);
    super.paint(g, a);
  }
Ejemplo n.º 3
0
 /**
  * Establishes the parent view for this view. This is guaranteed to be called before any other
  * methods if the parent view is functioning properly.
  *
  * <p>This is implemented to forward to the superclass as well as call the {@link
  * #setPropertiesFromAttributes setPropertiesFromAttributes} method to set the paragraph
  * properties from the css attributes. The call is made at this time to ensure the ability to
  * resolve upward through the parents view attributes.
  *
  * @param parent the new parent, or null if the view is being removed from a parent it was
  *     previously added to
  */
 public void setParent(View parent) {
   super.setParent(parent);
   if (parent != null) {
     setPropertiesFromAttributes();
   }
 }