Java Code Examples for org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities#getBlankImage()
The following examples show how to use
org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities#getBlankImage() .
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: 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 2
Source File: ImageWrapperDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns a colorized image tile. * * @param scheme * Color scheme for the colorization. * @return Colorized tile. */ protected BufferedImage getColorizedTile(SubstanceColorScheme scheme) { BufferedImage result = this.colorizedTileMap.get(scheme.getDisplayName()); if (result == null) { float scaleFactor = (float) NeonCortex.getScaleFactor(); int tileWidth = this.originalTile.getWidth(null); int tileHeight = this.originalTile.getHeight(null); BufferedImage tileBi = SubstanceCoreUtilities.getBlankImage((int) (tileWidth / scaleFactor), (int) (tileHeight / scaleFactor)); Graphics2D tile2D = tileBi.createGraphics(); tile2D.drawImage(this.originalTile, 0, 0, (int) (tileWidth / scaleFactor), (int) ( tileHeight / scaleFactor), null); tile2D.dispose(); result = SubstanceImageCreator.getColorSchemeImage(tileBi, scheme, 0.0f); this.colorizedTileMap.put(scheme.getDisplayName(), result); } return result; }
Example 3
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 4
Source File: SubstanceFileChooserUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Icon getIcon(File f) { Icon icon = getCachedIcon(f); if (icon != null) { return icon; } icon = getDefaultIcon(f); // System.out.println("System : " + f.getAbsolutePath() + " --> " // + icon); if (icon == null) { icon = super.getIcon(f); if (icon == null) { icon = new ImageIcon(SubstanceCoreUtilities.getBlankImage(8, 8)); } // System.out.println("Super : " + f.getAbsolutePath() + " --> " // + icon); } cacheIcon(f, icon); return icon; }
Example 5
Source File: GhostPaintingUtils.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns a scaled ghost image of the specified component. * * @param comp * Component. * @param scaleFactor * Scale factor. * @return A scaled ghost image of the specified component. */ protected static synchronized BufferedImage getComponentGhostImage(JComponent comp, Timeline ghostPressTimeline, double scaleFactor) { String key = ghostPressTimeline.getTimelinePosition() + ":" + comp.hashCode() + ":" + scaleFactor; BufferedImage result = componentGhostCache.get(key); if (result == null) { Rectangle bounds = comp.getBounds(); double iWidth = bounds.width * scaleFactor; double iHeight = bounds.height * scaleFactor; result = SubstanceCoreUtilities.getBlankImage((int) iWidth, (int) iHeight); Graphics2D iGraphics = result.createGraphics(); iGraphics.scale(scaleFactor, scaleFactor); comp.paint(iGraphics); iGraphics.dispose(); componentGhostCache.put(key, result); } return result; }
Example 6
Source File: GhostPaintingUtils.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns a scaled ghost image of the specified icon. * * @param comp * Component. * @param icon * Icon. * @param scaleFactor * Scale factor. * @return A scaled ghost image of the specified icon. */ protected static synchronized BufferedImage getIconGhostImage(JComponent comp, Timeline ghostRolloverTimeline, Icon icon, double scaleFactor) { String key = ghostRolloverTimeline.getTimelinePosition() + ":" + comp.hashCode() + ":" + icon.hashCode() + ":" + scaleFactor; BufferedImage result = iconGhostCache.get(key); if (result == null) { int oWidth = icon.getIconWidth(); int oHeight = icon.getIconHeight(); double iWidth = oWidth * scaleFactor; double iHeight = oHeight * scaleFactor; result = SubstanceCoreUtilities.getBlankImage((int) iWidth, (int) iHeight); Graphics2D iGraphics = result.createGraphics(); iGraphics.scale(scaleFactor, scaleFactor); icon.paintIcon(comp, iGraphics, 0, 0); iGraphics.dispose(); iconGhostCache.put(key, result); } return result; }
Example 7
Source File: JRibbonFrame.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static Image getImage(ResizableIcon.Factory iconFactory, int size) { ResizableIcon icon = iconFactory.createNewIcon(); icon.setDimension(new Dimension(size, size)); if (icon instanceof AsynchronousLoading) { AsynchronousLoading async = (AsynchronousLoading) icon; if (async.isLoading()) { final CountDownLatch latch = new CountDownLatch(1); final boolean[] status = new boolean[1]; AsynchronousLoadListener all = (boolean success) -> { status[0] = success; latch.countDown(); }; async.addAsynchronousLoadListener(all); try { latch.await(); } catch (InterruptedException ie) { } async.removeAsynchronousLoadListener(all); if (!status[0]) { return null; } if (async.isLoading()) { return null; } } } Image result = SubstanceCoreUtilities.getBlankImage(size, size); Graphics2D g2d = (Graphics2D) result.getGraphics().create(); icon.paintIcon(null, g2d, 0, 0); g2d.dispose(); return result; }
Example 8
Source File: DefaultPreviewPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void previewComponent(Container parent, Component component, int componentIndex, Graphics g, int x, int y, int w, int h) { if (component == null) return; int compWidth = component.getWidth(); int compHeight = component.getHeight(); if ((compWidth > 0) && (compHeight > 0)) { // draw component BufferedImage tempCanvas = SubstanceCoreUtilities.getBlankImage(compWidth, compHeight); Graphics tempCanvasGraphics = tempCanvas.getGraphics(); component.paint(tempCanvasGraphics); double scaleFactor = NeonCortex.getScaleFactor(); // check if need to scale down double coef = Math.min((double) w / (double) compWidth, (double) h / (double) compHeight) / scaleFactor; if (coef < 1.0) { int sdWidth = (int) (coef * compWidth); int sdHeight = (int) (coef * compHeight); int dx = x + ((int) (w / scaleFactor) - sdWidth) / 2; int dy = y + ((int) (h / scaleFactor) - sdHeight) / 2; BufferedImage thumbnail = NeonCortex.createThumbnail(tempCanvas, sdWidth); g.drawImage(thumbnail, dx, dy, (int) (thumbnail.getWidth() / scaleFactor), (int) (thumbnail.getHeight() / scaleFactor), null); } else { g.drawImage(tempCanvas, x, y, null); } } }
Example 9
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 10
Source File: ColorWheel.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void paintComponent(Graphics g) { int w = getWidth(); int h = getHeight(); double scaleFactor = NeonCortex.getScaleFactor(); if (colorWheelImage == null || (scaleFactor * colorWheelImage.getWidth(this)) != w || (scaleFactor * colorWheelImage.getHeight(this)) != h) { if (colorWheelImage != null) { colorWheelImage.flush(); } colorWheelProducer = new ColorWheelImageProducer((int) (w * scaleFactor), (int) (h * scaleFactor)); colorWheelImage = createImage(colorWheelProducer); if (scaleFactor > 1) { BufferedImage retinaWheelImage = SubstanceCoreUtilities.getBlankImage(w, h); Graphics2D wheel2D = retinaWheelImage.createGraphics(); wheel2D.drawImage(colorWheelImage, 0, 0, w, h, null); wheel2D.dispose(); colorWheelImage = retinaWheelImage; } } colorWheelProducer.setBrightness(model.getValue(2) / 100f); colorWheelProducer.regenerateColorWheel(); g.drawImage(colorWheelImage, 0, 0, (int) (colorWheelImage.getWidth(null) / scaleFactor), (int) (colorWheelImage.getHeight(null) / scaleFactor), this); int x = w / 2 + (int) (colorWheelProducer.getRadius() * model.getValue(1) / 100d * Math.cos(model.getValue(0) * Math.PI / 180d)); int y = h / 2 - (int) (colorWheelProducer.getRadius() * model.getValue(1) / 100d * Math.sin(model.getValue(0) * Math.PI / 180d)); g.setColor(Color.white); g.fillRect(x - 1, y - 1, 2, 2); g.setColor(Color.black); g.drawRect(x - 2, y - 2, 3, 3); }
Example 11
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 12
Source File: ArcDecorationPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Paints the title background. * * @param graphics * Graphics context. * @param comp * Component. * @param width * Width. * @param height * Height. * @param scheme * Color scheme for painting the title background. */ private void paintTitleBackground(Graphics2D graphics, Component comp, int width, int height, SubstanceColorScheme scheme) { // System.out.println(scheme.getDisplayName()); // create rectangular background and later draw it on // result image with contour clip. BufferedImage rectangular = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D rgraphics = (Graphics2D) rectangular.getGraphics(); // Fill background GeneralPath clipTop = new GeneralPath(); clipTop.moveTo(0, 0); clipTop.lineTo(width, 0); clipTop.lineTo(width, height / 2); clipTop.quadTo(width / 2, height / 4, 0, height / 2); clipTop.lineTo(0, 0); rgraphics.setClip(clipTop); LinearGradientPaint gradientTop = new LinearGradientPaint(0, 0, width, 0, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] { scheme.getLightColor(), scheme.getUltraLightColor(), scheme.getLightColor() }, CycleMethod.REPEAT); rgraphics.setPaint(gradientTop); rgraphics.fillRect(0, 0, width, height); GeneralPath clipBottom = new GeneralPath(); clipBottom.moveTo(0, height); clipBottom.lineTo(width, height); clipBottom.lineTo(width, height / 2); clipBottom.quadTo(width / 2, height / 4, 0, height / 2); clipBottom.lineTo(0, height); rgraphics.setClip(clipBottom); LinearGradientPaint gradientBottom = new LinearGradientPaint(0, 0, width, 0, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] { scheme.getMidColor(), scheme.getLightColor(), scheme.getMidColor() }, CycleMethod.REPEAT); rgraphics.setPaint(gradientBottom); rgraphics.fillRect(0, 0, width, height); GeneralPath mid = new GeneralPath(); mid.moveTo(width, height / 2); mid.quadTo(width / 2, height / 4, 0, height / 2); // rgraphics.setClip(new Rectangle(0, 0, width / 2, height)); // rgraphics // .setClip(new Rectangle(width / 2, 0, width - width / 2, height)); rgraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rgraphics.setClip(new Rectangle(0, 0, width, height)); rgraphics.draw(mid); graphics.drawImage(rectangular, 0, 0, width, height, null); }
Example 13
Source File: ScrollPaneSelector.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void display(Point aPointOnScreen) { if (theComponent == null) { return; } PreviewPainter previewPainter = WidgetUtilities.getComponentPreviewPainter(theScrollPane); if (!previewPainter.hasPreview(theComponent.getParent(), theComponent, 0)) { return; } Dimension pDimension = previewPainter.getPreviewWindowDimension(theComponent.getParent(), theComponent, 0); double compWidth = theComponent.getWidth(); double compHeight = theComponent.getHeight(); double scaleX = pDimension.getWidth() / compWidth; double scaleY = pDimension.getHeight() / compHeight; theScale = Math.min(scaleX, scaleY); int previewWidth = (int) (theComponent.getWidth() * theScale); int previewHeight = (int) (theComponent.getHeight() * theScale); theImage = SubstanceCoreUtilities.getBlankImage(previewWidth, previewHeight); Graphics2D g = theImage.createGraphics(); previewPainter.previewComponent(null, theComponent, 0, g, 0, 0, theImage.getWidth(), theImage.getHeight()); g.dispose(); theStartRectangle = theComponent.getVisibleRect(); Insets insets = getInsets(); theStartRectangle.x = (int) (theScale * theStartRectangle.x + insets.left); theStartRectangle.y = (int) (theScale * theStartRectangle.y + insets.right); theStartRectangle.width *= theScale; theStartRectangle.height *= theScale; theRectangle = theStartRectangle; Dimension pref = thePopupMenu.getPreferredSize(); Point buttonLocation = theButton.getLocationOnScreen(); Point popupLocation = new Point((theButton.getWidth() - pref.width) / 2, (theButton.getHeight() - pref.height) / 2); Point centerPoint = new Point( buttonLocation.x + popupLocation.x + theRectangle.x + theRectangle.width / 2, buttonLocation.y + popupLocation.y + theRectangle.y + theRectangle.height / 2); try { // Attempt to move the mouse pointer to the center of the selector's // rectangle. new Robot().mouseMove(centerPoint.x, centerPoint.y); theStartPoint = centerPoint; } catch (Exception e) { // Since we cannot move the cursor, we'll move the popup instead. theStartPoint = aPointOnScreen; popupLocation.x += theStartPoint.x - centerPoint.x; popupLocation.y += theStartPoint.y - centerPoint.y; } thePrevPoint = new Point(theStartPoint); toRestoreOriginal = true; thePopupMenu.show(theButton, popupLocation.x, popupLocation.y); }
Example 14
Source File: WaveDelegateFillPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void paintContourBackground(Graphics g, Component comp, float width, float height, Shape contour, boolean isFocused, SubstanceColorScheme fillScheme, boolean hasShine) { GeneralPath clipBottom = new GeneralPath(); clipBottom.moveTo(0, height); clipBottom.lineTo(width, height); clipBottom.lineTo(width, 0); clipBottom.curveTo(5 * width / 6, height / 3, 3 * width / 4, height / 2, width / 2, height / 2); clipBottom.curveTo(width / 3, height / 2, width / 4, height, 0, 7 * height / 8); clipBottom.lineTo(0, height); int iWidth = (int) Math.ceil(width); int iHeight = (int) Math.ceil(height); BufferedImage clipShapeBottom = SubstanceCoreUtilities.softClip(iWidth, iHeight, null, clipBottom); BufferedImage bottomImage = SubstanceCoreUtilities.getBlankImage(iWidth, iHeight); Graphics2D bottomGraphics = (Graphics2D) bottomImage.getGraphics(); bottomGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); SubstanceColorScheme bottomColorScheme = (this.transformation == null) ? fillScheme : this.transformation.transform(fillScheme); // Render our clip shape into the image. Note that we enable // antialiasing to achieve the soft clipping effect. Try // commenting out the line that enables antialiasing, and // you will see that you end up with the usual hard clipping. bottomGraphics.setComposite(AlphaComposite.Src); bottomGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); bottomGraphics.drawImage(clipShapeBottom, 0, 0, null); // Here's the trick... We use SrcAtop, which effectively uses the // alpha value as a coverage value for each pixel stored in the // destination. For the areas outside our clip shape, the destination // alpha will be zero, so nothing is rendered in those areas. For // the areas inside our clip shape, the destination alpha will be fully // opaque, so the full color is rendered. At the edges, the original // antialiasing is carried over to give us the desired soft clipping // effect. bottomGraphics.setComposite(AlphaComposite.SrcAtop); this.delegate.paintContourBackground(bottomGraphics, comp, width, height, contour, isFocused, bottomColorScheme, hasShine); // bottomGraphics.drawImage(bottomFullImage, 0, 0, null); BufferedImage image = SubstanceCoreUtilities.getBlankImage(iWidth, iHeight); Graphics2D graphics = (Graphics2D) image.getGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setClip(contour); this.delegate.paintContourBackground(graphics, comp, width, height, contour, isFocused, fillScheme, hasShine); // graphics.drawImage(topFullImage, 0, 0, null); graphics.drawImage(bottomImage, 0, 0, null); graphics.setClip(null); }
Example 15
Source File: WaveFillPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void paintContourBackground(Graphics g, Component comp, float width, float height, Shape contour, boolean isFocused, SubstanceColorScheme fillScheme, boolean hasShine) { int iWidth = (int) Math.ceil(width); int iHeight = (int) Math.ceil(height); // create rectangular background and later draw it on // result image with contour clip. BufferedImage rectangular = SubstanceCoreUtilities.getBlankImage(iWidth, iHeight); Graphics2D rgraphics = (Graphics2D) rectangular.getGraphics(); Color lightFillColor = fillScheme.getUltraLightColor(); Color midFillColor = fillScheme.getLightColor(); Color darkFillColor = fillScheme.getMidColor(); // Fill background GradientPaint gradientTop = new GradientPaint(0, 0, lightFillColor, width / 4, height / 2, midFillColor); GeneralPath clipTop = new GeneralPath(); clipTop.moveTo(0, 0); clipTop.lineTo(width, 0); clipTop.curveTo(5 * width / 6, height / 3, 3 * width / 4, height / 2, width / 2, height / 2); clipTop.curveTo(width / 3, height / 2, width / 4, height, 0, 7 * height / 8); clipTop.lineTo(0, 0); rgraphics.setClip(clipTop); rgraphics.setPaint(gradientTop); rgraphics.fillRect(0, 0, iWidth, iHeight); GradientPaint gradientBottom = new GradientPaint(2 * width / 3, 2 * height / 3, darkFillColor, width, height, midFillColor); GeneralPath clipBottom = new GeneralPath(); clipBottom.moveTo(0, height); clipBottom.lineTo(width, height); clipBottom.lineTo(width, 0); clipBottom.curveTo(5 * width / 6, height / 3, 3 * width / 4, height / 2, width / 2, height / 2); clipBottom.curveTo(width / 3, height / 2, width / 4, height, 0, 7 * height / 8); clipBottom.lineTo(0, height); rgraphics.setClip(clipBottom); rgraphics.setPaint(gradientBottom); rgraphics.fillRect(0, 0, iWidth, iHeight); rgraphics.setClip(null); GeneralPath mid = new GeneralPath(); mid.moveTo(width, 0); mid.curveTo(5 * width / 6, height / 3, 3 * width / 4, height / 2, width / 2, height / 2); mid.curveTo(width / 3, height / 2, width / 4, height, 0, 7 * height / 8); rgraphics.draw(mid); Graphics2D graphics = (Graphics2D) g.create(); graphics.setClip(contour); graphics.drawImage(rectangular, 0, 0, null); graphics.dispose(); }