Java Code Examples for org.pushingpixels.substance.internal.utils.SubstanceColorUtilities#getInterpolatedColor()

The following examples show how to use org.pushingpixels.substance.internal.utils.SubstanceColorUtilities#getInterpolatedColor() . 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: MatteDecorationPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Fills the relevant part with the gradient fill.
 *
 * @param graphics Graphics.
 * @param scheme   Color scheme to use.
 * @param offsetY  Vertical offset.
 * @param x        X coordinate of the fill area.
 * @param y        Y coordinate of the fill area.
 * @param width    Fill area width.
 * @param height   Fill area height.
 */
protected void fill(Graphics2D graphics, SubstanceColorScheme scheme,
        int offsetY, int x, int y, int width, int height) {
    // 0 - flex : light -> medium
    // flex - : medium fill

    Color startColor = scheme.getLightColor();
    Color endColor = SubstanceColorUtilities.getInterpolatedColor(startColor,
            scheme.getMidColor(), 0.4f);

    int gradientHeight = Math.max(FLEX_POINT, height + offsetY);
    Paint paint = (gradientHeight == FLEX_POINT) ?
            new GradientPaint(0, y - offsetY, startColor, 0, y + gradientHeight - offsetY,
                    endColor) :
            new LinearGradientPaint(
                    0, y - offsetY, 0, y + height - offsetY,
                    new float[] { 0.0f, (float) FLEX_POINT / (float) gradientHeight, 1.0f },
                    new Color[] { startColor, endColor, endColor },
                    MultipleGradientPaint.CycleMethod.NO_CYCLE);

    graphics.setPaint(paint);
    graphics.fillRect(x, y, width, height);
}
 
Example 2
Source File: MatteDecorationPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType
        decorationAreaType, Shape contour, SubstanceColorScheme colorScheme) {
    Point offset = SubstanceCoreUtilities.getOffsetInRootPaneCoords(comp);

    Color startColor = colorScheme.getLightColor();
    Color endColor = SubstanceColorUtilities.getInterpolatedColor(startColor,
            colorScheme.getMidColor(), 0.4f);

    int gradientHeight = Math.max(FLEX_POINT, comp.getHeight() + offset.y);
    Paint paint = (gradientHeight == FLEX_POINT) ?
            new GradientPaint(0, -offset.y, startColor, 0, gradientHeight - offset.y,
                    endColor) :
            new LinearGradientPaint(
                    0, -offset.y, 0, comp.getHeight() - offset.y,
                    new float[] { 0.0f, (float) FLEX_POINT / (float) gradientHeight, 1.0f },
                    new Color[] { startColor, endColor, endColor },
                    MultipleGradientPaint.CycleMethod.NO_CYCLE);

    graphics.setPaint(paint);
    graphics.fill(contour);
}
 
Example 3
Source File: FractionBasedBorderPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Color getRepresentativeColor(SubstanceColorScheme borderScheme) {
	for (int i = 0; i < this.fractions.length - 1; i++) {
		float fractionLow = this.fractions[i];
		float fractionHigh = this.fractions[i + 1];
		if (fractionLow == 0.5f) {
			return this.colorQueries[i].query(borderScheme);
		}
		if (fractionHigh == 0.5f) {
			return this.colorQueries[i + 1].query(borderScheme);
		}
		if ((fractionLow < 0.5f) || (fractionHigh > 0.5f)) {
			continue;
		}
		// current range contains 0.5f
		Color colorLow = this.colorQueries[i].query(borderScheme);
		Color colorHigh = this.colorQueries[i + 1].query(borderScheme);
		float colorLowLikeness = (0.5f - fractionLow) / (fractionHigh - fractionLow);
		return SubstanceColorUtilities.getInterpolatedColor(colorLow, colorHigh,
				colorLowLikeness);
	}
	throw new IllegalStateException("Could not find representative color");
}
 
Example 4
Source File: SubstanceEtchedBorder.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Returns the highlight color for the specified component.
 * 
 * @param c
 *            Component.
 * @return Matching highlight color.
 */
