/** * Returns the striped background for the specified component. This method * is relevant for components such as trees, tables and lists that use * odd-even striping for the alternating rows. * * @param component * Component. * @param rowIndex * Row index. * @return The striped background for the specified component. */ public static Color getStripedBackground(JComponent component, int rowIndex) { Color backgr = getBackgroundFillColor(component); if (backgr == null) return null; if (rowIndex % 2 == 0) return backgr; int r = backgr.getRed(); int g = backgr.getGreen(); int b = backgr.getBlue(); double coef = 0.96; if (!component.isEnabled()) coef = 1.0 - (1.0 - coef) / 2.0; Color darkerColor = new ColorUIResource((int) (coef * r), (int) (coef * g), (int) (coef * b)); return darkerColor; }
/** * Returns the striped background for the specified component. This method * is relevant for components such as trees, tables and lists that use * odd-even striping for the alternating rows. * * @param component * Component. * @param rowIndex * Row index. * @return The striped background for the specified component. */ public static Color getStripedBackground(JComponent component, int rowIndex) { Color backgr = getBackgroundFillColor(component); if (backgr == null) return null; if (rowIndex % 2 == 0) return backgr; int r = backgr.getRed(); int g = backgr.getGreen(); int b = backgr.getBlue(); double coef = 0.96; if (!component.isEnabled()) coef = 1.0 - (1.0 - coef) / 2.0; Color darkerColor = new ColorUIResource((int) (coef * r), (int) (coef * g), (int) (coef * b)); return darkerColor; }
@Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Color shadowColor = SubstanceColorUtilities .getBackgroundFillColor(comp).darker(); // need to handle components "embedded" in other components Component c = comp; Component topMostWithSameDecorationAreaType = c; while (c != null) { if (DecorationPainterUtils.getImmediateDecorationType(c) == decorationAreaType) { topMostWithSameDecorationAreaType = c; } c = c.getParent(); } Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), topMostWithSameDecorationAreaType); int dy = inTopMost.y; Graphics2D g2d = (Graphics2D) graphics.create(); g2d.translate(0, -dy); g2d.setPaint(new GradientPaint(0, 0, SubstanceColorUtilities .getAlphaColor(shadowColor, 160), 0, 4, SubstanceColorUtilities .getAlphaColor(shadowColor, 16))); g2d.fillRect(0, 0, comp.getWidth(), 4); g2d.dispose(); }
@Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Color shadowColor = SubstanceColorUtilities .getBackgroundFillColor(comp).darker(); // need to handle components "embedded" in other components Component topMostWithSameDecorationAreaType = SubstancePainterUtils .getTopMostParentWithDecorationAreaType(comp, decorationAreaType); Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), topMostWithSameDecorationAreaType); int dy = inTopMost.y; Graphics2D g2d = (Graphics2D) graphics.create(); g2d.translate(0, -dy); g2d.setPaint(new GradientPaint(0, 0, SubstanceColorUtilities .getAlphaColor(shadowColor, 160), 0, 4, SubstanceColorUtilities .getAlphaColor(shadowColor, 16))); g2d.fillRect(0, 0, comp.getWidth(), 4); g2d.dispose(); }
@Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Color shadowColor = SubstanceColorUtilities .getBackgroundFillColor(comp).darker(); Component topMostWithSameDecorationAreaType = SubstancePainterUtils .getTopMostParentWithDecorationAreaType(comp, decorationAreaType); int topHeight = topMostWithSameDecorationAreaType.getHeight(); Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), topMostWithSameDecorationAreaType); int dy = inTopMost.y; Graphics2D fillGraphics = (Graphics2D) graphics.create(); fillGraphics.translate(0, -dy); int shadowHeight = 4; GradientPaint fillPaint = new GradientPaint(0, topHeight - shadowHeight, SubstanceColorUtilities .getAlphaColor(shadowColor, 0), 0, topHeight, SubstanceColorUtilities.getAlphaColor(shadowColor, 128)); fillGraphics.setPaint(fillPaint); fillGraphics.fillRect(0, topHeight - shadowHeight, width, shadowHeight); fillGraphics.dispose(); }
@Override protected void installDefaults(JPanel p) { super.installDefaults(p); // support for per-window skins Color backgr = p.getBackground(); if ((backgr == null) || (backgr instanceof UIResource)) { Color backgroundFillColor = SubstanceColorUtilities .getBackgroundFillColor(p); // fix for issue 436 - logic in getBackground() of // custom panels can result in null value if (backgroundFillColor != null) { p.setBackground(new ColorUIResource(backgroundFillColor)); } } }
@Override protected void installDefaults(JPanel p) { super.installDefaults(p); // support for per-window skins Color backgr = p.getBackground(); if ((backgr == null) || (backgr instanceof UIResource)) { Color backgroundFillColor = SubstanceColorUtilities .getBackgroundFillColor(p); // fix for issue 436 - logic in getBackground() of // custom panels can result in null value if (backgroundFillColor != null) { p.setBackground(new ColorUIResource(backgroundFillColor)); } } }
.getBackgroundFillColor(menuComponent); fgColor = SubstanceColorUtilities.getInterpolatedColor(fgColor, bgFillColor, textAlpha);
.getBackgroundFillColor(menuItem); fgColor = SubstanceColorUtilities.getInterpolatedColor(fgColor, bgFillColor, textAlpha);
@Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Color shadowColor = SubstanceColorUtilities .getBackgroundFillColor(comp).darker(); Component c = comp; Component topMostWithSameDecorationAreaType = c; while (c != null) { if (DecorationPainterUtils.getImmediateDecorationType(c) == decorationAreaType) { topMostWithSameDecorationAreaType = c; } c = c.getParent(); } int topHeight = topMostWithSameDecorationAreaType.getHeight(); Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), topMostWithSameDecorationAreaType); int dy = inTopMost.y; Graphics2D fillGraphics = (Graphics2D) graphics.create(); fillGraphics.translate(0, -dy); int shadowHeight = 4; GradientPaint fillPaint = new GradientPaint(0, topHeight - shadowHeight, SubstanceColorUtilities .getAlphaColor(shadowColor, 0), 0, topHeight, SubstanceColorUtilities.getAlphaColor(shadowColor, 128)); fillGraphics.setPaint(fillPaint); fillGraphics.fillRect(0, topHeight - shadowHeight, width, shadowHeight); fillGraphics.dispose(); }
@Override protected void installDefaults(JComponent c) { super.installDefaults(c); // support for per-window skins Color backgr = c.getBackground(); if ((backgr == null) || (backgr instanceof UIResource)) { Color backgroundFillColor = SubstanceColorUtilities .getBackgroundFillColor(c); if (backgroundFillColor != null) { c.setBackground(new ColorUIResource(backgroundFillColor)); } } }
@Override protected void installDefaults(JRootPane c) { super.installDefaults(c); // support for per-window skins Color backgr = c.getBackground(); if ((backgr == null) || (backgr instanceof UIResource)) { Color backgroundFillColor = SubstanceColorUtilities .getBackgroundFillColor(c); // fix for issue 244 - set the root pane BG color if (backgroundFillColor != null) { c.setBackground(new ColorUIResource(backgroundFillColor)); } } }
@Override protected void installDefaults(JComponent c) { super.installDefaults(c); // support for per-window skins Color backgr = c.getBackground(); if ((backgr == null) || (backgr instanceof UIResource)) { Color backgroundFillColor = SubstanceColorUtilities .getBackgroundFillColor(c); if (backgroundFillColor != null) { c.setBackground(new ColorUIResource(backgroundFillColor)); } } }
@Override protected void installDefaults(JRootPane c) { super.installDefaults(c); // support for per-window skins Color backgr = c.getBackground(); if ((backgr == null) || (backgr instanceof UIResource)) { Color backgroundFillColor = SubstanceColorUtilities .getBackgroundFillColor(c); // fix for issue 244 - set the root pane BG color if (backgroundFillColor != null) { c.setBackground(new ColorUIResource(backgroundFillColor)); } } }
.getBackgroundFillColor(component); fgColor = SubstanceColorUtilities.getInterpolatedColor(fgColor, bgFillColor, textAlpha);
.getBackgroundFillColor(component); fgColor = SubstanceColorUtilities.getInterpolatedColor(fgColor, bgFillColor, textAlpha);
.getBackgroundFillColor(component); fgColor = SubstanceColorUtilities.getInterpolatedColor(fgColor, bgFillColor, textAlpha);
.getBackgroundFillColor(component); if (bgFillColor != null) { fgColor = SubstanceColorUtilities.getInterpolatedColor(fgColor,
public static Color getTextBackgroundFillColor(JComponent comp) { Color backgroundFillColor = SubstanceColorUtilities .getBackgroundFillColor(comp); JTextComponent componentForTransitions = SubstanceCoreUtilities .getTextComponentForTransitions(comp); if (componentForTransitions != null) { ComponentUI ui = componentForTransitions.getUI(); if (ui instanceof TransitionAwareUI) { TransitionAwareUI trackable = (TransitionAwareUI) ui; StateTransitionTracker stateTransitionTracker = trackable .getTransitionTracker(); Color outerTextComponentBorderColor = SubstanceColorUtilities .getOuterTextComponentBorderColor(backgroundFillColor); outerTextComponentBorderColor = SubstanceColorUtilities .getInterpolatedColor(outerTextComponentBorderColor, backgroundFillColor, 0.6); float selectionStrength = stateTransitionTracker .getFacetStrength(ComponentStateFacet.SELECTION); float rolloverStrength = stateTransitionTracker .getFacetStrength(ComponentStateFacet.ROLLOVER); backgroundFillColor = SubstanceColorUtilities .getInterpolatedColor(outerTextComponentBorderColor, backgroundFillColor, Math.max( selectionStrength, rolloverStrength)); } } return backgroundFillColor; }
public static Color getTextBackgroundFillColor(JComponent comp) { Color backgroundFillColor = SubstanceColorUtilities .getBackgroundFillColor(comp); JTextComponent componentForTransitions = SubstanceCoreUtilities .getTextComponentForTransitions(comp); if (componentForTransitions != null) { ComponentUI ui = componentForTransitions.getUI(); if (ui instanceof TransitionAwareUI) { TransitionAwareUI trackable = (TransitionAwareUI) ui; StateTransitionTracker stateTransitionTracker = trackable .getTransitionTracker(); Color outerTextComponentBorderColor = SubstanceColorUtilities .getOuterTextComponentBorderColor(backgroundFillColor); outerTextComponentBorderColor = SubstanceColorUtilities .getInterpolatedColor(outerTextComponentBorderColor, backgroundFillColor, 0.6); float selectionStrength = stateTransitionTracker .getFacetStrength(ComponentStateFacet.SELECTION); float rolloverStrength = stateTransitionTracker .getFacetStrength(ComponentStateFacet.ROLLOVER); backgroundFillColor = SubstanceColorUtilities .getInterpolatedColor(outerTextComponentBorderColor, backgroundFillColor, Math.max( selectionStrength, rolloverStrength)); } } return backgroundFillColor; }