Java 类javax.swing.RepaintManager 实例源码

项目:incubator-netbeans    文件:TagsAndEditorsTest.java   
public void testPropertySheetRepaintsCellOnPropertyChange() throws Exception {
    if (!canSafelyRunFocusTests()) {
        return;
    }
    Node n = new TNode(new SingleTagEditor());
    setCurrentNode(n, ps);
    Rectangle test = ps.table.getCellRect(1, 1, true);
    RM rm = new RM(test, ps.table);
    RepaintManager.setCurrentManager(rm);
    sleep();
    sleep();
    Node.Property prop = n.getPropertySets()[0].getProperties()[0];
    prop.setValue("new value");
    Thread.currentThread().sleep(1000);
    sleep();
    rm.assertRectRepainted();
}
项目:JuggleMasterPro    文件:AnimationJFrame.java   
/**
 * Method description
 * 
 * @see
 */
final public void initBufferingAndFonts() {

    // Hardware double-buffering :
    RepaintManager.currentManager(this).setDoubleBufferingEnabled(false);
    this.setIgnoreRepaint(true);

    // Waiting for the frame to be displayed :
    while (!this.isVisible()) {
        Thread.yield();
    }

    // Images :
    final Graphics2D objLjuggleMasterProJFrameGraphics2D = (Graphics2D) this.getGraphics();

    this.initBounds();

    // Font metrics :
    this.objGnormalFont = objLjuggleMasterProJFrameGraphics2D.getFont();
    this.objGboldFont = this.objGnormalFont.deriveFont(Font.BOLD);
    Constants.objS_GRAPHICS_FONT_METRICS = objLjuggleMasterProJFrameGraphics2D.getFontMetrics();
    objLjuggleMasterProJFrameGraphics2D.dispose();
}
项目:gcs    文件:CharacterSheet.java   
@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;
}
项目:PhET    文件:PhetJComponent.java   
public static void init( Window applicationWindow ) {


        if ( inited ) {
            throw new RuntimeException( "Multiple inits." );
        }

//        System.out.println( "Setting repaintManagerPhet." );
        RepaintManager.setCurrentManager( repaintManagerPhet );

        offscreen = new JWindow( applicationWindow ) {
            public void invalidate() {
            }

            public void paint( Graphics g ) {
            }
        };       //this seems to work.  I thought you might have needed a visible component, though (maybe for some JVM implementations?)
//        System.out.println( "offscreen.getOwner() = " + offscreen.getOwner() );

//        offscreen.getOwner().setVisible( true );
        offscreen.setSize( 0, 0 );
        offscreen.setVisible( true );
        offscreenContentPane.setOpaque( false );
        offscreen.setContentPane( offscreenContentPane );
        inited = true;
    }
项目:PhET    文件:PSwing.java   
/**
 * Renders the wrapped component to the graphics context provided.
 * 
 * @param g2 graphics context for rendering the JComponent
 */
public void paint(final Graphics2D g2) {
    if (component.getBounds().isEmpty()) {
        // The component has not been initialized yet.
        return;
    }

    final PSwingRepaintManager manager = (PSwingRepaintManager) RepaintManager.currentManager(component);
    manager.lockRepaint(component);

    final RenderingHints oldHints = g2.getRenderingHints();

    //Disable Fractional Metrics on Mac OS because when FRACTIONAL_METRICS are enabled on Mac OS, spurious ellipses
    // are rendered on PSwing text components. Disabling the FRACTIONAL_METRICS rendering hint on Windows causes
    // incorrect rendering of adjacent text PSwing nodes.
    if (System.getProperty("os.name").startsWith( "Mac OS X" )) {
        g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
    }
    component.paint(g2);

    g2.setRenderingHints(oldHints);

    manager.unlockRepaint(component);
}
项目:PhET    文件:PSwingRepaintManagerTest.java   
public void testUnlockRepaint() {
    final PSwingCanvas canvas = new PSwingCanvas();
    final RepaintManager currentManager = RepaintManager.currentManager(canvas);
    assertNotNull(currentManager);
    assertTrue(currentManager instanceof PSwingRepaintManager);

    final PSwingRepaintManager repaintManager = (PSwingRepaintManager) currentManager;
    repaintManager.lockRepaint(null);
    repaintManager.lockRepaint(canvas);

    repaintManager.unlockRepaint(null);
    repaintManager.unlockRepaint(canvas);

    // TODO: catch this array index out of bounds exception?
    final JComponent notLocked = new JPanel();
    try {
        repaintManager.unlockRepaint(notLocked);
    }
    catch (final ArrayIndexOutOfBoundsException e) {
        // expected
    }
}
项目:PhET    文件:PSwingRepaintManagerTest.java   
public void testAddInvalidComponent() {
    final PSwingCanvas canvas = new PSwingCanvas();
    final RepaintManager currentManager = RepaintManager.currentManager(canvas);
    assertNotNull(currentManager);
    assertTrue(currentManager instanceof PSwingRepaintManager);

    final PSwingRepaintManager repaintManager = (PSwingRepaintManager) currentManager;
    // TODO: should check for null and throw IAE, or keep NPE?
    try {
        repaintManager.addInvalidComponent(null);
    }
    catch (final NullPointerException e) {
        // expected
    }

    final JComponent component = new JPanel();
    final JComponent child = new JPanel();
    canvas.add(child);

    repaintManager.addInvalidComponent(canvas);
    repaintManager.addInvalidComponent(component);
    repaintManager.addInvalidComponent(child);

    // TODO: will need some additional work here for full test coverage
}
项目:eurocarbdb    文件:GlycanCanvas.java   
public int print(Graphics g, PageFormat pageFormat, int pageIndex)
        throws PrinterException {
    if (pageIndex > 0) {
        return NO_SUCH_PAGE;
    } else {
        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.respondToDocumentChange = true;
        this.paint(g2d);
        RepaintManager.currentManager(this).setDoubleBufferingEnabled(true);

        return PAGE_EXISTS;
    }
}
项目:piccolo2d.java    文件:PSwing.java   
/**
 * Renders the wrapped component to the graphics context provided.
 * 
 * @param g2 graphics context for rendering the JComponent
 */
