

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
4 messages in org.netbeans.graph.usersRe: Can't get LabelWidget painted on ...| From | Sent On | Attachments |
|---|---|---|
| Ruben Laguna | Apr 30, 2009 3:01 pm | |
| Ruben Laguna | Apr 30, 2009 3:10 pm | |
| Ruben Laguna | May 1, 2009 12:56 am | |
| Ruben Laguna | May 7, 2009 11:48 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: Can't get LabelWidget painted on top of ConnectionWidget | Actions... |
|---|---|---|
| From: | Ruben Laguna (rube...@gmail.com) | |
| Date: | May 7, 2009 11:48:35 pm | |
| List: | org.netbeans.graph.users | |
At the end the solution was very easy.
The problem was that I tried to change the ordering of the LayerWidgets before the LabelWidget got a location in the scene (The ConnectionWidget relies on the Anchors and the Anchors need the location of the relatedWidget) . The LabelWidgets will only get a location when they are painted on the screen after I add the scene.createView() to a visible JPanel. So I wait until the scene is painted for the first time and THEN i call mainLayer.bringToFront() from the TopComponent (I created a method bringMainLayerToFront in my scene to be able to do that).
If you want to see the results I wrote a blog post with the images http://rubenlaguna.com/wp/2009/05/07/painting-labelwidgets-on-top-of-the-connectionwidget-netbeans-visual-library/
/Ruben Laguna
On Fri, May 1, 2009 at 9:57 AM, Ruben Laguna <rube...@gmail.com> wrote:
On Fri, May 1, 2009 at 9:53 AM, Ruben Laguna <rube...@gmail.com>wrote:
Calling scene.validate() after adding each childen doesn't throw an IllegalStateException. It seems that Scene.validate() only throws the exception when the scene.createView() is added to the JPanel and shown. Do you mean calling widget.bringToBack in notifyStateChange? or what do yo mean? if the widget is already on a layer that is on top of mainLayer that would not help, would it?
I guess that the easy solution would be to put all widgets in the same layer and invoke .bringtoback() on all ConnectionWidgets. But it tried that and it didn't work
As soon as I remove the connectionLayer like this
mainLayer = new LayerWidget(this); addChild(mainLayer); connectionLayer = mainLayer; //connectionLayer = new LayerWidget(this); //addChild(connectionLayer); //mainLayer.bringToFront();
I get the same IllegalStateException if I uncomment the connectionLayer the addChild after, then I don't get the exception.
On Fri, May 1, 2009 at 12:22 AM, Maciej Madej <maci...@gmail.com>wrote:
Hi,
This exception is very strange :( Maybe try to use scene.validate() method after adding childre.
Maybe try to use own implementation of ConnectionWidget where you
override:
*notifyStateChanged<http://bits.netbeans.org/dev/javadoc/org-netbeans-api-visual/org/netbeans/api/visual/widget/Widget.html#notifyStateChanged%28org.netbeans.api.visual.model.ObjectState,%20org.netbeans.api.visual.model.ObjectState%29>
*(ObjectState<http://bits.netbeans.org/dev/javadoc/org-netbeans-api-visual/org/netbeans/api/visual/model/ObjectState.html>
previousState,
ObjectState<http://bits.netbeans.org/dev/javadoc/org-netbeans-api-visual/org/netbeans/api/visual/model/ObjectState.html>
state)
method. Place there code to bring your widget to back or bring every layer to front :-)
This is not very pretty solution, but It's midnight so my mind is sleepy :D
You wrote:
"It seems that connectionLayer has to be always on top of mainLayer"
That's not true.
You can also place connection widgets and label widgets in the same layer.
2009/5/1 Ruben Laguna <rube...@gmail.com>
Hi, I have a GraphScene with two LayerWidgets mainLayer where I put all the LabelWidgets and connectionLayer where I have the ConnectionWidgets.
mainLayer = new LayerWidget(this); addChild(mainLayer); connectionLayer = new LayerWidget(this); addChild(connectionLayer); mainLayer.bringToFront(); this.getActions().addAction(ActionFactory.createZoomAction());
My problem is that in certain graph the lines are painted over the labelwidget making difficult to read the label.
See the following image for an example
[image: 20090430-mp1fn6j3kka869caaejw1achu3.jpg]
When I try to change the order of the LayerWidget (either changing the order of the addChild calls or invoking mainLayer.bringToFront()) I get the following exception when trying to show the GraphScene. It seems that connectionLayer has to be always on top of mainLayer. Have anybody any idea on how to solve/workaround this?
java.lang.IllegalStateException: Widget (org.netbeans.api.visual.widget.LabelWidget@10014f0) was not added into the scene
at org.netbeans.api.visual.anchor.Anchor.getRelatedSceneLocation(Anchor.java:213)
at org.netbeans.modules.visual.anchor.RectangularAnchor.compute(RectangularAnchor.java:111)
at org.netbeans.modules.visual.router.DirectRouter.routeConnection(DirectRouter.java:65)
at org.netbeans.api.visual.widget.ConnectionWidget.calculateRouting(ConnectionWidget.java:527)
at org.netbeans.modules.visual.layout.ConnectionWidgetLayout.layout(ConnectionWidgetLayout.java:109)
at org.netbeans.api.visual.widget.Widget.layout(Widget.java:1350)
at org.netbeans.api.visual.widget.Widget.layout(Widget.java:1342)
at org.netbeans.api.visual.widget.LayerWidget.layout(LayerWidget.java:86)
at org.netbeans.api.visual.widget.Widget.layout(Widget.java:1342)
at org.netbeans.api.visual.widget.Scene.layoutScene(Scene.java:312)
at org.netbeans.api.visual.widget.Scene.validate(Scene.java:393)
at org.netbeans.api.visual.widget.SceneComponent.addNotify(SceneComponent.java:92)
at java.awt.Container.addImpl(Container.java:1039)
at java.awt.Container.add(Container.java:896)
at com.rubenlaguna.modules.mainmodule.GraphTopComponent.setDotFile(GraphTopComponent.java:80)
at com.rubenlaguna.modules.mainmodule.DotOpenSupport.createCloneableTopComponent(DotOpenSupport.java:31)
at org.openide.windows.CloneableOpenSupport.openCloneableTopComponent(CloneableOpenSupport.java:197)
at org.openide.windows.CloneableOpenSupport$1.run(CloneableOpenSupport.java:98)
at org.openide.util.Mutex.doEvent(Mutex.java:1335)
at org.openide.util.Mutex.writeAccess(Mutex.java:452)
at org.openide.windows.CloneableOpenSupport.open(CloneableOpenSupport.java:95)
at org.openide.actions.OpenAction.performAction(OpenAction.java:81)
at org.openide.util.actions.NodeAction$DelegateAction$1.run(NodeAction.java:589)
at org.netbeans.modules.openide.util.ActionsBridge.doPerformAction(ActionsBridge.java:77)
at org.openide.util.actions.NodeAction$DelegateAction.actionPerformed(NodeAction.java:585)
at org.openide.explorer.view.TreeView$PopupSupport.mouseClicked(TreeView.java:1515)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
at java.awt.Component.processMouseEvent(Component.java:6137)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5899)
at java.awt.Container.processEvent(Container.java:2023)
at java.awt.Component.dispatchEventImpl(Component.java:4501)
at java.awt.Container.dispatchEventImpl(Container.java:2081)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3974)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3895)
at java.awt.Container.dispatchEventImpl(Container.java:2067)
at java.awt.Window.dispatchEventImpl(Window.java:2458)
at java.awt.Component.dispatchEvent(Component.java:4331)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
-- /Rubén
-- /Rubén
-- Pozdrawiam Maciej Madej
-- /Rubén
-- /Rubén
-- /Rubén







