Search in sources :

Example 1 with MattePainter

use of org.jdesktop.swingx.painter.MattePainter in project CodenameOne by codenameone.

the class BaseForm method setOverrideMode.

public synchronized void setOverrideMode(boolean overrideMode, java.awt.Component c) {
    RootPaneContainer r = (RootPaneContainer) SwingUtilities.windowForComponent(c);
    if (overrideMode) {
        if (overrideImage == null) {
            overrideImage = new ImageIcon(getClass().getResource("/override_stamp.png"));
        }
        PainterGlasspane pg = new PainterGlasspane();
        MattePainter matte = new MattePainter(new Color(0xcc, 0xcc, 0xcc, 120)) {

            protected void doPaint(java.awt.Graphics2D g, java.lang.Object component, int width, int height) {
                super.doPaint(g, component, width, height);
                overrideImage.paintIcon(BaseForm.this, g, 0, 0);
            // g.drawImage(overrideImage.getImage(), width / 2 - overrideImage.getIconWidth() / 2, 0, BaseForm.this);
            }
        };
        pg.setPainter(matte);
        pg.addTarget(this);
        r.setGlassPane(pg);
        pg.setBounds(0, 0, r.getContentPane().getWidth(), r.getContentPane().getHeight());
        pg.setVisible(true);
    } else {
        r.setGlassPane(new JLabel());
    }
}
Also used : MattePainter(org.jdesktop.swingx.painter.MattePainter) ImageIcon(javax.swing.ImageIcon) Color(java.awt.Color) RootPaneContainer(javax.swing.RootPaneContainer) JLabel(javax.swing.JLabel) PainterGlasspane(org.jdesktop.swingx.painter.PainterGlasspane) Graphics2D(java.awt.Graphics2D)

Example 2 with MattePainter

use of org.jdesktop.swingx.painter.MattePainter in project MtgDesktopCompanion by nicho92.

the class CardsPicPanel method initGUI.

private void initGUI() {
    renderer = new ReflectionRenderer();
    setBackgroundPainter(new MattePainter(PaintUtils.NIGHT_GRAY, true));
    GestionnaireEvenements interactionManager = new GestionnaireEvenements(this);
    this.addMouseListener(interactionManager);
    this.addMouseMotionListener(interactionManager);
    this.addMouseWheelListener(interactionManager);
    timer = new Timer(30, e -> {
        repaint();
        xScale += xDelta;
        if (xScale > 1 || xScale < -1) {
            xDelta *= -1;
        }
        if (loop > 0 && ((int) xScale == 1 || (int) xScale == -1)) {
            timer.stop();
            launched = false;
        }
        loop++;
    });
}
Also used : MattePainter(org.jdesktop.swingx.painter.MattePainter) MTGControler(org.magic.services.MTGControler) Rectangle2D(java.awt.geom.Rectangle2D) Point(java.awt.Point) RenderingHints(java.awt.RenderingHints) AlphaComposite(java.awt.AlphaComposite) AffineTransformOp(java.awt.image.AffineTransformOp) Graphics2D(java.awt.Graphics2D) MouseWheelEvent(java.awt.event.MouseWheelEvent) MouseAdapter(java.awt.event.MouseAdapter) BorderLayout(java.awt.BorderLayout) Timer(javax.swing.Timer) Shape(java.awt.Shape) MattePainter(org.jdesktop.swingx.painter.MattePainter) MTGLogger(org.magic.services.MTGLogger) PaintUtils(org.jdesktop.swingx.util.PaintUtils) BufferedImage(java.awt.image.BufferedImage) ReflectionRenderer(org.jdesktop.swingx.graphics.ReflectionRenderer) AffineTransform(java.awt.geom.AffineTransform) MouseEvent(java.awt.event.MouseEvent) JXPanel(org.jdesktop.swingx.JXPanel) MagicEdition(org.magic.api.beans.MagicEdition) ThreadManager(org.magic.services.ThreadManager) Graphics(java.awt.Graphics) MagicCard(org.magic.api.beans.MagicCard) BasicStroke(java.awt.BasicStroke) Timer(javax.swing.Timer) ReflectionRenderer(org.jdesktop.swingx.graphics.ReflectionRenderer)

Aggregations

Graphics2D (java.awt.Graphics2D)2 MattePainter (org.jdesktop.swingx.painter.MattePainter)2 AlphaComposite (java.awt.AlphaComposite)1 BasicStroke (java.awt.BasicStroke)1 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1 Graphics (java.awt.Graphics)1 Point (java.awt.Point)1 RenderingHints (java.awt.RenderingHints)1 Shape (java.awt.Shape)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 MouseWheelEvent (java.awt.event.MouseWheelEvent)1 AffineTransform (java.awt.geom.AffineTransform)1 Rectangle2D (java.awt.geom.Rectangle2D)1 AffineTransformOp (java.awt.image.AffineTransformOp)1 BufferedImage (java.awt.image.BufferedImage)1 ImageIcon (javax.swing.ImageIcon)1 JLabel (javax.swing.JLabel)1 RootPaneContainer (javax.swing.RootPaneContainer)1