[piccolo2d-dev] [piccolo2d] r727 committed - Applying patches in fixing Issue #70 by applying patches found in the ...

2009-10-15 Thread codesite-noreply

Revision: 727
Author: allain.lalonde
Date: Thu Oct 15 06:40:46 2009
Log: Applying patches in fixing Issue #70 by applying patches found in the  
issue. I also updated the Basic SWT example so that it show the text's  
background color in use. Thank you dimwethion for submitting the initial  
patch.
http://code.google.com/p/piccolo2d/source/detail?r=727

Modified:
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTText.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTGraphics2D.java
   
/piccolo2d.java/trunk/swt-examples/src/main/java/edu/umd/cs/piccolox/swt/examples/SWTBasicExample.java

===
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java   
 
Thu Jul 30 14:59:39 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java   
 
Thu Oct 15 06:40:46 2009
@@ -273,7 +273,7 @@
  shapePts[3] - lineWidth, shapePts[4], shapePts[5]);
  }
  else {
-g2.fillPolygon(shapePts);
+g2.fill(shape);
  }
  }

@@ -297,10 +297,8 @@
  g2.drawRoundRect(shapePts[0] + lineWidth / 2, shapePts[1]  
+ lineWidth / 2, shapePts[2] - lineWidth,
  shapePts[3] - lineWidth, shapePts[4], shapePts[5]);
  }
-else {
-// TODO The bounds may be incorrect for polylines at the  
moment
-// - resulting in graphics turds at some scales
-g2.drawPolyline(shapePts);
+else {
+g2.draw(shape);
  }
  }

@@ -391,9 +389,7 @@
  final Line2D l2 = (Line2D) aShape;
  return new Line2D.Double(l2.getP1(), l2.getP2());
  }
