GoogleCodeArchive / piccolo2d

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

Prepare SwingLayoutNode for distribution #150

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
My colleagues and I also saw a need for a Swing-like layout solution for
Piccolo2D, so we wrote an adapter that actually uses a swing layout manager
to arrange Piccolo nodes.  I've attached the entire implementation and
example usage in SwingLayoutNode.java.  Let's discuss whether this should
be included in the upcoming Piccolo 1.3 release.

Sample using Swing's FlowLayout:
        SwingLayoutNode flowLayoutNode = new SwingLayoutNode( new
FlowLayout() );
        flowLayoutNode.addChild( new PText( "1+1" ) );
        flowLayoutNode.addChild( new PText( "2+2" ) );

Sample using Swing's BorderLayout:
        BorderLayout borderLayout = new BorderLayout();
        borderLayout.setHgap( 10 );
        borderLayout.setVgap( 5 );
        SwingLayoutNode borderLayoutNode = new SwingLayoutNode( borderLayout );
        borderLayoutNode.addChild( new PText( "North" ), BorderLayout.NORTH );
        borderLayoutNode.setAnchor( Anchor.CENTER );
        borderLayoutNode.addChild( new PText( "South" ), BorderLayout.SOUTH );
        borderLayoutNode.setAnchor( Anchor.WEST );
        borderLayoutNode.addChild( new PText( "East" ), BorderLayout.EAST );
        borderLayoutNode.addChild( new PText( "West" ), BorderLayout.WEST );
        borderLayoutNode.addChild( new PText( "CENTER" ),
BorderLayout.CENTER );

I'm also attaching a screenshot of the sample main() for your convenience.

Thanks,
Sam Reid

Original issue reported on code.google.com by samrr...@gmail.com on 1 Dec 2009 at 8:12

Attachments:

GoogleCodeExporter commented 9 years ago
On Dec 1, Michael Heuer wrote:

I think this is cool, and a good fit for piccolox.swing in extras.
Could you create an issue for this?  With the proper license header,
unit tests, checkstyle fixes, and refactoring of the example into a
separate class, this could go into 1.3.

   michael 

Original comment by samrr...@gmail.com on 1 Dec 2009 at 8:13

GoogleCodeExporter commented 9 years ago
See this thread for context:

http://groups.google.com/group/piccolo2d-users/browse_thread/thread/741bca3c0aa2
d96e?pli=1

Original comment by samrr...@gmail.com on 1 Dec 2009 at 8:14

GoogleCodeExporter commented 9 years ago
Chris suggested that we also spend some additional time to verify that (1) 
we're not
exposing anything that we'll regret later, and (2) method names are logical.  I 
agree
that we need to make sure the public API is acceptable before publishing this.

Original comment by samrr...@gmail.com on 1 Dec 2009 at 8:16

GoogleCodeExporter commented 9 years ago
I don't have plans for working on this in the near future, if someone wants to 
work
on it.  Here's a quick itemized summary of proposed work:

1. Add to SVN in piccolox
2. Add license header
3. Add unit tests
4. Add checkstyle fixes
5. Refactor sample usage to separate class
6. Make sure public interface is acceptable
7. Make sure private internal method naming, etc is acceptable

Original comment by samrr...@gmail.com on 1 Dec 2009 at 8:18

GoogleCodeExporter commented 9 years ago
I'll do it.

Original comment by allain.lalonde on 1 Dec 2009 at 8:21

GoogleCodeExporter commented 9 years ago
I'd tried something like this in the past and failed, so I'm very much liking 
this code.

Original comment by allain.lalonde on 1 Dec 2009 at 8:26

GoogleCodeExporter commented 9 years ago
I'm looking at the Anchor approach and am wondering if it's too restrictive.

It's basically a fill strategy for whatever bounds the LayoutManager assigns to 
a
node. It would seem that changing the bounds of the nodes is as valid an 
approach as
pinning the node to the WEST of the box but the current naming convention 
doesn't
make it clear that Anchor.FILL might be a valid fill strategy.

Thoughts?

Original comment by allain.lalonde on 2 Dec 2009 at 8:19

GoogleCodeExporter commented 9 years ago
I would vote to leave as-is for now.  Would you want to mark this one as Fixed, 
Allain?

Original comment by heue...@gmail.com on 15 Dec 2009 at 8:38

GoogleCodeExporter commented 9 years ago

Original comment by allain.lalonde on 15 Dec 2009 at 8:39

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 15 Dec 2009 at 8:56