Revision: 665
Author: allain.lalonde
Date: Fri Aug 7 08:33:26 2009
Log: PHtmlView - removed the JFrame.pack() hack. I feel better now.
http://code.google.com/p/piccolo2d/source/detail?r=665
Modified:
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/nodes/PHtmlView.java
=======================================
---
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/nodes/PHtmlView.java
Thu Aug 6 16:42:53 2009
+++
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/nodes/PHtmlView.java
Fri Aug 7 08:33:26 2009
@@ -35,7 +35,6 @@
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
-import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.Position;
@@ -270,17 +269,11 @@
private void fitHeightToHtmlContent() {
htmlView.setSize((float) getWidth(), 0f);
- float preferredWrapHeight = htmlView.getPreferredSpan(View.Y_AXIS);
- label.setPreferredSize(new Dimension((int) getWidth(), (int)
preferredWrapHeight));
-
- Font oldFont = label.getFont();
- JFrame frame = new JFrame();
- frame.getContentPane().add(label);
- frame.pack();
- label.setFont(oldFont);
-
- if (getHeight() != label.getHeight()) {
- super.setBounds(getX(), getY(), getWidth(), label.getHeight());
+ float wrapHeight = htmlView.getPreferredSpan(View.Y_AXIS);
+ label.setSize(new Dimension((int) getWidth(), (int) wrapHeight));
+
+ if (getHeight() != label.getHeight()) {
+ super.setBounds(getX(), getY(), getWidth(), wrapHeight);
}
}
@@ -308,13 +301,10 @@
*/
protected void paint(final PPaintContext paintContext) {
super.paint(paintContext);
-
- if (label.getWidth() != 0 && label.getHeight() != 0) {
- paintContext.pushClip(getBounds());
- final Graphics2D g2 = paintContext.getGraphics();
- htmlView.paint(g2, getBounds().getBounds());
- paintContext.popClip(getBounds());
- }
+ paintContext.pushClip(getBounds());
+ final Graphics2D g2 = paintContext.getGraphics();
+ htmlView.paint(g2, getBounds().getBounds());
+ paintContext.popClip(getBounds());
}
/**
--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---