Home Forums FlexGantt Custom behavior for ActivityObjects

  • Author
    Posts
  • Brian
    Post count: 0
    #12723 |

    I am using a DefaultActivityObject to display schedule entries on a Gantt Chart. I have found the percentage complete features to control some rendering/color of the schedule entries and I have found the feature to grey out entried in the past, which is all good. But, we want to go another step farther and change the color of the line based on an schedule entry being in process or being late. We would also like to indicate if the user has moved an item to a place in the timeline that violates a business rule. I see that I can set a status on the DefaultActivityObject, but I don’t see a way to have that impact the rendering, unless I write my own custom render. I think the behavior we are after is similar to the overview/radar chart.
    Will you verify my understanding and provide any guidance on how to accomplish this task?
    Thanks.

  • Dirk Lemmermann
    Keymaster
    Post count: 60
    #12726 |

    To change the color of a timeline object based on the status of your schedule entries you have to create a subclass of DefaultActivityObjectRenderer and override the getTimelineObjectRendererComponent() method. Inside of this method you have access to your schedule entry and you can check its status. Then you can call the various setXXXColor methods of the renderer.

    Dirk

    • Brian
      Post count: 0
      #12743 |

      I’ve extended GanttChart to contain our configuration/customization to the OOTB GanttChart class. In the construction of that, I have this line:
      this.getLayerContainer().setTimelineObjectRenderer(DefaultActivityObject.class, new CustomActivityRenderer());
      I see that this is getting called, since I have some logging in that constructor. But, of course, the construction is not really the critical method call.
      In that custom renderer, I override the getTimelineObjectRendererComponent like this:
      public Component getTimelineObjectRendererComponent(TimelineObjectLayer layer, TimelineObjectPath path, boolean selected, boolean focused, boolean highlighted, int row) {

      I have added lines onto the gantt chart like this:
      DefaultTimelineObject tlo = new DefaultTimelineObject<>(“Root TLO”, new TimeSpan(start, end));

      I was expecting to see a call the getTimelineObjectRendererComponent() call to indicate that I was plugged in correctly, but am not seeing that. Would you give me a bit more guidance on what I should be doing.

    • Brian
      Post count: 0
      #12744 |

      I think you can ignore this question. I believe all the above is correct, but I was creating & adding DefaultTimelineObject object to the gantt chart, rather than DefaultActivityObjects. It was a cut/paste error across a few versions of some test code I had around.

You must be logged in to reply to this topic.