Customizing the movements of activities in my Gantt Chart

Article ID: 2310
Last updated: 30 May, 2018
Article ID: 2310
Last updated: 30 May, 2018
Revision: 3
Views: 453
Posted: 30 Jul, 2010
by Dean J.
Updated: 30 May, 2018
by Gargani A.

Question

How can I customize the movements of activities in my Gantt Chart?

Answer

Depending on what you want to do, you can subclass IlvActivityGraphicMoveInteractor and override processMouseEvent() or processMouseMotionEvent() to perform additional tasks.

To have your new class taken into account, you must also subclass IlvGanttSelectInteractor and override getMoveSelectionInteractor() so that it returns an instance of your interactor.

Note that since JViews Gantt 7.5, IlvGanttSelectInteractor and IlvActivityGraphicMoveInteractor provide an API that allows users to restrict activity movement horizontally or vertically.

For example, assume you want to disable the vertical movement of an activity, you would have something like:

class MyActivityGraphicMoveInteractor

extends IlvActivityGraphicMoveInteractor

{

public

MyActivityGraphicMoveInteractor(IlvGanttSelectInteractor inter)

{

super(inter);

}

protected void

processMouseEvent(MouseEvent evt)

{

if

(evt.getID() == MouseEvent.MOUSE_PRESSED)

oldyPos = (int)evt.getPoint().getY();

super.processMouseEvent(evt);

}

protected void processMouseMotionEvent(MouseEvent

event)

{

if (event.getID() ==

MouseEvent.MOUSE_DRAGGED)

{

int

dy=(int)event.getPoint().getY() - oldyPos;

event.translatePoint(0,

-dy);

}

super.processMouseMotionEvent(event);

}

}

class

MyGanttSelectInteractor extends IlvGanttSelectInteractor

{

protected IlvManagerViewInteractor

getMoveSelectionInteractor()

{

IlvManagerViewInteractor interactor =

super.getMoveSelectionInteractor();

// returns our move select interactor to

restrict the move possibilities

if (interactor instanceof

IlvActivityGraphicMoveInteractor)

return new

MyActivityGraphicMoveInteractor(new

MyGanttSelectInteractor());

return interactor;

}

}

You can download this sample that illustrating this mechanism: sample_activities_movements.zip

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2310
Last updated: 30 May, 2018
Revision: 3
Views: 453
Posted: 30 Jul, 2010 by Dean J.
Updated: 30 May, 2018 by Gargani A.
Also listed in


Others in this category