kinnichiroh / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

Piccolo is missing HTML support #111

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Except when using PSwing Piccolo doesn't have a method for creating nodes 
that display HTML.  That's too bad since HTML is a language that most 
developers know and when it's compared to using PStyledText, it's trivial 
to style.

Sam Reid posted some excellent code here: 
http://groups.google.com/group/piccolo2d-
users/browse_thread/thread/25835a96a5d921e7/6cf577a995557268?
q=HTMLNode+piccolo#6cf577a995557268 that we should use as a starting point.

When compared to a PText node PHtml will render slower, but when compared 
to PStyledText, I think they'd be comparable.

I've created a branch called phtml where I'll be expanding the code posted 
by Sam.

Original issue reported on code.google.com by allain.lalonde on 28 Jul 2009 at 3:22

GoogleCodeExporter commented 9 years ago
great!

Original comment by mr0...@mro.name on 28 Jul 2009 at 3:28

GoogleCodeExporter commented 9 years ago
In some runs, I experimented with making the internal JLabel static (so all 
PHTML
shared a copy), and didn't see any problems with the rendering.  We should 
discuss
whether a static JLabel would be better or worse.

Original comment by samrr...@gmail.com on 28 Jul 2009 at 4:00

GoogleCodeExporter commented 9 years ago
A few thoughts about the code in the phtml branch, as of r620.

The license text is not exactly correct, it should match the text in 
license-piccolo.txt

I prefer the classname PHtmlText or PHTMLText to PHtml.

I prefer keeping the API in line with PText:

PROPERTY_HTML = "html";  -->  PROPERTY_TEXT = "text";
PROPERTY_CODE_HTML  -->  PROPERTY_CODE_TEXT
PROPERTY_HTML_COLOR = "html color";  -->  PROPERTY_TEXT_COLOR = "text color"
PROPERTY_CODE_HTML_COLOR  -->  PROPERTY_CODE_TEXT_COLOR
String getHtml()  -->  String getText()
void setHtml(final String newHtml)  -->  void setText(final String text)
Color getHtmlColor()  -->  Color getTextColor()
void setHtmlColor(final Color newColor)  -->  void setTextColor(final Color 
textColor)

Is it possible to use setTextPaint(Paint paint) instead of Color?

Add a javadoc note to the setBounds methods

/**
 * {@inheritDoc}
 *
 * <p>Subclasses that override this method must call
<code>super.setBounds(...)</code> for bounds changes to be processed 
correctly.</p>
 */

DEFAULT_FONT and DEFAULT_HTML_COLOR (or DEFAULT_TEXT_COLOR or 
DEFAULT_TEXT_PAINT as
it were) could be made package-private so that the unit test could check for 
those
instead of just IsNotNullByDefault.  Or PText has DEFAULT_FONT public.

Original comment by heue...@gmail.com on 29 Jul 2009 at 8:53

GoogleCodeExporter commented 9 years ago
On further consideration, I like PHtmlView or PHTMLView better as a class name.

It is not possible to use setTextPaint(Paint paint) because JLabel provides only
setForeground(Color).  I like then void setTextColor(final Color textColor) and 
similar.

The javadoc note about calling super.setBounds probably isn't necessary since 
that
recommendation holds for nearly all protected methods in Piccolo2D.

Original comment by heue...@gmail.com on 30 Jul 2009 at 3:06

GoogleCodeExporter commented 9 years ago
merged branch in r642

Original comment by allain.lalonde on 5 Aug 2009 at 12:55

GoogleCodeExporter commented 9 years ago

Original comment by allain.lalonde on 5 Aug 2009 at 12:51

GoogleCodeExporter commented 9 years ago
Committed some of the changes I mentioned above for review in r658.

$ svn commit -m "Issue 111 ; API and javadoc improvements to PHtmlView, html -->
text, htmlColor --> textColor, clickedAddress --> linkAddressAt, etc."
Sending        ...
Transmitting file data ...
Committed revision 658.

Original comment by heue...@gmail.com on 6 Aug 2009 at 5:22

GoogleCodeExporter commented 9 years ago
PHtmlView should also provide the paintGreek/greekThreshold mechanism as in 
PText and
PSwing.

Original comment by heue...@gmail.com on 6 Aug 2009 at 5:34

GoogleCodeExporter commented 9 years ago
Why's that? Why is it in PText at all? PSwing maybe, but even there...?

Original comment by allain.lalonde on 6 Aug 2009 at 5:50

GoogleCodeExporter commented 9 years ago
I guess paintGreek/greekThreshold can wait, if deemed necessary.  Marking as 
Verified.

Original comment by heue...@gmail.com on 30 Oct 2009 at 3:03