Java Code Examples for org.pushingpixels.substance.api.SubstanceSkin#getWatermarkColorScheme()

The following examples show how to use org.pushingpixels.substance.api.SubstanceSkin#getWatermarkColorScheme() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubstanceNoiseWatermark.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 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) {
    SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
    if (isPreview) {
        graphics.drawImage(NoiseFactory.getNoiseImage(skin, width, height,
                this.xFactor, this.yFactor, this.hasConstantZ,
                this.noiseFilter, this.toBlur, true), x, y, null);
    } else {
        int alpha = scheme.isDark() ? 200 : 140;
        graphics.setComposite(AlphaComposite.getInstance(
                AlphaComposite.SRC_OVER, alpha / 255.0f));
        graphics.drawImage(NoiseFactory.getNoiseImage(skin, width, height,
                this.xFactor, this.yFactor, this.hasConstantZ,
                this.noiseFilter, this.toBlur, false), x, y, null);
    }
    return true;
}
 
Example 2
Source File: SubstanceFlameFractalWatermark.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Draws the specified portion of the watermark image.
 *
 * @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) {
    if (isPreview) {
        // graphics.drawImage(NoiseFactory.getNoiseImage(
        // SubstanceCoreUtilities.getDefaultTheme(null)
        // .getFirstTheme().getColorScheme(),
        // SubstanceCoreUtilities.getDefaultTheme(null)
        // .getSecondTheme().getColorScheme(), width, height,
        // this.xFactor, this.yFactor, this.hasConstantZ,
        // this.noiseFilter, this.toBlur), x, y, null);
    } else {
        SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
        int alpha = scheme.isDark() ? 200 : 250;
        graphics.setComposite(AlphaComposite.getInstance(
                AlphaComposite.SRC_OVER, alpha / 255.0f));
        NeonCortex.drawImage(graphics, FractalFlameFactory.getFractalFlameImage(scheme,
                scheme, width, height, 25000000, this.functionSystem), x, y);
    }
    return true;
}
 
Example 3
Source File: SubstanceStripeWatermark.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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();
	}

	double scaleFactor = NeonCortex.getScaleFactor();
	double borderStrokeWidth = 1.0f / scaleFactor;
	graphics.setColor(stampColor);
	graphics.setStroke(new BasicStroke(1.0f / (float) scaleFactor,
			BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
	double row = y;
	while (row < (y + height)) {
	    graphics.draw(new Line2D.Double(x, row, x + width, row));
	    row += 2 * borderStrokeWidth;
       }

	if (isPreview) {
		graphics.setColor(Color.gray);
           row = y + 1;
           while (row < (y + height)) {
               graphics.draw(new Line2D.Double(x, row, x + width, row));
               row += 2 * borderStrokeWidth;
           }
	}
	return true;
}
 
Example 4
Source File: SubstanceExceedWatermark.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Draws watermark image.
 *
 * @param skin      Skin to use for painting the watermark.
 * @param graphics  Graphics context.
 * @param x         X coordinate for painting the watermark.
 * @param y         Y coordinate for painting the watermark.
 * @param width     Width of the watermark region.
 * @param height    Height of the watermark region.
 * @param isPreview Indicates whether the drawing should paint the watermark
 *                  preview.
 * @return If <code>true</code>, the watermark painting has succeeded.
 */
private boolean drawWatermarkImage(SubstanceSkin skin, Graphics2D graphics,
        int x, int y, int width, int height, boolean isPreview) {
    Color stampColorDark = null;
    Color stampColorLight = null;
    SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
    if (isPreview) {
        stampColorDark = scheme.isDark() ? Color.white : Color.black;
        stampColorLight = scheme.isDark() ? Color.black : Color.white;
    } else {
        stampColorDark = scheme.getWatermarkDarkColor();
        stampColorLight = scheme.getWatermarkLightColor();
    }

    graphics.setColor(stampColorDark);
    graphics.fillRect(0, 0, width, height);

    BufferedImage tile = NeonCortex.getBlankUnscaledImage(4, 4);
    tile.setRGB(3, 0, stampColorLight.getRGB());
    tile.setRGB(2, 1, stampColorLight.getRGB());
    tile.setRGB(0, 2, stampColorLight.getRGB());
    tile.setRGB(1, 3, stampColorLight.getRGB());

    for (int row = y; row < (y + height); row += 4) {
        for (int col = x; col < (x + width); col += 4) {
            graphics.drawImage(tile, col, row, null);
        }
    }
    return true;
}
 
Example 5
Source File: SubstanceKatakanaWatermark.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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) {
    SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
    Color stampColor;
    if (isPreview) {
        stampColor = scheme.isDark() ? Color.white : Color.black;
    } else {
        stampColor = scheme.getWatermarkStampColor();
    }

    graphics.setColor(stampColor);

    graphics.setFont(font);
    /**
     * Font size.
     */
    int fontSize = 14;
    int fontWidth = fontSize;
    int fontHeight = fontSize - 2;
    int rows = height / fontHeight;
    int columns = width / fontWidth;
    for (int col = 0; col <= columns; col++) {
        for (int row = 0; row <= rows; row++) {
            // choose random katakana letter
            int letterIndex = isPreview ? (33 + (col + columns * row) % 95)
                                        : (int) (33 + Math.random() * 95);
            char c = (char) letterIndex;
            graphics.drawString("" + c, x + col * fontWidth, y + fontHeight * (row + 1));
        }
    }
    return true;
}
 
