Java Code Examples for org.netbeans.api.visual.widget.Widget#setPreferredLocation()
The following examples show how to use
org.netbeans.api.visual.widget.Widget#setPreferredLocation() .
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: FreePlaceNodesLayouter.java From netbeans with Apache License 2.0 | 6 votes |
public void layoutNodesLocations( PageFlowScene scene, Collection<Page> nodes) { final Collection<Page> allNodes = scene.getNodes(); for( Page node : nodes ) { final Widget nodeWidget = scene.findWidget(node); if( nodeWidget == null ) { return; } if ( nodeWidget.getPreferredLocation() != null ) { /* If the getPreferredLocation has already been set by something else. */ /* The unique ID for a node is it's display name defined by: node.getDisplayName() */ positions.put(node.getDisplayName(), nodeWidget.getPreferredLocation()); } else { Point point = positions.get(node.getDisplayName()); if ( point == null ) { point = getNewComponentLocation(scene, positions, allNodes); } positions.put(node.getDisplayName(), point); nodeWidget.setPreferredLocation(point); } } }
Example 2
Source File: GraphLayout.java From netbeans with Apache License 2.0 | 6 votes |
/** * Should be called to set a new resolved preferred location of a node. * @param graph the universal graph * @param node the node with resolved location * @param newPreferredLocation the new resolved location */ protected final void setResolvedNodeLocation (UniversalGraph<N,E> graph, N node, Point newPreferredLocation) { ObjectScene scene = graph.getScene (); Widget widget = scene.findWidget (node); if (widget == null) return; Point previousPreferredLocation = widget.getPreferredLocation (); if (animated) scene.getSceneAnimator ().animatePreferredLocation (widget, newPreferredLocation); else widget.setPreferredLocation (newPreferredLocation); GraphLayoutListener<N,E>[] listeners = createListenersCopy (); for (GraphLayoutListener<N,E> listener : listeners) listener.nodeLocationChanged (graph, node, previousPreferredLocation, newPreferredLocation); }
Example 3
Source File: FruchtermanReingoldLayout.java From netbeans with Apache License 2.0 | 5 votes |
private void finish() { for (GraphNode n : scene.getNodes()) { NodeWidget w = getWidget(n); Widget wid = scene.findWidget(n); Point point = new Point(); point.setLocation(w.locX, w.locY); if (scene.isAnimated()) { scene.getSceneAnimator().animatePreferredLocation(wid, point); } else { wid.setPreferredLocation(point); } } }
Example 4
Source File: DiagramScene.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void stateChanged(ChangeEvent e) { Point p = DiagramScene.this.getScrollPane().getViewport().getViewPosition(); if (oldPosition == null || !p.equals(oldPosition)) { for (Widget w : relativePositions.keySet()) { Point curPoint = relativePositions.get(w); Point newPoint = new Point(p.x + curPoint.x, p.y + curPoint.y); w.setPreferredLocation(newPoint); DiagramScene.this.validate(); } oldPosition = p; } }
Example 5
Source File: DiagramScene.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void stateChanged(ChangeEvent e) { Point p = DiagramScene.this.getScrollPane().getViewport().getViewPosition(); if (oldPosition == null || !p.equals(oldPosition)) { for (Widget w : relativePositions.keySet()) { Point curPoint = relativePositions.get(w); Point newPoint = new Point(p.x + curPoint.x, p.y + curPoint.y); w.setPreferredLocation(newPoint); DiagramScene.this.validate(); } oldPosition = p; } }
Example 6
Source File: ControlFlowScene.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void setNewLocation(Widget widget, Point location) { Point originalLocation = getOriginalLocation(widget); int xOffset = location.x - originalLocation.x; int yOffset = location.y - originalLocation.y; for (Widget w : this.selection) { Point p = new Point(w.getPreferredLocation()); p.translate(xOffset, yOffset); w.setPreferredLocation(p); } }
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: PreferredLocationAnimator.java From netbeans with Apache License 2.0 | 5 votes |
protected void tick (double progress) { for (Map.Entry<Widget, Point> entry : targetLocations.entrySet ()) { Widget widget = entry.getKey (); Point sourceLocation = sourceLocations.get (widget); if (sourceLocation == null) { sourceLocation = widget.getPreferredLocation (); if (sourceLocation == null) { sourceLocation = widget.getLocation (); if (sourceLocation == null) { sourceLocation = new Point (); } } sourceLocations.put (widget, sourceLocation); } Point targetLocation = entry.getValue (); if (targetLocation == null) continue; Point point; if (progress >= 1.0) point = targetLocation; else point = new Point ( (int) (sourceLocation.x + progress * (targetLocation.x - sourceLocation.x)), (int) (sourceLocation.y + progress * (targetLocation.y - sourceLocation.y))); widget.setPreferredLocation (point); } if (progress >= 1.0) { sourceLocations.clear (); targetLocations.clear (); } }
Example 9
Source File: DiagramScene.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void stateChanged(ChangeEvent e) { Point p = DiagramScene.this.getScrollPane().getViewport().getViewPosition(); if (oldPosition == null || !p.equals(oldPosition)) { for (Widget w : relativePositions.keySet()) { Point curPoint = relativePositions.get(w); Point newPoint = new Point(p.x + curPoint.x, p.y + curPoint.y); w.setPreferredLocation(newPoint); DiagramScene.this.validate(); } oldPosition = p; } }
Example 10
Source File: ControlFlowScene.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void setNewLocation(Widget widget, Point location) { if (selection.contains(widget)) { // move entire selection Point originalLocation = getOriginalLocation(widget); int xOffset = location.x - originalLocation.x; int yOffset = location.y - originalLocation.y; for (Widget w : selection) { Point p = new Point(w.getPreferredLocation()); p.translate(xOffset, yOffset); w.setPreferredLocation(p); } } else { widget.setPreferredLocation(location); } }
Example 11
Source File: ControlFlowScene.java From hottub with GNU General Public License v2.0 | 5 votes |
public void setNewLocation(Widget widget, Point location) { Point originalLocation = getOriginalLocation(widget); int xOffset = location.x - originalLocation.x; int yOffset = location.y - originalLocation.y; for (Widget w : this.selection) { Point p = new Point(w.getPreferredLocation()); p.translate(xOffset, yOffset); w.setPreferredLocation(p); } }
Example 12
Source File: ControlFlowScene.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void setNewLocation(Widget widget, Point location) { Point originalLocation = getOriginalLocation(widget); int xOffset = location.x - originalLocation.x; int yOffset = location.y - originalLocation.y; for (Widget w : this.selection) { Point p = new Point(w.getPreferredLocation()); p.translate(xOffset, yOffset); w.setPreferredLocation(p); } }
Example 13
Source File: DiagramScene.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void stateChanged(ChangeEvent e) { Point p = DiagramScene.this.getScrollPane().getViewport().getViewPosition(); if (oldPosition == null || !p.equals(oldPosition)) { for (Widget w : relativePositions.keySet()) { Point curPoint = relativePositions.get(w); Point newPoint = new Point(p.x + curPoint.x, p.y + curPoint.y); w.setPreferredLocation(newPoint); DiagramScene.this.validate(); } oldPosition = p; } }
Example 14
Source File: DiagramScene.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public DiagramScene(Action[] actions, Action[] actionsWithSelection, DiagramViewModel model) { this.actions = actions; this.actionsWithSelection = actionsWithSelection; content = new InstanceContent(); lookup = new AbstractLookup(content); this.setCheckClipping(true); scrollPane = createScrollPane(); hoverAction = createObjectHoverAction(); // This panAction handles the event only when the left mouse button is // pressed without any modifier keys, otherwise it will not consume it // and the selection action (below) will handle the event panAction = new CustomizablePanAction(~0, MouseEvent.BUTTON1_DOWN_MASK); this.getActions().addAction(panAction); selectAction = createSelectAction(); this.getActions().addAction(selectAction); blockLayer = new LayerWidget(this); this.addChild(blockLayer); connectionLayer = new LayerWidget(this); this.addChild(connectionLayer); 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); LayerWidget selectionLayer = new LayerWidget(this); this.addChild(selectionLayer); this.setLayout(LayoutFactory.createAbsoluteLayout()); this.getInputBindings().setZoomActionModifiers(KeyEvent.CTRL_MASK); zoomAction = ActionFactory.createMouseCenteredZoomAction(1.2); this.getActions().addAction(zoomAction); this.getView().addMouseWheelListener(mouseWheelListener); this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider)); this.getActions().addAction(ActionFactory.createWheelPanAction()); LayerWidget selectLayer = new LayerWidget(this); this.addChild(selectLayer); this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider)); boolean b = this.getUndoRedoEnabled(); this.setUndoRedoEnabled(false); this.setNewModel(model); this.setUndoRedoEnabled(b); this.addObjectSceneListener(selectionChangedListener, ObjectSceneEventType.OBJECT_SELECTION_CHANGED, ObjectSceneEventType.OBJECT_HIGHLIGHTING_CHANGED, ObjectSceneEventType.OBJECT_HOVER_CHANGED); }
Example 15
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 16
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); }
Example 17
Source File: ActionFactory.java From netbeans with Apache License 2.0 | 4 votes |
public void setNewLocation (Widget widget, Point location) { widget.setPreferredLocation (location); }
Example 18
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 19
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 20
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); }