diff --git a/substance/src/main/java/org/pushingpixels/substance/internal/utils/SubstanceImageCreator.java b/substance/src/main/java/org/pushingpixels/substance/internal/utils/SubstanceImageCreator.java
index 2867ca48..d1f33364 100644
--- a/substance/src/main/java/org/pushingpixels/substance/internal/utils/SubstanceImageCreator.java
+++ b/substance/src/main/java/org/pushingpixels/substance/internal/utils/SubstanceImageCreator.java
@@ -51,14 +51,14 @@
/**
* Provides utility functions for creating various images for Substance
* look and feel. This class is for internal use only.
- *
+ *
* @author Kirill Grouchnikov
*/
public final class SubstanceImageCreator {
/**
* Custom fill painter for filling the checkmarks of checkboxes and radio
* buttons.
- *
+ *
* @author Kirill Grouchnikov
*/
public static class SimplisticSoftBorderReverseFillPainter extends
@@ -92,7 +92,7 @@ public Color getBottomFillColor(SubstanceColorScheme fillScheme) {
/**
* Paints border instance of specified dimensions and status.
- *
+ *
* @param c
* Component.
* @param graphics
@@ -139,7 +139,7 @@ public static void paintBorder(Component c, Graphics2D graphics, int x,
/**
* Paints border instance of specified dimensions and status.
- *
+ *
* @param c
* Component.
* @param graphics
@@ -243,7 +243,7 @@ public static void paintTextComponentBorder(JComponent c,
/**
* Retrieves check mark image.
- *
+ *
* @param dimension
* Check mark dimension.
* @param isEnabled
@@ -293,7 +293,7 @@ private static BufferedImage getCheckMark(int dimension, boolean isEnabled,
/**
* Returns arrow icon for the specified parameters.
- *
+ *
* @param fontSize
* Font size.
* @param direction
@@ -315,7 +315,7 @@ public static Icon getArrowIcon(int fontSize, int direction,
/**
* Retrieves arrow icon.
- *
+ *
* @param width
* Arrow width.
* @param height
@@ -340,7 +340,7 @@ public static Icon getArrowIcon(float width, float height,
/**
* Retrieves arrow image.
- *
+ *
* @param width
* Arrow width.
* @param height
@@ -433,7 +433,7 @@ public static BufferedImage getArrow(float width, float height,
/**
* Returns double arrow icon for the specified parameters.
- *
+ *
* @param fontSize
* Font size.
* @param deltaWidth
@@ -463,7 +463,7 @@ public static Icon getDoubleArrowIconDelta(int fontSize, float deltaWidth,
/**
* Retrieves arrow icon.
- *
+ *
* @param width
* Arrow width.
* @param height
@@ -533,7 +533,7 @@ public static Icon getDoubleArrowIcon(int fontSize, float width,
/**
* Returns rotated image.
- *
+ *
* @param bi
* Image to rotate.
* @param quadrantClockwise
@@ -576,7 +576,7 @@ public static BufferedImage getRotated(BufferedImage bi,
/**
* Returns rotated image.
- *
+ *
* @param bi
* Image to rotate.
* @param quadrantClockwise
@@ -619,7 +619,7 @@ public static VolatileImage getRotated(final VolatileImage bi,
/**
* Translated the specified icon to grey scale.
- *
+ *
* @param icon
* Icon.
* @return Greyscale version of the specified icon.
@@ -641,7 +641,7 @@ public static Icon toGreyscale(Icon icon) {
/**
* Makes the specified icon transparent.
- *
+ *
* @param c
* Component.
* @param icon
@@ -799,7 +799,7 @@ public static Icon makeTransparent(Component c, Icon icon, double alpha) {
/**
* Retrieves radio button of the specified size that matches the specified
* parameters.
- *
+ *
* @param component
* Component.
* @param dimension
@@ -877,8 +877,12 @@ public static BufferedImage getRadioButton(JComponent component,
Shape markOval = new Ellipse2D.Double(rc - radius, rc - radius,
2 * radius, 2 * radius);
+ // Avoid exception by making sure the alpha value is in the correct range.
+ // https://github.com/Insubstantial/insubstantial/issues/138
+ float alphaTimesVisibility = Math.max(0.0f, Math.min(1.0f, alpha * checkMarkVisibility));
+
graphics.setComposite(AlphaComposite.getInstance(
- AlphaComposite.SRC_OVER, alpha * checkMarkVisibility));
+ AlphaComposite.SRC_OVER, alphaTimesVisibility));
drawRadioMark(graphics, SubstanceColorUtilities.getMarkColor(
markColorScheme, !componentState.isDisabled()), markOval);
} else {
@@ -899,7 +903,7 @@ public static BufferedImage getRadioButton(JComponent component,
/**
* Draws radio mark.
- *
+ *
* @param graphics
* Graphics context.
* @param color
@@ -916,7 +920,7 @@ private static void drawRadioMark(Graphics2D graphics, Color color,
/**
* Retrieves check box of the specified size that matches the specified
* component state.
- *
+ *
* @param button
* Button for the check mark.
* @param dimension
@@ -1028,7 +1032,7 @@ public static BufferedImage getCheckBox(AbstractButton button,
*
* Combined together, the layers create the image for scrollbar track with
* continuation of the arrow increase and decrease buttons.
- *
+ *
* @param component
* Component.
* @param width
@@ -1083,7 +1087,7 @@ public static void paintCompositeRoundedBackground(JComponent component,
/**
* Overlays light-colored echo below the specified image.
- *
+ *
* @param image
* The input image.
* @param echoAlpha
@@ -1133,7 +1137,7 @@ private static BufferedImage overlayEcho(BufferedImage image,
/**
* Returns minimize
icon.
- *
+ *
* @param scheme
* Color scheme for the icon.
* @return Minimize
icon.
@@ -1146,7 +1150,7 @@ public static Icon getMinimizeIcon(SubstanceColorScheme scheme,
/**
* Returns minimize
icon.
- *
+ *
* @param iSize
* Icon dimension.
* @param scheme
@@ -1182,7 +1186,7 @@ public static Icon getMinimizeIcon(int iSize, SubstanceColorScheme scheme,
/**
* Returns restore
icon.
- *
+ *
* @param scheme
* Color scheme for the icon.
* @return Restore
icon.
@@ -1222,7 +1226,7 @@ public static Icon getRestoreIcon(SubstanceColorScheme scheme,
/**
* Returns maximize
icon.
- *
+ *
* @param scheme
* Color scheme for the icon.
* @return Maximize
icon.
@@ -1235,7 +1239,7 @@ public static Icon getMaximizeIcon(SubstanceColorScheme scheme,
/**
* Returns maximize
icon.
- *
+ *
* @param iSize
* Icon dimension.
* @param scheme
@@ -1271,7 +1275,7 @@ public static Icon getMaximizeIcon(int iSize, SubstanceColorScheme scheme,
/**
* Returns close
icon.
- *
+ *
* @param scheme
* Color scheme for the icon.
* @return Close
icon.
@@ -1285,7 +1289,7 @@ public static Icon getCloseIcon(SubstanceColorScheme scheme,
/**
* Returns close
icon.
- *
+ *
* @param iSize
* Icon dimension.
* @param colorScheme
@@ -1346,7 +1350,7 @@ public static Icon getCloseIcon(int iSize,
/**
* Paints rectangular gradient background.
- *
+ *
* @param g
* Graphic context.
* @param startX
@@ -1408,7 +1412,7 @@ public static void paintRectangularBackground(Component c, Graphics g,
/**
* Paints simple border.
- *
+ *
* @param g2d
* Graphics context.
* @param width
@@ -1472,7 +1476,7 @@ public static void paintSimpleBorderAliased(Component c, Graphics2D g2d,
/**
* Paints rectangular gradient background with spots and optional replicated
* stripe image.
- *
+ *
* @param g
* Graphics context.
* @param startX
@@ -1557,7 +1561,7 @@ public static void paintRectangularStripedBackground(Component c,
/**
* Returns diagonal stripe image.
- *
+ *
* @param baseSize
* Stripe base in pixels.
* @param color
@@ -1594,7 +1598,7 @@ public static BufferedImage getStripe(int baseSize, Color color) {
/**
* Returns drag bumps image.
- *
+ *
* @param c
* Component.
* @param colorScheme
@@ -1665,7 +1669,7 @@ public static BufferedImage getDragImage(Component c,
/**
* Paints the bump dots on the split pane dividers.
- *
+ *
* @param g
* Graphics context.
* @param divider
@@ -1739,7 +1743,7 @@ public static void paintSplitDividerBumpImage(Graphics g,
/**
* Returns resize grip image.
- *
+ *
* @param c
* Component.
* @param colorScheme
@@ -1801,7 +1805,7 @@ public static BufferedImage getResizeGripImage(Component c,
/**
* Retrieves tree icon.
- *
+ *
* @param tree
* Tree.
* @param fillScheme
@@ -1871,7 +1875,7 @@ public static BufferedImage getTreeIcon(JTree tree,
/**
* Retrieves a single crayon of the specified color and dimensions for the
* crayon panel in color chooser.
- *
+ *
* @param mainColor
* Crayon main color.
* @param width
@@ -2028,7 +2032,7 @@ public static BufferedImage getSingleCrayon(Color mainColor, int width,
/**
* Retrieves crayon X offset.
- *
+ *
* @param i
* Crayon index.
* @return Crayon X offset.
@@ -2039,7 +2043,7 @@ private static int crayonX(int i) {
/**
* Retrieves crayon Y offset.
- *
+ *
* @param i
* Crayon index.
* @return Crayon Y offset.
@@ -2050,7 +2054,7 @@ private static int crayonY(int i) {
/**
* Retrieves crayons image for the crayon panel of color chooser.
- *
+ *
* @return Crayons image.
*/
public static Image getCrayonsImage() {
@@ -2084,7 +2088,7 @@ public static Image getCrayonsImage() {
* Returns small icon representation of the specified integer value. The
* remainder of dividing the integer by 16 is translated to four circles
* arranged in 2*2 grid.
- *
+ *
* @param value
* Integer value to represent.
* @param colorScheme
@@ -2131,7 +2135,7 @@ public static Icon getHexaMarker(int value, SubstanceColorScheme colorScheme) {
/**
* Returns search icon.
- *
+ *
* @param dimension
* Icon dimension.
* @param colorScheme
@@ -2187,7 +2191,7 @@ public static Icon getSearchIcon(int dimension,
/**
* Returns an icon that matches the specified watermark.
- *
+ *
* @param watermark
* Watermark instance.
* @return Icon that matches the specified watermark.
@@ -2210,7 +2214,7 @@ public static Icon getWatermarkIcon(SubstanceWatermark watermark) {
/**
* Returns a lock icon that matches the specified scheme.
- *
+ *
* @param scheme
* Scheme instance.
* @return Lock icon that matches the specified scheme.
@@ -2286,7 +2290,7 @@ public static Icon getSmallLockIcon(SubstanceColorScheme scheme, Component c) {
/**
* Returns the negative of the specified image.
- *
+ *
* @param bi
* Image.
* @return The negative of the specified image.
@@ -2298,7 +2302,7 @@ public static BufferedImage getNegated(BufferedImage bi) {
/**
* Creates a new version of the specified icon that is rendered in the
* colors of the specified color scheme.
- *
+ *
* @param comp
* Component.
* @param original
@@ -2322,7 +2326,7 @@ public static BufferedImage getColorSchemeImage(Component comp,
/**
* Creates a new version of the specified image that is rendered in the
* colors of the specified color scheme.
- *
+ *
* @param original
* The original image.
* @param colorScheme