Example 6
Source File: SubstanceCrosshatchWatermark.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 = NeonCortex.getBlankUnscaledImage(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;
}
 
Example 7
Source File: SubstanceBinaryWatermark.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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;
    int fontWidth = 0;
    int fontHeight = 0;
    SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
    if (isPreview) {
        stampColor = scheme.isDark() ? Color.white : Color.black;
        graphics.setFont(tahomaPreview);
        fontWidth = fontSize - 6;
        fontHeight = fontSize - 4;
    } else {
        stampColor = scheme.getWatermarkStampColor();
        graphics.setFont(tahoma);
        fontWidth = fontSize - 4;
        fontHeight = fontSize - 2;
    }

    graphics.setColor(stampColor);

    int rows = height / fontHeight;
    int columns = width / fontWidth;
    for (int col = x; col <= (x + columns); col++) {
        for (int row = y; row <= (y + rows); row++) {
            // choose random 0/1 letter
            double val = isPreview ? Math.abs(Math.sin((2.8 + col + columns * row)))
                    : Math.random();
            char c = (val >= 0.5) ? '0' : '1';
            graphics.drawString("" + c, col * fontWidth, fontHeight * (row + 1));
        }
    }
    return true;
}
 
Example 8
Source File: SubstanceMosaicWatermark.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * 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) {
    int sqDim = 7;
    int sqGap = 2;
    int cellDim = sqDim + sqGap;

    SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
    int rows = height / cellDim;
    int columns = width / cellDim;
    for (int col = 0; col <= columns; col++) {
        for (int row = 0; row <= rows; row++) {
            double val = isPreview ? Math.abs(Math.sin((1 + col + columns
                    * row))) : Math.random();
            int delta = isPreview ? (int) (150.0 * val)
                                  : (int) (50.0 * val);
            int alpha = 0;
            if (isPreview) {
                alpha = 50 + delta;
            } else {
                if (scheme.isDark())
                    alpha = 50 + delta * 3 / 2;
                else
                    alpha = 25 + delta;
            }
            alpha = Math.min(alpha, 255);
            Color stampColor = null;
            if (isPreview) {
                stampColor = scheme.isDark() ? Color.lightGray
                                             : Color.darkGray;
                stampColor = SubstanceColorUtilities.getAlphaColor(
                        stampColor, alpha);
            } else {
                stampColor = SubstanceColorUtilities.getAlphaColor(scheme
                        .getWatermarkStampColor(), alpha);
            }
            graphics.setColor(stampColor);
            graphics.fillRect(x + col * cellDim, y + row * cellDim, sqDim,
                    sqDim);
        }
    }
    return true;
}
 
