Ejemplo n.º 1
0
 // ------------------------------
 public void
     scrollToCaret() { // not called - fixed with putting visible scrollbars on JScrollPane
   //
   Rectangle rect1 = scroller1.getViewport().getViewRect();
   double x1 = rect1.getX();
   double y1 = rect1.getY();
   double r1height = rect1.getHeight();
   double r1width = rect1.getWidth();
   Caret caret1 = editor1.getCaret();
   Point pt2 = caret1.getMagicCaretPosition(); // the end of the string
   double x2 = pt2.getX();
   double y2 = pt2.getY();
   if (((x2 > x1) && (x2 < (x1 + r1width))) && ((y2 > y1) && (y2 < (y1 + r1height)))) {
     // inview
   } else {
     double newheight = r1height / 2;
     double newwidth = r1width / 2;
     double x3 = pt2.getX() - newwidth;
     double y3 = pt2.getY() - newheight;
     if (x3 < 0) x3 = 0;
     if (y3 < 0) y3 = 0;
     Rectangle rect3 = new Rectangle((int) x3, (int) y3, (int) newwidth, (int) newheight);
     editor1.scrollRectToVisible(rect3);
   }
 } // end scrollToCaret
 /** Returns the coordinates of the top left corner of the value at the given index. */
 public Point getCoordinates(int index) {
   JScrollBar bar = scrollPane.getVerticalScrollBar();
   Rectangle r = pinsTable.getCellRect(index, 2, true);
   pinsTable.scrollRectToVisible(r);
   return new Point(
       (int) (r.getX() + topLevelLocation.getX()),
       (int) (r.getY() + topLevelLocation.getY() - bar.getValue()));
 }
Ejemplo n.º 3
0
 @NotNull
 private static List<EditorWindow> findWindowsInRow(
     @NotNull EditorWindow anchor, @NotNull List<EditorWindow> windows, final boolean vertical) {
   final Rectangle anchorRect = getEditorWindowRectangle(anchor);
   if (anchorRect != null) {
     final List<EditorWindow> result = new ArrayList<EditorWindow>();
     final double coord = vertical ? anchorRect.getX() : anchorRect.getY();
     for (EditorWindow window : windows) {
       final Rectangle rect = getEditorWindowRectangle(window);
       if (rect != null) {
         final double min = vertical ? rect.getX() : rect.getY();
         final double max = min + (vertical ? rect.getWidth() : rect.getHeight());
         if (coord >= min && coord <= max) {
           result.add(window);
         }
       }
     }
     Collections.sort(
         result,
         new Comparator<EditorWindow>() {
           @Override
           public int compare(EditorWindow window1, EditorWindow window2) {
             final Rectangle rect1 = getEditorWindowRectangle(window1);
             final Rectangle rect2 = getEditorWindowRectangle(window2);
             if (rect1 != null && rect2 != null) {
               final double diff =
                   vertical ? (rect1.getY() - rect2.getY()) : (rect1.getX() - rect2.getX());
               return diff < 0 ? -1 : diff > 0 ? 1 : 0;
             }
             return 0;
           }
         });
     return result;
   }
   return Collections.singletonList(anchor);
 }
Ejemplo n.º 4
0
 public void scrollRects() {
   for (Rectangle i : rectList) {
     i.setLocation((int) (i.getX()), (int) (i.getY() + (int) (player1.getVelocity() * 0.3)));
   }
 }