Search in sources :

Example 1 with FreeformFigure

use of org.eclipse.draw2d.FreeformFigure in project tdi-studio-se by Talend.

the class TalendGridLayer method paintGrid.

protected void paintGrid(Graphics g, IFigure f, org.eclipse.draw2d.geometry.Point origin, int distanceX, int distanceY) {
    FreeformFigure ff = (FreeformFigure) this.getParent();
    Rectangle clientArea = getClientArea();
    Rectangle bounds = ff.getFreeformExtent().getCopy();
    bounds.union(clientArea.x, clientArea.y, clientArea.width * AnimatableZoomManager.currentZoom, clientArea.height * AnimatableZoomManager.currentZoom);
    ff.setFreeformBounds(bounds);
    Rectangle original = g.getClip(Rectangle.SINGLETON);
    Rectangle clip = new Rectangle(original.x - original.x % distanceX, original.y - original.y % distanceY, original.width + Math.abs(original.x % distanceX), original.height + Math.abs(original.y % distanceY));
    if (distanceX > 0 && distanceY > 0) {
        if (origin.x >= clip.x) {
            while (origin.x - distanceX >= clip.x) {
                origin.x -= distanceX;
            }
        } else {
            while (origin.x < clip.x) {
                origin.x += distanceX;
            }
        }
        if (origin.y >= clip.y) {
            while (origin.y - distanceY >= clip.y) {
                origin.y -= distanceY;
            }
        } else {
            while (origin.y < clip.y) {
                origin.y += distanceY;
            }
        }
        for (int i = origin.x; i < clip.x + clip.width; i += distanceX) {
            for (int j = origin.y; j < clip.y + clip.height; j += distanceY) {
                // g.drawPoint(i, j);
                int re = Math.abs(i - j);
                if (re / distanceY % 2 == 0) {
                    g.drawImage(ImageProvider.getImage(EImage.CHESS_GRAY), i, j);
                }
            }
        }
    }
}
Also used : FreeformFigure(org.eclipse.draw2d.FreeformFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Aggregations

FreeformFigure (org.eclipse.draw2d.FreeformFigure)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1