本文整理匯總了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);