/** * Returns the immediate decoration area type of the specified component. * The component is checked for the registered decoration area type. If * {@link #setDecorationType(javax.swing.JComponent, DecorationAreaType)} was * not called on this component, this method returns <code>null</code>. * * @param comp * Component. * @return Immediate decoration area type of the component. */ public static DecorationAreaType getImmediateDecorationType(Component comp) { return DecorationPainterUtils.getImmediateDecorationType(comp); }
/** * Returns the immediate decoration area type of the specified component. * The component is checked for the registered decoration area type. If * {@link #setDecorationType(JComponent, DecorationAreaType, boolean)} was * not called on this component, this method returns <code>null</code>. * * @param comp * Component. * @return Immediate decoration area type of the component. */ public static DecorationAreaType getImmediateDecorationType(Component comp) { return DecorationPainterUtils.getImmediateDecorationType(comp); }
public static Component getTopMostParentWithDecorationAreaType( Component comp, DecorationAreaType type) { Component c = comp; Component topMostWithSameDecorationAreaType = c; while (c != null) { if (DecorationPainterUtils.getImmediateDecorationType(c) == type) { topMostWithSameDecorationAreaType = c; } c = c.getParent(); } return topMostWithSameDecorationAreaType; } }
@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(); 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 public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { 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; int fontSize = SubstanceSizeUtils.getComponentFontSize(comp); float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(fontSize); graphics.setStroke(new BasicStroke(borderStrokeWidth)); SubstanceColorScheme colorScheme = // skin.getColorScheme(comp, // ColorSchemeAssociationKind.SEPARATOR, ComponentState.DEFAULT); // colorScheme = skin.getBackgroundColorScheme(decorationAreaType); graphics.setColor(this.colorSchemeQuery.query(colorScheme)); graphics.drawLine(0, topMostWithSameDecorationAreaType.getHeight() - (int) borderStrokeWidth, width, topMostWithSameDecorationAreaType.getHeight() - (int) borderStrokeWidth); }
@Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { 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; int fontSize = SubstanceSizeUtils.getComponentFontSize(comp); float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(fontSize); graphics.setStroke(new BasicStroke(borderStrokeWidth)); SubstanceColorScheme colorScheme = skin .getBackgroundColorScheme(decorationAreaType); // skin.getColorScheme(comp, // ColorSchemeAssociationKind.SEPARATOR, ComponentState.DEFAULT); graphics.setColor(this.colorSchemeQuery.query(colorScheme)); graphics.drawLine(0, (int) borderStrokeWidth - dy - 1, width, (int) borderStrokeWidth - dy - 1); }
@Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { 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; int fontSize = SubstanceSizeUtils.getComponentFontSize(comp); float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(fontSize); graphics.setStroke(new BasicStroke(borderStrokeWidth)); SubstanceColorScheme colorScheme = skin .getBackgroundColorScheme(decorationAreaType); // skin.getColorScheme(comp, // ColorSchemeAssociationKind.SEPARATOR, ComponentState.DEFAULT); graphics.setColor(this.colorSchemeQueryTop.query(colorScheme)); graphics.drawLine(0, (int) (borderStrokeWidth) - dy - 1, width, (int) (borderStrokeWidth) - dy - 1); graphics.setColor(this.colorSchemeQueryBottom.query(colorScheme)); graphics.drawLine(0, (int) (2 * borderStrokeWidth) - dy - 1, width, (int) (2 * borderStrokeWidth) - dy - 1); }