2 Replies Latest reply: Feb 13, 2009 10:38 AM by 843851 RSS

    How to make a Selection Circular Bar Menu  with HAVi?

    843851
      hi! I'm Suse...I'm trying to make a menu selection circular, with:
      A static center focus --> F
      Horizontal Bar Menu --> H (Categories)
      Vertical Bar Menu --> V (Sub Categories)

      ......*V* Graphic
      ......*V*
      ......*V*
      HH  F HHHH
      ......*V*
      ......*V*

      When pressing Right Arrow... the F focus change to next(right) Item(*H*) and pressing Left Arrow change to the back(left) item(*H*)... where de F (focus) is static... if it pressing UP or Down Arrow is the same mechanism...in the Vertical Bar (*V*)....like the up Gaphic...

      I started to make with HAVi but I don't know which objects and methods I could use...
      I just use a Vector, HContainer, HListElement and HListGroup....

      If somebody wanna share some notes or tips ... thank you!
      import java.awt.Color;
      import java.awt.Font;
      import java.awt.Rectangle;
      import java.awt.event.ActionEvent;
      import java.awt.event.FocusEvent;
      import java.util.Vector;
      import org.havi.ui.HContainer;
      import org.havi.ui.HListElement;
      import org.havi.ui.HListGroup;
      import org.havi.ui.HScene;
      import org.havi.ui.HSceneFactory;
      import org.havi.ui.HSceneTemplate;
      import org.havi.ui.event.HActionListener;
      import org.havi.ui.event.HFocusListener;
      import org.havi.ui.event.HItemEvent;
      import org.havi.ui.event.HItemListener;
      
      public class HListGroupMenu extends HContainer implements HActionListener, HItemListener, HFocusListener{
      
           private static final long serialVersionUID = 1L;
           private static final Rectangle     SCREEN_BOUNDS = new Rectangle(0, 0, 640, 480);
           private static final Rectangle     LIST_GROUP_BOUNDS = new Rectangle(50, 105, 150, 169);
           private static final Color           LIST_GROUP_FOREGROUND = new Color(240, 240, 240); // for text and frame
           private static final Color           LIST_GROUP_BACKGROUND = new Color(78, 90, 20); // for text and frame     
           private static final Font           LIST_GROUP_FONT = new Font("tiresias", Font.BOLD, 14);
           private HScene                          m_scene;  
           private HListGroup                    m_listGroup;
      
           // list of text string to hold the result of ListGroup selection     
           private Vector     m_textList = new Vector();
      
           private static final String          LIST_GROUP_ITEMS[][] = {
      
                {"One", "Two","Three", "Four",     "Five",     "Six", "Seven "}
      
           };
              /*
            * called from Xlet.HListGroupMenu() ..........Instance
      */*
      *     public HListGroupMenu()*
      *     {*
      *          m_scene = HSceneFactory.getInstance().getBestScene(new HSceneTemplate());*
      *          m_scene.add(this);            *
      *          setBounds(SCREEN_BOUNDS);     *
      
      *//           Create List group*
      *          m_listGroup = new HListGroup();*
      *          m_listGroup.setBounds(LIST_GROUP_BOUNDS);*
      *          m_listGroup.setForeground(LIST_GROUP_FOREGROUND);*
      *          m_listGroup.setBackground(LIST_GROUP_BACKGROUND);*
      *          m_listGroup.setFont(LIST_GROUP_FONT);*
      *          m_listGroup.addItemListener(this);*
      *          m_listGroup.addHFocusListener(this);*
      *          m_listGroup.getHorizontalAlignment();*
      *          m_listGroup.setName("List Group");*
      
      *          // Add items to the List group*
      *          for (int i=0; i<LIST_GROUP_ITEMS.length; ++i){*
      *               for (int j=0; j<LIST_GROUP_ITEMS.length; ++j){*
      *               m_listGroup.addItem(new HListElement(LIST_GROUP_ITEMS[i][j]), j);*
      *               }*
      *          }     *
      *          add( m_listGroup );*
      *     }*

      *     /*
           * called from Xlet.startXlet() ..... Instance
      */*
      *     public void start()*
      *     {*
      *          m_scene.show();*
      *          m_listGroup.requestFocus();*
      *     }     *

      *     /*
           * called from Xlet.pauseXlet() ...Instance
      */*
      *     public void pause()*
      *     {*
      *          m_scene.setVisible(false);*
      *     }*


      *     /*
           * called from Xlet.destroyXlet() ..........Instance
           */
           public void destroy()
           {

                m_listGroup.removeItemListener(this);
                m_listGroup.removeHFocusListener(this);

                m_scene.setVisible(false);
                m_scene.removeAll();
                HSceneFactory.getInstance().dispose(m_scene);
                m_scene = null;
           }

           public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub

           }

           public void selectionChanged(HItemEvent event) {
                // TODO Auto-generated method stub

                HListElement item = (HListElement) event.getItem();     

                if (item != null)
                {
                     if (event.getID() == HItemEvent.ITEM_SELECTED )
                     {     
                          // an item was selected          & add it to the list
                          m_textList.addElement(new String(item.getLabel()));
                     }
                     else if (event.getID() == HItemEvent.ITEM_CLEARED)
                     {          
                          // an item was un-selected & remove it from the list
                          m_textList.removeElement(item.getLabel());     
                     }

                }
           }

           public void currentItemChanged(HItemEvent e) {
           }
           public void focusGained(FocusEvent e) {
           }
           public void focusLost(FocusEvent e) {
           }

      }
      Edited by: sesu on Jan 20, 2009 4:13 PM
      
      Edited by: sesu on Jan 20, 2009 4:15 PM