當前位置: 首頁>>代碼示例>>Java>>正文


Java RelativePoint.fromScreen方法代碼示例

本文整理匯總了Java中com.intellij.ui.awt.RelativePoint.fromScreen方法的典型用法代碼示例。如果您正苦於以下問題:Java RelativePoint.fromScreen方法的具體用法?Java RelativePoint.fromScreen怎麽用?Java RelativePoint.fromScreen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.ui.awt.RelativePoint的用法示例。


在下文中一共展示了RelativePoint.fromScreen方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: guessBestPopupLocation

import com.intellij.ui.awt.RelativePoint; //導入方法依賴的package包/類
@NotNull
private RelativePoint guessBestPopupLocation(@NotNull Editor editor) {
  RelativePoint preferredLocation = JBPopupFactory.getInstance().guessBestPopupLocation(editor);
  if (myDimensionServiceKey == null) {
    return preferredLocation;
  }
  Dimension preferredSize = DimensionService.getInstance().getSize(myDimensionServiceKey, myProject);
  if (preferredSize == null) {
    return preferredLocation;
  }
  Rectangle preferredBounds = new Rectangle(preferredLocation.getScreenPoint(), preferredSize);
  Rectangle adjustedBounds = new Rectangle(preferredBounds);
  ScreenUtil.moveRectangleToFitTheScreen(adjustedBounds);
  if (preferredBounds.y - adjustedBounds.y <= 0) {
    return preferredLocation;
  }
  int adjustedY = preferredBounds.y - editor.getLineHeight() * 3 / 2 - preferredSize.height;
  if (adjustedY < 0) {
    return preferredLocation;
  }
  Point point = new Point(preferredBounds.x, adjustedY);
  Component component = preferredLocation.getComponent();
  if (component == null) {
    return RelativePoint.fromScreen(point);
  }
  SwingUtilities.convertPointFromScreen(point, component);
  return new RelativePoint(component, point);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:29,代碼來源:AbstractPopup.java

示例2: getHintContainerShowPoint

import com.intellij.ui.awt.RelativePoint; //導入方法依賴的package包/類
AsyncResult<RelativePoint> getHintContainerShowPoint() {
  final AsyncResult<RelativePoint> result = new AsyncResult<RelativePoint>();
  if (myLocationCache == null) {
    if (myHintContainer != null) {
      final Point p = AbstractPopup.getCenterOf(myHintContainer, this);
      p.y -= myHintContainer.getVisibleRect().height / 4;
      myLocationCache = RelativePoint.fromScreen(p);
    } else {
      if (myContextComponent != null) {
        myLocationCache = JBPopupFactory.getInstance().guessBestPopupLocation(DataManager.getInstance().getDataContext(myContextComponent));
      } else {
        DataManager.getInstance().getDataContextFromFocus().doWhenDone(new Consumer<DataContext>() {
          @Override
          public void consume(DataContext dataContext) {
            myContextComponent = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
            myLocationCache = JBPopupFactory.getInstance().guessBestPopupLocation(DataManager.getInstance().getDataContext(myContextComponent));
          }
        });
      }
    }
  }
  final Component c = myLocationCache.getComponent();
  if (!(c instanceof JComponent && c.isShowing())) {
    //Yes. It happens sometimes.
    // 1. Empty frame. call nav bar, select some package and open it in Project View
    // 2. Call nav bar, then Esc
    // 3. Hide all tool windows (Ctrl+Shift+F12), so we've got empty frame again
    // 4. Call nav bar. NPE. ta da
    final JComponent ideFrame = WindowManager.getInstance().getIdeFrame(getProject()).getComponent();
    final JRootPane rootPane = UIUtil.getRootPane(ideFrame);
    myLocationCache = JBPopupFactory.getInstance().guessBestPopupLocation(rootPane);
  }
  result.setDone(myLocationCache);
  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:36,代碼來源:NavBarPanel.java


注:本文中的com.intellij.ui.awt.RelativePoint.fromScreen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。