public void paint(final Graphics2D g2) {
    if (component.getBounds().isEmpty()) {
        // The component has not been initialized yet.
        return;
    }

    final PSwingRepaintManager manager = (PSwingRepaintManager) RepaintManager.currentManager(component);
    manager.lockRepaint(component);

    final RenderingHints oldHints = g2.getRenderingHints();

    if (useBufferedPainting) {
        Graphics2D bufferedGraphics = getBufferedGraphics(g2);
        component.paint(bufferedGraphics);
        g2.drawRenderedImage(buffer, IDENTITY_TRANSFORM);
    } else {
        g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
        component.paint(g2);
    }

    g2.setRenderingHints(oldHints);

    manager.unlockRepaint(component);
}
项目:piccolo2d.java    文件:PSwingRepaintManagerTest.java   
public void testUnlockRepaint() {
    final PSwingCanvas canvas = new PSwingCanvas();
    final RepaintManager currentManager = RepaintManager.currentManager(canvas);
    assertNotNull(currentManager);
    assertTrue(currentManager instanceof PSwingRepaintManager);

    final PSwingRepaintManager repaintManager = (PSwingRepaintManager) currentManager;
    repaintManager.lockRepaint(null);
    repaintManager.lockRepaint(canvas);

    repaintManager.unlockRepaint(null);
    repaintManager.unlockRepaint(canvas);

    // TODO: catch this array index out of bounds exception?
    final JComponent notLocked = new JPanel();
    try {
        repaintManager.unlockRepaint(notLocked);
    }
    catch (final ArrayIndexOutOfBoundsException e) {
        // expected
    }
}
项目:piccolo2d.java    文件:PSwingRepaintManagerTest.java   
public void testAddInvalidComponent() {
    final PSwingCanvas canvas = new PSwingCanvas();
    final RepaintManager currentManager = RepaintManager.currentManager(canvas);
    assertNotNull(currentManager);
    assertTrue(currentManager instanceof PSwingRepaintManager);

    final PSwingRepaintManager repaintManager = (PSwingRepaintManager) currentManager;
    // TODO: should check for null and throw IAE, or keep NPE?
    try {
        repaintManager.addInvalidComponent(null);
    }
    catch (final NullPointerException e) {
        // expected
    }

    final JComponent component = new JPanel();
    final JComponent child = new JPanel();
    canvas.add(child);

    repaintManager.addInvalidComponent(canvas);
    repaintManager.addInvalidComponent(component);
    repaintManager.addInvalidComponent(child);

    // TODO: will need some additional work here for full test coverage
}
项目:umlet    文件:DrawPanel.java   
@Override
public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
    if (pageIndex > 0) {
        return NO_SUCH_PAGE;
    }
    else {
        Graphics2D g2d = (Graphics2D) g;
        RepaintManager currentManager = RepaintManager.currentManager(this);
        currentManager.setDoubleBufferingEnabled(false);
        Rectangle bounds = getContentBounds(Config.getInstance().getPrintPadding(), getGridElements());
        g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
        AffineTransform t = g2d.getTransform();
        double scale = Math.min(pageFormat.getImageableWidth() / bounds.width,
                pageFormat.getImageableHeight() / bounds.height);
        if (scale < 1) {
            t.scale(scale, scale);
            g2d.setTransform(t);
        }
        g2d.translate(-bounds.x, -bounds.y);
        paint(g2d);
        currentManager = RepaintManager.currentManager(this);
        currentManager.setDoubleBufferingEnabled(true);
        return PAGE_EXISTS;
    }
}
项目:tn5250j    文件:BasicTerminalUI.java   
public void installUI(JComponent c)
  {
    if (c instanceof JTerminal)
    {
      this.terminal = (JTerminal)c;
      if (graphicsDebugMode)
      {
        javax.swing.RepaintManager repaintManager = javax.swing.RepaintManager.currentManager(terminal);
        repaintManager.setDoubleBufferingEnabled(false);
        terminal.setDebugGraphicsOptions(javax.swing.DebugGraphics.FLASH_OPTION);
      }

      this.session  = terminal.getSession();
//      session.setRunningHeadless(true);
      installComponents();
      installListeners();
      installDefaults();
      installKeyboardActions();
    }
    else
      throw new Error("TerminalUI needs JTerminal");
  }
