DocumentsDownloadsWikiCommunityBlogAbout

OpenFlow GUI Extension - Control

From OpenFlow Wiki

Jump to: navigation, search

The are two approaches for adding controls to your GUI are described below.


Adding controls

To put the controls in a separate window you can simply create and use your own JFrame.


Adding controls in the topology window

To embed the controls in the same window as your topology, you need to reserve some space on the window for your controls. You can either reserve the right or bottom side of a window. The example code shows how to reserve space on the bottom of the main window:

   /** Overrides parent to reserve space for custom controls in the new window. */
   public void attachWindow(final PZWindow w) {
       super.attachWindow(w);
       if(getWindowIndex(w) == 0) {
           w.getContentPane().add(pnlCustom);
           w.setReservedHeightBottom(RESERVED_HEIGHT_BOTTOM);
           w.setMySize(w.getWidth(), w.getHeight(), w.getZoom());
       }
   }


This code reserves the space and also adds a custom JPanel. To ensure pnlCustom is placed and sized appropriately, we also override setLayoutSize(int,int):

   /**
    * Extends the parent implementation to relayout the custom controls section
    * to fit in the new area. 
    */
   public void setLayoutSize(int w, int h) {
       super.setLayoutSize(w, h);
       int margin = 20; 
       pnlCustom.setBounds(0, h + margin, w, RESERVED_HEIGHT_BOTTOM - 2 * margin);
   }


Graphs

You can also add graphs to your custom reserved space. This is described in the display section.

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