DocumentsDownloadsWikiCommunityBlogAbout

OpenFlow GUI Extension - Display

From OpenFlow Wiki

Jump to: navigation, search

The OpenFlow GUI provides default implementations to render common objects like switches, hosts, and links. How these objects are rendered can be changed. You can also display arbitrary graphics of your own choosing, including sophisticated elements like charts.


Contents

Adding Custom Graphics

You can add your own Drawables with the addDrawable(Drawable) method. Though this enables you to draw absolutely anything on the GUI, a number of helper classes are provided in the org.pzgui.icon package which make drawing common elements easier. The package includes the ability to easily draw and resize arbitrary polygons, images, Java Shape objects, text, transient (temporary) graphics, or any composition of these.


Custom Topology Element Graphics (Switches, etc.)

You can access Drawables when they are added to or removed from a topology by overriding the addDrawable(Drawable) and/or removeDrawable(Drawable) methods in your subclass of PZManager as shown in the example code.

Custom Node Graphics

Using this approach you can easily change the graphic used to represent each node:

   /** Adds the drawable as usual and then sets a custom switch graphic for some switch */
   public void addDrawable(Drawable d) {
       super.addDrawable(d);
       // TODO: any custom processing when a Drawable is added
       // example of drawing a particular switch specially
       if(d instanceof OpenFlowSwitch) {
           OpenFlowSwitch s = (OpenFlowSwitch)d;
           if(s.getID() == 0x00ABCD00) {
               s.setIcon(new ImageIcon("dgu.gif", 25, 25));
           }
       }
   }

This code uses a special image to represent an OpenFlowSwich object with a particular ID. You can use any Icon from org.pzgui.icon (not just images).

Completely Custom Drawing

Another approach to modifying how objects are drawn is to change the implementation of the drawObject(Graphics2D) method in the class whose appearance you wish to modify. This allows you to do any processing you like in order to draw the object and thus is more general but probably more difficult than the above approach. It can be used with any of the built-in Drawable including the OpenFlowSwitch, Host, and Link classes.


Charts

Charts can provide a wealth of information and they are so frequently needed that the OpenFlow GUI makes it easy to create them with the JFreeChart library which is included. In addition to the many styles of graphs provided by that library, some extensions to it are provided in the org.openflow.gui.chart package (notably a helper class for creating multi-pointer dial charts).

Copyright 2008 by the OpenFlow Consortium. All rights reserved. Powered by MediaWiki and WordPress.