Java Code Examples for java.awt.GradientPaint#getPoint1()

The following examples show how to use java.awt.GradientPaint#getPoint1() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GradientPaintSerializationWrapper.java    From pumpernickel with MIT License 5 votes vote down vote up
public GradientPaintSerializationWrapper(GradientPaint gp) {
	Point2D p1 = gp.getPoint1();
	Point2D p2 = gp.getPoint2();

	map.put(KEY_X1, p1.getX());
	map.put(KEY_Y1, p1.getY());
	map.put(KEY_X2, p2.getX());
	map.put(KEY_Y2, p2.getY());

	map.put(KEY_COLOR1, gp.getColor1());
	map.put(KEY_COLOR2, gp.getColor2());
	map.put(KEY_CYCLIC, gp.isCyclic());
}
 
Example 2
Source File: GradientPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * Create a GradientPanelUI from a GradientPaint.
 * 
 * @param gradientPaint
 *            if this is not a horizontal or vertical gradient then an
 *            IllegalArgumentException is thrown. The exact endpoints of
 *            this argument are disregarded, because this GradientPanelUI
 *            always paints gradients from one end to the other.
 */
public GradientPanelUI(GradientPaint gradientPaint) {
	this(Color.white);

	Point2D p1 = gradientPaint.getPoint1();
	Point2D p2 = gradientPaint.getPoint2();
	boolean forward;
	if (p1.getX() == p2.getX()) {
		setGradientOrientation(SwingConstants.VERTICAL);
		forward = p2.getY() > p1.getY();
	} else if (p1.getY() == p2.getY()) {
		setGradientOrientation(SwingConstants.HORIZONTAL);
		forward = p2.getX() > p1.getX();
	} else {
		throw new IllegalArgumentException(
				"The gradient provided must be either a horizontal or vertical gradient. "
						+ gradientPaint);
	}

	if (forward) {
		setFillColor1(gradientPaint.getColor1());
		setFillColor2(gradientPaint.getColor2());
	} else {
		setFillColor1(gradientPaint.getColor2());
		setFillColor2(gradientPaint.getColor1());
	}
}
 
Example 3
Source File: PaintAlpha.java    From openstock with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Create a new <code>GradientPaint</code> with its colors darkened.
 *
 * @param paint  the gradient paint (<code>null</code> not permitted).
 *
 * @return a darker version of the <code>GradientPaint</code>
 */
private static GradientPaint darker(GradientPaint paint) {
    return new GradientPaint(
            paint.getPoint1(), darker(paint.getColor1()),
            paint.getPoint2(), darker(paint.getColor2()),
            paint.isCyclic());
}
 
Example 4
Source File: PaintAlpha.java    From ccu-historian with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Create a new <code>GradientPaint</code> with its colors darkened.
 *
 * @param paint  the gradient paint (<code>null</code> not permitted).
 *
 * @return a darker version of the <code>GradientPaint</code>
 */
private static GradientPaint darker(GradientPaint paint) {
    return new GradientPaint(
            paint.getPoint1(), darker(paint.getColor1()),
            paint.getPoint2(), darker(paint.getColor2()),
            paint.isCyclic());
}
 
Example 5
Source File: PaintAlpha.java    From SIMVA-SoS with Apache License 2.0 3 votes vote down vote up
/**
 * Create a new <code>GradientPaint</code> with its colors darkened.
 *
 * @param paint  the gradient paint (<code>null</code> not permitted).
 *
 * @return a darker version of the <code>GradientPaint</code>
 */
private static GradientPaint darker(GradientPaint paint) {
    return new GradientPaint(
            paint.getPoint1(), darker(paint.getColor1()),
            paint.getPoint2(), darker(paint.getColor2()),
            paint.isCyclic());
}
 
Example 6
Source File: PaintAlpha.java    From ECG-Viewer with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a new <code>GradientPaint</code> with its colors darkened.
 *
 * @param paint  the gradient paint (<code>null</code> not permitted).
 *
 * @return a darker version of the <code>GradientPaint</code>
 */
private static GradientPaint darker(GradientPaint paint) {
    return new GradientPaint(
            paint.getPoint1(), darker(paint.getColor1()),
            paint.getPoint2(), darker(paint.getColor2()),
            paint.isCyclic());
}
 
Example 7
Source File: PaintAlpha.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Create a new <code>GradientPaint</code> with its colors darkened.
 *
 * @param paint  the gradient paint (<code>null</code> not permitted).
 *
 * @return a darker version of the <code>GradientPaint</code>
 */
private static GradientPaint darker(GradientPaint paint) {
    return new GradientPaint(
            paint.getPoint1(), darker(paint.getColor1()),
            paint.getPoint2(), darker(paint.getColor2()),
            paint.isCyclic());
}
 
Example 8
Source File: PaintAlpha.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Create a new <code>GradientPaint</code> with its colors darkened.
 *
 * @param paint  the gradient paint (<code>null</code> not permitted).
 *
 * @return a darker version of the <code>GradientPaint</code>
 */
private static GradientPaint darker(GradientPaint paint) {
    return new GradientPaint(
            paint.getPoint1(), darker(paint.getColor1()),
            paint.getPoint2(), darker(paint.getColor2()),
            paint.isCyclic());
}
 
Example 9
Source File: SVGGradientPaint.java    From birt with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * @param arg0
 * @param arg1
 * @param arg2
 * @param arg3
 * @param arg4
 * @param arg5
 * @param gradientPaint
 */
public SVGGradientPaint(GradientPaint gradientPaint) {
	super(gradientPaint.getPoint1(), gradientPaint.getColor1(), gradientPaint.getPoint2(), gradientPaint.getColor2(), gradientPaint.isCyclic());
	this.gradientPaint = gradientPaint;
}