本文整理匯總了Java中javax.swing.RepaintManager.isDoubleBufferingEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java RepaintManager.isDoubleBufferingEnabled方法的具體用法?Java RepaintManager.isDoubleBufferingEnabled怎麽用?Java RepaintManager.isDoubleBufferingEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.RepaintManager
的用法示例。
在下文中一共展示了RepaintManager.isDoubleBufferingEnabled方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: print
import javax.swing.RepaintManager; //導入方法依賴的package包/類
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
if (pageIndex >= getComponentCount()) {
mLastPage = -1;
return NO_SUCH_PAGE;
}
// We do the following trick to avoid going through the work twice,
// as we are called twice for each page, the first of which doesn't
// seem to be used.
if (mLastPage != pageIndex) {
mLastPage = pageIndex;
} else {
Component comp = getComponent(pageIndex);
RepaintManager mgr = RepaintManager.currentManager(comp);
boolean saved = mgr.isDoubleBufferingEnabled();
mgr.setDoubleBufferingEnabled(false);
mOkToPaint = true;
comp.print(graphics);
mOkToPaint = false;
mgr.setDoubleBufferingEnabled(saved);
}
return PAGE_EXISTS;
}
示例2: paintImmediately
import javax.swing.RepaintManager; //導入方法依賴的package包/類
/**
* Immediately repaints the surface.
*
* <p/>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).
*
* @param x The X coord to start painting at.
* @param y The Y coord to start painting at.
* @param w The width of the region to paint.
* @param h The height of the region to paint.
*/
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);
}
}
示例3: paintWidget
import javax.swing.RepaintManager; //導入方法依賴的package包/類
/**
* Paints the component widget.
*/
@Override
protected final void paintWidget() {
RepaintManager rm = RepaintManager.currentManager(null);
boolean isDoubleBuffered = component instanceof JComponent && rm.isDoubleBufferingEnabled();
if (isDoubleBuffered) {
rm.setDoubleBufferingEnabled(false);
}
Graphics2D graphics = getGraphics();
Rectangle bounds = getClientArea();
AffineTransform previousTransform = graphics.getTransform();
graphics.translate(bounds.x, bounds.y);
//double zoomFactor = getScene().getZoomFactor();
//graphics.scale(1 / zoomFactor, 1 / zoomFactor);
if (componentVisible) {
componentWrapper.doPaint(graphics);
} else {
component.paint(graphics);
}
graphics.setTransform(previousTransform);
if (isDoubleBuffered) {
rm.setDoubleBufferingEnabled(true);
}
}
示例4: paintImmediately
import javax.swing.RepaintManager; //導入方法依賴的package包/類
/**
* Setting the <code>RepaintManager</code> like seen
* <a href=http://java.sun.com/products/java-media/2D/samples/index.html>on the official examples for Java2D</a>
* (link last time checked on 12.08.2008).<br>
* This imitates the "On Screen" method used there and in some cases drastically improves performance (even when
* DoubleBuffering of this <code>JComponent</code> is off the DoubleBuffering might still be on because the
* DoubleBuffering is inherited from the main <code>JFrame</code>!).
*
* @param x the x coordinate for the bounding box to repaint
* @param y the y coordinate for the bounding box to repaint
* @param width the width
* @param height the height
*/
public void paintImmediately(int x, int y, int width, int height){
RepaintManager repaintManager = null;
boolean save = true;
if (!isDoubleBuffered()) {
repaintManager = RepaintManager.currentManager(this);
save = repaintManager.isDoubleBufferingEnabled();
repaintManager.setDoubleBufferingEnabled(false);
}
super.paintImmediately(x, y, width, height);
if (repaintManager != null) repaintManager.setDoubleBufferingEnabled(save);
}