Index: graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java =================================================================== RCS file: /cvs/graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java,v retrieving revision 1.69 diff -u -r1.69 RunDialog.java --- graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java 5 Jun 2007 08:41:00 -0000 1.69 +++ graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java 5 Jun 2007 09:12:41 -0000 @@ -38,6 +38,7 @@ "test.alignwith.AlignWithMoveGuideLinesTest", "test.alignwith.AlignWithTest", "test.alignwith.AlignWithResizeTest", + "test.anchor.ArrowAnchorShapeTest", "test.anchor.AnchorShapeWidthTest", "test.anchor.ImageAnchorShapeTest", "test.anchor.InvalidAnchorNegativeTest", Index: graph/examples/src/test/anchor/ArrowAnchorShapeTest.java =================================================================== RCS file: graph/examples/src/test/anchor/ArrowAnchorShapeTest.java diff -N graph/examples/src/test/anchor/ArrowAnchorShapeTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ graph/examples/src/test/anchor/ArrowAnchorShapeTest.java 5 Jun 2007 09:12:41 -0000 @@ -0,0 +1,48 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package test.anchor; + +import org.netbeans.api.visual.anchor.AnchorFactory; +import org.netbeans.api.visual.anchor.AnchorShapeFactory; +import org.netbeans.api.visual.widget.ConnectionWidget; +import org.netbeans.api.visual.widget.Scene; +import test.SceneSupport; + +import java.awt.*; + +/** + * @author David Kaspar + */ +public class ArrowAnchorShapeTest { + + public static void main (String[] args) { + Scene scene = new Scene (); + + ConnectionWidget child = new ConnectionWidget (scene); + child.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point (100, 100))); + child.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point (200, 200))); + child.setSourceAnchorShape (AnchorShapeFactory.createArrowAnchorShape (180, 8)); + child.setTargetAnchorShape (AnchorShapeFactory.createArrowAnchorShape (30, 16)); + scene.addChild (child); + + SceneSupport.show (scene); + } + +} Index: graph/lib/apichanges.xml =================================================================== RCS file: /cvs/graph/lib/apichanges.xml,v retrieving revision 1.15 diff -u -r1.15 apichanges.xml --- graph/lib/apichanges.xml 5 Jun 2007 08:43:24 -0000 1.15 +++ graph/lib/apichanges.xml 5 Jun 2007 09:12:41 -0000 @@ -239,6 +239,20 @@ + + + + AnchorShapeFactory.createArrowAnchorShape method introduced + + + + + + AnchorShapeFactory.createArrowAnchorShape method introduced. + + + + Index: graph/lib/manifest.mf =================================================================== RCS file: /cvs/graph/lib/manifest.mf,v retrieving revision 1.11 diff -u -r1.11 manifest.mf --- graph/lib/manifest.mf 5 Jun 2007 08:34:44 -0000 1.11 +++ graph/lib/manifest.mf 5 Jun 2007 09:12:41 -0000 @@ -1,4 +1,4 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.api.visual OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/visual/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 2.3 +OpenIDE-Module-Specification-Version: 2.4 Index: graph/lib/src/org/netbeans/api/visual/anchor/AnchorShapeFactory.java =================================================================== RCS file: /cvs/graph/lib/src/org/netbeans/api/visual/anchor/AnchorShapeFactory.java,v retrieving revision 1.5 diff -u -r1.5 AnchorShapeFactory.java --- graph/lib/src/org/netbeans/api/visual/anchor/AnchorShapeFactory.java 9 Mar 2007 10:02:12 -0000 1.5 +++ graph/lib/src/org/netbeans/api/visual/anchor/AnchorShapeFactory.java 5 Jun 2007 09:12:41 -0000 @@ -20,6 +20,7 @@ import org.netbeans.modules.visual.anchor.ImageAnchorShape; import org.netbeans.modules.visual.anchor.TriangleAnchorShape; +import org.netbeans.modules.visual.anchor.ArrowAnchorShape; import java.awt.*; @@ -74,6 +75,17 @@ */ public static AnchorShape createTriangleAnchorShape (int size, boolean filled, boolean output, int cutDistance) { return new TriangleAnchorShape (size, filled, output, false, cutDistance); + } + + /** + * Creates an arrow anchor shape. + * @param degrees the angle of the arrow in degrees (not radians) + * @param size the size of the arrow + * @return the anchor shape + * @since 2.4 + */ + public static AnchorShape createArrowAnchorShape (int degrees, int size) { + return new ArrowAnchorShape (degrees, size); } } Index: graph/lib/src/org/netbeans/modules/visual/anchor/ArrowAnchorShape.java =================================================================== RCS file: graph/lib/src/org/netbeans/modules/visual/anchor/ArrowAnchorShape.java diff -N graph/lib/src/org/netbeans/modules/visual/anchor/ArrowAnchorShape.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ graph/lib/src/org/netbeans/modules/visual/anchor/ArrowAnchorShape.java 5 Jun 2007 09:12:41 -0000 @@ -0,0 +1,70 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ +package org.netbeans.modules.visual.anchor; + +import org.netbeans.api.visual.anchor.AnchorShape; + +import java.awt.*; +import java.awt.geom.GeneralPath; + +/** + * @author Antonio + */ +public class ArrowAnchorShape implements AnchorShape { + + private static final Stroke STROKE = new BasicStroke (1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); + + private GeneralPath path; + private int size; + + public ArrowAnchorShape (int degrees, int size) { + this.size = size; + path = new GeneralPath (); + + double radians = Math.PI * degrees / 360.0; + double cos = Math.cos (radians); + double sin = -size * Math.sqrt (1 - cos * cos); + cos *= size; + + path.moveTo (0.0f, 0.0f); + path.lineTo ((float) cos, (float) -sin); + path.moveTo (0.0f, 0.0f); + path.lineTo ((float) cos, (float) sin); + } + + public boolean isLineOriented () { + return true; + } + + public int getRadius () { + return size + 1; + } + + public double getCutDistance () { + return 0; + } + + public void paint (Graphics2D graphics, boolean source) { + Stroke previousStroke = graphics.getStroke (); + graphics.setStroke (STROKE); + graphics.draw (path); + graphics.setStroke (previousStroke); + } + +} Index: graph/www/documentation.html =================================================================== RCS file: /cvs/graph/www/documentation.html,v retrieving revision 1.89 diff -u -r1.89 documentation.html --- graph/www/documentation.html 5 Jun 2007 08:43:26 -0000 1.89 +++ graph/www/documentation.html 5 Jun 2007 09:12:41 -0000 @@ -109,6 +109,7 @@
  • test.alignwith.AlignWithMoveGuideLinesTest - test of #97034 - incorrectly painted guide-lines for MoveAlignWithAction
  • test.alignwith.AlignWithTest - how to use MoveAlignWithAction
  • test.alignwith.AlignWithResizeTest - how to use AlignWithMoveAction and AlignWithResizeAction +
  • test.anchor.ArrowAnchorShapeTest - test of ArrowAnchorShape
  • test.anchor.AnchorShapeWidthTest - test of bugfix #91613 - Incorrectly rendered AnchorShapes
  • test.anchor.ImageAnchorShapeTest - test of ImageAnchorShape
  • test.anchor.InvalidAnchorNegativeTest - negative test of invalid anchor (its related widget is not added into scene)