Java Code Examples for org.netbeans.api.visual.widget.LayerWidget#addChild()
The following examples show how to use
org.netbeans.api.visual.widget.LayerWidget#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: 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 3
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 4
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 5
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); }
Example 6
Source File: LabelOrientationTest.java From netbeans with Apache License 2.0 | 5 votes |
private static LabelWidget createLabel (LayerWidget layer, String label, int x, int y, LabelWidget.Orientation orientation, LabelWidget.Alignment alignment, LabelWidget.VerticalAlignment verticalAlignment) { LabelWidget widget = new LabelWidget (layer.getScene (), label); widget.setOpaque (true); widget.setBackground (Color.YELLOW); widget.setPreferredLocation (new Point (x, y)); widget.setPreferredBounds (new Rectangle (-20, -30, 180, 180)); widget.setOrientation (orientation); widget.setAlignment (alignment); widget.setVerticalAlignment (verticalAlignment); layer.addChild (widget); return widget; }
Example 7
Source File: DiagramScene.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public DiagramScene(Action[] actions, DiagramViewModel model) { this.actions = actions; selectedWidgets = new ArrayList<FigureWidget>(); content = new InstanceContent(); lookup = new AbstractLookup(content); this.setCheckClipping(true); this.getInputBindings().setZoomActionModifiers(0); JComponent comp = this.createView(); comp.setDoubleBuffered(true); comp.setBackground(Color.WHITE); comp.setOpaque(true); this.setBackground(Color.WHITE); this.setOpaque(true); scrollPane = new JScrollPane(comp); scrollPane.setBackground(Color.WHITE); scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getViewport().addChangeListener(scrollChangeListener); hoverAction = this.createWidgetHoverAction(); blockLayer = new LayerWidget(this); this.addChild(blockLayer); startLayer = new LayerWidget(this); this.addChild(startLayer); // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections..."; String startLabelString = ""; LabelWidget w = new LabelWidget(this, startLabelString); scrollChangeListener.register(w, new Point(10, 10)); w.setAlignment(LabelWidget.Alignment.CENTER); startLabel = w; startLayer.addChild(w); mainLayer = new LayerWidget(this); this.addChild(mainLayer); topLeft = new Widget(this); topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(topLeft); bottomRight = new Widget(this); bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(bottomRight); slotLayer = new LayerWidget(this); this.addChild(slotLayer); connectionLayer = new LayerWidget(this); this.addChild(connectionLayer); LayerWidget selectionLayer = new LayerWidget(this); this.addChild(selectionLayer); this.setLayout(LayoutFactory.createAbsoluteLayout()); this.getActions().addAction(hoverAction); zoomAction = new BoundedZoomAction(1.1, false); zoomAction.setMaxFactor(ZOOM_MAX_FACTOR); zoomAction.setMinFactor(ZOOM_MIN_FACTOR); this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1)); panAction = new ExtendedPanAction(); this.getActions().addAction(panAction); this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider)); LayerWidget selectLayer = new LayerWidget(this); this.addChild(selectLayer); this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider)); blockWidgets = new HashMap<InputBlock, BlockWidget>(); boolean b = this.getUndoRedoEnabled(); this.setUndoRedoEnabled(false); this.setNewModel(model); this.setUndoRedoEnabled(b); }
Example 8
Source File: DiagramScene.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public DiagramScene(Action[] actions, DiagramViewModel model) { this.actions = actions; selectedWidgets = new ArrayList<FigureWidget>(); content = new InstanceContent(); lookup = new AbstractLookup(content); this.setCheckClipping(true); this.getInputBindings().setZoomActionModifiers(0); JComponent comp = this.createView(); comp.setDoubleBuffered(true); comp.setBackground(Color.WHITE); comp.setOpaque(true); this.setBackground(Color.WHITE); this.setOpaque(true); scrollPane = new JScrollPane(comp); scrollPane.setBackground(Color.WHITE); scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getViewport().addChangeListener(scrollChangeListener); hoverAction = this.createWidgetHoverAction(); blockLayer = new LayerWidget(this); this.addChild(blockLayer); startLayer = new LayerWidget(this); this.addChild(startLayer); // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections..."; String startLabelString = ""; LabelWidget w = new LabelWidget(this, startLabelString); scrollChangeListener.register(w, new Point(10, 10)); w.setAlignment(LabelWidget.Alignment.CENTER); startLabel = w; startLayer.addChild(w); mainLayer = new LayerWidget(this); this.addChild(mainLayer); topLeft = new Widget(this); topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(topLeft); bottomRight = new Widget(this); bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(bottomRight); slotLayer = new LayerWidget(this); this.addChild(slotLayer); connectionLayer = new LayerWidget(this); this.addChild(connectionLayer); LayerWidget selectionLayer = new LayerWidget(this); this.addChild(selectionLayer); this.setLayout(LayoutFactory.createAbsoluteLayout()); this.getActions().addAction(hoverAction); zoomAction = new BoundedZoomAction(1.1, false); zoomAction.setMaxFactor(ZOOM_MAX_FACTOR); zoomAction.setMinFactor(ZOOM_MIN_FACTOR); this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1)); panAction = new ExtendedPanAction(); this.getActions().addAction(panAction); this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider)); LayerWidget selectLayer = new LayerWidget(this); this.addChild(selectLayer); this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider)); blockWidgets = new HashMap<InputBlock, BlockWidget>(); boolean b = this.getUndoRedoEnabled(); this.setUndoRedoEnabled(false); this.setNewModel(model); this.setUndoRedoEnabled(b); }
Example 9
Source File: DiagramScene.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public DiagramScene(Action[] actions, DiagramViewModel model) { this.actions = actions; selectedWidgets = new ArrayList<FigureWidget>(); content = new InstanceContent(); lookup = new AbstractLookup(content); this.setCheckClipping(true); this.getInputBindings().setZoomActionModifiers(0); JComponent comp = this.createView(); comp.setDoubleBuffered(true); comp.setBackground(Color.WHITE); comp.setOpaque(true); this.setBackground(Color.WHITE); this.setOpaque(true); scrollPane = new JScrollPane(comp); scrollPane.setBackground(Color.WHITE); scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getViewport().addChangeListener(scrollChangeListener); hoverAction = this.createWidgetHoverAction(); blockLayer = new LayerWidget(this); this.addChild(blockLayer); startLayer = new LayerWidget(this); this.addChild(startLayer); // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections..."; String startLabelString = ""; LabelWidget w = new LabelWidget(this, startLabelString); scrollChangeListener.register(w, new Point(10, 10)); w.setAlignment(LabelWidget.Alignment.CENTER); startLabel = w; startLayer.addChild(w); mainLayer = new LayerWidget(this); this.addChild(mainLayer); topLeft = new Widget(this); topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(topLeft); bottomRight = new Widget(this); bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(bottomRight); slotLayer = new LayerWidget(this); this.addChild(slotLayer); connectionLayer = new LayerWidget(this); this.addChild(connectionLayer); LayerWidget selectionLayer = new LayerWidget(this); this.addChild(selectionLayer); this.setLayout(LayoutFactory.createAbsoluteLayout()); this.getActions().addAction(hoverAction); zoomAction = new BoundedZoomAction(1.1, false); zoomAction.setMaxFactor(ZOOM_MAX_FACTOR); zoomAction.setMinFactor(ZOOM_MIN_FACTOR); this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1)); panAction = new ExtendedPanAction(); this.getActions().addAction(panAction); this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider)); LayerWidget selectLayer = new LayerWidget(this); this.addChild(selectLayer); this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider)); blockWidgets = new HashMap<InputBlock, BlockWidget>(); boolean b = this.getUndoRedoEnabled(); this.setUndoRedoEnabled(false); this.setNewModel(model); this.setUndoRedoEnabled(b); }
Example 10
Source File: DesignView.java From netbeans with Apache License 2.0 | 4 votes |
/** * Creates a new instance of GraphView. * @param service * @param implementationClass */ public DesignView(ProjectService service, FileObject implementationClass) { super(new BorderLayout()); this.service = service; this.implementationClass = implementationClass; scene = new ObjectScene() { @Override /** * Use our own traversal policy */ public Comparable<DesignerWidgetIdentityCode> getIdentityCode(Object object) { return new DesignerWidgetIdentityCode(scene,object); } }; zoomer = new ZoomManager(scene); scene.getActions().addAction(ActionFactory.createCycleObjectSceneFocusAction()); scene.setKeyEventProcessingType (EventProcessingType.FOCUSED_WIDGET_AND_ITS_PARENTS); mainLayer = new LayerWidget(scene); mainLayer.setPreferredLocation(new Point(0, 0)); mainLayer.setLayout(LayoutFactory.createVerticalFlowLayout( LayoutFactory.SerialAlignment.JUSTIFY, 12)); scene.addChild(mainLayer); mainWidget = new Widget(scene); mainWidget.setLayout(LayoutFactory.createVerticalFlowLayout( LayoutFactory.SerialAlignment.JUSTIFY, 12)); headerWidget = new LabelWidget(scene); headerWidget.setFont(scene.getFont().deriveFont(Font.BOLD)); headerWidget.setForeground(Color.GRAY); headerWidget.setBorder(BorderFactory.createEmptyBorder(6,28,0,0)); mainWidget.addChild(headerWidget); separatorWidget = new SeparatorWidget(scene, SeparatorWidget.Orientation.HORIZONTAL); separatorWidget.setForeground(Color.ORANGE); mainWidget.addChild(separatorWidget); contentWidget = new Widget(scene); contentWidget.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); contentWidget.setLayout(LayoutFactory.createVerticalFlowLayout( LayoutFactory.SerialAlignment.JUSTIFY, 16)); mainWidget.addChild(contentWidget); JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER){ /* (non-Javadoc) * @see java.awt.FlowLayout#layoutContainer(java.awt.Container) */ @Override public void layoutContainer( Container target ) { super.layoutContainer(target); Component[] components = target.getComponents(); double height = target.getSize().getHeight()/2; for (Component component : components) { Point location = component.getLocation(); component.setLocation( (int)location.getX(), (int)height ); } } }); panel.add(new JLabel(NbBundle.getMessage( DesignView.class, "LBL_Wait"))); add( panel,BorderLayout.CENTER); mainLayer.addChild(mainWidget); messageWidget = new Widget(scene); messageWidget.setLayout(LayoutFactory.createVerticalFlowLayout( LayoutFactory.SerialAlignment.JUSTIFY, 4)); mainLayer.addChild(messageWidget); scene.addObject(messageLayerKey, messageWidget); initServiceModel(); }
Example 11
Source File: DiagramScene.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public DiagramScene(Action[] actions, DiagramViewModel model) { this.actions = actions; selectedWidgets = new ArrayList<FigureWidget>(); content = new InstanceContent(); lookup = new AbstractLookup(content); this.setCheckClipping(true); this.getInputBindings().setZoomActionModifiers(0); JComponent comp = this.createView(); comp.setDoubleBuffered(true); comp.setBackground(Color.WHITE); comp.setOpaque(true); this.setBackground(Color.WHITE); this.setOpaque(true); scrollPane = new JScrollPane(comp); scrollPane.setBackground(Color.WHITE); scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getViewport().addChangeListener(scrollChangeListener); hoverAction = this.createWidgetHoverAction(); blockLayer = new LayerWidget(this); this.addChild(blockLayer); startLayer = new LayerWidget(this); this.addChild(startLayer); // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections..."; String startLabelString = ""; LabelWidget w = new LabelWidget(this, startLabelString); scrollChangeListener.register(w, new Point(10, 10)); w.setAlignment(LabelWidget.Alignment.CENTER); startLabel = w; startLayer.addChild(w); mainLayer = new LayerWidget(this); this.addChild(mainLayer); topLeft = new Widget(this); topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(topLeft); bottomRight = new Widget(this); bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(bottomRight); slotLayer = new LayerWidget(this); this.addChild(slotLayer); connectionLayer = new LayerWidget(this); this.addChild(connectionLayer); LayerWidget selectionLayer = new LayerWidget(this); this.addChild(selectionLayer); this.setLayout(LayoutFactory.createAbsoluteLayout()); this.getActions().addAction(hoverAction); zoomAction = new BoundedZoomAction(1.1, false); zoomAction.setMaxFactor(ZOOM_MAX_FACTOR); zoomAction.setMinFactor(ZOOM_MIN_FACTOR); this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1)); panAction = new ExtendedPanAction(); this.getActions().addAction(panAction); this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider)); LayerWidget selectLayer = new LayerWidget(this); this.addChild(selectLayer); this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider)); blockWidgets = new HashMap<InputBlock, BlockWidget>(); boolean b = this.getUndoRedoEnabled(); this.setUndoRedoEnabled(false); this.setNewModel(model); this.setUndoRedoEnabled(b); }
Example 12
Source File: DiagramScene.java From hottub with GNU General Public License v2.0 | 4 votes |
public DiagramScene(Action[] actions, DiagramViewModel model) { this.actions = actions; selectedWidgets = new ArrayList<FigureWidget>(); content = new InstanceContent(); lookup = new AbstractLookup(content); this.setCheckClipping(true); this.getInputBindings().setZoomActionModifiers(0); JComponent comp = this.createView(); comp.setDoubleBuffered(true); comp.setBackground(Color.WHITE); comp.setOpaque(true); this.setBackground(Color.WHITE); this.setOpaque(true); scrollPane = new JScrollPane(comp); scrollPane.setBackground(Color.WHITE); scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getViewport().addChangeListener(scrollChangeListener); hoverAction = this.createWidgetHoverAction(); blockLayer = new LayerWidget(this); this.addChild(blockLayer); startLayer = new LayerWidget(this); this.addChild(startLayer); // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections..."; String startLabelString = ""; LabelWidget w = new LabelWidget(this, startLabelString); scrollChangeListener.register(w, new Point(10, 10)); w.setAlignment(LabelWidget.Alignment.CENTER); startLabel = w; startLayer.addChild(w); mainLayer = new LayerWidget(this); this.addChild(mainLayer); topLeft = new Widget(this); topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(topLeft); bottomRight = new Widget(this); bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(bottomRight); slotLayer = new LayerWidget(this); this.addChild(slotLayer); connectionLayer = new LayerWidget(this); this.addChild(connectionLayer); LayerWidget selectionLayer = new LayerWidget(this); this.addChild(selectionLayer); this.setLayout(LayoutFactory.createAbsoluteLayout()); this.getActions().addAction(hoverAction); zoomAction = new BoundedZoomAction(1.1, false); zoomAction.setMaxFactor(ZOOM_MAX_FACTOR); zoomAction.setMinFactor(ZOOM_MIN_FACTOR); this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1)); panAction = new ExtendedPanAction(); this.getActions().addAction(panAction); this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider)); LayerWidget selectLayer = new LayerWidget(this); this.addChild(selectLayer); this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider)); blockWidgets = new HashMap<InputBlock, BlockWidget>(); boolean b = this.getUndoRedoEnabled(); this.setUndoRedoEnabled(false); this.setNewModel(model); this.setUndoRedoEnabled(b); }
Example 13
Source File: DiagramScene.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public DiagramScene(Action[] actions, DiagramViewModel model) { this.actions = actions; selectedWidgets = new ArrayList<FigureWidget>(); content = new InstanceContent(); lookup = new AbstractLookup(content); this.setCheckClipping(true); this.getInputBindings().setZoomActionModifiers(0); JComponent comp = this.createView(); comp.setDoubleBuffered(true); comp.setBackground(Color.WHITE); comp.setOpaque(true); this.setBackground(Color.WHITE); this.setOpaque(true); scrollPane = new JScrollPane(comp); scrollPane.setBackground(Color.WHITE); scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getViewport().addChangeListener(scrollChangeListener); hoverAction = this.createWidgetHoverAction(); blockLayer = new LayerWidget(this); this.addChild(blockLayer); startLayer = new LayerWidget(this); this.addChild(startLayer); // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections..."; String startLabelString = ""; LabelWidget w = new LabelWidget(this, startLabelString); scrollChangeListener.register(w, new Point(10, 10)); w.setAlignment(LabelWidget.Alignment.CENTER); startLabel = w; startLayer.addChild(w); mainLayer = new LayerWidget(this); this.addChild(mainLayer); topLeft = new Widget(this); topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(topLeft); bottomRight = new Widget(this); bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(bottomRight); slotLayer = new LayerWidget(this); this.addChild(slotLayer); connectionLayer = new LayerWidget(this); this.addChild(connectionLayer); LayerWidget selectionLayer = new LayerWidget(this); this.addChild(selectionLayer); this.setLayout(LayoutFactory.createAbsoluteLayout()); this.getActions().addAction(hoverAction); zoomAction = new BoundedZoomAction(1.1, false); zoomAction.setMaxFactor(ZOOM_MAX_FACTOR); zoomAction.setMinFactor(ZOOM_MIN_FACTOR); this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1)); panAction = new ExtendedPanAction(); this.getActions().addAction(panAction); this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider)); LayerWidget selectLayer = new LayerWidget(this); this.addChild(selectLayer); this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider)); blockWidgets = new HashMap<InputBlock, BlockWidget>(); boolean b = this.getUndoRedoEnabled(); this.setUndoRedoEnabled(false); this.setNewModel(model); this.setUndoRedoEnabled(b); }
Example 14
Source File: DiagramScene.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public DiagramScene(Action[] actions, DiagramViewModel model) { this.actions = actions; selectedWidgets = new ArrayList<FigureWidget>(); content = new InstanceContent(); lookup = new AbstractLookup(content); this.setCheckClipping(true); this.getInputBindings().setZoomActionModifiers(0); JComponent comp = this.createView(); comp.setDoubleBuffered(true); comp.setBackground(Color.WHITE); comp.setOpaque(true); this.setBackground(Color.WHITE); this.setOpaque(true); scrollPane = new JScrollPane(comp); scrollPane.setBackground(Color.WHITE); scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); scrollPane.getViewport().addChangeListener(scrollChangeListener); hoverAction = this.createWidgetHoverAction(); blockLayer = new LayerWidget(this); this.addChild(blockLayer); startLayer = new LayerWidget(this); this.addChild(startLayer); // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections..."; String startLabelString = ""; LabelWidget w = new LabelWidget(this, startLabelString); scrollChangeListener.register(w, new Point(10, 10)); w.setAlignment(LabelWidget.Alignment.CENTER); startLabel = w; startLayer.addChild(w); mainLayer = new LayerWidget(this); this.addChild(mainLayer); topLeft = new Widget(this); topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(topLeft); bottomRight = new Widget(this); bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE)); this.addChild(bottomRight); slotLayer = new LayerWidget(this); this.addChild(slotLayer); connectionLayer = new LayerWidget(this); this.addChild(connectionLayer); LayerWidget selectionLayer = new LayerWidget(this); this.addChild(selectionLayer); this.setLayout(LayoutFactory.createAbsoluteLayout()); this.getActions().addAction(hoverAction); zoomAction = new BoundedZoomAction(1.1, false); zoomAction.setMaxFactor(ZOOM_MAX_FACTOR); zoomAction.setMinFactor(ZOOM_MIN_FACTOR); this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1)); panAction = new ExtendedPanAction(); this.getActions().addAction(panAction); this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider)); LayerWidget selectLayer = new LayerWidget(this); this.addChild(selectLayer); this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider)); blockWidgets = new HashMap<InputBlock, BlockWidget>(); boolean b = this.getUndoRedoEnabled(); this.setUndoRedoEnabled(false); this.setNewModel(model); this.setUndoRedoEnabled(b); }