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

The following examples show how to use java.awt.GradientPaint#isCyclic() . 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: SVGGradientPaint.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public boolean equals(Object object) {
	if (object == null) return false;
	if ( object instanceof GradientPaint )
	{
		GradientPaint gp = (GradientPaint) object;
		return ( gp.getColor1( ).equals( getColor1( ) )
				&& gp.getColor2( ).equals( getColor2( ) )
				&& ( gp.isCyclic( ) == gp.isCyclic( ) )
				&& gp.getPoint1( ).equals( getPoint1( ) ) && gp.getPoint2( )
				.equals( getPoint2( ) ) );
	}
	else
	{
		return false;
	}

}
 
Example 2
Source File: PaintUtilities.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the two <code>Paint</code> objects are equal 
 * OR both <code>null</code>.  This method handles
 * <code>GradientPaint</code> as a special case.
 *
 * @param p1  paint 1 (<code>null</code> permitted).
 * @param p2  paint 2 (<code>null</code> permitted).
 *
 * @return A boolean.
 */
public static boolean equal(final Paint p1, final Paint p2) {

    // handle cases where either or both arguments are null
    if (p1 == null) {
        return (p2 == null);   
    }
    if (p2 == null) {
        return false;   
    }
    
    boolean result = false;
    // handle GradientPaint as a special case...
    if (p1 instanceof GradientPaint && p2 instanceof GradientPaint) {
        final GradientPaint gp1 = (GradientPaint) p1;
        final GradientPaint gp2 = (GradientPaint) p2;
        result = gp1.getColor1().equals(gp2.getColor1()) 
            && gp1.getColor2().equals(gp2.getColor2())
            && gp1.getPoint1().equals(gp2.getPoint1())    
            && gp1.getPoint2().equals(gp2.getPoint2())
            && gp1.isCyclic() == gp2.isCyclic()
            && gp1.getTransparency() == gp1.getTransparency(); 
    }
    else {
        result = p1.equals(p2);
    }
    return result;

}
 
Example 3
Source File: PaintUtilities.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the two <code>Paint</code> objects are equal
 * OR both <code>null</code>.  This method handles
 * <code>GradientPaint</code> as a special case.
 *
 * @param p1  paint 1 (<code>null</code> permitted).
 * @param p2  paint 2 (<code>null</code> permitted).
 *
 * @return A boolean.
 */
public static boolean equal(Paint p1, Paint p2) {

    // handle cases where either or both arguments are null
    if (p1 == null) {
        return (p2 == null);
    }
    if (p2 == null) {
        return false;
    }

    boolean result = false;
    // handle GradientPaint as a special case...
    if (p1 instanceof GradientPaint && p2 instanceof GradientPaint) {
        GradientPaint gp1 = (GradientPaint) p1;
        GradientPaint gp2 = (GradientPaint) p2;
        result = gp1.getColor1().equals(gp2.getColor1())
            && gp1.getColor2().equals(gp2.getColor2())
            && gp1.getPoint1().equals(gp2.getPoint1())
            && gp1.getPoint2().equals(gp2.getPoint2())
            && gp1.isCyclic() == gp2.isCyclic()
            && gp1.getTransparency() == gp1.getTransparency();
    }
    else {
        result = p1.equals(p2);
    }
    return result;

}
 
Example 4
Source File: PaintUtilities.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the two <code>Paint</code> objects are equal 
 * OR both <code>null</code>.  This method handles
 * <code>GradientPaint</code> as a special case.
 *
 * @param p1  paint 1 (<code>null</code> permitted).
 * @param p2  paint 2 (<code>null</code> permitted).
 *
 * @return A boolean.
 */
public static boolean equal(Paint p1, Paint p2) {

    // handle cases where either or both arguments are null
    if (p1 == null) {
        return (p2 == null);   
    }
    if (p2 == null) {
        return false;   
    }
    
    boolean result = false;
    // handle GradientPaint as a special case...
    if (p1 instanceof GradientPaint && p2 instanceof GradientPaint) {
        GradientPaint gp1 = (GradientPaint) p1;
        GradientPaint gp2 = (GradientPaint) p2;
        result = gp1.getColor1().equals(gp2.getColor1()) 
            && gp1.getColor2().equals(gp2.getColor2())
            && gp1.getPoint1().equals(gp2.getPoint1())    
            && gp1.getPoint2().equals(gp2.getPoint2())
            && gp1.isCyclic() == gp2.isCyclic()
            && gp1.getTransparency() == gp1.getTransparency(); 
    }
    else {
        result = p1.equals(p2);
    }
    return result;

}
 
