Java Gantt Control: The magnifying glass trick

Posted by Bernd-Rainer Lauber on Jul 21, 2014 4:02:00 PM

Controlling long-term projects is a callenge for planners. On the one hand, they want to see the big picture and on the other hand they need to understand all details of the short-term schedule to better manage and steer the operations. In such a scenario, Gantt chart users benefit from a visualization that combines the three time spans past-present-future in one overview. In some cases it can be even more helpful to visualize a time span around the current date in more details than future or past ones. Read in this post blog how to develop such a kind of magnifying glass with a Java Gantt Control.  

The key to the magnifying glass is the time scale. In our Java Gantt control VARCHART JGantt the function time scale is very powerful and it allows you to partition the time scale into several sections. There are only two steps to be done:

  • Define three sections with two resolutions: a section representing the time span around time-now with a higher resolution and the other two sections with lower time resolution.
  • Visually highlight the "time now zone" by adding an optical veil over the past and the future.




The below code fragment sketches one possible approach. Further information including the complete code can be found in the sample EnhancedTimeScale of the sample collection which you get when you download a VARCHART JGantt trial version.

else if (noOfSections==3)

  double absRelFactor = 1.;

  if (stepRule.equals("10Y"))
      absRelFactor = 70.;
  else if (stepRule.equals("5Y"))
      absRelFactor = 40.;
  else if (stepRule.equals("Y"))
      absRelFactor = 40.;
  else if (stepRule.equals("6M"))
      absRelFactor = 30.;
  else if (stepRule.equals("3M"))
      absRelFactor = 30.;
  else if (stepRule.equals("M"))
      absRelFactor = 6.;
  else if (stepRule.equals("W"))
      absRelFactor = 6.;
  else if (stepRule.equals("D") || stepRule.equals("12H") || stepRule.equals("6H") 
           || stepRule.equals("3H"))
      absRelFactor = 9.;
    stepRule = myJGTimeScale.getDefaultSection().getVisibleRibbonStripe().
     absRelFactor = 9.;

  long firstSectionStart = JGTimeScaleHelper.roundTime(System.currentTimeMillis(), 
                           stepRule, true);
  long secondSectionStart = JGTimeScaleHelper.roundTime(System.currentTimeMillis(), 
                           stepRule, false);

  JGTimeScaleSection newSection1 = new JGTimeScaleSection 
  myJGTimeScale.addSection(firstSectionStart, newSection1);

  JGTimeScaleSection newSection2 = new JGTimeScaleSection 
  myJGTimeScale.addSection(secondSectionStart, newSection2);
  myEnhancedTimeScale.myTabbedPaneHandler.mySections = myJGTimeScale.getSections();


Interested in learning more about important Java Gantt control features for complex scheduling applications? You are very welcome to download our free Gantt best practice Ebook.


Ebook- 9 Key Features of a Industry-Proof Java Gantt Control


Topics: Java Gantt Control, JGantt development tricks, Gantt Best Practice, Gantt Chart Controls