public interface IlvActivityLayout
IlvActivityLayout
defines a strategy for how activity
graphics are arranged within an IlvGanttRow
. An
IlvActivityLayout
object is used by an IlvGanttRow
to compute the positions and z-order of its activity graphics. When you add
an activity graphic object to a Gantt row, the activity layout is used
to determine the position of the new inserted activity graphic. When you
change the time interval of an activity, the activity layout is also used to
readjust the position of the associated activity graphic.Modifier and Type | Method and Description |
---|---|
void |
arrange(IlvGanttRow row,
IlvActivityGraphic graphic)
This method is called to layout the position of a single activity graphic within a
row.
|
void |
arrange(IlvGanttRow row,
IlvActivityGraphic[] graphics)
This method is called to layout the position of all the activity graphics within a
row.
|
void arrange(IlvGanttRow row, IlvActivityGraphic graphic)
This method is called to layout the position of a single activity graphic within a row. Typically, this occurs when an activity has been newly inserted into or assigned to an already existing row. At a minimum, this method must set the definition rectangle of the activity graphic. Here is an example of how the activity layout should set the definition rectangle of the graphic:
public void arrange(IlvGanttRow row, IlvActivityGraphic graphic) { IlvTimeConverter converter = row.getTimeConverter(); if (converter == null) { return; } IlvActivity activity = graphic.getActivity(); double start = converter.getUnits(activity.getStartTime()); double end = converter.getUnits(activity.getEndTime()); IlvRect defRect = new IlvRect(start, row.getTop(), end-start, row.getHeight()); graphic.setDefinitionRect(defRect); }
If the layout strategy also controls the z-order of the activity graphics, it is
best to implement the draw ordering in the arrange(IlvGanttRow,
IlvActivityGraphic[])
method. Then implement this method to delegate like this:
public void arrange(IlvGanttRow row, IlvActivityGraphic graphic) { // Relayout the entire row so that z-ordering is respected between all graphics. arrange(row, row.getActivityGraphics()); }
row
- The Gantt row that contains the graphic.graphic
- The activity graphic to be arranged.void arrange(IlvGanttRow row, IlvActivityGraphic[] graphics)
This method is called to layout the position of all the activity graphics within a row. This method should set the definition rectangle of each activity graphic and can optionally rearrange their drawing order.
The ordering of the graphics in the array indicates the z-order in which the activity graphics currently draw. Graphics at a higher index in the array are drawn after graphics at a lower index. This method can reorder the graphics within the provided array to change their z-order.
Here is an example of how the activity layout should set the definition rectangle of each graphic and can set the graphics z-order to correspond to the relative start times of the activities:
public void arrange(IlvGanttRow row, IlvActivityGraphic[] graphics) { IlvTimeConverter converter = row.getTimeConverter(); if (converter == null) return; // Set the definition rectangle of each activity graphic in the row. for (int i = 0; i < graphics.length; i++) { IlvActivityGraphic graphic = graphics[i]; IlvActivity activity = graphic.getActivity(); double start = converter.getUnits(activity.getStartTime()); double end = converter.getUnits(activity.getEndTime()); IlvRect defRect = new IlvRect(start, row.getTop(), end-start, row.getHeight()); graphic.setDefinitionRect(defRect); } // Set the graphics z-order to match that of the activity start times. Arrays.sort(graphics, new Comparator<IlvActivityGraphic>() { public int compare(IlvActivityGraphic o1, IlvActivityGraphic o2) { Date start1 = o1.getActivity().getStartTime(); Date start2 = o2.getActivity().getStartTime(); return start1.compareTo(start2); } }); }
row
- The Gantt row that contains the graphics.graphics
- The array of activity graphics in the row. The ordering of the
graphics in the array indicates the z-order in which the activity
graphics draw. Graphics at a higher index in the array are drawn
after graphics at a lower index. This method can rearrange the
graphics within the array to change their drawing order.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.