org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities Java Examples
The following examples show how to use
org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities.
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: LockBorderWidget.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Checks whether the specified component should show a lock icon. Is used in the * {@link LockBorderWidget} widget. * * @param comp * Component. * @return <code>true</code> if the specified component should show a lock icon, * <code>false</code> otherwise. */ private static boolean hasLockIcon(Component comp) { if (!SubstanceCoreUtilities.toShowExtraWidgets(comp)) return false; // Skip password fields if (comp instanceof JPasswordField) { return false; } // check the HAS_LOCK_ICON property boolean isEditableTextComponent = (comp instanceof JTextComponent) ? ((JTextComponent) comp).isEditable() : false; if (comp instanceof JComponent) { if (!isEditableTextComponent && Boolean.TRUE .equals(((JComponent) comp).getClientProperty(SubstanceSynapse.HAS_LOCK_ICON))) return true; if (Boolean.FALSE .equals(((JComponent) comp).getClientProperty(SubstanceSynapse.HAS_LOCK_ICON))) return false; } if (!isEditableTextComponent && Boolean.TRUE.equals(UIManager.get(SubstanceSynapse.HAS_LOCK_ICON))) return true; return false; }
Example #2
Source File: SubstanceFileChooserUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void installIcons(JFileChooser fc) { super.installIcons(fc); SubstanceIconPack iconPack = SubstanceCortex.GlobalScope.getIconPack(); SubstanceColorScheme colorScheme = SubstanceCoreUtilities.getSkin(fc) .getEnabledColorScheme(DecorationAreaType.NONE); directoryIcon = iconPack.getFileChooserDirectoryIcon(ICON_SIZE, colorScheme); fileIcon = iconPack.getFileChooserFileIcon(ICON_SIZE, colorScheme); computerIcon = iconPack.getFileChooserComputerIcon(ICON_SIZE, colorScheme); hardDriveIcon = iconPack.getFileChooserHardDriveIcon(ICON_SIZE, colorScheme); floppyDriveIcon = iconPack.getFileChooserFloppyDriveIcon(ICON_SIZE, colorScheme); newFolderIcon = iconPack.getFileChooserNewFolderIcon(ICON_SIZE, colorScheme); upFolderIcon = iconPack.getFileChooserUpFolderIcon(ICON_SIZE, colorScheme); homeFolderIcon = iconPack.getFileChooserHomeFolderIcon(ICON_SIZE, colorScheme); detailsViewIcon = iconPack.getFileChooserDetailsViewIcon(ICON_SIZE, colorScheme); listViewIcon = iconPack.getFileChooserListViewIcon(ICON_SIZE, colorScheme); viewMenuIcon = iconPack.getFileChooserViewMenuIcon(ICON_SIZE, colorScheme); }
Example #3
Source File: SubstanceDesktopIconUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void installDefaults() { super.installDefaults(); Font f = this.desktopIcon.getFont(); if ((f == null) || (f instanceof UIResource)) { this.desktopIcon.setFont(UIManager.getFont("DesktopIcon.font")); } this.width = UIManager.getInt("DesktopIcon.width"); this.desktopIcon.setBackground( SubstanceCoreUtilities.getBackgroundFill( SubstanceCoreUtilities.getSkin(this.desktopIcon.getInternalFrame()), DecorationAreaType.SECONDARY_TITLE_PANE)); // SubstanceCoreUtilities.getSkin(this.desktopIcon.getInternalFrame()). // getBackgroundColorScheme(DecorationAreaType.SECONDARY_TITLE_PANE) // .getBackgroundFillColor()); for (SubstanceWidget lafWidget : this.lafWidgets) { lafWidget.installDefaults(); } }
Example #4
Source File: SubstanceStripeWatermark.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public boolean updateWatermarkImage(SubstanceSkin skin) { // fix by Chris for bug 67 - support for multiple screens Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); } int screenWidth = virtualBounds.width; int screenHeight = virtualBounds.height; SubstanceStripeWatermark.watermarkImage = SubstanceCoreUtilities .getBlankImage(screenWidth, screenHeight); Graphics2D graphics = SubstanceStripeWatermark.watermarkImage.createGraphics(); boolean status = this.drawWatermarkImage(skin, graphics, 0, 0, screenWidth, screenHeight, false); graphics.dispose(); return status; }
Example #5
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 #6
Source File: SubstanceColorSelectorPanelUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void paintBottomDivider(Graphics g, int x, int y, int width, int height) { Color borderColor = SubstanceCoreUtilities.getSkin(this.colorSelectorPanel).getOverlayColor( SubstanceSlices.ColorOverlayType.LINE, DecorationPainterUtils.getDecorationType(this.colorSelectorPanel), ComponentState.ENABLED); if (borderColor == null) { SubstanceColorScheme bgBorderScheme = SubstanceColorSchemeUtilities.getColorScheme( this.colorSelectorPanel, ColorSchemeAssociationKind.HIGHLIGHT_BORDER, ComponentState.ENABLED); borderColor = bgBorderScheme.getLineColor(); } float lineThickness = SubstanceSizeUtils.getBorderStrokeWidth(); Graphics2D g2d = (Graphics2D) g.create(); g2d.setStroke(new BasicStroke(lineThickness)); g2d.setColor(borderColor); float lineY = y + height - lineThickness; g2d.draw(new Line2D.Float(x, lineY, x + width, lineY)); g2d.dispose(); }
Example #7
Source File: BasicPopupPanelUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Installs listeners on the associated command popup menu. */ protected void installListeners() { initiliazeGlobalListeners(); this.awtEventListener = (AWTEvent event) -> { if (event instanceof MouseEvent) { MouseEvent me = (MouseEvent) event; if (me.getID() == MouseEvent.MOUSE_PRESSED) { Component src = me.getComponent(); for (Component c = src; c != null; c = c.getParent()) { if (c instanceof Window) { break; } else if (c instanceof JPopupPanel) { return; } } PopupPanelManager.defaultManager().hidePopups(null); } } }; SubstanceCoreUtilities.registerAWTEventListener(this.awtEventListener); }
Example #8
Source File: SubstanceFileChooserUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the default file icon. * * @param f * File. * @return File icon. */ public Icon getDefaultIcon(File f) { JFileChooser fileChooser = getFileChooser(); Icon icon = fileChooser.getFileSystemView().getSystemIcon(f); if (icon instanceof ResizableIconUIResource) { SubstanceIconPack iconPack = SubstanceCortex.GlobalScope.getIconPack(); SubstanceColorScheme colorScheme = SubstanceCoreUtilities.getSkin(fileChooser) .getEnabledColorScheme(DecorationAreaType.NONE); icon = f.isDirectory() ? iconPack.getFileChooserDirectoryIcon(ICON_SIZE, colorScheme) : iconPack.getFileChooserFileIcon(ICON_SIZE, colorScheme); } if (SubstanceCoreUtilities.useThemedDefaultIcon(null)) { icon = SubstanceCoreUtilities.getThemedIcon(fileChooser, icon); } return icon; }
Example #9
Source File: TopShadowOverlayPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Color shadowColor = SubstanceColorUtilities.deriveByBrightness( SubstanceColorUtilities.getBackgroundFillColor(comp), -0.4f); // need to handle components "embedded" in other components Component topMostWithSameDecorationAreaType = SubstanceCoreUtilities .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, this.startAlpha), 0, 4, SubstanceColorUtilities.getAlphaColor(shadowColor, 16))); g2d.fillRect(0, 0, comp.getWidth(), 4); g2d.dispose(); }
Example #10
Source File: FractionBasedDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void paintDecoratedBackground(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceColorScheme scheme) { Graphics2D g2d = (Graphics2D) graphics.create(); Color[] fillColors = new Color[this.fractions.length]; for (int i = 0; i < this.fractions.length; i++) { ColorSchemeSingleColorQuery colorQuery = this.colorQueries[i]; fillColors[i] = colorQuery.query(scheme); } Component topMostWithSameDecorationAreaType = SubstanceCoreUtilities .getTopMostParentWithDecorationAreaType(comp, decorationAreaType); Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), topMostWithSameDecorationAreaType); int dy = inTopMost.y; MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, topMostWithSameDecorationAreaType.getHeight(), this.fractions, fillColors, CycleMethod.REPEAT); g2d.setPaint(gradient); g2d.translate(0, -dy); g2d.fillRect(0, 0, width, topMostWithSameDecorationAreaType.getHeight()); g2d.dispose(); }
Example #11
Source File: FractionBasedDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void paintDecoratedBackground(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, Shape contour, SubstanceColorScheme scheme) { Graphics2D g2d = (Graphics2D) graphics.create(); Color[] fillColors = new Color[this.fractions.length]; for (int i = 0; i < this.fractions.length; i++) { ColorSchemeSingleColorQuery colorQuery = this.colorQueries[i]; fillColors[i] = colorQuery.query(scheme); } Component topMostWithSameDecorationAreaType = SubstanceCoreUtilities .getTopMostParentWithDecorationAreaType(comp, decorationAreaType); Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), topMostWithSameDecorationAreaType); int dy = inTopMost.y; MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, topMostWithSameDecorationAreaType.getHeight(), this.fractions, fillColors, CycleMethod.REPEAT); g2d.setPaint(gradient); g2d.translate(0, -dy); g2d.fill(contour); g2d.dispose(); }
Example #12
Source File: ArcDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Paints the background of non-title decoration areas. * * @param graphics * Graphics context. * @param parent * Component ancestor for computing the correct offset of the background painting. * @param comp * Component. * @param width * Width. * @param height * Height. * @param scheme * Color scheme for painting the title background. */ private void paintExtraBackground(Graphics2D graphics, Container parent, Component comp, int width, int height, SubstanceColorScheme scheme) { Point offset = SubstanceCoreUtilities.getOffsetInRootPaneCoords(comp); JRootPane rootPane = SwingUtilities.getRootPane(parent); // fix for bug 234 - Window doesn't have a root pane. JLayeredPane layeredPane = rootPane.getLayeredPane(); Insets layeredPaneInsets = (layeredPane != null) ? layeredPane.getInsets() : null; int pWidth = (layeredPane == null) ? parent.getWidth() : layeredPane.getWidth() - layeredPaneInsets.left - layeredPaneInsets.right; if (pWidth != 0) { LinearGradientPaint gradientBottom = new LinearGradientPaint(-offset.x, 0, -offset.x + pWidth, 0, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] { scheme.getMidColor(), scheme.getLightColor(), scheme.getMidColor() }, CycleMethod.REPEAT); Graphics2D g2d = (Graphics2D) graphics.create(); g2d.setPaint(gradientBottom); g2d.fillRect(-offset.x, 0, pWidth, height); g2d.dispose(); } }
Example #13
Source File: MatteDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, Shape contour, SubstanceColorScheme colorScheme) { Point offset = SubstanceCoreUtilities.getOffsetInRootPaneCoords(comp); Color startColor = colorScheme.getLightColor(); Color endColor = SubstanceColorUtilities.getInterpolatedColor(startColor, colorScheme.getMidColor(), 0.4f); int gradientHeight = Math.max(FLEX_POINT, comp.getHeight() + offset.y); Paint paint = (gradientHeight == FLEX_POINT) ? new GradientPaint(0, -offset.y, startColor, 0, gradientHeight - offset.y, endColor) : new LinearGradientPaint( 0, -offset.y, 0, comp.getHeight() - offset.y, new float[] { 0.0f, (float) FLEX_POINT / (float) gradientHeight, 1.0f }, new Color[] { startColor, endColor, endColor }, MultipleGradientPaint.CycleMethod.NO_CYCLE); graphics.setPaint(paint); graphics.fill(contour); }
Example #14
Source File: ImageWrapperDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Paints the background of non-title decoration areas. * * @param graphics * Graphics context. * @param comp * Component. * @param decorationAreaType * Decoration area type. Must not be <code>null</code>. * @param width * Width. * @param height * Height. * @param skin * Skin for painting the background of non-title decoration areas. */ private void paintExtraBackground(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Point offset = SubstanceCoreUtilities.getOffsetInRootPaneCoords(comp); SubstanceColorScheme tileScheme = skin.getBackgroundColorScheme(decorationAreaType); if (this.baseDecorationPainter != null) { this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType, width, height, skin); } else { graphics.setColor(tileScheme.getMidColor()); graphics.fillRect(0, 0, width, height); } Graphics2D temp = (Graphics2D) graphics.create(); this.tileArea(temp, comp, tileScheme, offset.x, offset.y, width, height); temp.dispose(); }
Example #15
Source File: ImageWrapperDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, Shape contour, SubstanceColorScheme colorScheme) { Point offset = SubstanceCoreUtilities.getOffsetInRootPaneCoords(comp); if (this.baseDecorationPainter != null) { this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType, contour, colorScheme); } else { graphics.setColor(colorScheme.getMidColor()); graphics.fill(contour); } Graphics2D temp = (Graphics2D) graphics.create(); // Clip the area for tiling with the image. Ideally this would be done // with soft clipping (in SubstanceCoreUtilities), but that creates an // additional image. For now do hard clipping instead. temp.setClip(contour); this.tileArea(temp, comp, colorScheme, offset.x, offset.y, comp.getWidth(), comp.getHeight()); temp.dispose(); }
Example #16
Source File: ClassicDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { SubstanceColorScheme scheme = skin.getBackgroundColorScheme(decorationAreaType); if (width * height < 100000) { HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, scheme.getDisplayName()); BufferedImage result = smallImageCache.get(key); if (result == null) { result = SubstanceCoreUtilities.getBlankImage(width, height); this.internalPaint((Graphics2D) result.getGraphics(), comp, width, height, scheme); smallImageCache.put(key, result); } NeonCortex.drawImage(graphics, result, 0, 0); return; } this.internalPaint(graphics, comp, width, height, scheme); }
Example #17
Source File: SubstancePopupMenuBorder.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities.getColorScheme(c, ColorSchemeAssociationKind.BORDER, ComponentState.ENABLED); Graphics2D g2d = (Graphics2D) g.create(); float borderThickness = SubstanceSizeUtils.getBorderStrokeWidth(); float borderDelta = borderThickness / 2.0f; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g2d.setStroke( new BasicStroke(borderThickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); g2d.translate(x, y); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities.getBorderPainter(c); Color outline = borderPainter.getRepresentativeColor(borderScheme); g2d.setColor(outline); g2d.draw(new Rectangle2D.Float(borderDelta, borderDelta, width - borderThickness, height - borderThickness)); g2d.dispose(); }
Example #18
Source File: BasePolygonShaper.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Border getButtonBorder(final Dimension preferredSize) { return new SubstanceButtonBorder(this.getClass()) { public Insets getBorderInsets(Component c) { if (c instanceof AbstractButton) { AbstractButton button = (AbstractButton) c; if (SubstanceCoreUtilities.hasText(button)) { int width = preferredSize.width; int height = preferredSize.height; double finalWidth = width * (1.0 + leftCoef + rightCoef); double finalHeight = height * (1.0 + topCoef + bottomCoef); double finalRatio = finalWidth / finalHeight; int dx = 0; int dy = 0; if (finalRatio > canonicalPath.getRatio()) { // need dy dy = (int) (finalWidth / canonicalPath.getRatio() - finalHeight); } else { // need dx dx = (int) (canonicalPath.getRatio() * finalHeight - finalWidth); } return new Insets((int) (topCoef * height) + dy / 2, (int) (leftCoef * width) + dx / 2, (int) (bottomCoef * height) + dy / 2, (int) (rightCoef * width) + dx / 2); } } return new Insets(0, 0, 0, 0); } }; }
Example #19
Source File: JRibbonFrame.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@SuppressWarnings("deprecation") @Override public void hide() { SubstanceCoreUtilities.unregisterAWTEventListener(this.awtEventListener); KeyTipManager.defaultManager().removeKeyTipListener(this.keyTipListener); super.hide(); }
Example #20
Source File: DnDBorderFactory.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { int yh = y + height - 1; SubstanceIconPack iconPack = SubstanceCortex.GlobalScope.getIconPack(); SubstanceColorScheme colorScheme = SubstanceCoreUtilities.getSkin(c) .getEnabledColorScheme(ComponentOrParentChainScope.getDecorationType(c)); ResizableIcon icon = iconPack.getAllowedIcon(12, colorScheme); Graphics2D g2d = (Graphics2D) g.create(); g2d.translate(x, yh - icon.getIconHeight()); icon.paintIcon(c, g2d, 0, 0); yh -= 4; g.setColor(colorScheme.getForegroundColor()); g.drawLine(x + 16, yh, x + 40, yh); }
Example #21
Source File: GlowingIcon.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void paintIcon(Component c, Graphics g, int x, int y) { if (this.delegate == null) return; float fadePos = this.iconGlowTracker.getIconGlowPosition(); // System.out.println(fadePos); Icon toPaint = this.iconMap.get(fadePos); if (toPaint == null) { int width = this.getIconWidth(); int height = this.getIconHeight(); BufferedImage image = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D graphics = (Graphics2D) image.getGraphics(); //graphics.scale(1.0f / scale, 1.0f / scale); this.delegate.paintIcon(c, graphics, 0, 0); int pixelWidth = image.getWidth(); int pixelHeight = image.getHeight(); for (int i = 0; i < pixelWidth; i++) { for (int j = 0; j < pixelHeight; j++) { int rgba = image.getRGB(i, j); int transp = (rgba >>> 24) & 0xFF; double coef = Math.sin(2.0 * Math.PI * fadePos / 2.0) / glowDampeningFactor; Color newColor = (coef >= 0.0) ? SubstanceColorUtilities .getLighterColor(new Color(rgba), coef) : SubstanceColorUtilities.getDarkerColor(new Color( rgba), -coef); image.setRGB(i, j, (transp << 24) | (newColor.getRed() << 16) | (newColor.getGreen() << 8) | newColor.getBlue()); } } toPaint = new ImageWrapperIcon(image); this.iconMap.put(fadePos, toPaint); } Graphics2D g2d = (Graphics2D) g.create(); g2d.translate(x, y); toPaint.paintIcon(c, g, 0, 0); g2d.dispose(); }
Example #22
Source File: TabPreviewThread.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Computes and offers the preview thumbnail for a single tab. * * @param tabPane * Tabbed pane. * @param previewPainter * Tab preview painter. * @param previewInfo * Preview info. * @param tabIndex * Index of the tab to preview. */ protected void getSingleTabPreviewImage(final JTabbedPane tabPane, final TabPreviewPainter previewPainter, final TabPreviewInfo previewInfo, final int tabIndex) { int pWidth = previewInfo.getPreviewWidth(); int pHeight = previewInfo.getPreviewHeight(); final BufferedImage previewImage = SubstanceCoreUtilities.getBlankImage(pWidth, pHeight); Component comp = tabPane.getComponentAt(tabIndex); if (previewPainter.hasPreview(tabPane, tabIndex)) { Map<Component, Boolean> dbSnapshot = new HashMap<>(); WidgetUtilities.makePreviewable(comp, dbSnapshot); previewPainter.previewTab(tabPane, tabIndex, previewImage, 0, 0, pWidth, pHeight); WidgetUtilities.restorePreviewable(comp, dbSnapshot); } else { Graphics2D gr = previewImage.createGraphics(); gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); gr.setColor(Color.red); gr.setStroke(new BasicStroke(Math.max(5.0f, Math.min(pWidth, pHeight) / 10.0f))); gr.drawLine(0, 0, pWidth, pHeight); gr.drawLine(0, pHeight, pWidth, 0); gr.dispose(); } if (previewInfo.previewCallback != null) { SwingUtilities.invokeLater(() -> previewInfo.previewCallback.offer(tabPane, tabIndex, previewImage)); } }
Example #23
Source File: FlatDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { graphics.setColor(SubstanceCoreUtilities.getBackgroundFill( skin, DecorationAreaType.PRIMARY_TITLE_PANE)); // skin.getBackgroundColorScheme(DecorationAreaType.PRIMARY_TITLE_PANE) // .getBackgroundFillColor()); graphics.fillRect(0, 0, width, height); }
Example #24
Source File: SubstanceToolBarUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void update(Graphics g, JComponent c) { boolean isOpaque = SubstanceCoreUtilities.isOpaque(c); if (isOpaque) { BackgroundPaintingUtils.update(g, c, false); } else { super.update(g, c); } GhostPaintingUtils.paintGhostImages(c, g); }
Example #25
Source File: BasePolygonShaper.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Shape getButtonOutline(AbstractButton button, float extraInsets, float width, float height, boolean isInner) { if (SubstanceCoreUtilities.hasText(button)) { return this.canonicalPath.getPath(width, height, extraInsets); } return SubstanceOutlineUtilities.getBaseOutline(width, height, 2, null, extraInsets); }
Example #26
Source File: SubstanceCheckBoxMenuItemUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); JCheckBoxMenuItem item = (JCheckBoxMenuItem) comp; // add rollover listener item.setRolloverEnabled(true); return new SubstanceCheckBoxMenuItemUI((JCheckBoxMenuItem) comp); }
Example #27
Source File: ArcDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { if ((decorationAreaType == DecorationAreaType.PRIMARY_TITLE_PANE) || (decorationAreaType == DecorationAreaType.SECONDARY_TITLE_PANE)) { this.paintTitleBackground(graphics, comp, width, height, skin.getBackgroundColorScheme(decorationAreaType)); } else { this.paintExtraBackground(graphics, SubstanceCoreUtilities.getHeaderParent(comp), comp, width, height, skin.getBackgroundColorScheme(decorationAreaType)); } }
Example #28
Source File: SubstanceRibbonComponentUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void paintIcon(Graphics g, JRibbonComponent ribbonComp, Icon icon, int x, int y) { if (ribbonComp.isEnabled() && (icon != null) && SubstanceCoreUtilities.useThemedDefaultIcon(ribbonComp)) { icon = SubstanceCoreUtilities.getThemedIcon(ribbonComp, icon); } Graphics2D g2d = (Graphics2D) g.create(); g2d.translate(x, y); icon.paintIcon(ribbonComp, g2d, 0, 0); g2d.dispose(); }
Example #29
Source File: ScrollPaneSelectorWidget.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void installUI() { if (SubstanceCoreUtilities.toShowExtraWidgets(this.jcomp)) { PreviewPainter pPainter = WidgetUtilities.getComponentPreviewPainter(this.jcomp); if (pPainter == null) return; this.scrollPaneSelector = new ScrollPaneSelector(); this.scrollPaneSelector.installOnScrollPane(this.jcomp); } }
Example #30
Source File: BackgroundPaintingUtils.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Updates the background of the specified component on the specified * graphic context in the specified rectangle. * * @param g * Graphic context. * @param c * Component. * @param fillColor * Fill color. * @param rect * The rectangle to fill. */ public static void fillAndWatermark(Graphics g, JComponent c, Color fillColor, Rectangle rect) { // failsafe for LAF change if (!SubstanceCoreUtilities.isCurrentLookAndFeel()) { return; } boolean isInCellRenderer = (SwingUtilities.getAncestorOfClass( CellRendererPane.class, c) != null); if ((!c.isShowing()) && (!isInCellRenderer)) { return; } Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(WidgetUtilities.getAlphaComposite(c, g)); graphics.setColor(fillColor); graphics.fillRect(rect.x, rect.y, rect.width, rect.height); graphics.setComposite(WidgetUtilities.getAlphaComposite(c, 1.0f, g)); // stamp watermark SubstanceWatermark watermark = SubstanceCoreUtilities.getSkin(c).getWatermark(); if ((watermark != null) && !isInCellRenderer && c.isShowing() && SubstanceCoreUtilities.toDrawWatermark(c)) { watermark.drawWatermarkImage(graphics, c, rect.x, rect.y, rect.width, rect.height); } graphics.dispose(); }