Skip to content

Commit

Permalink
Migrate older fill painters to be fraction-based
Browse files Browse the repository at this point in the history
And clean up the internal color query utilities that added more complexity than necessary. For #462
  • Loading branch information
kirill-grouchnikov committed Mar 4, 2024
1 parent 4168c2b commit b223182
Show file tree
Hide file tree
Showing 65 changed files with 80 additions and 311 deletions.
Binary file modified docs/images/theming/skins/autumn1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/autumn2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/business1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/business2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/businessblacksteel1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/businessblacksteel2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/businessbluesteel1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/businessbluesteel2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/cerulean1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/cerulean2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/creme1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/creme2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/cremecoffee1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/cremecoffee2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/dust1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/dust2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/dustcoffee1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/dustcoffee2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/gemini1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/gemini2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/graphite1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/graphite2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/graphiteaqua1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/graphiteaqua2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/graphitechalk1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/theming/skins/graphitechalk2.png
Binary file modified docs/images/theming/skins/graphiteelectric1.png
Binary file modified docs/images/theming/skins/graphiteglass1.png
Binary file modified docs/images/theming/skins/graphiteglass2.png
Binary file modified docs/images/theming/skins/graphitegold1.png
Binary file modified docs/images/theming/skins/graphitegold2.png
Binary file modified docs/images/theming/skins/graphitesienna1.png
Binary file modified docs/images/theming/skins/graphitesunset1.png
Binary file modified docs/images/theming/skins/graphitesunset2.png
Binary file modified docs/images/theming/skins/greenmagic1.png
Binary file modified docs/images/theming/skins/greenmagic2.png
Binary file modified docs/images/theming/skins/magellan1.png
Binary file modified docs/images/theming/skins/magellan2.png
Binary file modified docs/images/theming/skins/mariner1.png
Binary file modified docs/images/theming/skins/mariner2.png
Binary file modified docs/images/theming/skins/mistaqua1.png
Binary file modified docs/images/theming/skins/mistaqua2.png
Binary file modified docs/images/theming/skins/mistsilver1.png
Binary file modified docs/images/theming/skins/mistsilver2.png
Binary file modified docs/images/theming/skins/moderate1.png
Binary file modified docs/images/theming/skins/moderate2.png
Binary file modified docs/images/theming/skins/nebula1.png
Binary file modified docs/images/theming/skins/nebula2.png
Binary file modified docs/images/theming/skins/nebulaamethyst1.png
Binary file modified docs/images/theming/skins/nebulaamethyst2.png
Binary file modified docs/images/theming/skins/nebulabrickwall1.png
Binary file modified docs/images/theming/skins/nebulabrickwall2.png
Binary file modified docs/images/theming/skins/raven1.png
Binary file modified docs/images/theming/skins/raven2.png
Binary file modified docs/images/theming/skins/sahara1.png
Binary file modified docs/images/theming/skins/sahara2.png
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@
*/
package org.pushingpixels.radiance.theming.api.painter.fill;

import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.colorscheme.ColorSchemeSingleColorQuery;
import org.pushingpixels.radiance.theming.internal.utils.RadianceColorUtilities;

import java.awt.*;

