Gantt Chart Editing by Mouse Wheel: Java Gantt Chart Best Practice

Posted by Bernd-Rainer Lauber on Oct 20, 2015 11:05:00 AM

Drag and drop is the interaction most frequently used in a Gantt chart: Activities are shifted either horizontally or vertically. In some cases, the data editing mode is used for modifications: The according node is selected by mouse, an info box appears and the according data field can be modified via key board.

There is yet another, more comfortable and faster way of modifying data: by mouse wheel. By clicking the node the field’s content is displayed and can be modified immediately by turning the mouse wheel.

This blogpost shows you how you can accomplish this mouse wheel driven interaction with our Java Gantt chart control VARCHART JGantt. It provides you also with code snippets so that you can turn this feature into action rapidly in your Java Gantt chart application.

How it may look

This video shows a simple example to demonstrate how you can modify data by using the mouse wheel:

 

 

How to in VARCHART JGantt

// Adding the MousewheelHandler

 jGantt1.addMouseWheelListener(new MousewheelHandler(jGantt1));

 public class MousewheelHandler implements MouseWheelListener

   {

   JGantt jGantt1;

     public MousewheelHandler (JGantt jGantt)

      {

      jGantt1 = jGantt;

      }

    @Override

   public void mouseWheelMoved(MouseWheelEvent e)

      {

      Iterator iter = jGantt1.selectedEntitiesIterator();

     // No entity was selected

      if (!iter.hasNext())

         return;

      // Only the first selected Entity is cosidered

      NeIEntity ent = (NeIEntity) iter.next();

      String priority =  ent.getValueAsString(DataHandler.PRIORITY);

      int rot = e.getWheelRotation();

      

      if (rot == 1)

         {

        // Priority is increased

         if (priority.equals ("Normal"))

            priority = "High";

         else if (priority.equals ("High"))

            priority = "Highest";

         else

            priority = "Normal";

         }

      else

         {

        // Priority is decreased

         if (priority.equals ("Normal"))

            priority = "Highest";

         else if (priority.equals ("High"))

            priority = "Normal";

         else

            priority = "High";

         }

     

      ent.setValue(DataHandler.PRIORITY, priority);

      }

   }  

 

User-Friendliness

Form this Java Gantt chart best practice your learned how editing data by mouse wheel offers additional planning support to the user, allowing settings like

VARCHART JGantt mouse wheel interactions

  • Maximum or minimum values
  • Individual increments such as 60 min or 30 min
  • Limited options for the planner, thus forcing faster decisions, like canceling order status, releasing

 

 

Need more Java Gantt chart best practice tips? Here are further Java Gantt Control Best Practices blog posts awaiting you.

Your next step

Why not turning this idea into action? Download your free trial version of VARCHART JGantt and get going today.

 New Call-to-action

 

Topics: Java Gantt Control, Gantt Chart Controls