项目:lojix    文件:Surface.java   
/**
 * 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);
    }
}
项目:GUITester-core    文件:ComponentNotifier_JFC.java   
@Override
public BufferedImage getComponentImage(Object compObj) {
  BufferedImage image = null;
  if (compObj instanceof Component) {
    Component component = (Component) compObj;

    if (component == null || component.getWidth() <= 0 || component.getHeight() <= 0)
      return null;
    else {
      image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);
      // switch off double buffering
      RepaintManager.currentManager(component).setDoubleBufferingEnabled(false);

      component.paint(image.getGraphics());

      // switch on double buffering
      RepaintManager.currentManager(component).setDoubleBufferingEnabled(true);
    }
  }
  return image;
}
项目:JRLib    文件:JRLibComponentWidget.java   
/**
 * 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);
    }
}
项目:incubator-netbeans    文件:AnimationLayer.java   
/**
 * Initial point of the next frame (invoked by the animation timer).
 *
 * @param e action event.
 */
@Override
public void actionPerformed(ActionEvent e) {
    updatePhase();
    RepaintManager manager = RepaintManager.currentManager(glassPane);
    manager.markCompletelyDirty(glassPane);
    manager.paintDirtyRegions();
}
项目:incubator-netbeans    文件:QueryBuilder.java   
private static void doShowBusyCursor(boolean busy) {
    JFrame mainWindow = (JFrame)WindowManager.getDefault().getMainWindow();
    if(busy){
        RepaintManager.currentManager(mainWindow).paintDirtyRegions();
        mainWindow.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        mainWindow.getGlassPane().setVisible(true);
        mainWindow.repaint();
    } else {
        mainWindow.getGlassPane().setVisible(false);
        mainWindow.getGlassPane().setCursor(null);
        mainWindow.repaint();
    }
}
项目:incubator-netbeans    文件:DebuggingViewComponent.java   
/**
 * Restore stored scroll position.
 */
private void restoreScrollPosition(boolean delayScrollWithMarkingDirtyRegion) {
    if (visibleTreePosition != null) {
        JTree tree = getJTree();
        if (tree != null) {
            int row = tree.getRowForPath(visibleTreePosition.getPath());
            if (row != -1) {
                Rectangle bounds = tree.getRowBounds(row);
                if (bounds != null) {
                    int scrollY = bounds.y - visibleTreePosition.getOffset();
                    JViewport viewport = mainScrollPane.getViewport();
                    Rectangle rect = viewport.getViewRect();
                    rect.y = scrollY;
                    if (!rect.isEmpty()) {
                        JComponent view = (JComponent) viewport.getView();
                        if (delayScrollWithMarkingDirtyRegion) {
                            RepaintManager.currentManager(viewport).addDirtyRegion(
                                    view,
                                    rect.x, rect.x, rect.width, rect.height);
                        }
                        ignoreScrollAdjustment = true;
                        try {
                            view.scrollRectToVisible(
                                    rect);
                        } finally {
                            ignoreScrollAdjustment = false;
                        }
                    }
                }
            }
        }
    }
}
项目:smile_1.5.0_java7    文件:PlotPanel.java   
@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;
}
项目:OpenJSharp    文件:SwingAccessor.java   
/**
 * Retrieve the accessor object for the RepaintManager class.
 */
