Пример #1
0
  private void paintVisibleWindow(Graphics2D g) {
    Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
    int firstVisibleLine = getMapYFromEditorY((int) visibleArea.getMinY());
    int height =
        coords.linesToPixels(
            (int) ((visibleArea.getMaxY() - visibleArea.getMinY()) / editor.getLineHeight()));

    // Draw the current viewport
    g.setColor(viewportColor);
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.50f));
    g.drawRect(0, firstVisibleLine, getWidth(), height);
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.20f));
    g.fillRect(0, firstVisibleLine, getWidth(), height);
  }
Пример #2
0
  @Override
  public void paint(Graphics gfx) {
    Graphics2D g = (Graphics2D) gfx;
    g.setColor(editor.getColorsScheme().getDefaultBackground());
    g.fillRect(0, 0, getWidth(), getHeight());

    logger.debug(String.format("Rendering to buffer: %d", activeBuffer));
    if (activeBuffer >= 0) {
      paintSelection(g);

      Minimap minimap = minimaps[activeBuffer];

      Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();

      double documentEndY =
          editor
              .logicalPositionToXY(
                  editor.offsetToLogicalPosition(editor.getDocument().getTextLength() - 1))
              .getY();

      coords
          .setMinimap(minimap)
          .setPanelHeight(getHeight())
          .setPanelWidth(getWidth())
          .setPercentageComplete(
              visibleArea.getMinY()
                  / (documentEndY - (visibleArea.getMaxY() - visibleArea.getMinY())))
          .setHidpiScale(getHidpiScale());

      Rectangle src = coords.getImageSource();
      Rectangle dest = coords.getImageDestination();

      // Draw the image and scale it to stretch vertically.
      g.drawImage(
          minimap.img, // source image
          dest.x,
          dest.y,
          dest.width,
          dest.height,
          src.x,
          src.y,
          src.width,
          src.height,
          null);

      paintVisibleWindow(g);
    }
  }
Пример #3
0
 @Override
 public Rectangle getCurrentItemBounds() {
   int index = myList.getSelectedIndex();
   if (index < 0) {
     LOG.error("No selected element, size=" + getListModel().getSize() + "; items" + getItems());
   }
   Rectangle itmBounds = myList.getCellBounds(index, index);
   if (itmBounds == null) {
     LOG.error("No bounds for " + index + "; size=" + getListModel().getSize());
     return null;
   }
   Point layeredPanePoint =
       SwingUtilities.convertPoint(myList, itmBounds.x, itmBounds.y, getComponent());
   itmBounds.x = layeredPanePoint.x;
   itmBounds.y = layeredPanePoint.y;
   return itmBounds;
 }
Пример #4
0
    @Override
    public void mousePressed(MouseEvent e) {
      if (!dragging && inResizeGutter(e.getX())) {
        resizing = true;
      } else if (!resizing) {
        dragging = true;
      }

      if (resizing) {
        resizeStart = e.getXOnScreen();
        widthStart = config.width;
      }

      if (dragging) {
        Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
        int firstVisibleLine = getMapYFromEditorY((int) visibleArea.getMinY());
        int height =
            coords.linesToPixels(
                (int) ((visibleArea.getMaxY() - visibleArea.getMinY()) / editor.getLineHeight()));

        int panelY = e.getY() - getY();

        if (config.jumpOnMouseDown
            && (panelY <= firstVisibleLine || panelY >= (firstVisibleLine + height))) {
          editor.getScrollingModel().disableAnimation();
          editor
              .getScrollingModel()
              .scrollTo(
                  editor.offsetToLogicalPosition(
                      coords.screenSpaceToOffset(e.getY(), config.percentageBasedClick)),
                  ScrollType.CENTER);
          editor.getScrollingModel().enableAnimation();
        }

        scrollStart = editor.getScrollingModel().getVerticalScrollOffset();
        mouseStart = e.getY();
      }
    }
Пример #5
0
 private boolean isMouseOverTooltip(@NotNull Point mouseLocationOnScreen) {
   Rectangle bounds = getHintBounds();
   return bounds != null && bounds.contains(mouseLocationOnScreen);
 }
 public boolean shouldScrollHistoryToEnd() {
   final Rectangle visibleArea = myHistoryViewer.getScrollingModel().getVisibleArea();
   final Dimension contentSize = myHistoryViewer.getContentSize();
   return contentSize.getHeight() - visibleArea.getMaxY() < 2 * myHistoryViewer.getLineHeight();
 }