# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/jaras/netbeans/core-main/contrib # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: visual.examples/src/org/netbeans/modules/visual/examples/RunDialog.java --- visual.examples/src/org/netbeans/modules/visual/examples/RunDialog.java Base (BASE) +++ visual.examples/src/org/netbeans/modules/visual/examples/RunDialog.java Locally Modified (Based On LOCAL) @@ -136,6 +136,7 @@ "test.widget.ConnectionWidgetOrderTest", "test.widget.IconNodeHeaderTest", "test.widget.RelativeDecorationTest", + "test.widget.RotatingWidgetTest", "test.zoom.FitToViewTest", }; Index: visual.examples/src/test/widget/MyLabelWidget.java --- visual.examples/src/test/widget/MyLabelWidget.java Base (BASE) +++ visual.examples/src/test/widget/MyLabelWidget.java Locally New @@ -0,0 +1,90 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package test.widget; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.LinearGradientPaint; +import java.awt.geom.Point2D; +import org.netbeans.api.visual.widget.Scene; +import org.netbeans.api.visual.widget.Widget; + +/** + * + * @author benoit + */ +public class MyLabelWidget extends Widget { + + public MyLabelWidget(Scene scene, String label) { + super(scene); + } + + public MyLabelWidget(Scene scene) { + super(scene); + } + + @Override + protected void paintWidget() { + Graphics2D gr = getGraphics(); + Point2D start = new Point2D.Float(0, 10); + Point2D end = new Point2D.Float(100, 240); + float[] dist = {0.0f, 0.4f, 1.0f}; + Color[] colors = {Color.RED, Color.YELLOW, Color.GREEN}; + LinearGradientPaint p = + new LinearGradientPaint(start, end, dist, colors); + + gr.setPaint(p); + gr.fillRect(getBounds().x + getBorder().getInsets().left, + getBounds().y + getBorder().getInsets().right, + (int) getBounds().width - getBorder().getInsets().right - getBorder().getInsets().left, + (int) getBounds().height - getBorder().getInsets().bottom - getBorder().getInsets().top); + gr.setPaint(Color.BLACK); + gr.drawLine(getBounds().x + getBorder().getInsets().left, + getBounds().y + getBorder().getInsets().right, + (int) getBounds().width - getBorder().getInsets().right, + (int) getBounds().height - getBorder().getInsets().bottom); + gr.drawRect(getBounds().x + getBorder().getInsets().left, + getBounds().y + getBorder().getInsets().right, + (int) getBounds().width - getBorder().getInsets().right - getBorder().getInsets().left, + (int) getBounds().height - getBorder().getInsets().bottom - getBorder().getInsets().top); + } +} Index: visual.examples/src/test/widget/RectangleWidget.java --- visual.examples/src/test/widget/RectangleWidget.java Base (BASE) +++ visual.examples/src/test/widget/RectangleWidget.java Locally New @@ -0,0 +1,62 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package test.widget; + +import org.netbeans.api.visual.widget.Scene; +import org.netbeans.api.visual.widget.Widget; + +/** + * + * @author benoit + */ +public class RectangleWidget extends Widget { + + public RectangleWidget(Scene scene) { + super(scene); + } + + @Override + protected void paintWidget() { + getGraphics().setColor(getForeground()); + getGraphics().fillRect(getBounds().x, getBounds().y, getBounds().width, getBounds().height); + } +} Index: visual.examples/src/test/widget/RotatingWidgetTest.java --- visual.examples/src/test/widget/RotatingWidgetTest.java Base (BASE) +++ visual.examples/src/test/widget/RotatingWidgetTest.java Locally New @@ -0,0 +1,124 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package test.widget; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.LinearGradientPaint; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.geom.Point2D; +import org.netbeans.api.visual.action.ActionFactory; +import org.netbeans.api.visual.action.EditProvider; +import org.netbeans.api.visual.border.BorderFactory; +import org.netbeans.api.visual.widget.LayerWidget; +import org.netbeans.api.visual.widget.Scene; +import org.netbeans.api.visual.widget.Widget; +import test.SceneSupport; + +/** + * + * @author benoit + */ +public class RotatingWidgetTest { + + public static void main(String[] args) { + final Scene scene = new Scene(); + LayerWidget layer = new LayerWidget(scene); + scene.addChild(layer); + layer.addChild(createRectWidget(scene, Color.RED, 100)); + + final Widget header = new MyLabelWidget(scene, + "Visibility of this label should not affect the " //NOI18N + + "position of the top-left corner of the image " //NOI18N + + "in the scene."); //NOI18N + Point2D start = new Point2D.Float(0, 10); + Point2D end = new Point2D.Float(25, 10); + float[] dist = {0.0f, 0.4f, 1.0f}; + Color[] colors = {Color.RED, Color.YELLOW, Color.GREEN}; + LinearGradientPaint p = + new LinearGradientPaint(start, end, dist, colors); + header.setBackground(p); + + header.setOpaque(true); + // the location of the header relatively to the reference point + header.setPreferredLocation(new Point(100, 100)); + header.setPreferredBounds(new Rectangle(0, 0, 100, 200)); + layer.addChild(header); + header.setBorder(BorderFactory.createLineBorder(5, Color.RED)); + header.getActions().addAction(ActionFactory.createEditAction( + new RotateEditProvider())); + header.getActions().addAction(ActionFactory.createMoveAction()); + Widget center = new RectangleWidget(scene); + center.setBackground(Color.BLUE); + center.setForeground(Color.BLUE); + center.setPreferredBounds(new Rectangle(0, 0, 10, 10)); + center.setPreferredLocation(new Point(45, 95)); + header.addChild(center); + layer.addChild(createRectWidget(scene, Color.GREEN, 150)); + layer.addChild(createRectWidget(scene, Color.BLUE, 200)); + SceneSupport.show(scene); + } + + private static Widget createRectWidget(Scene scene, Color c, int size) { + Widget w = new RectangleWidget(scene); + w.getActions().addAction(ActionFactory.createMoveAction()); + w.getActions().addAction(ActionFactory.createEditAction( + new RotateEditProvider())); + w.setForeground(c); + w.setPreferredSize(new Dimension(size, size)); + w.setPreferredLocation(new Point((int) Math.random() * 300, + (int) Math.random() * 300)); + w.setBorder(BorderFactory.createLineBorder()); + return w; + } + + private static class RotateEditProvider implements EditProvider { + + public void edit(Widget widget) { + widget.getTransform().rotate(-Math.PI / 6, + widget.getBounds().getCenterX(), + widget.getBounds().getCenterY()); + widget.revalidate(); + } + } +}