public static RepaintManagerAccessor getRepaintManagerAccessor() {
    if (repaintManagerAccessor == null) {
        unsafe.ensureClassInitialized(RepaintManager.class);
    }
    return repaintManagerAccessor;
}
项目:OpenJSharp    文件:SwingUtilities3.java   
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
项目:jdk8u-jdk    文件:SwingAccessor.java   
/**
 * Retrieve the accessor object for the RepaintManager class.
 */
public static RepaintManagerAccessor getRepaintManagerAccessor() {
    if (repaintManagerAccessor == null) {
        unsafe.ensureClassInitialized(RepaintManager.class);
    }
    return repaintManagerAccessor;
}
项目:jdk8u-jdk    文件:SwingUtilities3.java   
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
项目:jdk8u-jdk    文件:bug6608456.java   
@Override
public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
    if (RepaintManager.currentManager(c) == this) {
        testFuture.defaultCalled();
    } else {
        testFuture.delegateCalled();
    }
    super.addDirtyRegion(c, x, y, w, h);
}
项目:jdk8u-jdk    文件:bug6608456.java   
private static boolean registerDelegate(JComponent c,
        RepaintManager repaintManager) {
    boolean rv = false;
    try {
        Class<?> clazz = Class.forName("com.sun.java.swing.SwingUtilities3");
        Method method = clazz.getMethod("setDelegateRepaintManager",
            JComponent.class, RepaintManager.class);
        method.invoke(clazz, c, repaintManager);
        rv = true;
    } catch (Exception ignore) {
    }
    return rv;
}
项目:openjdk-jdk10    文件:SwingUtilities3.java   
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
项目:openjdk-jdk10    文件:bug6608456.java   
@Override
public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
    if (RepaintManager.currentManager(c) == this) {
        testFuture.defaultCalled();
    } else {
        testFuture.delegateCalled();
    }
    super.addDirtyRegion(c, x, y, w, h);
}
项目:openjdk-jdk10    文件:bug6608456.java   
private static boolean registerDelegate(JComponent c,
        RepaintManager repaintManager) {
    boolean rv = false;
    try {
        Class<?> clazz = Class.forName("com.sun.java.swing.SwingUtilities3");
        Method method = clazz.getMethod("setDelegateRepaintManager",
            JComponent.class, RepaintManager.class);
        method.invoke(clazz, c, repaintManager);
        rv = true;
    } catch (Exception ignore) {
    }
    return rv;
}
项目:openjdk9    文件:SwingUtilities3.java   
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
项目:openjdk9    文件:bug6608456.java   
@Override
public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
    if (RepaintManager.currentManager(c) == this) {
        testFuture.defaultCalled();
    } else {
        testFuture.delegateCalled();
    }
    super.addDirtyRegion(c, x, y, w, h);
}
项目:openjdk9    文件:bug6608456.java   
private static boolean registerDelegate(JComponent c,
        RepaintManager repaintManager) {
    boolean rv = false;
    try {
        Class<?> clazz = Class.forName("com.sun.java.swing.SwingUtilities3");
        Method method = clazz.getMethod("setDelegateRepaintManager",
            JComponent.class, RepaintManager.class);
        method.invoke(clazz, c, repaintManager);
        rv = true;
    } catch (Exception ignore) {
    }
    return rv;
}
项目:PhET    文件:HUDNode.java   
private void initRepaintManager() {
    SwingUtilities.invokeLater( new Runnable() {
        public void run() {
            final RepaintManager repaintManager = RepaintManager.currentManager( component );
            if ( !( repaintManager instanceof JMERepaintManager ) ) {
                RepaintManager.setCurrentManager( new JMERepaintManager() );
            }
        }
    } );
}
项目:PhET    文件:PSwingRepaintManagerTest.java   
public void testCurrentManager() {
    RepaintManager currentManager = RepaintManager.currentManager(null);
    assertNotNull(currentManager);
    // TODO: this assertion is true when running this test case in isolation
    // but since PSwingCanvas may have been instantiated elsewhere in the
    // test suite
    // may not be true when running this test case as part of a test suite
    // assertFalse(currentManager instanceof PSwingRepaintManager);

    final Component awtComponent = new Canvas();
    currentManager = RepaintManager.currentManager(awtComponent);
    assertNotNull(currentManager);
    // assertFalse(currentManager instanceof PSwingRepaintManager);

    final JComponent swingComponent = new JPanel();
    currentManager = RepaintManager.currentManager(swingComponent);
    assertNotNull(currentManager);
    // assertFalse(currentManager instanceof PSwingRepaintManager);

    final PSwingCanvas pswingCanvas = new PSwingCanvas();
    currentManager = RepaintManager.currentManager(pswingCanvas);
    assertNotNull(currentManager);
    assertTrue(currentManager instanceof PSwingRepaintManager);

    // once a PSwingCanvas has been instantiated,
    // PSwingRepaintManager replaces RepaintManager everwhere
    currentManager = RepaintManager.currentManager(awtComponent);
    assertTrue(currentManager instanceof PSwingRepaintManager);

    currentManager = RepaintManager.currentManager(swingComponent);
    assertTrue(currentManager instanceof PSwingRepaintManager);

    currentManager = RepaintManager.currentManager(pswingCanvas);
    assertTrue(currentManager instanceof PSwingRepaintManager);
}
项目:PhET    文件:PSwingRepaintManagerTest.java   
public void testLockRepaint() {
    final PSwingCanvas canvas = new PSwingCanvas();
    final RepaintManager currentManager = RepaintManager.currentManager(canvas);
    assertNotNull(currentManager);
    assertTrue(currentManager instanceof PSwingRepaintManager);

    final PSwingRepaintManager repaintManager = (PSwingRepaintManager) currentManager;
    // TODO: should lockRepaint allow null?
    repaintManager.lockRepaint(null);
    repaintManager.lockRepaint(canvas);
}
项目:PhET    文件:PSwingRepaintManagerTest.java   
public void testIsPainting() {
    final PSwingCanvas canvas = new PSwingCanvas();
    final RepaintManager currentManager = RepaintManager.currentManager(canvas);
    assertNotNull(currentManager);
    assertTrue(currentManager instanceof PSwingRepaintManager);

    final PSwingRepaintManager repaintManager = (PSwingRepaintManager) currentManager;
    repaintManager.lockRepaint(null);
    repaintManager.lockRepaint(canvas);
    final JComponent notLocked = new JPanel();

    assertTrue(repaintManager.isPainting(null));
    assertTrue(repaintManager.isPainting(canvas));
    assertFalse(repaintManager.isPainting(notLocked));
}
项目:PhET    文件:PSwingRepaintManagerTest.java   
public void testAddDirtyRegion() {
    final PSwingCanvas canvas = new PSwingCanvas();
    final RepaintManager currentManager = RepaintManager.currentManager(canvas);
    assertNotNull(currentManager);
    assertTrue(currentManager instanceof PSwingRepaintManager);

    final PSwingRepaintManager repaintManager = (PSwingRepaintManager) currentManager;
    repaintManager.addDirtyRegion(canvas, 0, 0, canvas.getWidth(), canvas.getHeight());

    final JComponent child = new JPanel();
    canvas.add(child);
    repaintManager.addDirtyRegion(child, 0, 0, child.getWidth(), child.getHeight());

    // TODO: will need some additional work here for full test coverage
}
项目:PhET    文件:PCanvas.java   
/**
 * If not painting immediately, send paint notification to RepaintManager,
 * otherwise does nothing.
 */