Example 9
Source File: SubstanceLatchWatermark.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * 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;
    SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
    if (isPreview) {
        stampColorDark = scheme.isDark() ? Color.white : Color.black;
        stampColorAll = Color.lightGray;
    } else {
        stampColorDark = scheme.getWatermarkDarkColor();
        stampColorAll = scheme.getWatermarkStampColor();
    }

    Color c1 = stampColorDark;
    Color c2 = SubstanceColorUtilities.getInterpolatedColor(stampColorDark,
            stampColorAll, 0.5);
    graphics.setColor(stampColorAll);
    graphics.fillRect(0, 0, width, height);

    int dimension = 12;
    BufferedImage tile = NeonCortex.getBlankUnscaledImage(dimension, dimension);
    GeneralPath latch1 = new GeneralPath();
    latch1.moveTo(0.45f * dimension, 0);
    latch1.quadTo(0.45f * dimension, 0.45f * dimension, 0.05f * dimension, 0.45f * dimension);
    latch1.quadTo(0.15f * dimension, 0.15f * dimension, 0.45f * dimension, 0);
    this.drawLatch(tile, latch1, c1, c2);

    GeneralPath latch2 = new GeneralPath();
    latch2.moveTo(0.55f * dimension, 0.55f * dimension);
    latch2.quadTo(0.75f * dimension, 0.4f * dimension, dimension, dimension);
    latch2.quadTo(0.4f * dimension, 0.75f * dimension, 0.5f * dimension, 0.5f * dimension);
    this.drawLatch(tile, latch2, c1, c2);

    for (int row = 0; row < height; row += dimension) {
        for (int col = 0; col < width; col += dimension) {
            graphics.drawImage(tile, x + col, y + row, null);
        }
    }
    return true;
}
 
Example 10
Source File: SubstanceBubblesWatermark.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * 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.white : Color.black;
    else {
        stampColor = scheme.getWatermarkStampColor();
    }
    int minBubbleRadius = 10;
    int maxBubbleRadius = 20;

    int cellSize = (minBubbleRadius + maxBubbleRadius);
    int rowCount = height / cellSize;
    int columnCount = width / cellSize;

    graphics.setColor(stampColor);
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
            RenderingHints.VALUE_STROKE_PURE);
    graphics.setStroke(new BasicStroke(1.0f / (float) NeonCortex.getScaleFactor(),
            BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));

    for (int col = 0; col <= columnCount; col++) {
        for (int row = 0; row <= rowCount; row++) {
            // location
            double xval = isPreview ? Math.abs(Math
                    .sin((2.8 + col + columnCount * row))) : Math.random();
            int xc = x + (int) (col * cellSize + cellSize * xval);
            double yval = isPreview ? Math.abs(Math
                    .sin((3.5 + col + columnCount * row))) : Math.random();
            int yc = y + (int) (row * cellSize + cellSize * yval);
            double val = isPreview ? 0.1 * Math.abs(Math
                    .sin((1 + col + columnCount * row))) : Math.random();
            int r = minBubbleRadius
                    + (int) (val * (maxBubbleRadius - minBubbleRadius));
            graphics.drawOval(xc - r, yc - r, 2 * r, 2 * r);

            GeneralPath shine = new GeneralPath();
            shine.moveTo(xc - 0.2f * r, yc - 0.8f * r);
            shine.quadTo(xc - 0.7f * r, yc - 0.6f * r, xc - 0.8f * r, yc
                    - 0.1f * r);
            shine.lineTo(xc - 0.3f * r, yc + 0.2f * r);
            shine.quadTo(xc - 0.3f * r, yc - 0.4f * r, xc, yc - 0.6f * r);
            shine.lineTo(xc - 0.2f * r, yc - 0.8f * r);
            graphics.draw(shine);
        }
    }
    return true;
}
 
Example 11
Source File: NoiseFactory.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * 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,
        NoiseFilter noiseFilter, 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 = NeonCortex.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);

    int imageWidth = dst.getWidth();
    int imageHeight = dst.getHeight();
    double m2 = xFactor * imageWidth * xFactor * imageWidth + yFactor * imageHeight
            * yFactor * imageHeight;
    int pos = 0;
    for (int j = 0; j < imageHeight; j++) {
        double jj = yFactor * j;
        for (int i = 0; i < imageWidth; 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);
            if (noiseFilter != null)
                noise = noiseFilter.apply(i, j, z, noise);

            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) {
        float edgeBlur = 0.08f / (float) NeonCortex.getScaleFactor();
        ConvolveOp convolve = new ConvolveOp(new Kernel(3, 3, new float[] {
                edgeBlur, edgeBlur, edgeBlur, edgeBlur, 1.06f - 8 * edgeBlur, edgeBlur,
                edgeBlur, edgeBlur, edgeBlur }),
                ConvolveOp.EDGE_NO_OP, null);
        dst = convolve.filter(dst, NeonCortex.getBlankImage(width, height));
    }
    return dst;
}