org.pushingpixels.radiance.tools.svgtranscoder.api.java.SvgTranscoderTemplateRadiance.templ Maven / Gradle / Ivy
TOKEN_PACKAGE
import java.awt.*;
import java.awt.geom.*;
import java.util.Stack;
import javax.swing.plaf.UIResource;
import org.jdesktop.swingx.icon.RadianceIcon;
import org.jdesktop.swingx.icon.RadianceIconUIResource;
/**
* This class has been automatically generated using
* Radiance SVG converter.
*/
public class TOKEN_CLASSNAME 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
TOKEN_RASTER_CODE
TOKEN_PAINTING_CODE
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();
}
}
TOKEN_PAINTING_INVOCATIONS
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 TOKEN_ORIG_X;
}
/**
* 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 TOKEN_ORIG_Y;
}
/**
* 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 TOKEN_ORIG_WIDTH;
}
/**
* 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 TOKEN_ORIG_HEIGHT;
}
/** 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 TOKEN_CLASSNAME() {
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 TOKEN_SUPPORTS_COLOR_FILTER;
}
@Override
public void setColorFilter(ColorFilter colorFilter) {
TOKEN_SET_COLOR_FILTER
}
@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) {
TOKEN_CLASSNAME base = new TOKEN_CLASSNAME();
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) {
TOKEN_CLASSNAME base = new TOKEN_CLASSNAME();
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 TOKEN_CLASSNAME::new;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy