本文整理汇总了Java中org.patchca.color.ColorFactory类的典型用法代码示例。如果您正苦于以下问题:Java ColorFactory类的具体用法?Java ColorFactory怎么用?Java ColorFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColorFactory类属于org.patchca.color包,在下文中一共展示了ColorFactory类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.patchca.color.ColorFactory; //导入依赖的package包/类
private void init(int min, int max){
MIN_LEN = min;
MAX_LEN = max;
cs.setColorFactory(new ColorFactory() {
@Override
public Color getColor(int x) {
int[] c = new int[3];
int i = random.nextInt(c.length);
for (int fi = 0; fi < c.length; fi++) {
if (fi == i) {
c[fi] = random.nextInt(71);
} else {
c[fi] = random.nextInt(256);
}
}
return new Color(c[0], c[1], c[2]);
}
});
RandomWordFactory wf = new RandomWordFactory();
wf.setCharacters(RANDOM_CHAR);
wf.setMaxLength(MIN_LEN);
wf.setMinLength(MAX_LEN);
cs.setWordFactory(wf);
}
示例2: convertToCharacters
import org.patchca.color.ColorFactory; //导入依赖的package包/类
protected TextString convertToCharacters(String text, Graphics2D g, FontFactory fontFactory, ColorFactory colorFactory) {
TextString characters = new TextString();
FontRenderContext frc = g.getFontRenderContext();
double lastx = 0;
for (int i = 0; i < text.length(); i++) {
Font font = fontFactory.getFont(i);
char c = text.charAt(i);
FontMetrics fm = g.getFontMetrics(font);
Rectangle2D bounds = font.getStringBounds(String.valueOf(c), frc);
TextCharacter tc = new TextCharacter();
tc.setCharacter(c);
tc.setFont(font);
tc.setWidth(fm.charWidth(c));
tc.setHeight(fm.getAscent() + fm.getDescent());
tc.setAscent(fm.getAscent());
tc.setDescent(fm.getDescent());
tc.setX(lastx);
tc.setY(0);
tc.setFont(font);
tc.setColor(colorFactory.getColor(i));
lastx += bounds.getWidth();
characters.addCharacter(tc);
}
return characters;
}
示例3: draw
import org.patchca.color.ColorFactory; //导入依赖的package包/类
@Override
public void draw(String text, BufferedImage canvas, FontFactory fontFactory, ColorFactory colorFactory) {
Graphics2D g = (Graphics2D) canvas.getGraphics();
TextString ts = convertToCharacters(text, g, fontFactory, colorFactory);
arrangeCharacters(canvas.getWidth(), canvas.getHeight(), ts);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
for (TextCharacter tc : ts.getCharacters()) {
g.setColor(tc.getColor());
g.drawString(tc.iterator(), (float) tc.getX(), (float) tc.getY());
}
}
示例4: setColorFactory
import org.patchca.color.ColorFactory; //导入依赖的package包/类
public void setColorFactory(ColorFactory colorFactory) {
this.colorFactory = colorFactory;
}
示例5: getColorFactory
import org.patchca.color.ColorFactory; //导入依赖的package包/类
public ColorFactory getColorFactory() {
return colorFactory;
}
示例6: CurvesRippleFilterFactory
import org.patchca.color.ColorFactory; //导入依赖的package包/类
public CurvesRippleFilterFactory(ColorFactory colorFactory) {
setColorFactory(colorFactory);
}
示例7: setColorFactory
import org.patchca.color.ColorFactory; //导入依赖的package包/类
public void setColorFactory(ColorFactory colorFactory) {
curves.setColorFactory(colorFactory);
}
示例8: draw
import org.patchca.color.ColorFactory; //导入依赖的package包/类
void draw(String text, BufferedImage canvas, FontFactory fontFactory, ColorFactory colorFactory);