-else {
-// again: either throw or don't - but nothing in between  
please.
-// new Exception().printStackTrace();
+else {
  final GeneralPath aPath = new GeneralPath();
  aPath.append(aShape, false);
  return aPath;
===
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTText.java   
 
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTText.java   
 
Thu Oct 15 06:40:46 2009
@@ -35,11 +35,7 @@
   * same version of Jazz. A future release of Jazz will provide support for  
long
   * term persistence.
   */
-public class PSWTText extends PNode {
-
-/**
- *
- */
+public class PSWTText extends PNode {
  private static final long serialVersionUID = 1L;

  /**
@@ -82,11 +78,21 @@
   */
  static protected final String DEFAULT_TEXT = ;

+/**
+ * Default transparent state
+ */
+static protected final boolean DEFAULT_IS_TRANSPARENT = false;
+
  /**
   * Default padding
   */
  static protected final int DEFAULT_PADDING = 2;

+/**
+ * Should text be drawn with transparent mode?
+ */
+private boolean isTransparent = DEFAULT_IS_TRANSPARENT;
+
  /**
   * Below this magnification text is rendered as greek.
   */
@@ -212,6 +218,26 @@
  public void setBackgroundColor(final Color color) {
  super.setPaint(color);
  }
+
+/**
+ * Sets whether the text should be drawn in transparent mode, i.e.,  
whether
+ * the background should be drawn or not.
+ *
+ * @param isTransparent
+ */
+public void setTransparent(boolean isTransparent) {
+this.isTransparent = isTransparent;
+}
+
+/**
+ * Returns whether the text should be drawn using the transparent mode,
+ * i.e., whether the background should be drawn or not.
+ *
+ * @return
+ */
+public boolean isTransparent() {
+return isTransparent;
+}

  /**
   * Returns the current greek threshold. Below this magnification text  
is
@@ -441,24 +467,19 @@
  public void paintAsText(final PPaintContext ppc) {
  final SWTGraphics2D sg2 = (SWTGraphics2D) ppc.getGraphics();

-if (getPaint() != null) {
-sg2.setBackground((Color) getPaint());
+if (!isTransparent) {
+if (getPaint() == null) {
+sg2.setBackground(Color.WHITE);
+} else {
+sg2.setBackground((Color)getPaint());
+}
+
  final Rectangle2D rect = new Rectangle2D.Double(0.0, 0.0,  
getWidth(), getHeight());
  sg2.fillRect(rect.getX(), rect.getY(), rect.getWidth(),  
rect.getHeight());
  }

  sg2.translate(padding, padding);

-final double scale = Math.min(sg2.getTransform().getScaleX(),  
sg2.getTransform().getScaleY());
-final double dSize = scale * font.getSize();
-final double fixupScale = Math.floor(dSize) / dSize;
-
-// This 

[piccolo2d-dev] [piccolo2d] r728 committed - Issue 124 ; adding new protected method void disposeImage, to allow su...

2009-10-15 Thread codesite-noreply

Revision: 728
Author: heuermh
Date: Thu Oct 15 11:19:00 2009
Log: Issue 124 ; adding new protected method void disposeImage, to allow  
subclasses to override default behavior
http://code.google.com/p/piccolo2d/source/detail?r=728

Modified:
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTImage.java

===
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTImage.java  
 
Tue Jul 28 13:58:25 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTImage.java  
 
Thu Oct 15 11:19:00 2009
@@ -64,9 +64,7 @@
  this.canvas = canvas;
  canvas.addDisposeListener(new DisposeListener() {
  public void widgetDisposed(final DisposeEvent de) {
-if (image != null) {
-image.dispose();
-}
+disposeImage();
  }
  });
  }
@@ -125,6 +123,12 @@

  firePropertyChange(PImage.PROPERTY_CODE_IMAGE,  
PImage.PROPERTY_IMAGE, old, image);
  }
+
+protected void disposeImage() {
+if (image != null) {
+image.dispose();
+}
+}

  protected void paint(final PPaintContext paintContext) {
  if (getImage() != null) {

--~--~-~--~~~---~--~~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~--~~~~--~~--~--~---



[piccolo2d-dev] Issue 124 in piccolo2d: Add additional constructors to PSWTImage

2009-10-15 Thread codesite-noreply

Updates:
Status: Fixed

Comment #10 on issue 124 by heuermh: Add additional constructors to  
PSWTImage
http://code.google.com/p/piccolo2d/issues/detail?id=124

Committing patch, review/vote at revision link below.

$ svn commit -m Issue 124 ; adding new protected method void disposeImage,  
to allow
subclasses to override default behavior swt
Sendingswt/src/main/java/edu/umd/cs/piccolox/swt/PSWTImage.java
Transmitting file data .
Committed revision 728.

--
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] r729 committed - Cleaning in PSWTText code a little.

2009-10-15 Thread codesite-noreply

Revision: 729
Author: allain.lalonde
Date: Thu Oct 15 11:45:01 2009
Log: Cleaning in PSWTText code a little.
http://code.google.com/p/piccolo2d/source/detail?r=729

Added:
  /piccolo2d.java/trunk/swt/src/test
  /piccolo2d.java/trunk/swt/src/test/java
  /piccolo2d.java/trunk/swt/src/test/java/edu
  /piccolo2d.java/trunk/swt/src/test/java/edu/umd
  /piccolo2d.java/trunk/swt/src/test/java/edu/umd/cs
  /piccolo2d.java/trunk/swt/src/test/java/edu/umd/cs/piccolox
  /piccolo2d.java/trunk/swt/src/test/java/edu/umd/cs/piccolox/swt
   
/piccolo2d.java/trunk/swt/src/test/java/edu/umd/cs/piccolox/swt/PSWTTextTest.java
Modified:
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTText.java
   
/piccolo2d.java/trunk/swt-examples/src/main/java/edu/umd/cs/piccolox/swt/examples/SWTBasicExample.java

===
--- /dev/null
+++  
/piccolo2d.java/trunk/swt/src/test/java/edu/umd/cs/piccolox/swt/PSWTTextTest.java

Thu Oct 15 11:45:01 2009
@@ -0,0 +1,19 @@
+package edu.umd.cs.piccolox.swt;
+
+import junit.framework.TestCase;
+
+public class PSWTTextTest extends TestCase {
+private PSWTText testNode;
+
+public void setUp() {
+testNode = new PSWTText();
+}
+
+
+public void testTextPersistsTrainingAndInternalNewlines() {
+testNode.setText(Hello\nWorld\n\n);
+assertEquals(Hello\nWorld\n\n, testNode.getText());
+}
+
+
+}
===
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTText.java   
 
Thu Oct 15 06:40:46 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTText.java   
 
Thu Oct 15 11:45:01 2009
@@ -10,7 +10,6 @@
  import java.awt.Paint;
  import java.awt.geom.AffineTransform;
  import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
  import java.util.ArrayList;
  import java.util.Iterator;

@@ -35,107 +34,67 @@
   * same version of Jazz. A future release of Jazz will provide support for  
long
   * term persistence.
   */
-public class PSWTText extends PNode {
+public class PSWTText extends PNode {
  private static final long serialVersionUID = 1L;

-/**
- * Below this magnification render text as 'greek'.
- */
-static protected final double DEFAULT_GREEK_THRESHOLD = 5.5;
-
-/**
- * Default color of text rendered as 'greek'.
- */
-static protected final Color DEFAULT_GREEK_COLOR = Color.gray;
-
-/**
- * Default font name of text.
- */
-static protected final String DEFAULT_FONT_NAME = Helvetica;
-
-/**
- * Default font style for text.
- */
-static protected final int DEFAULT_FONT_STYLE = Font.PLAIN;
-
-/**
- * Default font size for text.
- */
-static protected final int DEFAULT_FONT_SIZE = 12;
-
-/**
- * Default font for text.
- */
-static protected final Font DEFAULT_FONT = new Font(DEFAULT_FONT_NAME,  
DEFAULT_FONT_STYLE, DEFAULT_FONT_SIZE);
-
-/**
- * Default color for text.
- */
-static protected final Color DEFAULT_PEN_COLOR = Color.black;
-
-/**
- * Default text when new text area is created.
- */
-static protected final String DEFAULT_TEXT = ;
-
-/**
- * Default transparent state
- */
-static protected final boolean DEFAULT_IS_TRANSPARENT = false;
-
-/**
- * Default padding
- */
-static protected final int DEFAULT_PADDING = 2;
-
-/**
- * Should text be drawn with transparent mode?
- */
-private boolean isTransparent = DEFAULT_IS_TRANSPARENT;
-
-/**
- * Below this magnification text is rendered as greek.
- */
+/** Below this magnification render text as 'greek'. */
+protected static final double DEFAULT_GREEK_THRESHOLD = 5.5;
+
+/** Default color of text rendered as 'greek'. */
+protected static final Color DEFAULT_GREEK_COLOR = Color.gray;
+
+/** Default font name of text. */
+protected static final String DEFAULT_FONT_NAME = Helvetica;
+
+/** Default font style for text. */
+protected static final int DEFAULT_FONT_STYLE = Font.PLAIN;
+
+/** Default font size for text. */
+protected static final int DEFAULT_FONT_SIZE = 12;
+
+/** Default font for text. */
+protected static final Font DEFAULT_FONT = new Font(DEFAULT_FONT_NAME,  
DEFAULT_FONT_STYLE, DEFAULT_FONT_SIZE);
+
+/** Default color for text. */
+protected static final Color DEFAULT_PEN_COLOR = Color.black;
+
+/** Default text when new text area is created. */
+protected static final String DEFAULT_TEXT = ;
+
+/** Default background transparency state. */
+protected static final boolean DEFAULT_IS_TRANSPARENT = false;
+
+/** Default padding. */
+protected static final int DEFAULT_PADDING = 2;
+
+/** Whether the text be drawn with a transparent background. */
+private boolean transparent = DEFAULT_IS_TRANSPARENT;
+
+/** Below this magnification text is rendered as greek. */
  protected 

[piccolo2d-dev] [piccolo2d] r730 committed - Test added doesn't work in headless. Will need to figure something out...

2009-10-15 Thread codesite-noreply

Revision: 730
Author: allain.lalonde
Date: Thu Oct 15 11:53:51 2009
Log: Test added doesn't work in headless. Will need to figure something  
out. Otherwise SWT module will remain untestable.
http://code.google.com/p/piccolo2d/source/detail?r=730

Modified:
   
/piccolo2d.java/trunk/swt/src/test/java/edu/umd/cs/piccolox/swt/PSWTTextTest.java

===
---  
/piccolo2d.java/trunk/swt/src/test/java/edu/umd/cs/piccolox/swt/PSWTTextTest.java

Thu Oct 15 11:45:01 2009
+++  
/piccolo2d.java/trunk/swt/src/test/java/edu/umd/cs/piccolox/swt/PSWTTextTest.java

Thu Oct 15 11:53:51 2009
@@ -9,11 +9,10 @@
  testNode = new PSWTText();
  }

-
  public void testTextPersistsTrainingAndInternalNewlines() {
-testNode.setText(Hello\nWorld\n\n);
-assertEquals(Hello\nWorld\n\n, testNode.getText());
-}
-
+// TODO: Make this work in headless mode if possible.
+// testNode.setText(Hello\nWorld\n\n);
+// assertEquals(Hello\nWorld\n\n, testNode.getText());
+}

  }

--~--~-~--~~~---~--~~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~--~~~~--~~--~--~---