private final Cursor fZoomCursor = Display.getDefault().getSystemCursor(SWT.CURSOR_SIZEWE);
private final List<ViewerFilter> fFilters = new ArrayList<>();
private MenuDetectEvent fPendingMenuDetectEvent = null;
+ private boolean fGridLinesVisible = true;
+ private Color fGridLineColor = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
private boolean fHideArrows = false;
private int fAutoExpandLevel = ALL_LEVELS;
fTimeProvider.setStartFinishTimeNotify(time0, time1);
}
+ /**
+ * Set the grid lines visibility. The default is true.
+ *
+ * @param visible
+ * true to show the grid lines, false otherwise
+ * @since 2.0
+ */
+ public void setGridLinesVisible(boolean visible) {
+ fGridLinesVisible = visible;
+ }
+
+ /**
+ * Get the grid lines visibility.
+ *
+ * @return true if the grid lines are visible, false otherwise
+ * @since 2.0
+ */
+ public boolean getGridLinesVisible() {
+ return fGridLinesVisible;
+ }
+
+ /**
+ * Set the grid line color. The default is SWT.COLOR_GRAY.
+ *
+ * @param color
+ * the grid line color
+ * @since 2.0
+ */
+ public void setGridLineColor(Color color) {
+ fGridLineColor = color;
+ }
+
+ /**
+ * Get the grid line color.
+ *
+ * @return the grid line color
+ * @since 2.0
+ */
+ public Color getGridLineColor() {
+ return fGridLineColor;
+ }
+
/**
* Hide arrows
*
drawBackground(bounds, nameSpace, gc);
+ // draw the grid lines
+ drawGridLines(bounds, gc);
+
// draw items
drawItems(bounds, fTimeProvider, fItemData.fExpandedItems, fTopIndex, nameSpace, gc);
drawLinks(bounds, fTimeProvider, fItemData.fLinks, nameSpace, gc);
}
}
+ /**
+ * Draw the grid lines
+ *
+ * @param bounds
+ * The rectangle of the area
+ * @param gc
+ * Reference to the SWT GC object
+ * @since 2.0
+ */
+ public void drawGridLines(Rectangle bounds, GC gc) {
+ if (!fGridLinesVisible) {
+ return;
+ }
+ gc.setForeground(fGridLineColor);
+ for (int x : fTimeGraphScale.getTickList()) {
+ gc.drawLine(x, bounds.y, x, bounds.y + bounds.height);
+ }
+ }
+
/**
* Draw many items at once
*
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
private long fTime1bak;
private boolean fIsInUpdate;
private int fHeight;
+ private List<Integer> fTickList = new ArrayList<>();
/**
* Standard constructor
redraw();
}
+ /**
+ * Get the list of visible ticks of the time axis.
+ *
+ * @return the list of visible tick x-coordinates
+ * @since 2.0
+ */
+ public List<Integer> getTickList() {
+ return fTickList;
+ }
+
private long calcTimeDelta(int width, double pixelsPerNanoSec) {
long timeDelta;
double minDelta = (pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec;
gc.fillRectangle(rect0);
if (time1 <= time0 || timeSpace < 2) {
+ fTickList.clear();
return;
}
timeDraw.drawAbsHeader(gc, time, absHeaderRect);
}
+ List<Integer> tickList = new ArrayList<>();
while (true) {
int x = rect.x + leftSpace + (int) (Math.floor((time - time0) * pixelsPerNanoSec));
if (x >= rect.x + leftSpace + rect.width - rect0.width) {
if (x + rect0.width <= rect.x + rect.width) {
timeDraw.draw(gc, time, rect0);
}
+ tickList.add(x);
}
if (pixelsPerNanoSec == 0 || time > Long.MAX_VALUE - timeDelta || timeDelta == 0) {
break;
time += timeDelta;
}
}
+ fTickList = tickList;
}
private static void drawRangeDecorators(Rectangle rect, GC gc, int x1, int x2) {