/**
* Fill painter that draws visuals with classic appearance. This class is part
* of officially supported API.
*
* @author Kirill Grouchnikov
*/
public class ClassicFillPainter extends StandardFillPainter {
public class ClassicFillPainter extends FractionBasedFillPainter {
/**
* Reusable instance of this painter.
*/
Expand All @@ -50,22 +48,15 @@ public class ClassicFillPainter extends StandardFillPainter {
* Creates a new classic gradient painter.
*/
public ClassicFillPainter() {
}

@Override
public String getDisplayName() {
return "Classic";
}

@Override
public Color getTopFillColor(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getInterpolatedColor(super.getBottomFillColor(fillScheme),
super.getMidFillColorTop(fillScheme), 0.5f);
}

@Override
public Color getMidFillColorTop(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getInterpolatedColor(super.getMidFillColorTop(fillScheme),
super.getBottomFillColor(fillScheme), 0.7f);
super("Classic",
new float[] {0.0f, 0.5f, 1.0f},
new ColorSchemeSingleColorQuery[] {
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getMidColor(), scheme.getUltraLightColor(), 0.5f),
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getMidColor(), scheme.getUltraLightColor(), 0.7f),
ColorSchemeSingleColorQuery.ULTRALIGHT
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,29 @@
*/
package org.pushingpixels.radiance.theming.api.painter.fill;

import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.colorscheme.ColorSchemeSingleColorQuery;
import org.pushingpixels.radiance.theming.internal.utils.RadianceColorUtilities;

import java.awt.*;

/**
* Fill painter that draws visuals with glass appearance. This class is part
* of officially supported API.
*
* @author Kirill Grouchnikov
*/
public class GlassFillPainter extends StandardFillPainter {
@Override
public String getDisplayName() {
return "Glass";
}

@Override
public Color getTopFillColor(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getInterpolatedColor(super.getBottomFillColor(fillScheme),
super.getMidFillColorTop(fillScheme), 0.6f);
}

@Override
public Color getMidFillColorTop(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getInterpolatedColor(this.getTopFillColor(fillScheme),
super.getMidFillColorTop(fillScheme), 0.8f);
}

@Override
public Color getMidFillColorBottom(RadianceColorScheme fillScheme) {
return super.getMidFillColorTop(fillScheme);
public class GlassFillPainter extends FractionBasedFillPainter {
public GlassFillPainter() {
super("Glass",
new float[] {0.0f, 0.4999999f, 0.5f, 1.0f},
new ColorSchemeSingleColorQuery[] {
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getMidColor(), scheme.getUltraLightColor(), 0.4f),
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getMidColor(), scheme.getUltraLightColor(), 0.52f),
ColorSchemeSingleColorQuery.MID,
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getMidColor(), scheme.getUltraLightColor(), 0.7f),
}
);
}

@Override
public Color getBottomFillColor(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getInterpolatedColor(this.getMidFillColorBottom(fillScheme),
super.getBottomFillColor(fillScheme), 0.7f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,35 @@
*/
package org.pushingpixels.radiance.theming.api.painter.fill;

import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.colorscheme.ColorSchemeSingleColorQuery;
import org.pushingpixels.radiance.theming.internal.utils.RadianceColorUtilities;

import java.awt.*;

/**
* Fill painter that draws visuals with matte appearance. This class is part of
* officially supported API.
*
* @author Kirill Grouchnikov
*/
public class MatteFillPainter extends ClassicFillPainter {
public class MatteFillPainter extends FractionBasedFillPainter {
/**
* Reusable instance of this painter.
*/
public static final MatteFillPainter INSTANCE = new MatteFillPainter();

/**
* Creates a new matte fill painter.
* Creates a new classic gradient painter.
*/
public MatteFillPainter() {
super();
}

@Override
public String getDisplayName() {
return "Matte";
}

@Override
public Color getTopFillColor(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getInterpolatedColor(super.getBottomFillColor(fillScheme),
super.getMidFillColorTop(fillScheme), 0.5f);
}

@Override
public Color getMidFillColorTop(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getInterpolatedColor(super.getMidFillColorTop(fillScheme),
super.getBottomFillColor(fillScheme), 0.7f);
}

@Override
public Color getBottomFillColor(RadianceColorScheme fillScheme) {
return super.getMidFillColorTop(fillScheme);
super("Matte",
new float[] {0.0f, 0.5f, 1.0f},
new ColorSchemeSingleColorQuery[] {
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getMidColor(), scheme.getUltraLightColor(), 0.35f),
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getMidColor(), scheme.getUltraLightColor(), 0.49f),
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getMidColor(), scheme.getUltraLightColor(), 0.7f),
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public void paintContourBackground(Graphics g, Component comp, float width, floa

if ((shineWidth > 0) && (shineHeight > 0)) {
BufferedImage shineImage = getShineImage(comp, contour,
RadianceColorUtilities.getTopShineColor(fillScheme),
RadianceColorUtilities.getBottomShineColor(fillScheme),
fillScheme.getUltraLightColor(),
fillScheme.getLightColor(),
this.alpha, shineWidth, shineHeight);

Graphics2D graphics = (Graphics2D) g.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,97 +29,25 @@
*/
package org.pushingpixels.radiance.theming.api.painter.fill;

import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.colorscheme.ColorSchemeSingleColorQuery;
import org.pushingpixels.radiance.theming.internal.utils.RadianceColorUtilities;

import java.awt.*;
import java.awt.MultipleGradientPaint.CycleMethod;

/**
* Fill painter that draws visuals with subtle 3D gradient appearance. This class is part of
* officially supported API.
*
* @author Kirill Grouchnikov
*/
public class StandardFillPainter implements RadianceFillPainter {
@Override
public String getDisplayName() {
return "Standard";
}

@Override
public void paintContourBackground(Graphics g, Component comp, float width, float height,
Shape contour, RadianceColorScheme fillScheme) {

// long millis = System.nanoTime();

Graphics2D graphics = (Graphics2D) g.create();

Color topFillColor = this.getTopFillColor(fillScheme);
Color midFillColorTop = this.getMidFillColorTop(fillScheme);
Color midFillColorBottom = this.getMidFillColorBottom(fillScheme);
Color bottomFillColor = this.getBottomFillColor(fillScheme);

// Fill background
// long millis000 = System.nanoTime();

MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, height,
new float[]{0.0f, 0.4999999f, 0.5f, 1.0f},
new Color[]{topFillColor, midFillColorTop, midFillColorBottom, bottomFillColor},
CycleMethod.REPEAT);
graphics.setPaint(gradient);
graphics.fill(contour);

graphics.dispose();
}

/**
* Computes the color of the top portion of the fill. Override to provide different visual.
*
* @param fillScheme
* The fill scheme.
* @return The color of the top portion of the fill.
*/
public Color getTopFillColor(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getTopFillColor(fillScheme);
}

/**
* Computes the color of the middle portion of the fill from the top. Override to provide
* different visual.
*
* @param fillScheme
* The fill scheme.
* @return The color of the middle portion of the fill from the top.
*/
public Color getMidFillColorTop(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getMidFillColor(fillScheme);
}

/**
* Computes the color of the middle portion of the fill from the bottom. Override to provide
* different visual.
*
* @param fillScheme
* The fill scheme.
* @return The color of the middle portion of the fill from the bottom.
*/
public Color getMidFillColorBottom(RadianceColorScheme fillScheme) {
return this.getMidFillColorTop(fillScheme);
}

/**
* Computes the color of the bottom portion of the fill. Override to provide different visual.
*
* @param fillScheme
* The fill scheme.
* @return The color of the bottom portion of the fill.
*/
public Color getBottomFillColor(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getBottomFillColor(fillScheme);
}
@Override
public Color getRepresentativeColor(RadianceColorScheme fillScheme) {
return this.getMidFillColorTop(fillScheme);
public class StandardFillPainter extends FractionBasedFillPainter {
public StandardFillPainter() {
super("Standard",
new float[] {0.0f, 0.5f, 1.0f},
new ColorSchemeSingleColorQuery[] {
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getDarkColor(), scheme.getMidColor(), 0.4f),
ColorSchemeSingleColorQuery.MID,
ColorSchemeSingleColorQuery.ULTRALIGHT
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,25 @@
*/
package org.pushingpixels.radiance.theming.api.painter.fill;

import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.colorscheme.ColorSchemeSingleColorQuery;
import org.pushingpixels.radiance.theming.internal.utils.RadianceColorUtilities;

import java.awt.*;

/**
* Fill painter that draws visuals with subdued 3D gradient appearance. This
* class is part of officially supported API.
*
* @author Kirill Grouchnikov
*/
public class SubduedFillPainter extends StandardFillPainter {
@Override
public String getDisplayName() {
return "Subdued";
}

@Override
public Color getTopFillColor(RadianceColorScheme fillScheme) {
return RadianceColorUtilities.getInterpolatedColor(super
.getTopFillColor(fillScheme), this
.getMidFillColorTop(fillScheme), 0.3);
public class SubduedFillPainter extends FractionBasedFillPainter {
public SubduedFillPainter() {
super("Subdued",
new float[] {0.0f, 0.5f, 1.0f},
new ColorSchemeSingleColorQuery[] {
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getDarkColor(), scheme.getMidColor(), 0.12f),
ColorSchemeSingleColorQuery.MID,
ColorSchemeSingleColorQuery.ULTRALIGHT
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@

import org.pushingpixels.radiance.common.api.RadianceCommonCortex;
import org.pushingpixels.radiance.theming.api.ComponentState;
import org.pushingpixels.radiance.theming.api.colorscheme.ColorSchemeSingleColorQuery;
import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.painter.border.FlatBorderPainter;
import org.pushingpixels.radiance.theming.api.painter.border.RadianceBorderPainter;
import org.pushingpixels.radiance.theming.api.painter.fill.FractionBasedFillPainter;
import org.pushingpixels.radiance.theming.api.painter.fill.RadianceFillPainter;
import org.pushingpixels.radiance.theming.internal.painter.SimplisticFillPainter;
import org.pushingpixels.radiance.theming.internal.utils.RadianceColorUtilities;
import org.pushingpixels.radiance.theming.internal.utils.RadianceOutlineUtilities;
import org.pushingpixels.radiance.theming.internal.utils.RadianceSizeUtils;
Expand All @@ -53,31 +54,22 @@ public class BladeIconUtils {
*
* @author Kirill Grouchnikov
*/
private static class SimplisticSoftBorderReverseFillPainter extends SimplisticFillPainter {
private static class SimplisticSoftBorderReverseFillPainter extends FractionBasedFillPainter {
/**
* Singleton instance.
*/
public static final RadianceFillPainter INSTANCE = new SimplisticSoftBorderReverseFillPainter();

/**
* Private constructor.
*/
private SimplisticSoftBorderReverseFillPainter() {
}

@Override
public String getDisplayName() {
return "Simplistic Soft Border Reverse";
}

@Override
public Color getTopFillColor(RadianceColorScheme fillScheme) {
return super.getBottomFillColor(fillScheme);
}

@Override
public Color getBottomFillColor(RadianceColorScheme fillScheme) {
return super.getTopFillColor(fillScheme);
super("Simplistic Soft Border Reverse",
new float[] {0.0f, 0.5f, 1.0f},
new ColorSchemeSingleColorQuery[] {
ColorSchemeSingleColorQuery.ULTRALIGHT,
scheme -> RadianceColorUtilities.getInterpolatedColor(
scheme.getMidColor(), scheme.getUltraLightColor(), 0.5f),
ColorSchemeSingleColorQuery.MID
}
);
}
}

Expand Down
Loading

0 comments on commit b223182

Please sign in to comment.