All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jdesktop.swingx.icon.TrafficLightRedIcon Maven / Gradle / Ivy

The newest version!
package org.jdesktop.swingx.icon;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Composite;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LinearGradientPaint;
import java.awt.MultipleGradientPaint;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.util.Stack;

import javax.swing.plaf.UIResource;

/**
 * This class has been automatically generated using 
 * Radiance SVG converter.
 */
public class TrafficLightRedIcon implements RadianceIcon {
    private Shape shape = null;
    private GeneralPath generalPath = null;
    private Paint paint = null;
    private Stroke stroke = null;
    private RadianceIcon.ColorFilter colorFilter = null;
    private Stack transformsStack = new Stack<>();

	// EUG https://github.com/homebeaver (rotation + point/axis reflection)
    private int rsfx = 1, rsfy = 1;
    public void setReflection(boolean horizontal, boolean vertical) {
    	this.rsfx = vertical ? -1 : 1;
    	this.rsfy = horizontal ? -1 : 1;
    }    
    public boolean isReflection() {
		return rsfx==-1 || rsfy==-1;
	}
	
    private double theta = 0;
    public void setRotation(double theta) {
    	this.theta = theta;
    }    
    public double getRotation() {
		return theta;
	}
	// EUG -- END

    

	private void _paint0(Graphics2D g,float origAlpha) {
transformsStack.push(g.getTransform());
// 
g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha));
transformsStack.push(g.getTransform());
g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f));
// _0
g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha));
transformsStack.push(g.getTransform());
g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, -261.6295166015625f, -313.940673828125f));
// _0_0
g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha));
transformsStack.push(g.getTransform());
g.transform(new AffineTransform(1.1734694242477417f, 0.0f, 0.0f, 1.1734694242477417f, -65.53622436523438f, -74.61061096191406f));
// _0_0_0
if (generalPath == null) {
   generalPath = new GeneralPath();
} else {
   generalPath.reset();
}
generalPath.moveTo(476.79202f, 430.10822f);
generalPath.curveTo(476.95065f, 465.58118f, 458.1171f, 498.4276f, 427.4228f, 516.21f);
generalPath.curveTo(396.7285f, 533.9925f, 358.86566f, 533.9925f, 328.17136f, 516.21f);
generalPath.curveTo(297.47705f, 498.4276f, 278.6435f, 465.58118f, 278.80212f, 430.10822f);
generalPath.curveTo(278.6435f, 394.63525f, 297.47705f, 361.78882f, 328.17136f, 344.00638f);
generalPath.curveTo(358.86566f, 326.22394f, 396.7285f, 326.22394f, 427.4228f, 344.00638f);
generalPath.curveTo(458.1171f, 361.78882f, 476.95065f, 394.63525f, 476.79202f, 430.10822f);
generalPath.closePath();
shape = generalPath;
paint = new LinearGradientPaint(new Point2D.Double(438.05487060546875, 506.7217102050781), new Point2D.Double(314.9568176269531, 356.07720947265625), new float[] {0.0f,1.0f}, new Color[] {((colorFilter != null) ? colorFilter.filter(new Color(16, 16, 16, 255)) : new Color(16, 16, 16, 255)),((colorFilter != null) ? colorFilter.filter(new Color(64, 64, 64, 255)) : new Color(64, 64, 64, 255))}, MultipleGradientPaint.CycleMethod.NO_CYCLE, MultipleGradientPaint.ColorSpaceType.SRGB, new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f));
g.setPaint(paint);
g.fill(shape);
g.setTransform(transformsStack.pop());
g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha));
transformsStack.push(g.getTransform());
g.transform(new AffineTransform(1.0306123495101929f, 0.0f, 0.0f, 1.0306123495101929f, -11.565216064453125f, -13.166579246520996f));
// _0_0_1
if (generalPath == null) {
   generalPath = new GeneralPath();
} else {
   generalPath.reset();
}
generalPath.moveTo(476.79202f, 430.10822f);
generalPath.curveTo(476.95065f, 465.58118f, 458.1171f, 498.4276f, 427.4228f, 516.21f);
generalPath.curveTo(396.7285f, 533.9925f, 358.86566f, 533.9925f, 328.17136f, 516.21f);
generalPath.curveTo(297.47705f, 498.4276f, 278.6435f, 465.58118f, 278.80212f, 430.10822f);
generalPath.curveTo(278.6435f, 394.63525f, 297.47705f, 361.78882f, 328.17136f, 344.00638f);
generalPath.curveTo(358.86566f, 326.22394f, 396.7285f, 326.22394f, 427.4228f, 344.00638f);
generalPath.curveTo(458.1171f, 361.78882f, 476.95065f, 394.63525f, 476.79202f, 430.10822f);
generalPath.closePath();
shape = generalPath;
paint = new LinearGradientPaint(new Point2D.Double(316.4324951171875, 353.9866638183594), new Point2D.Double(437.5220031738281, 508.812255859375), new float[] {0.0f,1.0f}, new Color[] {((colorFilter != null) ? colorFilter.filter(new Color(16, 16, 16, 255)) : new Color(16, 16, 16, 255)),((colorFilter != null) ? colorFilter.filter(new Color(64, 64, 64, 255)) : new Color(64, 64, 64, 255))}, MultipleGradientPaint.CycleMethod.NO_CYCLE, MultipleGradientPaint.ColorSpaceType.SRGB, new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f));
g.setPaint(paint);
g.fill(shape);
g.setTransform(transformsStack.pop());
g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha));
transformsStack.push(g.getTransform());
g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f));
// _0_0_2
if (generalPath == null) {
   generalPath = new GeneralPath();
} else {
   generalPath.reset();
}
generalPath.moveTo(476.79202f, 430.10822f);
generalPath.curveTo(476.95065f, 465.58118f, 458.1171f, 498.4276f, 427.4228f, 516.21f);
generalPath.curveTo(396.7285f, 533.9925f, 358.86566f, 533.9925f, 328.17136f, 516.21f);
generalPath.curveTo(297.47705f, 498.4276f, 278.6435f, 465.58118f, 278.80212f, 430.10822f);
generalPath.curveTo(278.6435f, 394.63525f, 297.47705f, 361.78882f, 328.17136f, 344.00638f);
generalPath.curveTo(358.86566f, 326.22394f, 396.7285f, 326.22394f, 427.4228f, 344.00638f);
generalPath.curveTo(458.1171f, 361.78882f, 476.95065f, 394.63525f, 476.79202f, 430.10822f);
generalPath.closePath();
shape = generalPath;
paint = (colorFilter != null) ? colorFilter.filter(new Color(240, 0, 0, 255)) : new Color(240, 0, 0, 255);
g.setPaint(paint);
g.fill(shape);
g.setTransform(transformsStack.pop());
g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha));
transformsStack.push(g.getTransform());
g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f));
// _0_0_3
if (generalPath == null) {
   generalPath = new GeneralPath();
} else {
   generalPath.reset();
}
generalPath.moveTo(455.07373f, 398.7935f);
generalPath.curveTo(449.2557f, 429.6131f, 413.2274f, 440.72052f, 376.7869f, 445.76556f);
generalPath.curveTo(340.2812f, 450.81964f, 297.92938f, 446.63812f, 289.7151f, 411.1858f);
generalPath.curveTo(281.51862f, 375.8104f, 323.15186f, 331.11328f, 377.79706f, 331.11328f);
generalPath.curveTo(432.44226f, 331.11328f, 460.87363f, 368.06982f, 455.07373f, 398.7935f);
generalPath.closePath();
shape = generalPath;
paint = new LinearGradientPaint(new Point2D.Double(348.5026550292969, 337.67926025390625), new Point2D.Double(372.0980529785156, 443.2402038574219), new float[] {0.0f,1.0f}, new Color[] {((colorFilter != null) ? colorFilter.filter(new Color(255, 255, 255, 255)) : new Color(255, 255, 255, 255)),((colorFilter != null) ? colorFilter.filter(new Color(255, 255, 255, 0)) : new Color(255, 255, 255, 0))}, MultipleGradientPaint.CycleMethod.NO_CYCLE, MultipleGradientPaint.ColorSpaceType.SRGB, new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f));
g.setPaint(paint);
g.fill(shape);
g.setTransform(transformsStack.pop());
g.setTransform(transformsStack.pop());
g.setTransform(transformsStack.pop());
g.setTransform(transformsStack.pop());

}



	private void innerPaint(Graphics2D g) {
        float origAlpha = 1.0f;
        Composite origComposite = g.getComposite();
        if (origComposite instanceof AlphaComposite) {
            AlphaComposite origAlphaComposite = 
                (AlphaComposite)origComposite;
            if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) {
                origAlpha = origAlphaComposite.getAlpha();
            }
        }
        
	    _paint0(g, origAlpha);


	    shape = null;
	    generalPath = null;
	    paint = null;
	    stroke = null;
        transformsStack.clear();
	}

    /**
     * Returns the X of the bounding box of the original SVG image.
     * 
     * @return The X of the bounding box of the original SVG image.
     */
    public static double getOrigX() {
        return 0.0;
    }

    /**
     * Returns the Y of the bounding box of the original SVG image.
     * 
     * @return The Y of the bounding box of the original SVG image.
     */
    public static double getOrigY() {
        return 0.0;
    }

	/**
	 * Returns the width of the bounding box of the original SVG image.
	 * 
	 * @return The width of the bounding box of the original SVG image.
	 */
	public static double getOrigWidth() {
		return 232.3350830078125;
	}

	/**
	 * Returns the height of the bounding box of the original SVG image.
	 * 
	 * @return The height of the bounding box of the original SVG image.
	 */
	public static double getOrigHeight() {
		return 232.3350830078125;
	}

	/** The current width of this icon. */
	private int width;

    /** The current height of this icon. */
	private int height;

	/**
	 * Creates a new transcoded SVG image. This is marked as private to indicate that app
	 * code should be using the {@link #of(int, int)} method to obtain a pre-configured instance.
	 */
	private TrafficLightRedIcon() {
        this.width = (int) getOrigWidth();
        this.height = (int) getOrigHeight();
	}

    @Override
	public int getIconHeight() {
		return height;
	}

    @Override
	public int getIconWidth() {
		return width;
	}

	@Override
	public synchronized void setDimension(Dimension newDimension) {
		this.width = newDimension.width;
		this.height = newDimension.height;
	}

    @Override
    public boolean supportsColorFilter() {
        return true;
    }

    @Override
    public void setColorFilter(ColorFilter colorFilter) {
        this.colorFilter = colorFilter;
    }

    @Override
	public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
		Graphics2D g2d = (Graphics2D) g.create();
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        if(getRotation()!=0) {
            g2d.rotate(getRotation(), x+width/2, y+height/2);
        }
        if(isReflection()) {
        	g2d.translate(x+width/2, y+height/2);
        	g2d.scale(this.rsfx, this.rsfy);
        	g2d.translate(-x-width/2, -y-height/2);
        }
		g2d.translate(x, y);

        double coef1 = (double) this.width / getOrigWidth();
        double coef2 = (double) this.height / getOrigHeight();
        double coef = Math.min(coef1, coef2);
        g2d.clipRect(0, 0, this.width, this.height);
        g2d.scale(coef, coef);
        g2d.translate(-getOrigX(), -getOrigY());
        if (coef1 != coef2) {
            if (coef1 < coef2) {
               int extraDy = (int) ((getOrigWidth() - getOrigHeight()) / 2.0);
               g2d.translate(0, extraDy);
            } else {
               int extraDx = (int) ((getOrigHeight() - getOrigWidth()) / 2.0);
               g2d.translate(extraDx, 0);
            }
        }
        Graphics2D g2ForInner = (Graphics2D) g2d.create();
        innerPaint(g2ForInner);
        g2ForInner.dispose();
        g2d.dispose();
	}
    
    /**
     * Returns a new instance of this icon with specified dimensions.
     *
     * @param width Required width of the icon
     * @param height Required height of the icon
     * @return A new instance of this icon with specified dimensions.
     */
    public static RadianceIcon of(int width, int height) {
       TrafficLightRedIcon base = new TrafficLightRedIcon();
       base.width = width;
       base.height = height;
       return base;
    }

    /**
     * Returns a new {@link UIResource} instance of this icon with specified dimensions.
     *
     * @param width Required width of the icon
     * @param height Required height of the icon
     * @return A new {@link UIResource} instance of this icon with specified dimensions.
     */
    public static RadianceIconUIResource uiResourceOf(int width, int height) {
       TrafficLightRedIcon base = new TrafficLightRedIcon();
       base.width = width;
       base.height = height;
       return new RadianceIconUIResource(base);
    }

    /**
     * Returns a factory that returns instances of this icon on demand.
     *
     * @return Factory that returns instances of this icon on demand.
     */
    public static Factory factory() {
        return TrafficLightRedIcon::new;
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy