Example usage for javax.swing RepaintManager currentManager

List of usage examples for javax.swing RepaintManager currentManager

Introduction

In this page you can find the example usage for javax.swing RepaintManager currentManager.

Prototype

public static RepaintManager currentManager(JComponent c) 

Source Link

Document

Return the RepaintManager for the calling thread given a JComponent.

Usage

From source file:com.alvermont.terraj.util.io.PrintUtilities.java

/**
 * Enable double buffering for a component
 * /*from w w w  . j  av a 2  s  . c o m*/
 * @param c The component to enable double buffering for
 */
public static void enableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(true);
}

From source file:net.sf.maltcms.chromaui.ui.PaintScalePanel.java

@Override
public void stateChanged(ChangeEvent ce) {
    if (ce.getSource() == this.jSlider1 || ce.getSource() == this.jSlider2) {
        PaintScale psc = ((PaintScaleLabel) this.jLabel4).getPaintScale();
        if (psc instanceof GradientPaintScale) {
            ((GradientPaintScale) psc).setAlphaBeta(getAlpha(), getBeta());
            RepaintManager.currentManager(this.jLabel4).markCompletelyDirty(this.jLabel4);
        }/*  ww w .j a  v a 2  s . c om*/
    }

    //        System.out.println("Alpha value: " + getAlpha());
    //        System.out.println("Beta value: " + getBeta());
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.reporting.AnnotationReportCanvas.java

public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
    if (pageIndex > 0) {
        return NO_SUCH_PAGE;
    } else {//from www .  j a v a2s . c  om
        Graphics2D g2d = (Graphics2D) g;
        g2d.setBackground(Color.white);
        g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());

        Dimension td = this.getPreferredSize();
        double sx = pageFormat.getImageableWidth() / td.width;
        double sy = pageFormat.getImageableHeight() / td.height;
        double s = Math.min(sx, sy);
        if (s < 1.)
            g2d.scale(s, s);

        RepaintManager.currentManager(this).setDoubleBufferingEnabled(false);
        this.paint(g2d);
        RepaintManager.currentManager(this).setDoubleBufferingEnabled(true);

        return PAGE_EXISTS;
    }
}

From source file:MyJava3D.java

/**
 * It's possible to turn off double-buffering for just the repaint calls
 * invoked directly on the non double buffered component. This can be done
 * by overriding paintImmediately() (which is called as a result of repaint)
 * and getting the current RepaintManager and turning off double buffering
 * in the RepaintManager before calling super.paintImmediately(g).
 *//*  w w w .  j  av  a2 s .  c  om*/
public void paintImmediately(int x, int y, int w, int h) {
    RepaintManager repaintManager = null;
    boolean save = true;
    if (!isDoubleBuffered()) {
        repaintManager = RepaintManager.currentManager(this);
        save = repaintManager.isDoubleBufferingEnabled();
        repaintManager.setDoubleBufferingEnabled(false);
    }
    super.paintImmediately(x, y, w, h);

    if (repaintManager != null) {
        repaintManager.setDoubleBufferingEnabled(save);
    }
}

From source file:org.pentaho.reporting.engine.classic.core.util.ComponentDrawable.java

/**
 * A helper method that performs some cleanup and disconnects the component from the AWT and the Swing-Framework to
 * avoid memory-leaks./*from   w  ww. j av a  2 s .  com*/
 */
protected final void cleanUp() {
    if (component instanceof JComponent && isOwnPeerConnected() == false) {
        final JComponent jc = (JComponent) component;
        RepaintManager.currentManager(jc).removeInvalidComponent(jc);
        RepaintManager.currentManager(jc).markCompletelyClean(jc);
    }
    contentPane.removeAll();
    RepaintManager.currentManager(contentPane).removeInvalidComponent(contentPane);
    RepaintManager.currentManager(contentPane).markCompletelyClean(contentPane);
    peerSupply.dispose();
}

From source file:savant.debug.DebugRepaintManager.java

public DebugRepaintManager() {
    realManager = RepaintManager.currentManager(null);
}