Beispiel #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);
  }
Beispiel #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);
    }
  }
  public static Point getLocationForCaret(JTextComponent pathTextField) {
    Point point;

    int position = pathTextField.getCaretPosition();
    try {
      final Rectangle rec = pathTextField.modelToView(position);
      point = new Point((int) rec.getMaxX(), (int) rec.getMaxY());
    } catch (BadLocationException e) {
      point = pathTextField.getCaret().getMagicCaretPosition();
    }

    SwingUtilities.convertPointToScreen(point, pathTextField);

    point.y += 2;

    return point;
  }
Beispiel #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();
      }
    }
 public boolean shouldScrollHistoryToEnd() {
   final Rectangle visibleArea = myHistoryViewer.getScrollingModel().getVisibleArea();
   final Dimension contentSize = myHistoryViewer.getContentSize();
   return contentSize.getHeight() - visibleArea.getMaxY() < 2 * myHistoryViewer.getLineHeight();
 }
Beispiel #6
0
 public static RelativePoint getPointForBounds(JComponent aComponent, final Rectangle aBounds) {
   return new RelativePoint(aComponent, new Point(aBounds.x, (int) aBounds.getMaxY()));
 }