public Color getHighlightColor(Component c) {
	SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities
			.getColorScheme(c, ColorSchemeAssociationKind.SEPARATOR,
					ComponentState.ENABLED);
	boolean isDark = colorScheme.isDark();
	Color foreDark = isDark ? colorScheme.getExtraLightColor()
			: SubstanceColorUtilities.getInterpolatedColor(colorScheme
					.getMidColor(), colorScheme.getDarkColor(), 0.4);

	return SubstanceColorUtilities.getAlphaColor(foreDark, 196);
}
 
Example 5
Source File: SubduedFillPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getTopFillColor(SubstanceColorScheme fillScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(super
			.getTopFillColor(fillScheme), this
			.getMidFillColorTop(fillScheme), 0.3);
}
 
Example 6
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 7
Source File: ShiftColorScheme.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Creates a new shifted color scheme.
 * 
 * @param origScheme
 *            The original color scheme.
 * @param backgroundShiftColor
 *            Shift color for the background colors.
 * @param backgroundShiftFactor
 *            Shift factor for the background colors. Should be in 0.0-1.0
 *            range.
 * @param foregroundShiftColor
 *            Shift color for the foreground colors.
 * @param foregroundShiftFactor
 *            Shift factor for the foreground colors. Should be in 0.0-1.0
 *            range.
 * @param shiftByBrightness
 *            If <code>true</code>, the shift will account for the
 *            brightness of the original color scheme colors.
 */
public ShiftColorScheme(SubstanceColorScheme origScheme, Color backgroundShiftColor,
		double backgroundShiftFactor, Color foregroundShiftColor, double foregroundShiftFactor,
		boolean shiftByBrightness) {
	super("Shift " + origScheme.getDisplayName() + " to backgr [" + backgroundShiftColor + "] "
			+ (int) (100 * backgroundShiftFactor) + "%, foregr [" + foregroundShiftColor + "]"
			+ (int) (100 * foregroundShiftFactor) + "%", origScheme.isDark());
	this.backgroundShiftColor = backgroundShiftColor;
	this.backgroundShiftFactor = backgroundShiftFactor;
	this.foregroundShiftColor = foregroundShiftColor;
	this.foregroundShiftFactor = foregroundShiftFactor;
	this.origScheme = origScheme;
	this.foregroundColor = (this.foregroundShiftColor != null)
			? SubstanceColorUtilities.getInterpolatedColor(this.foregroundShiftColor,
					origScheme.getForegroundColor(), this.foregroundShiftFactor)
			: origScheme.getForegroundColor();
	shiftByBrightness = shiftByBrightness && (this.backgroundShiftColor != null);
	Color ultraDarkToShiftTo = shiftByBrightness
			? SubstanceColorUtilities.deriveByBrightness(this.backgroundShiftColor,
					origScheme.getUltraDarkColor())
			: this.backgroundShiftColor;
	this.mainUltraDarkColor = (this.backgroundShiftColor != null)
			? SubstanceColorUtilities.getInterpolatedColor(ultraDarkToShiftTo,
					origScheme.getUltraDarkColor(), this.backgroundShiftFactor)
			: origScheme.getUltraDarkColor();
	Color darkToShiftTo = shiftByBrightness
			? SubstanceColorUtilities.deriveByBrightness(this.backgroundShiftColor,
					origScheme.getDarkColor())
			: this.backgroundShiftColor;
	this.mainDarkColor = (this.backgroundShiftColor != null)
			? SubstanceColorUtilities.getInterpolatedColor(darkToShiftTo,
					origScheme.getDarkColor(), this.backgroundShiftFactor)
			: origScheme.getDarkColor();
	Color midToShiftTo = shiftByBrightness
			? SubstanceColorUtilities.deriveByBrightness(this.backgroundShiftColor,
					origScheme.getMidColor())
			: this.backgroundShiftColor;
	this.mainMidColor = (this.backgroundShiftColor != null)
			? SubstanceColorUtilities.getInterpolatedColor(midToShiftTo,
					origScheme.getMidColor(), this.backgroundShiftFactor)
			: origScheme.getMidColor();
	Color lightToShiftTo = shiftByBrightness
			? SubstanceColorUtilities.deriveByBrightness(this.backgroundShiftColor,
					origScheme.getLightColor())
			: this.backgroundShiftColor;
	this.mainLightColor = (this.backgroundShiftColor != null)
			? SubstanceColorUtilities.getInterpolatedColor(lightToShiftTo,
					origScheme.getLightColor(), this.backgroundShiftFactor)
			: origScheme.getLightColor();
	Color extraLightToShiftTo = shiftByBrightness
			? SubstanceColorUtilities.deriveByBrightness(this.backgroundShiftColor,
					origScheme.getExtraLightColor())
			: this.backgroundShiftColor;
	this.mainExtraLightColor = (this.backgroundShiftColor != null)
			? SubstanceColorUtilities.getInterpolatedColor(extraLightToShiftTo,
					origScheme.getExtraLightColor(), this.backgroundShiftFactor)
			: origScheme.getExtraLightColor();
	Color ultraLightToShiftTo = shiftByBrightness
			? SubstanceColorUtilities.deriveByBrightness(this.backgroundShiftColor,
					origScheme.getUltraLightColor())
			: this.backgroundShiftColor;
	this.mainUltraLightColor = (this.backgroundShiftColor != null)
			? SubstanceColorUtilities.getInterpolatedColor(ultraLightToShiftTo,
					origScheme.getUltraLightColor(), this.backgroundShiftFactor)
			: origScheme.getUltraLightColor();
}
 
