diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-09-05 20:47:38 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-09-05 20:47:38 +0000 |
commit | 228fc33f661314b6723b691635085ee4ff6a69b2 (patch) | |
tree | 50e78696593f8df21fe9330258dff98537d39f65 /javax/swing/text/html/ParagraphView.java | |
parent | f090c35d5776db64813ccf19d8327cf0ae756ac7 (diff) | |
download | classpath-228fc33f661314b6723b691635085ee4ff6a69b2.tar.gz |
2006-09-05 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD-->generics from 2006/08/12 to 2006/09/03.
Diffstat (limited to 'javax/swing/text/html/ParagraphView.java')
-rw-r--r-- | javax/swing/text/html/ParagraphView.java | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/javax/swing/text/html/ParagraphView.java b/javax/swing/text/html/ParagraphView.java index 2339f4e66..951f70b60 100644 --- a/javax/swing/text/html/ParagraphView.java +++ b/javax/swing/text/html/ParagraphView.java @@ -39,12 +39,14 @@ exception statement from your version. */ package javax.swing.text.html; import java.awt.Graphics; +import java.awt.Rectangle; import java.awt.Shape; import javax.swing.SizeRequirements; import javax.swing.text.AttributeSet; import javax.swing.text.Document; import javax.swing.text.Element; +import javax.swing.text.StyleConstants; import javax.swing.text.View; /** @@ -55,10 +57,20 @@ import javax.swing.text.View; * @author Roman Kennke (kennke@aicas.com) */ public class ParagraphView - extends javax.swing.text.ParagraphView + extends javax.swing.text.ParagraphView { /** + * The attributes used by this view. + */ + private AttributeSet attributes; + + /** + * The stylesheet's box painter. + */ + private StyleSheet.BoxPainter painter; + + /** * Creates a new ParagraphView for the specified element. * * @param element the element @@ -88,8 +100,11 @@ public class ParagraphView */ public AttributeSet getAttributes() { - // FIXME: Implement this multiplexing thing. - return super.getAttributes(); + if (attributes == null) + { + attributes = getStyleSheet().getViewAttributes(this); + } + return attributes; } /** @@ -98,7 +113,32 @@ public class ParagraphView */ protected void setPropertiesFromAttributes() { - // FIXME: Implement this. + super.setPropertiesFromAttributes(); + + // Fetch CSS attributes. + AttributeSet atts = getAttributes(); + Object o = atts.getAttribute(CSS.Attribute.TEXT_ALIGN); + if (o != null) + { + String align = o.toString(); + if (align.equals("left")) + setJustification(StyleConstants.ALIGN_LEFT); + else if (align.equals("right")) + setJustification(StyleConstants.ALIGN_RIGHT); + else if (align.equals("center")) + setJustification(StyleConstants.ALIGN_CENTER); + else if (align.equals("justify")) + setJustification(StyleConstants.ALIGN_JUSTIFIED); + } + + // Fetch StyleSheet's box painter. + painter = getStyleSheet().getBoxPainter(atts); + setInsets((short) painter.getInset(TOP, this), + (short) painter.getInset(LEFT, this), + (short) painter.getInset(BOTTOM, this), + (short) painter.getInset(RIGHT, this)); + + // TODO: Handle CSS width and height attributes somehow. } /** @@ -147,15 +187,20 @@ public class ParagraphView } /** - * Paints this view. This delegates to the superclass after the coordinates - * have been updated for tab calculations. + * Paints this view. This paints the box using the stylesheet's + * box painter for this view and delegates to the super class paint() + * afterwards. * * @param g the graphics object * @param a the current allocation of this view */ public void paint(Graphics g, Shape a) { - // FIXME: Implement the above specified behaviour. + if (a != null) + { + Rectangle r = a instanceof Rectangle ? (Rectangle) a : a.getBounds(); + painter.paint(g, r.x, r.y, r.width, r.height, this); + } super.paint(g, a); } |