Example 5
Source File: GradientPaintKey.java    From jfreesvg with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks this instance for equality with an arbitrary object.
 * 
 * @param obj  the object to test against ({@code null} permitted).
 * 
 * @return A boolean. 
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof GradientPaintKey)) {
        return false;
    }
    GradientPaintKey that = (GradientPaintKey) obj;
    GradientPaint thisGP = this.paint;
    GradientPaint thatGP = that.getPaint();
    if (!thisGP.getColor1().equals(thatGP.getColor1())) {
        return false;
    }
    if (!thisGP.getColor2().equals(thatGP.getColor2())) {
        return false;
    }
    if (!thisGP.getPoint1().equals(thatGP.getPoint1())) {
        return false;
    }
    if (!thisGP.getPoint2().equals(thatGP.getPoint2())) {
        return false;
    }
    if (thisGP.getTransparency() != thatGP.getTransparency()) {
        return false;
    }
    if (thisGP.isCyclic() != thatGP.isCyclic()) {
        return false;
    }
    return true;
}
 
Example 6
Source File: ObjectUtils.java    From orson-charts with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns {@code true} if the two {@code Paint} objects are equal 
 * OR both {@code null}.  This method handles
 * {@code GradientPaint}, {@code LinearGradientPaint} and 
 * {@code RadialGradientPaint} as a special cases, since those classes do
 * not override the {@code equals()} method.
 *
 * @param p1  paint 1 ({@code null} permitted).
 * @param p2  paint 2 ({@code null} permitted).
 *
 * @return A boolean.
 */
public static boolean equalsPaint(Paint p1, Paint p2) {
    if (p1 == p2) {
        return true;
    }
        
    // handle cases where either or both arguments are null
    if (p1 == null) {
        return (p2 == null);   
    }
    if (p2 == null) {
        return false;   
    }

    // handle GradientPaint as a special case...
    if (p1 instanceof GradientPaint && p2 instanceof GradientPaint) {
        GradientPaint gp1 = (GradientPaint) p1;
        GradientPaint gp2 = (GradientPaint) p2;
        return gp1.getColor1().equals(gp2.getColor1()) 
                && gp1.getColor2().equals(gp2.getColor2())
                && gp1.getPoint1().equals(gp2.getPoint1())    
                && gp1.getPoint2().equals(gp2.getPoint2())
                && gp1.isCyclic() == gp2.isCyclic()
                && gp1.getTransparency() == gp1.getTransparency(); 
    } else if (p1 instanceof LinearGradientPaint 
            && p2 instanceof LinearGradientPaint) {
        LinearGradientPaint lgp1 = (LinearGradientPaint) p1;
        LinearGradientPaint lgp2 = (LinearGradientPaint) p2;
        return lgp1.getStartPoint().equals(lgp2.getStartPoint())
                && lgp1.getEndPoint().equals(lgp2.getEndPoint()) 
                && Arrays.equals(lgp1.getFractions(), lgp2.getFractions())
                && Arrays.equals(lgp1.getColors(), lgp2.getColors())
                && lgp1.getCycleMethod() == lgp2.getCycleMethod()
                && lgp1.getColorSpace() == lgp2.getColorSpace()
                && lgp1.getTransform().equals(lgp2.getTransform());
    } else if (p1 instanceof RadialGradientPaint 
            && p2 instanceof RadialGradientPaint) {
        RadialGradientPaint rgp1 = (RadialGradientPaint) p1;
        RadialGradientPaint rgp2 = (RadialGradientPaint) p2;
        return rgp1.getCenterPoint().equals(rgp2.getCenterPoint())
                && rgp1.getRadius() == rgp2.getRadius() 
                && rgp1.getFocusPoint().equals(rgp2.getFocusPoint())
                && Arrays.equals(rgp1.getFractions(), rgp2.getFractions())
                && Arrays.equals(rgp1.getColors(), rgp2.getColors())
                && rgp1.getCycleMethod() == rgp2.getCycleMethod()
                && rgp1.getColorSpace() == rgp2.getColorSpace()
                && rgp1.getTransform().equals(rgp2.getTransform());
    } else {
        return p1.equals(p2);
    }
}
 
Example 7
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 8
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 9
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 10
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 11
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 12
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 13
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;
}