Ejemplo n.º 1
1
 final void disableTrueDoubleBuffering() {
   if (useTrueDoubleBuffering) {
     if (!IGNORE_DISABLE_TRUE_DOUBLE_BUFFERING) {
       if (LOG_DISABLE_TRUE_DOUBLE_BUFFERING) {
         System.out.println("Disabling true double buffering for " + this);
         Thread.dumpStack();
       }
       useTrueDoubleBuffering = false;
       RepaintManager.currentManager(this).doubleBufferingChanged(this);
     }
   }
 }
Ejemplo n.º 2
0
 /** [Internal] */
 public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
   if (pi >= 1) {
     return Printable.NO_SUCH_PAGE;
   }
   RepaintManager currentManager = RepaintManager.currentManager(this);
   currentManager.setDoubleBufferingEnabled(false);
   Graphics2D g2 = (Graphics2D) g;
   initState(g2, true);
   g2.translate((int) (pf.getImageableX() + 1), (int) (pf.getImageableY() + 1));
   g2.scale(printScale, printScale);
   doBuffer(g2, true, null);
   currentManager.setDoubleBufferingEnabled(true);
   return Printable.PAGE_EXISTS;
 }
Ejemplo n.º 3
0
 /**
  * Repaints the specified rectangle of this component within <code>time</code> milliseconds. Refer
  * to <code>RepaintManager</code> for details on how the repaint is handled.
  *
  * @param time maximum time in milliseconds before update
  * @param x the <i>x</i> coordinate
  * @param y the <i>y</i> coordinate
  * @param width the width
  * @param height the height
  * @see RepaintManager
  * @since 1.6
  */
 public void repaint(long time, int x, int y, int width, int height) {
   if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
     RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width, height);
   } else {
     super.repaint(time, x, y, width, height);
   }
 }
Ejemplo n.º 4
0
  public void propertyChange(PropertyChangeEvent event) {
    debug(this + " " + "propertyChange: " + event.getSource() + " " + event.getPropertyName());

    if (event.getSource() == searchnav) {
      String changeName = event.getPropertyName();
      if (changeName.equals("helpModel")) {

        reloadData((HelpModel) event.getNewValue());

      } else if (changeName.equals("font")) {
        debug("Font change");
        Font newFont = (Font) event.getNewValue();
        searchparams.setFont(newFont);
        RepaintManager.currentManager(searchparams).markCompletelyDirty(searchparams);
        tree.setFont(newFont);
        RepaintManager.currentManager(tree).markCompletelyDirty(tree);
      }
      // changes to UI property?
    }
  }
Ejemplo n.º 5
0
 public static void enableDoubleBuffering(Component c) {
   RepaintManager currentManager = RepaintManager.currentManager(c);
   currentManager.setDoubleBufferingEnabled(true);
 }
