本文整理汇总了Java中org.pushingpixels.substance.api.SubstanceSkin.getWatermarkColorScheme方法的典型用法代码示例。如果您正苦于以下问题:Java SubstanceSkin.getWatermarkColorScheme方法的具体用法?Java SubstanceSkin.getWatermarkColorScheme怎么用?Java SubstanceSkin.getWatermarkColorScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pushingpixels.substance.api.SubstanceSkin
的用法示例。
在下文中一共展示了SubstanceSkin.getWatermarkColorScheme方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawWatermarkImage
import org.pushingpixels.substance.api.SubstanceSkin; //导入方法依赖的package包/类
/**
* Draws the specified portion of the watermark image.
*
* @param skin
* Skin to use for painting the watermark.
* @param graphics
* Graphic context.
* @param x
* the <i>x</i> coordinate of the watermark to be drawn.
* @param y
* The <i>y</i> coordinate of the watermark to be drawn.
* @param width
* The width of the watermark to be drawn.
* @param height
* The height of the watermark to be drawn.
* @param isPreview
* Indication whether the result is a preview image.
* @return Indication whether the draw succeeded.
*/
private boolean drawWatermarkImage(SubstanceSkin skin, Graphics2D graphics,
int x, int y, int width, int height, boolean isPreview) {
Color stampColor = null;
SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
if (isPreview)
stampColor = scheme.isDark() ? Color.lightGray : Color.darkGray;
else {
stampColor = scheme.getWatermarkStampColor();
}
graphics.setColor(stampColor);
for (int row = y; row < (y + height); row += 2) {
graphics.drawLine(x, row, x + width, row);
}
if (isPreview) {
graphics.setColor(Color.gray);
for (int row = y + 1; row < (y + height); row += 2) {
graphics.drawLine(x, row, x + width, row);
}
}
return true;
}
示例2: drawWatermarkImage
import org.pushingpixels.substance.api.SubstanceSkin; //导入方法依赖的package包/类
/**
* Draws the specified portion of the watermark image.
*
* @param skin
* Skin to use for painting the watermark.
* @param graphics
* Graphic context.
* @param x
* the <i>x</i> coordinate of the watermark to be drawn.
* @param y
* The <i>y</i> coordinate of the watermark to be drawn.
* @param width
* The width of the watermark to be drawn.
* @param height
* The height of the watermark to be drawn.
* @param isPreview
* Indication whether the result is a preview image.
* @return Indication whether the draw succeeded.
*/
private boolean drawWatermarkImage(SubstanceSkin skin, Graphics2D graphics,
int x, int y, int width, int height, boolean isPreview) {
Color stampColorDark = null;
Color stampColorAll = null;
Color stampColorLight = null;
SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
if (isPreview) {
stampColorDark = scheme.isDark() ? Color.white : Color.black;
stampColorAll = Color.lightGray;
stampColorLight = scheme.isDark() ? Color.black : Color.white;
} else {
stampColorDark = scheme.getWatermarkDarkColor();
stampColorAll = scheme.getWatermarkStampColor();
stampColorLight = scheme.getWatermarkLightColor();
}
graphics.setColor(stampColorAll);
graphics.fillRect(0, 0, width, height);
BufferedImage tile = SubstanceCoreUtilities.getBlankImage(4, 4);
tile.setRGB(0, 0, stampColorDark.getRGB());
tile.setRGB(2, 2, stampColorDark.getRGB());
tile.setRGB(0, 1, stampColorLight.getRGB());
tile.setRGB(2, 3, stampColorLight.getRGB());
Graphics2D g2d = (Graphics2D) graphics.create();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
0.4f));
for (int row = y; row < (y + height); row += 4) {
for (int col = x; col < (x + width); col += 4) {
g2d.drawImage(tile, col, row, null);
}
}
g2d.dispose();
return true;
}
示例3: getNoiseImage
import org.pushingpixels.substance.api.SubstanceSkin; //导入方法依赖的package包/类
/**
* Returns a noise image.
*
* @param skin
* The skin to use for rendering the image.
* @param width
* Image width.
* @param height
* Image height.
* @param xFactor
* X stretch factor.
* @param yFactor
* Y stretch factor.
* @param hasConstantZ
* Indication whether the Z is constant.
* @param noiseFilter
* Noise filter to apply.
* @param toBlur
* Indication whether the resulting image should be blurred.
* @param isPreview
* Indication whether the image is in preview mode.
* @return Noise image.
*/
public static BufferedImage getNoiseImage(SubstanceSkin skin, int width,
int height, double xFactor, double yFactor, boolean hasConstantZ,
boolean toBlur, boolean isPreview) {
SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
Color c1 = scheme.getWatermarkDarkColor();
// c1 = new Color(255, 0, 0, 0);
// System.out.println(c1.getAlpha());
// Color c2 = scheme.getWatermarkStampColor();
Color c3 = scheme.getWatermarkLightColor();
BufferedImage dst = SubstanceCoreUtilities.getBlankImage(width, height);
//
// new BufferedImage(width, height,
// BufferedImage.TYPE_INT_ARGB);
// Borrow from Sebastien Petrucci fast blur code - direct access
// to the raster data
int[] dstBuffer = ((DataBufferInt) dst.getRaster().getDataBuffer())
.getData();
// System.out.println((dstBuffer[0] >>> 24) & 0xFF);
double m2 = xFactor * width * xFactor * width + yFactor * height
* yFactor * height;
int pos = 0;
for (int j = 0; j < height; j++) {
double jj = yFactor * j;
for (int i = 0; i < width; i++) {
double ii = xFactor * i;
double z = hasConstantZ ? 1.0 : Math.sqrt(m2 - ii * ii - jj
* jj);
double noise = 0.5 + 0.5 * PerlinNoiseGenerator
.noise(ii, jj, z);
double likeness = Math.max(0.0, Math.min(1.0, 2.0 * noise));
// likeness = 0.0;
dstBuffer[pos++] = SubstanceColorUtilities.getInterpolatedRGB(
c3, c1, likeness);
}
}
// System.out.println((dstBuffer[0] >>> 24) & 0xFF);
if (toBlur) {
ConvolveOp convolve = new ConvolveOp(new Kernel(3, 3, new float[] {
.08f, .08f, .08f, .08f, .38f, .08f, .08f, .08f, .08f }),
ConvolveOp.EDGE_NO_OP, null);
dst = convolve.filter(dst, null);
}
return dst;
}