Painting LabelWidgets on top of the ConnectionWidget - Netbeans Visual Library

I was fiddling with the Netbeans Visual Library again, trying to show a complex graph on screen and I run into a problem: There were so many connection in the graph that some widgets were hard to read because the ConnectionWidget arrows were printed over them. So I tried to I try to rearrange the order of my LayerWidgets to paint the LabelWidgets on top of ConnectionWidgets. A call to mainLayer.bringToFront() should be enough, but this is what I got when I tried that: ...

May 7, 2009

NullPointerException in FontDesignMetrics$MetricsKey.init when using Netbeans Visual Library

If you’re getting a NullPointerException stacktrace like the one below while using the Netbeans Visual Library to create your own GraphScene, check that your adding your widgets propertly to scene. A good idea is to use LayerWidgets, declaring them in the constructor of your GraphScene: mainLayer = new LayerWidget(this); addChild(mainLayer); connectionLayer = new LayerWidget(this); addChild(connectionLayer); and then add the widgets to those layers in attachNodeWidget and attachEdgeWidget: @Override protected Widget attachNodeWidget(String node) { LabelWidget w = new LabelWidget(this, node); w.setBorder(BORDER4); w.getActions().addAction(createSelectAction()); w.getActions().addAction(createObjectHoverAction()); w.getActions().addAction(ActionFactory.createMoveAction()); this.mainLayer.addChild(w); return w; } @Override protected Widget attachEdgeWidget(String edge) { ConnectionWidget w = new ConnectionWidget(this); w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); this.connectionLayer.addChild(w); return w; } The stacktrace: ...

April 30, 2009

Add Platform Sources using Netbeans Platform Manager

To be able to do Navigate ⇒ Go to Source on netbeans classes like TopComponent you need to link the sources to the Netbeans Plaform using the Netbeans Plaform Manager as explained in Hyperlinking to NetBeans API Sources. Be sure to download the proper source zip from the netbeans download page, otherwise the Platform Manager won’t let you attach the source file to the platform (all invalid options are greyed out/dimmed): ...

April 29, 2009

Opening Favorites window at startup in a Netbeans Platform Application

After learning about the Favorites window in the NetBeans Platform Quick Start. I wanted to use it in an application of my own. This easy task became more difficult that I though because I was getting random results, sometimes after a clean build I got the Favorites window open and sometimes not. But let’s start from the beginning, I put my hands at work, it was just a matter of adding the Favorites module to the Netbeans Platform Application (app’s properties ⇒ Libraries ⇒ Platform Modules ⇒ platform9 ⇒ Favorites) and edit one of my modules layer.xml to override Windows2/Modes/explorer/favorites.wstcref. Just go to Important Files ⇒ XML Layer ⇒ this layer in context ⇒ Windows2 ⇒ Modes ⇒ explore ⇒ favorites.wstcref and replace ...

April 28, 2009

Force Directed Layout in NetBeans

I just came up with the idea of reproducing the GraphView demo I saw in prefuse by using the Netbeans Visual Library API. The GraphView demo uses a Force Directed Layout algorithm to dinamically position the nodes on the screen. It’s really fast and cool. Download prefuse and experiment with it by yourself. I wanted to achieve something similiar with the Visual Library and I succeed up to a point. The force based layout algorithm that I implemented is much simpler that the used in prefuse, so there is no spring-like movement. It looks way cooler with springs. It just uses repulsion between nodes and attraction between connected nodes. ...

March 9, 2009

How to hide/remove the Save, Undo and Redo buttons on the Toolbar (Netbeans Platform)

The default Netbeans Platform Application generated by the Netbeans IDE wizard has the Save, Undo and Redo button showing up in the toolbar by default. Since my applications doesn’t have anything to save I decided to hide those buttons. I turns out that remove them is really simple, I knew that I had to fiddle with the layer.xml file and hide something but I didn’t know exactly what. At the end I found the solution buried in this A NetBeans Platform Sample and Tutorial. ...

March 8, 2009

GPLv3 license template for Netbeans

To add an GPL notice to all your new files Just open the Netbeans Template Manager by clicking Tools ⇒ Templates. Click on the Default License and press the Duplicate button. Then select the newly created “license-default_1.txt” and rename it to “license-gplv3.txt” (the name it’s important copy exactly the same name). Then click on “Open in Editor” button and replace the contents of the license file with the following: ...

March 5, 2009

Simple Interactions Between NetBeans TopComponents

Basic stuff: how to communicate / interact bewteen two TopComponent in Netbeans. LIke a updating a JTable inside a TopComponent from a JButton in another TopComponent. The key is in the TopComponent.findInstance method as explained by Geertjan in p. Simple Interactions Between NetBeans TopComponents.

March 3, 2009

Netbeans: "Problem when deserializing TopComponent for tcID"

Today I experienced a strange problem. Or I thought it was strange . I just checkout a my project from Subversion into Netbeans and it didn’t work!. How come? I have another working copy that works just ok. So I check the logs in $app/build/testuserdir/var/log/messages.log and I found INFO [org.netbeans.core.windows.persistence]: [PersistenceManager.getTopComponentForID] Problem when deserializing TopComponent for tcID:'XBeeTopComponent'. Reason: com/rapplogic/xbee/api/XBeeException java.lang.NoClassDefFoundError: com/rapplogic/xbee/api/XBeeException at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2395) at java.lang.Class.getMethod0(Class.java:2642) at java.lang.Class.getMethod(Class.java:1579) at org.netbeans.modules.settings.convertors.XMLSettingsSupport$SettingsRecognizer.createFromMethod(XMLSettingsSupport.java:664) at org.netbeans.modules.settings.convertors.XMLSettingsSupport$SettingsRecognizer.instanceCreate(XMLSettingsSupport.java:581) at org.netbeans.modules.settings.convertors.SerialDataConvertor$SettingsInstance.instanceCreate(SerialDataConvertor.java:420) [catch] at org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentPersistentForID(PersistenceManager.java:531) at org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentForID(PersistenceManager.java:641) at org.netbeans.core.windows.PersistenceHandler.getTopComponentForID(PersistenceHandler.java:422) at org.netbeans.core.windows.PersistenceHandler.load(PersistenceHandler.java:162) at org.netbeans.core.windows.WindowSystemImpl.load(WindowSystemImpl.java:69) at org.netbeans.core.NonGui$2.run(NonGui.java:178) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:461) at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) NoClassDefDFoundError. ok. It was working before but I can take look. Guess what I changed the name of the jar that contains that class, long time ago but it didn’t show up until now when I started from a clean directory. I found that in the Library Wrapper Module project..xml still contains the old name ...

March 2, 2009

"Reload in target plaform" is not working in Netbeans 6.1/6.5 RC2 in Mac OS X 10.5 Leopard

I filed a bug report http://www.netbeans.org/issues/show_bug.cgi?id=153354 It seems that it cannot find the inner class ResolvableHelper inside the TopComponent. (throws a NoClassDefFoundException, see the messages.log for details ). It’s funny though, because it works perfectly in Windows XP and Vista, I thought this stuff was platform independent.

November 19, 2008