Ejemplo n.º 6
0
  public ApplicationImpl(
      boolean isInternal,
      boolean isUnitTestMode,
      boolean isHeadless,
      boolean isCommandLine,
      @NotNull String appName) {
    super(null);

    getPicoContainer().registerComponentInstance(Application.class, this);

    CommonBundle.assertKeyIsFound = isUnitTestMode;

    if ((isInternal || isUnitTestMode)
        && !Comparing.equal("off", System.getProperty("idea.disposer.debug"))) {
      Disposer.setDebugMode(true);
    }
    myStartTime = System.currentTimeMillis();
    myName = appName;
    ApplicationManagerEx.setApplication(this);

    PluginsFacade.INSTANCE =
        new PluginsFacade() {
          public IdeaPluginDescriptor getPlugin(PluginId id) {
            return PluginManager.getPlugin(id);
          }

          public IdeaPluginDescriptor[] getPlugins() {
            return PluginManager.getPlugins();
          }
        };

    if (!isUnitTestMode && !isHeadless) {
      Toolkit.getDefaultToolkit().getSystemEventQueue().push(IdeEventQueue.getInstance());
      if (Patches.SUN_BUG_ID_6209673) {
        RepaintManager.setCurrentManager(new IdeRepaintManager());
      }
      IconLoader.activate();
    }

    myIsInternal = isInternal;
    myTestModeFlag = isUnitTestMode;
    myHeadlessMode = isHeadless;
    myCommandLineMode = isCommandLine;

    loadApplicationComponents();

    if (myTestModeFlag) {
      registerShutdownHook();
    }

    if (!isUnitTestMode && !isHeadless) {
      Disposer.register(this, Disposer.newDisposable(), "ui");

      StartupUtil.addExternalInstanceListener(
          new Consumer<List<String>>() {
            @Override
            public void consume(final List<String> args) {
              invokeLater(
                  new Runnable() {
                    @Override
                    public void run() {
                      final Project project = CommandLineProcessor.processExternalCommandLine(args);
                      final IdeFrame frame;
                      if (project != null) {
                        frame = WindowManager.getInstance().getIdeFrame(project);
                      } else {
                        frame = WindowManager.getInstance().getAllFrames()[0];
                      }
                      ((IdeFrameImpl) frame).requestFocus();
                    }
                  });
            }
          });
    }

    final String s = System.getProperty("jb.restart.code");
    if (s != null) {
      try {
        myRestartCode = Integer.parseInt(s);
      } catch (NumberFormatException ignore) {
      }
    }
  }
  private void dragFrameFaster(JComponent f, int newX, int newY) {

    Rectangle previousBounds =
        new Rectangle(currentBounds.x, currentBounds.y, currentBounds.width, currentBounds.height);

    // move the frame
    currentBounds.x = newX;
    currentBounds.y = newY;

    if (didDrag) {
      // Only initiate cleanup if we have actually done a drag.
      emergencyCleanup(f);
    } else {
      didDrag = true;
      // We reset the danger field as until now we haven't actually
      // moved the internal frame so we don't need to initiate repaint.
      ((JInternalFrame) f).danger = false;
    }

    boolean floaterCollision = isFloaterCollision(previousBounds, currentBounds);

    // System.out.println(previousBounds);
    JComponent parent = (JComponent) f.getParent();
    Rectangle visBounds = previousBounds.intersection(desktopBounds);
    //  System.out.println(previousBounds);

    // System.out.println(visBounds);

    RepaintManager currentManager = RepaintManager.currentManager(f);

    currentManager.beginPaint();
    try {
      if (!floaterCollision) {
        currentManager.copyArea(
            parent,
            desktopGraphics,
            visBounds.x,
            visBounds.y,
            visBounds.width,
            visBounds.height,
            newX - previousBounds.x,
            newY - previousBounds.y,
            true);
      }

      f.setBounds(currentBounds);

      if (floaterCollision) {
        // since we couldn't blit we just redraw as fast as possible
        // the isDragging mucking is to avoid activating emergency
        // cleanup
        ((JInternalFrame) f).isDragging = false;
        parent.paintImmediately(currentBounds);
        ((JInternalFrame) f).isDragging = true;
      }

      // fake out the repaint manager.  We'll take care of everything

      currentManager.markCompletelyClean(parent);
      currentManager.markCompletelyClean(f);

      // compute the minimal newly exposed area
      // if the rects intersect then we use computeDifference.  Otherwise
      // we'll repaint the entire previous bounds
      Rectangle[] dirtyRects = null;
      if (previousBounds.intersects(currentBounds)) {
        dirtyRects = SwingUtilities.computeDifference(previousBounds, currentBounds);
      } else {
        dirtyRects = new Rectangle[1];
        dirtyRects[0] = previousBounds;
        //  System.out.println("no intersection");
      }
      ;

      // Fix the damage
      for (int i = 0; i < dirtyRects.length; i++) {
        parent.paintImmediately(dirtyRects[i]);
      }

      // new areas of blit were exposed
      if (!(visBounds.equals(previousBounds))) {
        dirtyRects = SwingUtilities.computeDifference(previousBounds, desktopBounds);
        for (int i = 0; i < dirtyRects.length; i++) {
          dirtyRects[i].x += newX - previousBounds.x;
          dirtyRects[i].y += newY - previousBounds.y;
          ((JInternalFrame) f).isDragging = false;

          parent.paintImmediately(dirtyRects[i]);
          ((JInternalFrame) f).isDragging = true;

          // System.out.println(dirtyRects[i]);
        }
      }
    } finally {
      currentManager.endPaint();
    }

    // update window if it's non-opaque
    Window topLevel = SwingUtilities.getWindowAncestor(f);
    Toolkit tk = Toolkit.getDefaultToolkit();
    if (!AWTAccessor.getWindowAccessor().isOpaque(topLevel)
        && (tk instanceof SunToolkit)
        && ((SunToolkit) tk).needUpdateWindow()) {
      AWTAccessor.getWindowAccessor().updateWindow(topLevel);
    }
  }
Ejemplo n.º 8
0
 /**
  * {@inheritDoc}
  *
  * @since 1.6
  */
 public void setDoubleBuffered(boolean aFlag) {
   if (isDoubleBuffered() != aFlag) {
     super.setDoubleBuffered(aFlag);
     RepaintManager.currentManager(this).doubleBufferingChanged(this);
   }
 }
 public synchronized void addInvalidComponent(JComponent component) {
   checkEDTRule(component);
   super.addInvalidComponent(component);
 }
 public synchronized void addDirtyRegion(JComponent component, int x, int y, int w, int h) {
   checkEDTRule(component);
   super.addDirtyRegion(component, x, y, w, h);
 }