Java Code Examples for org.pushingpixels.substance.api.ComponentState#DISABLED_UNSELECTED
The following examples show how to use
org.pushingpixels.substance.api.ComponentState#DISABLED_UNSELECTED .
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: SubstanceColorUtilities.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static Color getBackgroundFillColorScrollBar(JScrollBar scrollbar) { ComponentState state = scrollbar.isEnabled() ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED; Color backgr = SubstanceColorUtilities.getDefaultBackgroundColor( scrollbar, state); if (state.isDisabled()) { float alpha = SubstanceColorSchemeUtilities.getAlpha(scrollbar, state); if (alpha < 1.0f) { Color defaultColor = SubstanceColorUtilities .getDefaultBackgroundColor(scrollbar, ComponentState.ENABLED); backgr = SubstanceColorUtilities.getInterpolatedColor( backgr, defaultColor, 1.0f - (1.0f - alpha) / 2.0f); } } SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities.getColorScheme(scrollbar, state); float factor = colorScheme.isDark() ? 0.98f : 0.9f; backgr = SubstanceColorUtilities.getInterpolatedColor(backgr, SubstanceColorUtilities.getAlphaColor(colorScheme.getForegroundColor(), backgr.getAlpha()), factor); return backgr; }
Example 2
Source File: SubstanceTableHeaderUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the grid color for the table header. * * @param header * Table header. * @return Grid color. */ protected static Color getGridColor(JTableHeader header) { boolean isEnabled = header.isEnabled(); if (header.getTable() != null) { // fix for issue 472 - handle standalone table headers isEnabled = isEnabled && header.getTable().isEnabled(); } ComponentState currState = isEnabled ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED; Color gridColor = SubstanceCoreUtilities.getSkin(header).getOverlayColor( SubstanceSlices.ColorOverlayType.LINE, DecorationPainterUtils.getDecorationType(header), currState); if (gridColor == null) { gridColor = SubstanceColorSchemeUtilities.getColorScheme( header, ColorSchemeAssociationKind.BORDER, currState).getLineColor(); } return gridColor; }
Example 3
Source File: ListPanel.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel result = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); result.setForeground(list.getForeground()); int comp = 156 + 10 * (index % 9); int blue = 255 - (255 - comp) / 2; this.setBackground( isSelected ? list.getSelectionBackground() : new Color(comp, comp, blue)); ModelEntry entry = (ModelEntry) value; // mark every fifth row as disabled if ((index % 5) == 0) { result.setEnabled(false); ComponentState state = isSelected ? ComponentState.DISABLED_SELECTED : ComponentState.DISABLED_UNSELECTED; result.setForeground(SubstanceCortex.ComponentScope.getCurrentSkin(list) .getColorScheme(list, state).getForegroundColor()); result.setBackground(new Color(255, 196, 196)); result.setText(entry.text + " [disabled by renderer]"); } else { result.setEnabled(true); result.setText(entry.text); } if (showIcons) { result.setIcon(entry.icon); } else { result.setIcon(null); } return result; }
Example 4
Source File: SubstanceIconFactory.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Retrieves icon that matches the specified state of the tree. */ private static ImageWrapperIcon getIcon(JTree tree, boolean isCollapsed) { ComponentState state = ((tree == null) || tree.isEnabled()) ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED; SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities.getColorScheme(tree, state); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities.getColorScheme(tree, ColorSchemeAssociationKind.BORDER, state); SubstanceColorScheme markScheme = SubstanceColorSchemeUtilities.getColorScheme(tree, ColorSchemeAssociationKind.MARK, state); int fontSize = SubstanceSizeUtils.getComponentFontSize(tree); HashMapKey key = SubstanceCoreUtilities.getHashKey(fontSize, fillScheme.getDisplayName(), borderScheme.getDisplayName(), markScheme.getDisplayName(), isCollapsed); ImageWrapperIcon result = TreeIcon.icons.get(key); if (result != null) return result; result = new ImageWrapperIcon(SubstanceImageCreator.getTreeIcon(tree, fillScheme, borderScheme, markScheme, isCollapsed)); TreeIcon.icons.put(key, result); return result; }
Example 5
Source File: SubstanceTableHeaderUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void update(Graphics g, JComponent c) { // fix for issue 175 - table header under resize mode off // was painted in color scheme-agnostic (gray) color. boolean isEnabled = this.header.isEnabled(); if (this.header.getTable() != null) { // fix for issue 472 - handle standalone table headers isEnabled = isEnabled && this.header.getTable().isEnabled(); } ComponentState backgroundState = isEnabled ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED; // fix for issue 360 - respect the clip bounds of the // table header Rectangle clip = g.getClipBounds(); if (clip == null) clip = c.getBounds(); // do not use the highlight scheme for painting the // table header background SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities.getColorScheme(c, backgroundState); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities.getColorScheme(c, ColorSchemeAssociationKind.HIGHLIGHT_BORDER, backgroundState); HighlightPainterUtils.paintHighlight(g, null, c, clip, 0.0f, null, fillScheme, borderScheme); Graphics2D g2d = (Graphics2D) g.create(); NeonCortex.installDesktopHints(g2d, c.getFont()); paint(g2d, c); g2d.dispose(); }
Example 6
Source File: SubstanceTableHeaderUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g.create(); // System.err.println("Painting " + this.hashCode() + " from " // + ((header == null) ? "null" : header.hashCode())); boolean ltr = header.getComponentOrientation().isLeftToRight(); final ComponentState backgroundState = (header.isEnabled() && header.getTable().isEnabled()) ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED; SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities.getColorScheme( this.header, ColorSchemeAssociationKind.HIGHLIGHT, backgroundState); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities.getColorScheme( this.header, ColorSchemeAssociationKind.HIGHLIGHT_BORDER, backgroundState); HighlightPainterUtils.paintHighlight(g2d, null, this.header, new Rectangle(0, 0, this.getWidth(), this.getHeight()), 0.0f, null, fillScheme, borderScheme); g2d.setColor(getGridColor(this.header)); float strokeWidth = SubstanceSizeUtils.getBorderStrokeWidth(); g2d.setStroke( new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setComposite(WidgetUtilities.getAlphaComposite(this.header, 0.7f, g)); int x = ltr ? (int) strokeWidth / 2 : getWidth() - 1 - (int) strokeWidth / 2; g2d.drawLine(x, 0, x, getHeight()); g2d.dispose(); }
Example 7
Source File: SubstancePasswordFieldUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Draws the echo character(s) for a single password field character. The number of echo * characters is defined by * {@link org.pushingpixels.substance.internal.SubstanceSynapse#PASSWORD_ECHO_PER_CHAR} * client property. * * @param g Graphics context * @param x X coordinate of the first echo character to draw. * @param y Y coordinate of the first echo character to draw. * @param c Password field. * @param isSelected Indicates whether the password field character is selected. * @return The X location of the next echo character. * @see org.pushingpixels.substance.internal.SubstanceSynapse#PASSWORD_ECHO_PER_CHAR */ private float drawEchoCharacter(Graphics g, float x, float y, char c, boolean isSelected) { Container container = this.getContainer(); Graphics2D graphics = (Graphics2D) g; graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); JPasswordField field = (JPasswordField) container; int fontSize = SubstanceSizeUtils.getComponentFontSize(this.field); int dotDiameter = SubstanceSizeUtils.getPasswordDotDiameter(fontSize); int dotGap = SubstanceSizeUtils.getPasswordDotGap(fontSize); ComponentState state = field.isEnabled() ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED; SubstanceColorScheme scheme = SubstanceColorSchemeUtilities.getColorScheme(field, state); Color color = isSelected ? scheme.getSelectionForegroundColor() : SubstanceColorUtilities.getForegroundColor(scheme); graphics.setColor(color); int echoPerChar = SubstanceCoreUtilities.getEchoPerChar(field); for (int i = 0; i < echoPerChar; i++) { graphics.fillOval((int) (x + dotGap / 2), (int) (y - dotDiameter), dotDiameter, dotDiameter); x += (dotDiameter + dotGap); } return x; }
Example 8
Source File: KeyTipRenderingUtilities.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static void renderKeyTip(Graphics g, Container c, Rectangle rect, String keyTip, boolean toPaintEnabled) { SubstanceFillPainter fillPainter = SubstanceCoreUtilities.getFillPainter(c); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(c); ComponentState state = toPaintEnabled ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED; float alpha = SubstanceColorSchemeUtilities.getAlpha(c, state); SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities .getColorScheme(c, state); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(c, SubstanceSlices.ColorSchemeAssociationKind.BORDER, state); float radius = SubstanceSizeUtils.getClassicButtonCornerRadius( SubstanceSizeUtils.getComponentFontSize(c)); float borderDelta = SubstanceSizeUtils.getBorderStrokeWidth() / 2.0f; Graphics2D g2d = (Graphics2D) g.create(); g2d.setComposite(WidgetUtilities.getAlphaComposite(c, alpha, g)); g2d.translate(rect.x, rect.y); Shape contour = SubstanceOutlineUtilities.getBaseOutline(rect.width, rect.height, radius, null, borderDelta); fillPainter.paintContourBackground(g2d, c, rect.width, rect.height, contour, false, fillScheme, true); float borderThickness = SubstanceSizeUtils.getBorderStrokeWidth(); Shape contourInner = SubstanceOutlineUtilities.getBaseOutline(rect.width, rect.height, radius, null, borderDelta + borderThickness); borderPainter.paintBorder(g2d, c, rect.width, rect.height, contour, contourInner, borderScheme); g2d.setColor(SubstanceColorSchemeUtilities.getColorScheme(c, state).getForegroundColor()); Font font = SubstanceCortex.GlobalScope.getFontPolicy().getFontSet(). getControlFont(); font = font.deriveFont(font.getSize() + 1.0f); g2d.setFont(font); int strWidth = g2d.getFontMetrics().stringWidth(keyTip); LineMetrics lineMetrics = g2d.getFontMetrics().getLineMetrics(keyTip, g2d); int strHeight = (int) lineMetrics.getHeight(); NeonCortex.installDesktopHints(g2d, font); g2d.drawString(keyTip, (rect.width - strWidth) / 2, (rect.height + strHeight) / 2 - g2d.getFontMetrics().getDescent()); g2d.dispose(); }
Example 9
Source File: SubstanceBorder.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Paints border instance for the specified component. * * @param c * The component. * @param g * Graphics context. * @param x * Component left X (in graphics context). * @param y * Component top Y (in graphics context). * @param width * Component width. * @param height * Component height. * @param isEnabled * Component enabled status. * @param hasFocus * Component focus ownership status. * @param alpha * Alpha value. */ private void paintBorder(Component c, Graphics g, int x, int y, int width, int height, boolean isEnabled, boolean hasFocus, float alpha) { // failsafe for LAF change if (!SubstanceCoreUtilities.isCurrentLookAndFeel()) { return; } if ((width <= 0) || (height <= 0)) return; if (alpha == 0.0f) { return; } Graphics2D graphics = (Graphics2D) g.create(); float radius = this.radiusScaleFactor * SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(c)); ComponentState state = isEnabled ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED; SubstanceColorScheme borderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(c, ColorSchemeAssociationKind.BORDER, state); float finalAlpha = alpha * SubstanceColorSchemeUtilities.getAlpha(c, state); graphics.setComposite(WidgetUtilities.getAlphaComposite(c, finalAlpha, g)); if (width * height < 100000) { HashMapKey hashKey = SubstanceCoreUtilities.getHashKey( SubstanceCoreUtilities.getBorderPainter(c).getDisplayName(), SubstanceSizeUtils.getComponentFontSize(c), width, height, radius, borderColorScheme.getDisplayName()); BufferedImage result = smallImageCache.get(hashKey); if (result == null) { result = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D g2d = result.createGraphics(); SubstanceImageCreator.paintBorder(c, g2d, 0, 0, width, height, radius, borderColorScheme); g2d.dispose(); smallImageCache.put(hashKey, result); } NeonCortex.drawImage(graphics, result, x, y); } else { // for borders larger than 100000 pixels, use simple // painting graphics.translate(x, y); SubstanceImageCreator.paintSimpleBorder(c, graphics, width, height, borderColorScheme); } graphics.dispose(); }
Example 10
Source File: SubstanceColorUtilities.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Returns the foreground text color of the specified component. * * @param component Component. * @param modelStateInfo Component model state info. * @return The foreground text color of the specified component. */ public static Color getForegroundColor(Component component, StateTransitionTracker.ModelStateInfo modelStateInfo) { ComponentState currState = modelStateInfo.getCurrModelState(); Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo.getStateContributionMap(); // special case for enabled buttons with no background - // always use the color scheme for the default state. if (component instanceof AbstractButton) { AbstractButton button = (AbstractButton) component; if (SubstanceCoreUtilities.isButtonNeverPainted(button) || !button.isContentAreaFilled() || (button instanceof JRadioButton) || (button instanceof JCheckBox)) { if (!currState.isDisabled()) { currState = ComponentState.ENABLED; activeStates = null; } else { currState = ComponentState.DISABLED_UNSELECTED; activeStates = null; } } } SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(component, currState); if (currState.isDisabled() || (activeStates == null) || (activeStates.size() == 1)) { return colorScheme.getForegroundColor(); } float aggrRed = 0; float aggrGreen = 0; float aggrBlue = 0; for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates.entrySet()) { ComponentState activeState = activeEntry.getKey(); float alpha = activeEntry.getValue().getContribution(); SubstanceColorScheme activeColorScheme = SubstanceColorSchemeUtilities .getColorScheme(component, activeState); Color activeForeground = activeColorScheme.getForegroundColor(); aggrRed += alpha * activeForeground.getRed(); aggrGreen += alpha * activeForeground.getGreen(); aggrBlue += alpha * activeForeground.getBlue(); } return new Color((int) aggrRed, (int) aggrGreen, (int) aggrBlue); }
Example 11
Source File: SubstanceLabelUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void paint(Graphics g, JComponent c) { JLabel label = (JLabel) c; String text = label.getText(); Icon icon; Icon themedIcon = null; float rolloverAmount = 0.0f; if (label.isEnabled()) { icon = label.getIcon(); if ((icon != null) && SubstanceCoreUtilities.useThemedDefaultIcon(label)) { if (label instanceof ThemedIconAwareRenderer) { ThemedIconAwareRenderer themedIconAwareRenderer = (ThemedIconAwareRenderer) label; rolloverAmount = themedIconAwareRenderer.getRolloverArmAmount(); themedIcon = SubstanceCoreUtilities.getThemedIcon(c, icon); } else { icon = SubstanceCoreUtilities.getThemedIcon(c, icon); } } } else { icon = label.getDisabledIcon(); } if ((icon == null) && (text == null)) { return; } Insets insets = label.getInsets(paintViewInsets); paintViewR.x = insets.left; paintViewR.y = insets.top; paintViewR.width = c.getWidth() - (insets.left + insets.right); paintViewR.height = c.getHeight() - (insets.top + insets.bottom); paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0; paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0; g.setFont(label.getFont()); String clippedText = SwingUtilities.layoutCompoundLabel(label, g.getFontMetrics(), text, icon, label.getVerticalAlignment(), label.getHorizontalAlignment(), label.getVerticalTextPosition(), label.getHorizontalTextPosition(), paintViewR, paintIconR, paintTextR, label.getIconTextGap()); Graphics2D g2d = (Graphics2D) g.create(); BackgroundPaintingUtils.updateIfOpaque(g2d, c); if (icon != null) { g2d.translate(paintIconR.x, paintIconR.y); if (themedIcon != null) { if (rolloverAmount > 0) { themedIcon.paintIcon(c, g2d, 0, 0); g2d.setComposite(WidgetUtilities.getAlphaComposite(c, rolloverAmount, g)); icon.paintIcon(c, g2d, 0, 0); g2d.setComposite(WidgetUtilities.getAlphaComposite(c, g)); } else { themedIcon.paintIcon(c, g2d, 0, 0); } } else { icon.paintIcon(c, g2d, 0, 0); } g2d.translate(-paintIconR.x, -paintIconR.y); } ComponentState labelState = label.isEnabled() ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED; float labelAlpha = SubstanceColorSchemeUtilities.getAlpha(label, labelState); if (text != null) { final View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g2d, paintTextR); } else { if (label.getClientProperty(SubstanceSynapse.IS_TITLE_PANE_LABEL) == Boolean.TRUE) { SubstanceSkin skin = SubstanceCoreUtilities.getSkin(label.getRootPane()); SubstanceColorScheme scheme = skin .getEnabledColorScheme(SubstanceSlices.DecorationAreaType.PRIMARY_TITLE_PANE); SubstanceColorScheme fillScheme = skin .getBackgroundColorScheme(SubstanceSlices.DecorationAreaType.PRIMARY_TITLE_PANE); Color echoColor = !scheme.isDark() ? fillScheme.getUltraDarkColor() : fillScheme.getUltraLightColor(); FontMetrics fm = SubstanceMetricsUtilities.getFontMetrics(label.getFont()); int yOffset = paintTextR.y + (int) ((paintTextR.getHeight() - fm.getHeight()) / 2) + fm.getAscent(); g2d.translate(paintTextR.x + 3, 0); SubstanceTextUtilities.paintTextWithDropShadow(label, g2d, SubstanceColorUtilities.getForegroundColor(scheme), echoColor, clippedText, paintTextR.width + 6, paintTextR.height, 0, yOffset); } else { // fix for issue 406 - use the same FG computation // color as for other controls SubstanceTextUtilities.paintText(g2d, label, paintTextR, clippedText, label.getDisplayedMnemonicIndex(), labelState, labelAlpha); } } } g2d.dispose(); }
Example 12
Source File: SubstanceProgressBarUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
private ComponentState getFillState() { return progressBar.isEnabled() ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED; }