/******************************************************************************* * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.graphics; import org.eclipse.swt.*; public class Pattern extends Resource { Image image; float x1, y1, x2, y2; int alpha1, alpha2; Color color1, color2; public Pattern (Device device, Image image) { super(device); if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); this.image = image; } public Pattern (Device device, float x1, float y1, float x2, float y2, Color color1, Color color2) { this(device, x1, y1, x2, y2, color1, 0xFF, color2, 0xFF); } public Pattern (Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) { super(device); if (color1 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (color1.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); if (color2 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (color2.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; this.alpha1 = alpha1; this.color1 = color1; this.alpha2 = alpha2; this.color2 = color2; } void destroy () { image = null; } public boolean isDisposed () { return device == null; } public String toString () { if (isDisposed()) return "Pattern {*DISPOSED*}"; return "Pattern {" + "}"; } }