Revision: 641 Author: allain.lalonde Date: Tue Aug 4 07:05:16 2009 Log: Modified HTMLExample to refer to match renaming of PHtml to PHtmlView http://code.google.com/p/piccolo2d/source/detail?r=641
Added: /piccolo2d.java/branches/phtml/examples/src/main/java/edu/umd/cs/piccolo/examples/HtmlViewExample.java Deleted: /piccolo2d.java/branches/phtml/examples/src/main/java/edu/umd/cs/piccolo/examples/HTMLExample.java Modified: /piccolo2d.java/branches/phtml/examples/src/main/java/edu/umd/cs/piccolo/examples/ExampleRunner.java ======================================= --- /dev/null +++ /piccolo2d.java/branches/phtml/examples/src/main/java/edu/umd/cs/piccolo/examples/HtmlViewExample.java Tue Aug 4 07:05:16 2009 @@ -0,0 +1,74 @@ +package edu.umd.cs.piccolo.examples; + +import java.awt.geom.Point2D; + +import javax.swing.JOptionPane; + +import edu.umd.cs.piccolo.PCanvas; +import edu.umd.cs.piccolo.PNode; +import edu.umd.cs.piccolo.event.PBasicInputEventHandler; +import edu.umd.cs.piccolo.event.PInputEvent; +import edu.umd.cs.piccolo.nodes.PHtmlView; +import edu.umd.cs.piccolox.PFrame; + +public class HtmlViewExample extends PFrame { + private static final long serialVersionUID = 1L; + private StringBuffer html; + + public HtmlViewExample() { + this(null); + } + + public HtmlViewExample(final PCanvas aCanvas) { + super("HTMLExample", false, aCanvas); + } + + public void initialize() { + html = new StringBuffer(); + html.append("<p style='margin-bottom: 10px;'>"); + html.append("This is an example <a href='#testing'>of what can</a> be done with PHtml."); + html.append("</p>"); + html.append("<p>It supports:</p>"); + appendFeatures(); + + final PHtmlView htmlNode = new PHtmlView(html.toString()); + htmlNode.setBounds(0, 0, 400, 400); + getCanvas().getLayer().addChild(htmlNode); + + getCanvas().addInputEventListener(new PBasicInputEventHandler() { + public void mouseClicked(final PInputEvent event) { + final PNode clickedNode = event.getPickedNode(); + if (!(clickedNode instanceof PHtmlView)) { + return; + } + + final Point2D clickPoint = event.getPositionRelativeTo(clickedNode); + final PHtmlView htmlNode = (PHtmlView) clickedNode; + + final String url = htmlNode.getClickedAddress(clickPoint); + JOptionPane.showMessageDialog(null, url); + } + }); + } + + private void appendFeatures() { + html.append("<ul>"); + html.append("<li><b>HTML</b> 3.2</li>"); + html.append("<li><font style='color:red; font-style: italic;'>Limited CSS 1.0</font></li>"); + html.append("<li>Tables:"); + appendTable(); + html.append("</li>"); + html.append("</ul>"); + } + + private void appendTable() { + html.append("<table border='1' cellpadding='2' cellspacing='0'>"); + html.append("<tr><th>Col 1</th><th>Col 2</th></tr>"); + html.append("<tr><td>Col 1 val</td><td>Col 2 val</td></tr>"); + html.append("</table>"); + } + + public static void main(final String[] args) { + new HtmlViewExample(); + } +} ======================================= --- /piccolo2d.java/branches/phtml/examples/src/main/java/edu/umd/cs/piccolo/examples/HTMLExample.java Tue Jul 28 21:39:14 2009 +++ /dev/null @@ -1,74 +0,0 @@ -package edu.umd.cs.piccolo.examples; - -import java.awt.geom.Point2D; - -import javax.swing.JOptionPane; - -import edu.umd.cs.piccolo.PCanvas; -import edu.umd.cs.piccolo.PNode; -import edu.umd.cs.piccolo.event.PBasicInputEventHandler; -import edu.umd.cs.piccolo.event.PInputEvent; -import edu.umd.cs.piccolo.nodes.PHtml; -import edu.umd.cs.piccolox.PFrame; - -public class HTMLExample extends PFrame { - private static final long serialVersionUID = 1L; - private StringBuffer html; - - public HTMLExample() { - this(null); - } - - public HTMLExample(final PCanvas aCanvas) { - super("HTMLExample", false, aCanvas); - } - - public void initialize() { - html = new StringBuffer(); - html.append("<p style='margin-bottom: 10px;'>"); - html.append("This is an example <a href='#testing'>of what can</a> be done with PHtml."); - html.append("</p>"); - html.append("<p>It supports:</p>"); - appendFeatures(); - - final PHtml htmlNode = new PHtml(html.toString()); - htmlNode.setBounds(0, 0, 400, 400); - getCanvas().getLayer().addChild(htmlNode); - - getCanvas().addInputEventListener(new PBasicInputEventHandler() { - public void mouseClicked(final PInputEvent event) { - final PNode clickedNode = event.getPickedNode(); - if (!(clickedNode instanceof PHtml)) { - return; - } - - final Point2D clickPoint = event.getPositionRelativeTo(clickedNode); - final PHtml htmlNode = (PHtml) clickedNode; - - final String url = htmlNode.getClickedAddress(clickPoint); - JOptionPane.showMessageDialog(null, url); - } - }); - } - - private void appendFeatures() { - html.append("<ul>"); - html.append("<li><b>HTML</b> 3.2</li>"); - html.append("<li><font style='color:red; font-style: italic;'>Limited CSS 1.0</font></li>"); - html.append("<li>Tables:"); - appendTable(); - html.append("</li>"); - html.append("</ul>"); - } - - private void appendTable() { - html.append("<table border='1' cellpadding='2' cellspacing='0'>"); - html.append("<tr><th>Col 1</th><th>Col 2</th></tr>"); - html.append("<tr><td>Col 1 val</td><td>Col 2 val</td></tr>"); - html.append("</table>"); - } - - public static void main(final String[] args) { - new HTMLExample(); - } -} ======================================= --- /piccolo2d.java/branches/phtml/examples/src/main/java/edu/umd/cs/piccolo/examples/ExampleRunner.java Tue Jul 28 10:22:29 2009 +++ /piccolo2d.java/branches/phtml/examples/src/main/java/edu/umd/cs/piccolo/examples/ExampleRunner.java Tue Aug 4 07:05:16 2009 @@ -86,7 +86,7 @@ BirdsEyeViewExample.class, CameraExample.class, CenterExample.class, ChartLabelExample.class, ClipExample.class, CompositeExample.class, DynamicExample.class, EventHandlerExample.class, FullScreenNodeExample.class, GraphEditorExample.class, GridExample.class, GroupExample.class, - HandleExample.class, HelloWorldExample.class, HierarchyZoomExample.class, HTMLExample.class, + HandleExample.class, HelloWorldExample.class, HierarchyZoomExample.class, HtmlViewExample.class, KeyEventFocusExample.class, LayoutExample.class, LensExample.class, NavigationExample.class, NodeCacheExample.class, NodeEventExample.class, NodeExample.class, NodeLinkExample.class, PanToExample.class, PathExample.class, PositionExample.class, PositionPathActivityExample.class, --~--~---------~--~----~------------~-------~--~----~ Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en -~----------~----~----~----~------~----~------~--~---