Search in sources :

Example 1 with RepaintManager

use of javax.swing.RepaintManager in project smile by haifengl.

the class PlotPanel method print.

@Override
public int print(java.awt.Graphics g, PageFormat pf, int page) throws PrinterException {
    if (page > 0) {
        // We have only one page, and 'page' is zero-based
        return NO_SUCH_PAGE;
    }
    Graphics2D g2d = (Graphics2D) g;
    // User (0,0) is typically outside the imageable area, so we must
    // translate by the X and Y values in the PageFormat to avoid clipping
    g2d.translate(pf.getImageableX(), pf.getImageableY());
    // Scale plots to paper size.
    double scaleX = pf.getImageableWidth() / contentPane.getWidth();
    double scaleY = pf.getImageableHeight() / contentPane.getHeight();
    g2d.scale(scaleX, scaleY);
    // Disable double buffering
    RepaintManager currentManager = RepaintManager.currentManager(this);
    currentManager.setDoubleBufferingEnabled(false);
    // Now we perform our rendering
    contentPane.printAll(g);
    // Enable double buffering
    currentManager.setDoubleBufferingEnabled(true);
    // tell the caller that this page is part of the printed document
    return PAGE_EXISTS;
}
Also used : Graphics2D(java.awt.Graphics2D) RepaintManager(javax.swing.RepaintManager)

Example 2 with RepaintManager

use of javax.swing.RepaintManager in project adempiere by adempiere.

the class Env method updateUI.

//	sleep
/**
	 * Update all windows after look and feel changes.
	 * @since 2006-11-27 
	 */
public static Set<Window> updateUI() {
    Set<Window> updated = new HashSet<Window>();
    for (Container c : s_windows) {
        Window w = getFrame(c);
        if (w == null)
            continue;
        if (updated.contains(w))
            continue;
        SwingUtilities.updateComponentTreeUI(w);
        w.validate();
        RepaintManager mgr = RepaintManager.currentManager(w);
        Component[] childs = w.getComponents();
        for (Component child : childs) {
            if (child instanceof JComponent)
                mgr.markCompletelyDirty((JComponent) child);
        }
        w.repaint();
        updated.add(w);
    }
    for (Window w : s_hiddenWindows) {
        if (updated.contains(w))
            continue;
        SwingUtilities.updateComponentTreeUI(w);
        w.validate();
        RepaintManager mgr = RepaintManager.currentManager(w);
        Component[] childs = w.getComponents();
        for (Component child : childs) {
            if (child instanceof JComponent)
                mgr.markCompletelyDirty((JComponent) child);
        }
        w.repaint();
        updated.add(w);
    }
    return updated;
}
Also used : Window(java.awt.Window) Container(java.awt.Container) JComponent(javax.swing.JComponent) JComponent(javax.swing.JComponent) Component(java.awt.Component) HashSet(java.util.HashSet) RepaintManager(javax.swing.RepaintManager)

Example 3 with RepaintManager

use of javax.swing.RepaintManager in project adempiere by adempiere.

the class AEnv method updateUI.

//  cacheReset
/**
	 * Update all windows after look and feel changes.
	 * @since 2006-11-27 
	 */
public static void updateUI() {
    Set<Window> updated = Env.updateUI();
    JFrame top = Env.getWindow(0);
    if (top instanceof AMenu) {
        CFrame[] frames = ((AMenu) top).getWindowManager().getWindows();
        for (CFrame f : frames) {
            if (updated.contains(f))
                continue;
            SwingUtilities.updateComponentTreeUI(f);
            f.validate();
            RepaintManager mgr = RepaintManager.currentManager(f);
            Component[] childs = f.getComponents();
            for (Component c : childs) {
                if (c instanceof JComponent)
                    mgr.markCompletelyDirty((JComponent) c);
            }
            f.repaint();
            updated.add(f);
        }
    }
}
Also used : Window(java.awt.Window) JFrame(javax.swing.JFrame) JComponent(javax.swing.JComponent) JComponent(javax.swing.JComponent) Component(java.awt.Component) CFrame(org.compiere.swing.CFrame) RepaintManager(javax.swing.RepaintManager)

Example 4 with RepaintManager

use of javax.swing.RepaintManager in project jdk8u_jdk by JetBrains.

the class SwingUtilities3 method getDelegateRepaintManager.

/**
     * Returns delegate {@code RepaintManager} for {@code component} hierarchy.
     */
public static RepaintManager getDelegateRepaintManager(Component component) {
    RepaintManager delegate = null;
    if (Boolean.TRUE == SunToolkit.targetToAppContext(component).get(DELEGATE_REPAINT_MANAGER_KEY)) {
        while (delegate == null && component != null) {
            while (component != null && !(component instanceof JComponent)) {
                component = component.getParent();
            }
            if (component != null) {
                delegate = (RepaintManager) ((JComponent) component).getClientProperty(DELEGATE_REPAINT_MANAGER_KEY);
                component = component.getParent();
            }
        }
    }
    return delegate;
}
Also used : JComponent(javax.swing.JComponent) RepaintManager(javax.swing.RepaintManager)

Aggregations

RepaintManager (javax.swing.RepaintManager)4 JComponent (javax.swing.JComponent)3 Component (java.awt.Component)2 Window (java.awt.Window)2 Container (java.awt.Container)1 Graphics2D (java.awt.Graphics2D)1 HashSet (java.util.HashSet)1 JFrame (javax.swing.JFrame)1 CFrame (org.compiere.swing.CFrame)1