Transform transform = new Transform(device);
transform.translate(0, translateY);
gc.setTransform(transform);
transform.dispose();
Path path = new Path(device);
path.addRectangle(0, 0, width, 50);
Pattern pattern = new Pattern(device, 0, 0, width, 50, device.getSystemColor(SWT.COLOR_BLUE), 0x7f, device
.getSystemColor(SWT.COLOR_RED), 0x7f);
gc.setBackgroundPattern(pattern);
gc.fillPath(path);
gc.drawPath(path);
path.dispose();
// vertical rectangle
transform = new Transform(device);
transform.translate(translateX, 0);
gc.setTransform(transform);
transform.dispose();
path = new Path(device);
path.addRectangle(0, 0, 50, height);
pattern.dispose();
pattern = new Pattern(device, 0, 0, 50, height, device.getSystemColor(SWT.COLOR_DARK_CYAN), 0x7f, device
.getSystemColor(SWT.COLOR_WHITE), 0x7f);
gc.setBackgroundPattern(pattern);
gc.fillPath(path);
gc.drawPath(path);
path.dispose();
// diagonal rectangle from bottom right corner
Rectangle rect = new Rectangle(0, 0, 50, height);
transform = new Transform(device);
transform.translate(width - diagTranslateX1, height / 2 - diagTranslateY1);
// rotate on center of rectangle
transform.translate(rect.width / 2, rect.height / 2);
transform.rotate(45);
transform.translate(-rect.width / 2, -rect.height / 2);
gc.setTransform(transform);
transform.dispose();
path = new Path(device);
path.addRectangle(rect.x, rect.y, rect.width, rect.height);
pattern.dispose();
pattern = new Pattern(device, rect.x, rect.y, rect.width, rect.height, device
.getSystemColor(SWT.COLOR_DARK_GREEN), 0x7f, device.getSystemColor(SWT.COLOR_DARK_MAGENTA), 0x7f);
gc.setBackgroundPattern(pattern);
gc.fillPath(path);
gc.drawPath(path);
path.dispose();
// diagonal rectangle from top right corner
transform = new Transform(device);
transform.translate(width - diagTranslateX2, height / 2 - diagTranslateY2);
// rotate on center of rectangle
transform.translate(rect.width / 2, rect.height / 2);
transform.rotate(-45);
transform.translate(-rect.width / 2, -rect.height / 2);
gc.setTransform(transform);
transform.dispose();
path = new Path(device);
path.addRectangle(rect.x, rect.y, rect.width, rect.height);
pattern.dispose();
pattern = new Pattern(device, rect.x, rect.y, rect.width, rect.height, device
.getSystemColor(SWT.COLOR_DARK_RED), 0x7f, device.getSystemColor(SWT.COLOR_YELLOW), 0x7f);
gc.setBackgroundPattern(pattern);
gc.fillPath(path);
gc.drawPath(path);
pattern.dispose();
path.dispose();
}