public void paintImmediately() {
    if (paintingImmediately) {
        return;
    }

    paintingImmediately = true;
    RepaintManager.currentManager(this).paintDirtyRegions();
    paintingImmediately = false;
}
项目:SeqMonk    文件:SVGGenerator.java   
/**
 * This is the method used to create an SVG representation
 * of a component.  The returned string contains valid SVG
 * 
 * @param c The component to convert
 * @return An SVG representation of the component
 */
public static void writeSVG (PrintWriter pr, Component c) {

    /*
     * Before using our Graphics class we need to disable double
     * buffering on the component.  If we don't do this then we
     * just get an image from the offscreen buffer to draw into
     * our Graphics object - we never see the individual method
     * calls to the Graphics interface.
     * 
     * This only affects Windows/Linux where java does the buffering
     * internally.  OSX does it via the window manager so this works
     * without changing anything.
     */

    boolean doubleBuffered = RepaintManager.currentManager(c).isDoubleBufferingEnabled();
    if (doubleBuffered) {
        RepaintManager.currentManager(c).setDoubleBufferingEnabled(false);
    }

    new SVGGenerator(pr,c);

    if (doubleBuffered) {
        RepaintManager.currentManager(c).setDoubleBufferingEnabled(true);
    }

}
项目:jdk8u_jdk    文件:SwingAccessor.java   
/**
 * Retrieve the accessor object for the RepaintManager class.
 */
public static RepaintManagerAccessor getRepaintManagerAccessor() {
    if (repaintManagerAccessor == null) {
        unsafe.ensureClassInitialized(RepaintManager.class);
    }
    return repaintManagerAccessor;
}