Java Code Examples for org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities#isOpaque()

The following examples show how to use org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities#isOpaque() . 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: SubstanceDesktopPaneUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void update(Graphics g, JComponent c) {
	if (!c.isShowing()) {
		return;
	}
	Graphics2D graphics = (Graphics2D) g.create();
	graphics.setComposite(WidgetUtilities.getAlphaComposite(c, g));
	if (SubstanceCoreUtilities.isOpaque(c)) {
		// hack for JLayeredPane.paint() and JDesktopPane.isOpaque()
		Color back = c.getBackground();
		if (back instanceof UIResource) {
			graphics.setColor(UIManager.getColor("Panel.background"));
			graphics.fillRect(0, 0, c.getWidth(), c.getHeight());
		}
		BackgroundPaintingUtils.updateIfOpaque(graphics, c);
	}
	super.paint(graphics, c);
	GhostPaintingUtils.paintGhostImages(c, graphics);
	graphics.dispose();
}
 
Example 2
Source File: SubstanceToolBarUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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 3
Source File: SubstanceMenuBarUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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 4
Source File: SubstanceScrollPaneUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void update(Graphics g, JComponent c) {
    BackgroundPaintingUtils.updateIfOpaque(g, c);
    JScrollPane jsp = (JScrollPane) c;

    LayoutManager lm = jsp.getLayout();
    ScrollPaneLayout scrollLm = null;
    if (lm instanceof ScrollPaneLayout) {
        scrollLm = (ScrollPaneLayout) lm;
    }

    if (scrollLm != null) {
        Set<Component> corners = new HashSet<>();
        if (scrollLm.getCorner(ScrollPaneLayout.LOWER_LEFT_CORNER) != null) {
            corners.add(scrollLm.getCorner(ScrollPaneLayout.LOWER_LEFT_CORNER));
        }
        if (scrollLm.getCorner(ScrollPaneLayout.LOWER_RIGHT_CORNER) != null) {
            corners.add(scrollLm.getCorner(ScrollPaneLayout.LOWER_RIGHT_CORNER));
        }
        if (scrollLm.getCorner(ScrollPaneLayout.UPPER_LEFT_CORNER) != null) {
            corners.add(scrollLm.getCorner(ScrollPaneLayout.UPPER_LEFT_CORNER));
        }
        if (scrollLm.getCorner(ScrollPaneLayout.UPPER_RIGHT_CORNER) != null) {
            corners.add(scrollLm.getCorner(ScrollPaneLayout.UPPER_RIGHT_CORNER));
        }

        if (SubstanceCoreUtilities.isOpaque(c)) {
            Graphics2D g2d = (Graphics2D) g.create();
            g2d.setColor(SubstanceColorUtilities
                    .getBackgroundFillColorScrollBar(this.scrollpane.getVerticalScrollBar()));
            for (Component corner : corners) {
                g2d.fill(corner.getBounds());
                // BackgroundPaintingUtils.fillAndWatermark(g, c, c
                // .getBackground(), corner.getBounds());
            }

            JScrollBar horizontal = this.scrollpane.getHorizontalScrollBar();
            JScrollBar vertical = this.scrollpane.getVerticalScrollBar();
            if ((horizontal != null) && (vertical != null)) {
                if (this.scrollpane.getComponentOrientation().isLeftToRight()) {
                    // Bottom right corner
                    if (scrollLm.getCorner(ScrollPaneLayout.LOWER_RIGHT_CORNER) == null) {
                        g2d.fillRect(horizontal.getX() + horizontal.getWidth(),
                                horizontal.getY(), vertical.getWidth(), horizontal.getHeight());
                    }
                } else {
                    // Bottom left corner
                    if (scrollLm.getCorner(ScrollPaneLayout.LOWER_LEFT_CORNER) == null) {
                        g2d.fillRect(0, horizontal.getY(), vertical.getWidth(),
                                horizontal.getHeight());
                    }
                }
            }
        }
    }

    super.paint(g, c);
}
 
Example 5
Source File: SubstanceViewportUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Returns indication whether the viewport background should be filled.
 * 
 * @param c
 *            Component (should be {@link JViewport}).
 * @return <code>true</code> if the viewport background should be filled
 *         with the background color, <code>false</code> otherwise.
 */
private boolean toPaintBackground(JComponent c) {
	return SubstanceCoreUtilities.isOpaque(c);
}
 
Example 6
Source File: SubstancePanelUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Returns indication whether the panel background should be filled.
 * 
 * @param c
 *            Component (should be {@link JPanel}).
 * @return <code>true</code> if the panel background should be filled with
 *         the background color, <code>false</code> otherwise.
 */
private boolean toPaintBackground(JComponent c) {
	return SubstanceCoreUtilities.isOpaque(c);
}
 
Example 7
Source File: BackgroundPaintingUtils.java    From radiance with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Updates the background of the specified component on the specified
 * graphic context. The background is updated only if the component is
 * opaque.
 * 
 * @param g
 *            Graphic context.
 * @param c
 *            Component.
 */
public static void updateIfOpaque(Graphics g, JComponent c) {
	if (SubstanceCoreUtilities.isOpaque(c)) {
		update(g, c, false);
	}
}