Example 8
Source File: SimplisticFillPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getMidFillColorTop(SubstanceColorScheme fillScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(super
			.getMidFillColorTop(fillScheme), super
			.getBottomFillColor(fillScheme), 0.5);
}
 
Example 9
Source File: DerivedColorsResolverLight.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getTextBackgroundFillColor() {
	return SubstanceColorUtilities.getInterpolatedColor(this.scheme.getUltraLightColor(),
			this.scheme.getExtraLightColor(), 0.8f);
}
 
Example 10
Source File: DerivedColorsResolverLight.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getLineColor() {
	return SubstanceColorUtilities.getInterpolatedColor(this.scheme.getMidColor(),
			this.scheme.getDarkColor(), 0.7f);
}
 
Example 11
Source File: DerivedColorsResolverDark.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getTextBackgroundFillColor() {
	return SubstanceColorUtilities.getInterpolatedColor(this.scheme.getMidColor(),
			this.scheme.getLightColor(), 0.4f);
}
 
Example 12
Source File: MatteFillPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getMidFillColorTop(SubstanceColorScheme fillScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(super.getMidFillColorTop(fillScheme),
			super.getBottomFillColor(fillScheme), 0.7f);
}
 
Example 13
Source File: MatteFillPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getTopFillColor(SubstanceColorScheme fillScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(super.getBottomFillColor(fillScheme),
			super.getMidFillColorTop(fillScheme), 0.5f);
}
 
Example 14
Source File: ClassicFillPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getMidFillColorTop(SubstanceColorScheme fillScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(super.getMidFillColorTop(fillScheme),
			super.getBottomFillColor(fillScheme), 0.7f);
}
 
Example 15
Source File: ClassicFillPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getTopFillColor(SubstanceColorScheme fillScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(super.getBottomFillColor(fillScheme),
			super.getMidFillColorTop(fillScheme), 0.5f);
}
 
Example 16
Source File: GlassFillPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getBottomFillColor(SubstanceColorScheme fillScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(this.getMidFillColorBottom(fillScheme),
			super.getBottomFillColor(fillScheme), 0.7f);
}
 
Example 17
Source File: GlassFillPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getMidFillColorTop(SubstanceColorScheme fillScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(this.getTopFillColor(fillScheme),
			super.getMidFillColorTop(fillScheme), 0.8f);
}
 
Example 18
Source File: GlassFillPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getTopFillColor(SubstanceColorScheme fillScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(super.getBottomFillColor(fillScheme),
			super.getMidFillColorTop(fillScheme), 0.6f);
}
 
Example 19
Source File: GlassBorderPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getTopBorderColor(SubstanceColorScheme borderScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(super.getTopBorderColor(borderScheme),
			super.getMidBorderColor(borderScheme), 0.0f);
}
 
Example 20
Source File: ClassicBorderPainter.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Color getTopBorderColor(SubstanceColorScheme borderScheme) {
	return SubstanceColorUtilities.getInterpolatedColor(super.getTopBorderColor(borderScheme),
			super.getMidBorderColor(borderScheme), 0.0f);
}