[piccolo2d-dev] Issue 106 in piccolo2d: toImage array is too simple in its fill behaviour
Comment #1 on issue 106 by allain.lalonde: toImage array is too simple in its fill behaviour http://code.google.com/p/piccolo2d/issues/detail?id=106 Actually #2 (the first one) is the one I'll go with as the default. -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~-~--~~~---~--~~ Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en -~--~~~~--~~--~--~---
[piccolo2d-dev] [piccolo2d] r649 committed - Fixed issue 106. Added fillStrategy to the toImage method....
Revision: 649 Author: allain.lalonde Date: Wed Aug 5 07:47:02 2009 Log: Fixed issue 106. Added fillStrategy to the toImage method. Not sure if this method will stick around long term in 2.0, since it's doing something that more appropriately belongs in a helper class of some sort, but it works now. Tests have been added aswell. http://code.google.com/p/piccolo2d/source/detail?r=649 Modified: /piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PNode.java /piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/PNodeTest.java === --- /piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PNode.java Tue Aug 4 18:13:28 2009 +++ /piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PNode.java Wed Aug 5 07:47:02 2009 @@ -44,13 +44,13 @@ import java.awt.image.BufferedImage; import java.awt.print.Book; import java.awt.print.PageFormat; -import java.awt.print.Paper; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -64,6 +64,7 @@ import java.util.List; import java.util.ListIterator; +import javax.imageio.ImageIO; import javax.swing.event.EventListenerList; import javax.swing.event.SwingPropertyChangeSupport; import javax.swing.text.MutableAttributeSet; @@ -353,6 +354,25 @@ /** Stores the name associated to this node. */ private String name; +/** + * toImage fill strategy that stretches the node be as large as possible + * while still retaining its aspect ratio. + */ +public static final int FILL_STRATEGY_ASPECT_FIT = 1; + +/** + * toImage fill strategy that stretches the node be large enough to cover + * the image, and centers it. + */ +public static final int FILL_STRATEGY_ASPECT_COVER = 2; + +/** + * toImage fill strategy that stretches the node to be exactly the + * dimensions of the image. Will result in distortion if the aspect ratios + * are different. + */ +public static final int FILL_STRATEGY_EXACT_FIT = 4; + /** * Creates a new PNode with the given name. * @@ -2865,23 +2885,79 @@ * image */ public Image toImage(final BufferedImage image, final Paint backGroundPaint) { -final int width = image.getWidth(); -final int height = image.getHeight(); +return toImage(image, backGroundPaint, FILL_STRATEGY_ASPECT_FIT); +} + +/** + * Paint a representation of this node into the specified buffered image. If + * background, paint is null, then the image will not be filled with a color + * prior to rendering + * + * @param image Image onto which this node will be painted + * @param backGroundPaint will fill background of image with this. May be + *null. + * @param fillStrategy strategy to use regarding how node will cover the + *image + * @return a rendering of this image and its descendants onto the specified + * image + */ +public Image toImage(final BufferedImage image, final Paint backGroundPaint, int fillStrategy) { +final int imageWidth = image.getWidth(); +final int imageHeight = image.getHeight(); final Graphics2D g2 = image.createGraphics(); if (backGroundPaint != null) { g2.setPaint(backGroundPaint); -g2.fillRect(0, 0, width, height); +g2.fillRect(0, 0, imageWidth, imageHeight); } -// reuse print method -final Paper paper = new Paper(); -paper.setSize(width, height); -paper.setImageableArea(0, 0, width, height); -final PageFormat pageFormat = new PageFormat(); -pageFormat.setPaper(paper); -print(g2, pageFormat, 0); - +final PBounds imageBounds = getFullBounds(); + +imageBounds.expandNearestIntegerDimensions(); + +g2.setClip(0, 0, imageWidth, imageHeight); + +double imageRatio = imageWidth / (imageHeight * 1.0); +double nodeRatio = getWidth() / getHeight(); +double scale; +switch (fillStrategy) { +case FILL_STRATEGY_ASPECT_FIT: +// scale the graphics so node's full bounds fit in the imageable +// bounds but aspect ration is retained + +if (nodeRatio = imageRatio) { +scale = image.getHeight() / getHeight(); +} +else { +scale = image.getWidth() / getWidth(); +} +g2.scale(scale, scale); +g2.translate(-imageBounds.x, -imageBounds.y); +break; +
[piccolo2d-dev] Issue 120 in piccolo2d: ant all fails to build all of piccolo
Updates: Status: WontFix Labels: Type-Defect Priority-Medium Effort-Low OpSys-Linux Toolkit-Piccolo2D.Java Milestone-1.2.1 Comment #1 on issue 120 by allain.lalonde: ant all fails to build all of piccolo http://code.google.com/p/piccolo2d/issues/detail?id=120 This issue results from attempting to run ant without the necessary environment setup. The script build.sh at the root of the piccolo-1.2.1 directory is the preferred method for compiling Piccolo2D on Linux since it guarantees that all dependencies are properly met. -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~-~--~~~---~--~~ Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en -~--~~~~--~~--~--~---
[piccolo2d-dev] Issue 88 in piccolo2d: toImage doesn't return an image of the proper size
Updates: Status: Fixed Comment #6 on issue 88 by allain.lalonde: toImage doesn't return an image of the proper size http://code.google.com/p/piccolo2d/issues/detail?id=88 Fixed in r649 -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~-~--~~~---~--~~ Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en -~--~~~~--~~--~--~---
[piccolo2d-dev] [piccolo2d] r651 committed - Fixed bug causing PFrame not to display by default.
Revision: 651 Author: allain.lalonde Date: Wed Aug 5 09:16:51 2009 Log: Fixed bug causing PFrame not to display by default. http://code.google.com/p/piccolo2d/source/detail?r=651 Modified: /piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java === --- /piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java Tue Aug 4 13:42:37 2009 +++ /piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java Wed Aug 5 09:16:51 2009 @@ -172,7 +172,7 @@ *not. */ public void setFullScreenMode(final boolean fullScreenMode) { -if (fullScreenMode != isFullScreenMode()) { +if (fullScreenMode != isFullScreenMode() || !isVisible()) { if (fullScreenMode) { switchToFullScreenMode(); } --~--~-~--~~~---~--~~ Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en -~--~~~~--~~--~--~---
[piccolo2d-dev] Issue 56 in piccolo2d: Infinite rendering loop caused by setOffset/Bounds/Scale in layoutChildren
Updates: Status: Verified Comment #2 on issue 56 by allain.lalonde: Infinite rendering loop caused by setOffset/Bounds/Scale in layoutChildren http://code.google.com/p/piccolo2d/issues/detail?id=56 Because of the code in setBounds: if (bounds.x != x || bounds.y != y || bounds.width != width || bounds.height != height) { this problem no longer occurs. -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~-~--~~~---~--~~ Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en -~--~~~~--~~--~--~---
[piccolo2d-dev] Issue 120 in piccolo2d: ant all fails to build all of piccolo
Updates: Status: Accepted Comment #3 on issue 120 by allain.lalonde: ant all fails to build all of piccolo http://code.google.com/p/piccolo2d/issues/detail?id=120 Very good point. I'll make try and make this work. -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~-~--~~~---~--~~ Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en -~--~~~~--~~--~--~---
[piccolo2d-dev] Issue 120 in piccolo2d: ant all fails to build all of piccolo
Comment #4 on issue 120 by allain.lalonde: ant all fails to build all of piccolo http://code.google.com/p/piccolo2d/issues/detail?id=120 Here's a patch that allows it to compile on my system. I'm not sure about the procedure for patching a tag release-1.2.1 so, I'll let someone else apply it. Index: build.xml === --- build.xml (revision 652) +++ build.xml (working copy) @@ -274,7 +274,7 @@ javac srcdir=${build.tests.src} destdir=${build.tests.dest} - classpath=${build.dir}/${name}.jar;${build.dir}/${name}x.jar + classpath=${build.dir}/${name}.jar;${build.dir}/${name}x.jar;${lib.dir}/junit.jar debug=${debug} deprecation=${deprecation} optimize=${optimize} @@ -327,6 +327,7 @@ target name=runtests depends=tests java fork=yes classname=junit.textui.TestRunner taskname=junit failonerror=true arg value=RunAllUnitTests/ + jvmarg value=-Djava.awt.headless=true / classpath pathelement location=${build.dir}/${name}.jar / pathelement location=${build.dir}/${name}x.jar / Index: tests/PFrameTest.java === --- tests/PFrameTest.java (revision 652) +++ tests/PFrameTest.java (working copy) @@ -13,6 +13,9 @@ } public void testComponentResized() throws InvocationTargetException, InterruptedException { +if (java.awt.GraphicsEnvironment.isHeadless()) { + return; +} final PFrame frame = new PFrame(); frame.setBounds(0, 0, TEST_WIDTH, TEST_HEIGHT); EventQueue.invokeAndWait(new Runnable() { -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~-~--~~~---~--~~ Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en -~--~~~~--~~--~--~---
[piccolo2d-dev] Issue 13 in piccolo2d: PSwing components cause extraneous redraws
Updates: Status: Verified Comment #11 on issue 13 by allain.lalonde: PSwing components cause extraneous redraws http://code.google.com/p/piccolo2d/issues/detail?id=13 Thought it through even handles when the component is larger than the repaint region. -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~-~--~~~---~--~~ Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en -~--~~~~--~~--~--~---