Java Code Examples for org.netbeans.api.visual.widget.Scene#addChild()
The following examples show how to use
org.netbeans.api.visual.widget.Scene#addChild() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayerWidget103528Test.java From netbeans with Apache License 2.0 | 6 votes |
public void testLayerPreferredLocation () { Scene scene = new Scene (); scene.addChild (new LayerWidget (scene)); LayerWidget layer = new LayerWidget (scene); layer.setPreferredLocation (new Point (100, 100)); scene.addChild (layer); Widget widget = new Widget (scene); widget.setPreferredBounds (new Rectangle (-20, -10, 100, 50)); widget.setOpaque (true); widget.setBackground (Color.RED); layer.addChild (widget); Color color = (Color) (new DefaultLookFeel()).getBackground(); assertScene (scene, color, new Rectangle (80, 90, 100, 50)); }
Example 2
Source File: ConnectionWidgetCollisionsCollectorTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testCollisionsCollector () { Scene scene = new Scene (); ConnectionWidget widget = new ConnectionWidget (scene); widget.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point (100, 100))); widget.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point (300, 200))); widget.setRouter (RouterFactory.createOrthogonalSearchRouter (new CollisionsCollector() { public void collectCollisions (List<Rectangle> verticalCollisions, List<Rectangle> horizontalCollisions) { getRef ().println ("CollisionsCollector invoked"); } })); scene.addChild (widget); JFrame frame = showFrame (scene); frame.setVisible(false); frame.dispose (); compareReferenceFiles (); }
Example 3
Source File: ConnectionWidgetCollisionsCollectorTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testConnectionWidgetCollisionsCollector () { Scene scene = new Scene (); final ConnectionWidget widget = new ConnectionWidget (scene); widget.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point (100, 100))); widget.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point (300, 200))); widget.setRouter (RouterFactory.createOrthogonalSearchRouter (new ConnectionWidgetCollisionsCollector () { public void collectCollisions (ConnectionWidget connectionWidget, List<Rectangle> verticalCollisions, List<Rectangle> horizontalCollisions) { getRef ().println ("ConnectionWidgetCollisionsCollector invoked - is widget valid: " + (connectionWidget == widget)); } })); scene.addChild (widget); JFrame frame = showFrame (scene); frame.setVisible(false); frame.dispose (); compareReferenceFiles (); }
Example 4
Source File: OffscreenRenderingTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testOffscreenRendering () { Scene scene = new Scene (); LayerWidget layer = new LayerWidget (scene); layer.setPreferredBounds (new Rectangle (0, 0, 80, 80)); scene.addChild (layer); LabelWidget widget = new LabelWidget (scene, "Hi"); widget.setVerticalAlignment (LabelWidget.VerticalAlignment.CENTER); widget.setAlignment (LabelWidget.Alignment.CENTER); widget.setBorder (BorderFactory.createLineBorder ()); widget.setPreferredLocation (new Point (20, 20)); widget.setPreferredBounds (new Rectangle (0, 0, 40, 40)); layer.addChild (widget); BufferedImage image = dumpSceneOffscreenRendering (scene); Color backgroundColor = (Color) (new DefaultLookFeel()).getBackground(); Color foregroundColor = (new DefaultLookFeel()).getForeground(); assertCleaness (testCleaness (image, backgroundColor, foregroundColor), image, null); assertScene (scene, backgroundColor, new Rectangle (19, 19, 42, 42)); }
Example 5
Source File: FlowLayout105400Test.java From netbeans with Apache License 2.0 | 5 votes |
public void testFlowLayoutInsets () { Scene scene = new Scene (); Widget parent = new Widget (scene); parent.setBorder (BorderFactory.createResizeBorder (10)); parent.setLayout (LayoutFactory.createVerticalFlowLayout ()); scene.addChild (parent); Widget child = new Widget (scene); child.setBackground (Color.BLUE); child.setOpaque (true); child.setPreferredBounds (new Rectangle (-50, -30, 30, 20)); parent.addChild (child); assertScene (scene, Color.WHITE, new Rectangle (-1, -1, 52, 42)); }
Example 6
Source File: FlowLayoutWeightOverflow108052Test.java From netbeans with Apache License 2.0 | 5 votes |
public void testFlowLayoutWeightOverflow () { Scene scene = new Scene (); LayerWidget layer = new LayerWidget (scene); layer.setMinimumSize (new Dimension (300, 200)); scene.addChild (layer); Widget vbox = new Widget (scene); vbox.setBorder (BorderFactory.createLineBorder (1, Color.BLACK)); vbox.setLayout (LayoutFactory.createVerticalFlowLayout (LayoutFactory.SerialAlignment.JUSTIFY, 0)); layer.addChild (vbox); Widget hbox1 = new Widget (scene); hbox1.setBorder (BorderFactory.createLineBorder (1, Color.BLUE)); hbox1.setLayout (LayoutFactory.createHorizontalFlowLayout ()); vbox.addChild (hbox1); Widget item1 = new LabelWidget (scene, "Item1"); item1.setBorder (BorderFactory.createLineBorder (1, Color.GREEN)); hbox1.addChild (item1); Widget item2 = new LabelWidget (scene, "Item2"); item2.setBorder (BorderFactory.createLineBorder (1, Color.YELLOW)); hbox1.addChild (item2, 1000); Widget item3 = new LabelWidget (scene, "Item3"); item3.setBorder (BorderFactory.createLineBorder (1, Color.RED)); hbox1.addChild (item3); Widget hbox2 = new Widget (scene); hbox2.setBorder (BorderFactory.createLineBorder (1, Color.BLUE)); hbox2.setPreferredSize (new Dimension (200, 20)); vbox.addChild (hbox2); Color color = (Color) (new DefaultLookFeel()).getBackground(); assertScene (scene, color, new Rectangle (-5, -5, 210, 100)); }
Example 7
Source File: BasicTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testShow () { Scene scene = new Scene (); LayerWidget mainLayer = new LayerWidget (scene); scene.addChild(mainLayer); Widget w1 = new Widget (scene); w1.setBorder (BorderFactory.createLineBorder ()); w1.setPreferredLocation (new Point (100, 100)); w1.setPreferredSize (new Dimension (40, 20)); mainLayer.addChild(w1); Widget w2 = new Widget (scene); w2.setBorder (BorderFactory.createLineBorder ()); w2.setPreferredLocation (new Point (200, 100)); w2.setPreferredSize (new Dimension (40, 20)); mainLayer.addChild(w2); LayerWidget connLayer = new LayerWidget (scene); scene.addChild(connLayer); ConnectionWidget conn = new ConnectionWidget(scene); conn.setSourceAnchor(AnchorFactory.createRectangularAnchor(w1)); conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(w2)); connLayer.addChild(conn); Color color = (Color) (new DefaultLookFeel()).getBackground(); assertScene (scene, color, new Rectangle (99, 99, 42, 22), new Rectangle (199, 99, 42, 22), new Rectangle (138, 108, 64, 4) ); }
Example 8
Source File: AnchorNotificationTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testNotify () { StringBuffer log = new StringBuffer (); Scene scene = new Scene (); Widget w = new Widget (scene); scene.addChild (w); ConnectionWidget c = new ConnectionWidget (scene); scene.addChild (c); TestAnchor testAnchor = new TestAnchor (w, log); c.setSourceAnchor (testAnchor); c.setTargetAnchor (testAnchor); JFrame frame = showFrame (scene); c.setSourceAnchor (null); c.setTargetAnchor (null); scene.validate (); frame.setVisible (false); frame.dispose (); assertEquals (log.toString (), "notifyEntryAdded\n" + "notifyUsed\n" + "notifyRevalidate\n" + "notifyEntryAdded\n" + "notifyRevalidate\n" + "notifyRevalidate\n" + "compute\n" + "compute\n" + "notifyEntryRemoved\n" + "notifyRevalidate\n" + "notifyEntryRemoved\n" + "notifyUnused\n" + "notifyRevalidate\n" ); }
Example 9
Source File: WidgetPaintBorderTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testPaintWidgetBorder () { Scene scene = new Scene (); MyWidget widget = new MyWidget (scene); scene.addChild (widget); takeOneTimeSnapshot (scene, 10, 10); assertTrue ("Widget border is not painted", widget.borderPainted); }
Example 10
Source File: LabelOrientationTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testLabelOrientations () { Scene scene = new Scene (); LayerWidget layer = new LayerWidget (scene); scene.addChild(layer); layer.addChild (new Widget (scene)); createLabel (layer, "N O R M A L", 100, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.BASELINE).setPreferredBounds (null); createLabel (layer, "R O T A T E 9 0", 100, 100, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.BASELINE).setPreferredBounds (null); createLabel (layer, "NORMAL BASELINE", 200, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.BASELINE, LabelWidget.VerticalAlignment.BASELINE); createLabel (layer, "ROTATE90 BASELINE", 200, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.BASELINE, LabelWidget.VerticalAlignment.BASELINE); createLabel (layer, "NORMAL LEFT,TOP", 400, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.TOP); createLabel (layer, "ROTATE90 LEFT,TOP", 400, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.TOP); createLabel (layer, "NORMAL CENTER", 600, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.CENTER, LabelWidget.VerticalAlignment.CENTER); createLabel (layer, "ROTATE90 CENTER", 600, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.CENTER, LabelWidget.VerticalAlignment.CENTER); createLabel (layer, "NORMAL RIGHT,BOTTOM", 800, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.RIGHT, LabelWidget.VerticalAlignment.BOTTOM); createLabel (layer, "ROTATE90 RIGHT,BOTTOM", 800, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.RIGHT, LabelWidget.VerticalAlignment.BOTTOM); BufferedImage snapshot = takeOneTimeSnapshot (scene); BufferedImage clean = clearRegions (snapshot, Color.RED, new Rectangle (100, 80, 100, 30), new Rectangle (80, 0, 30, 110), new Rectangle (190, 90, 130, 30), new Rectangle (380, 70, 110, 30), new Rectangle (610, 150, 120, 30), new Rectangle (810, 230, 150, 30), new Rectangle (180, 270, 30, 130), new Rectangle (380, 270, 30, 160), new Rectangle (650, 290, 30, 150), new Rectangle (945, 275, 30, 190) ); Color color = (Color) (new DefaultLookFeel()).getBackground(); assertCleaness (testCleaness (clean, color, Color.YELLOW, Color.RED), snapshot, clean); }