/**
   * Translate coordinates from one window into another. Optimized for XAWT - uses cached data when
   * possible. Preferable over pure XTranslateCoordinates.
   *
   * @return coordinates relative to dst, or null if error happened
   */
  static Point toOtherWindow(long src, long dst, int x, int y) {
    Point rpt = new Point(0, 0);

    // Check if both windows belong to XAWT - then no X calls are necessary

    XBaseWindow srcPeer = XToolkit.windowToXWindow(src);
    XBaseWindow dstPeer = XToolkit.windowToXWindow(dst);

    if (srcPeer != null && dstPeer != null) {
      // (x, y) is relative to src
      rpt.x = x + srcPeer.getAbsoluteX() - dstPeer.getAbsoluteX();
      rpt.y = y + srcPeer.getAbsoluteY() - dstPeer.getAbsoluteY();
    } else if (dstPeer != null && XlibUtil.isRoot(src, dstPeer.getScreenNumber())) {
      // from root into peer
      rpt.x = x - dstPeer.getAbsoluteX();
      rpt.y = y - dstPeer.getAbsoluteY();
    } else if (srcPeer != null && XlibUtil.isRoot(dst, srcPeer.getScreenNumber())) {
      // from peer into root
      rpt.x = x + srcPeer.getAbsoluteX();
      rpt.y = y + srcPeer.getAbsoluteY();
    } else {
      rpt = XlibUtil.translateCoordinates(src, dst, new Point(x, y));
    }
    return rpt;
  }
  public void drawOn(Page page) throws Exception {
    if (fill_shape) {
      page.setBrushColor(color[0], color[1], color[2]);
    } else {
      page.setPenColor(color[0], color[1], color[2]);
    }
    page.setPenWidth(width);
    page.setLinePattern(pattern);

    for (int i = 0; i < points.size(); i++) {
      Point point = points.get(i);
      point.x += box_x;
      point.y += box_y;
    }

    if (fill_shape) {
      page.drawPath(points, 'f');
    } else {
      if (close_path) {
        page.drawPath(points, 's');
      } else {
        page.drawPath(points, 'S');
      }
    }

    for (int i = 0; i < points.size(); i++) {
      Point point = points.get(i);
      point.x -= box_x;
      point.y -= box_y;
    }
  }
Beispiel #3
0
  /**
   * Returns the closest point to @param p. Works recursively. Compares current point with p, then
   * checks which tree to explore sub-trees
   *
   * @param t
   * @param p
   * @param best
   * @param bestDistance
   * @param cd
   * @return Point nearest to p
   */
  private Point nearest(TreeNode t, Point p, Point best, double bestDistance, boolean cd) {
    if (p == null) return best;
    if (t == null) return best;
    nodesTouchedOnNearest++;
    // System.out.println(t.p.toString());

    double distance = squaredDistance(t.p, p);
    if (distance < bestDistance) {
      best = t.p;
      bestDistance = distance;
    }

    Point result;
    if (cd) {
      if (p.x() < t.p.x()) result = nearest(t.left, p, best, bestDistance, !cd);
      else if (p.x() > t.p.x()) result = nearest(t.right, p, best, bestDistance, !cd);
      else { // They must be equal, cut on y
        if (p.y() < t.p.y()) result = nearest(t.left, p, best, bestDistance, !cd);
        else result = nearest(t.right, p, best, bestDistance, !cd);
      }
    } else {
      if (p.y() < t.p.y()) result = nearest(t.left, p, best, bestDistance, !cd);
      else if (p.y() > t.p.y()) result = nearest(t.right, p, best, bestDistance, !cd);
      else { // They must be equal, cut on x
        if (p.x() < t.p.x()) result = nearest(t.left, p, best, bestDistance, !cd);
        else result = nearest(t.right, p, best, bestDistance, !cd);
      }
    }
    distance = squaredDistance(result, p);
    if (distance < bestDistance) {
      best = result;
      bestDistance = distance;
    }
    return best;
  }
Beispiel #4
0
 // This method returns true of p lies in the rectangle outlined by sw, se, nw, ne
 private boolean subTreeInRange(Point sw, Point se, Point nw, Point ne, Point p) {
   if (sw.x() < p.x() && p.x() < se.x()) {
     if (sw.y() < p.y() && p.y() < nw.y()) {
       return true;
     }
   }
   return false;
 }
Beispiel #5
0
 public Point getLocation() {
   if (inEditMode) {
     tmpLoc.x = defLoc.x;
     tmpLoc.y = defLoc.y;
   } else {
     tmpLoc.x = curLoc.x;
     tmpLoc.y = curLoc.y;
   }
   return tmpLoc;
 }
Beispiel #6
0
  private boolean boxOverlaps(TreeNode t, Point sw, Point ne) {
    Point nw = new Point(sw.x(), ne.y());
    Point se = new Point(ne.x(), sw.y());

    Point myNw = new Point(t.minX.p.x(), t.maxY.p.y());
    Point mySe = new Point(t.maxX.p.x(), t.minY.p.y());

    if (myNw.x() >= nw.x() || myNw.y() >= nw.y() || mySe.x() <= se.x() || mySe.y() <= se.y()) {
      return true;
    }
    return false;
  }
Beispiel #7
0
 public void reshape(int x, int y, int w, int h) {
   if (inEditMode) {
     defLoc.x = x;
     defLoc.y = y;
     defDim.width = w;
     defDim.height = h;
   }
   curLoc.x = x;
   curLoc.y = y;
   curDim.width = w;
   curDim.height = h;
   super.reshape(x, y, w, h);
 }
  /**
   * Calls the given treeNode.
   *
   * @param treeNode the <tt>TreeNode</tt> to call
   */
  private void call(TreeNode treeNode, JButton button, boolean isVideo, boolean isDesktopSharing) {
    if (!(treeNode instanceof ContactNode)) return;

    UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor();

    Point location = new Point(button.getX(), button.getY() + button.getHeight());

    SwingUtilities.convertPointToScreen(location, treeContactList);

    location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y;
    location.x += 8;
    location.y -= 8;

    CallManager.call(contactDescriptor, isVideo, isDesktopSharing, treeContactList, location);
  }
 @Override
 protected RelativePoint getPointToShowResults() {
   Rectangle rect = myEntryTable.getCellRect(myEntryTable.getSelectedRow(), 1, false);
   Point location = rect.getLocation();
   location.y += rect.height;
   return new RelativePoint(myEntryTable, location);
 }
Beispiel #10
0
 private void centerOnScreen(Frame frame) {
   Point point = frame.getLocationOnScreen();
   Dimension dimension = frame.getSize();
   Dimension dimension1 = getSize();
   point.x += (dimension.width - dimension1.width) / 2;
   point.y += (dimension.height - dimension1.height) / 2;
   Dimension dimension2 = Toolkit.getDefaultToolkit().getScreenSize();
   if (point.x < 0
       || point.y < 0
       || point.x + dimension1.width > dimension2.width
       || point.y + dimension1.height > dimension2.height) {
     point.x = (dimension2.width - dimension1.width) / 2;
     point.y = (dimension2.height - dimension1.height) / 2;
   }
   setLocation(point.x, point.y);
 }
Beispiel #11
0
 public void scaleBy(double factor) throws Exception {
   for (int i = 0; i < points.size(); i++) {
     Point point = points.get(i);
     point.x *= factor;
     point.y *= factor;
   }
 }
Beispiel #12
0
  public TabSpawnable spawn() {
    JFrame f = new JFrame();
    f.getContentPane().setLayout(new BorderLayout());
    f.setTitle(_title);
    TabSpawnable newPanel = (TabSpawnable) clone();
    if (newPanel == null) return null; // failed to clone
    newPanel.setTitle(_title);
    if (newPanel instanceof TabToDoTarget) {
      TabToDoTarget me = (TabToDoTarget) this;
      TabToDoTarget it = (TabToDoTarget) newPanel;
      it.setTarget(me.getTarget());
    } else if (newPanel instanceof TabModelTarget) {
      TabModelTarget me = (TabModelTarget) this;
      TabModelTarget it = (TabModelTarget) newPanel;
      it.setTarget(me.getTarget());
    }
    f.getContentPane().add(newPanel, BorderLayout.CENTER);
    Rectangle bounds = getBounds();
    bounds.height += OVERLAPP * 2;
    f.setBounds(bounds);

    Point loc = new Point(0, 0);
    SwingUtilities.convertPointToScreen(loc, this);
    loc.y -= OVERLAPP;
    f.setLocation(loc);
    f.setVisible(true);

    if (_tear && (getParent() instanceof JTabbedPane)) ((JTabbedPane) getParent()).remove(this);

    return newPanel;
  }
Beispiel #13
0
 /** NOTE: the connection from java to matlab */
 public RCvalue java2Matlab() throws EvalException {
   if (rc == null) {
     if (poly != null) {
       Value[] v = new Value[poly.degree()];
       for (int i = 0; i < v.length; i++) {
         Point pt = poly.point(i);
         assert pt.type() == CohoDouble.type
             : "The result type is not CohoDouble, it is " + pt.type();
         //					if(pt.type()!=CohoDouble.type){
         //					throw new RuntimeException("The result type is not CohoDouble, it is "+pt.type() );
         //					}
         v[i] =
             RCvalue.factory()
                 .create(
                     new Value[] {
                       DoubleValue.factory()
                           .create(new Double(((CohoDouble) pt.x()).doubleValue()), null),
                       DoubleValue.factory()
                           .create(new Double(((CohoDouble) pt.y()).doubleValue()), null)
                     },
                     false);
       }
       rc = (RCvalue) (RCvalue.factory().create(v, true));
     } else { // empty polygon
       rc = (RCvalue) (RCvalue.factory().create(new Value[0], true));
     }
   }
   return (rc);
 }
Beispiel #14
0
  // Private method for deleting a node. Called from the public delete method. Works recursively
  // Method works by recursively deleting a node, and then once backing out of the recursion all
  // data members are updated for each node
  private boolean delete(TreeNode t, Point p, boolean cd) {
    boolean status = false;
    // Base case, not found so return false
    if (t == null) return false;
    if (t.p.equals(p)) { // Found the node, now delete it
      if (t.right != null) {
        TreeNode min = findMin(t.right, cd);
        swapData(t, min);
        status = delete(min, min.p, min.cd);
      } else if (t.left != null) {
        TreeNode min = findMin(t.left, cd);
        swapData(t, min);
        t.right = t.left;
        t.left = null;
        status = delete(min, min.p, min.cd);
      } else { // At a leaf, remove the node
        size--;
        status = deleteFromParent(t);
      }
    } else if (cd) {
      if (p.x() < t.p.x()) status = delete(t.left, p, !cd);
      else if (p.x() > t.p.x()) status = delete(t.right, p, !cd);
      else { // They must be equal, cut on y
        if (p.y() < t.p.y()) status = delete(t.left, p, !cd);
        else status = delete(t.right, p, !cd);
      }
    } else {
      if (p.y() < t.p.y()) status = delete(t.left, p, !cd);
      else if (p.y() > t.p.y()) status = delete(t.right, p, !cd);
      else { // They must be equal, cut on x
        if (p.x() < t.p.x()) status = delete(t.left, p, !cd);
        else status = delete(t.right, p, !cd);
      }
    }
    // Backing out of recursion, need to update data members
    updateMinMaxOnDeleteAndRebuild(t);
    t.height = maxHeight(t.left, t.right) + 1;

    // Check if becoming unbalanced
    if (unbalanced(t)) {
      Point[] points = collectSatanSpawn(t);
      TDTree newSubTree = new TDTree(points, cd);
      swapDataMembers(t, newSubTree.root);
    }
    return status;
  } // End private delete method
  public void updatePosition() {
    Point position = new Point(spaceOccupied.x, spaceOccupied.y);

    // Insert random behavior.  During
    // each update, a sprite has about
    // one chance in 10 of making a
    // random change to its
    // motionVector.  When a change
    // occurs, the motionVector
    // coordinate values are forced to
    // fall between -7 and 7.  This
    // puts a cap on the maximum speed
    // for a sprite.
    if (rand.nextInt() % 10 == 0) {
      Point randomOffset = new Point(rand.nextInt() % 3, rand.nextInt() % 3);
      motionVector.x += randomOffset.x;
      if (motionVector.x >= 7) motionVector.x -= 7;
      if (motionVector.x <= -7) motionVector.x += 7;
      motionVector.y += randomOffset.y;
      if (motionVector.y >= 7) motionVector.y -= 7;
      if (motionVector.y <= -7) motionVector.y += 7;
    } // end if

    // Move the sprite on the screen
    position.translate(motionVector.x, motionVector.y);

    // Bounce off the walls
    boolean bounceRequired = false;
    Point tempMotionVector = new Point(motionVector.x, motionVector.y);

    // Handle walls in x-dimension
    if (position.x < bounds.x) {
      bounceRequired = true;
      position.x = bounds.x;
      // reverse direction in x
      tempMotionVector.x = -tempMotionVector.x;
    } else if ((position.x + spaceOccupied.width) > (bounds.x + bounds.width)) {
      bounceRequired = true;
      position.x = bounds.x + bounds.width - spaceOccupied.width;
      // reverse direction in x
      tempMotionVector.x = -tempMotionVector.x;
    } // end else if

    // Handle walls in y-dimension
    if (position.y < bounds.y) {
      bounceRequired = true;
      position.y = bounds.y;
      tempMotionVector.y = -tempMotionVector.y;
    } else if ((position.y + spaceOccupied.height) > (bounds.y + bounds.height)) {
      bounceRequired = true;
      position.y = bounds.y + bounds.height - spaceOccupied.height;
      tempMotionVector.y = -tempMotionVector.y;
    } // end else if

    if (bounceRequired)
      // save new motionVector
      setMotionVector(tempMotionVector);
    // update spaceOccupied
    setSpaceOccupied(position);
  } // end updatePosition()
Beispiel #16
0
 public void reshape(int x, int y, int w, int h) {
   if (inEditMode) {
     defLoc.x = x;
     defLoc.y = y;
     defDim.width = w;
     defDim.height = h;
   }
   curLoc.x = x;
   curLoc.y = y;
   curDim.width = w;
   curDim.height = h;
   if (!inEditMode) {
     if ((h != nHeight) || (h < rHeight)) {
       adjustFont(w, h);
     }
   }
   super.reshape(x, y, w, h);
 }
Beispiel #17
0
  /* カーソル移動 */
  public void move_cursor(Object.DIRECTION dir) {
    int nx = select_point.x + Object.DirectionVector[dir.ordinal()][0];
    int ny = select_point.y + Object.DirectionVector[dir.ordinal()][1];

    if (inner(nx, ny)) {
      select_point.x = nx;
      select_point.y = ny;
    }
  }
Beispiel #18
0
 // Recursive method for determining if a point is in the tree
 // This function works very similar to the insert method
 private boolean contains(TreeNode t, Point p, boolean even) {
   if (p == null) return false;
   if (t == null) return false;
   if (t.p.equals(p)) return true; // Found the point, return true
   if (even) {
     if (p.x() < t.p.x()) return contains(t.left, p, !even);
     else if (p.x() > t.p.x()) return contains(t.right, p, !even);
     else { // They must be equal, cut on y
       if (p.y() < t.p.y()) return contains(t.left, p, !even);
       else return contains(t.right, p, !even);
     }
   } else {
     if (p.y() < t.p.y()) return contains(t.left, p, !even);
     else if (p.y() > t.p.y()) return contains(t.right, p, !even);
     else { // They must be equal, cut on x
       if (p.x() < t.p.x()) return contains(t.left, p, !even);
       else return contains(t.right, p, !even);
     }
   }
 } // End contains method
Beispiel #19
0
 public void setSizeRatio(double x, double y) {
   xRatio = x;
   yRatio = y;
   if (x > 1.0) xRatio = x - 1.0;
   if (y > 1.0) yRatio = y - 1.0;
   if (defDim.width <= 0) defDim = getPreferredSize();
   curLoc.x = (int) ((double) defLoc.x * xRatio);
   curLoc.y = (int) ((double) defLoc.y * yRatio);
   curDim.width = (int) ((double) defDim.width * xRatio);
   curDim.height = (int) ((double) defDim.height * yRatio);
   if (!inEditMode) setBounds(curLoc.x, curLoc.y, curDim.width, curDim.height);
 }
Beispiel #20
0
 public void setSizeRatio(double x, double y) {
   double rx = x;
   double ry = y;
   if (rx > 1.0) rx = x - 1.0;
   if (ry > 1.0) ry = y - 1.0;
   if (defDim.width <= 0) defDim = getPreferredSize();
   curLoc.x = (int) ((double) defLoc.x * rx);
   curLoc.y = (int) ((double) defLoc.y * ry);
   curDim.width = (int) ((double) defDim.width * rx);
   curDim.height = (int) ((double) defDim.height * ry);
   if (!inEditMode) setBounds(curLoc.x, curLoc.y, curDim.width, curDim.height);
   twin.setSizeRatio(x, y);
 }
Beispiel #21
0
 public void duplication() {
   if (shapes.size() != 0) {
     for (Shape shape : shapes) {
       Shape clone = shape.duplicateShape();
       Point point = new Point(shape.origin());
       point.y += 120;
       clone.setOrigin(point);
       shapesCloneList.add(clone);
       System.out.println("shape is duplicated");
     }
     this.repaint();
   }
 }
Beispiel #22
0
 public void setEditMode(boolean s) {
   twin.setEditMode(s);
   setOpaque(s);
   if (s) {
     addMouseListener(ml);
     curLoc.x = defLoc.x;
     curLoc.y = defLoc.y;
     defDim = getPreferredSize();
     curDim.width = defDim.width;
     curDim.height = defDim.height;
   } else removeMouseListener(ml);
   inEditMode = s;
 }
  /** Constrains a point to the current grid. */
  protected Point constrainPoint(Point p) {
    // constrain to view size
    Dimension size = getSize();
    // p.x = Math.min(size.width, Math.max(1, p.x));
    // p.y = Math.min(size.height, Math.max(1, p.y));
    p.x = Geom.range(1, size.width, p.x);
    p.y = Geom.range(1, size.height, p.y);

    if (fConstrainer != null) {
      return fConstrainer.constrainPoint(p);
    }
    return p;
  }
Beispiel #24
0
    private void ensureInBounds() {
      if (bounds == null) {
        bounds = new Rect(0, 0, width, height);
      }

      float xMin = bounds.x + radius;
      float xMax = bounds.w + bounds.x - radius;
      float yMin = bounds.y + radius;
      float yMax = (bounds.h + bounds.y) - radius;
      if (pos.x < xMin) {
        pos.x = xMin;

        vel.x *= COLLISION_SCALE;
      } else if (pos.x > xMax) {
        pos.x = xMax;

        vel.x *= COLLISION_SCALE;
      }

      if (pos.y < yMin) {
        pos.y = yMin;
        vel.y *= COLLISION_SCALE;
      } else if (pos.y > yMax) {
        pos.y = yMax;
        vel.y *= COLLISION_SCALE;
      }

      Float p1 = new Float(pos.x);
      Float p2 = new Float(pos.y);
      Float v1 = new Float(vel.x);
      Float v2 = new Float(vel.y);

      // If anything is NaN -- make new Point and Velocity
      if (p1.isNaN(p1) || p2.isNaN(p2) || v1.isNaN(v1) || v2.isNaN(v2)) {
        pos = new Point(random(width), random(height)); // Place new point randomly
        vel = new Vector(0.0f, 0.0f); // Start it out with no movement
      }
    }
  /**
   * Returns the component in the currently selected path which contains sourcePoint.
   *
   * @param source The component in whose coordinate space sourcePoint is given
   * @param sourcePoint The point which is being tested
   * @return The component in the currently selected path which contains sourcePoint (relative to
   *     the source component's coordinate space. If sourcePoint is not inside a component on the
   *     currently selected path, null is returned.
   */
  public Component componentForPoint(Component source, Point sourcePoint) {
    int screenX, screenY;
    Point p = sourcePoint;
    int i, c, j, d;
    Component mc;
    Rectangle r2;
    int cWidth, cHeight;
    MenuElement menuElement;
    MenuElement subElements[];
    Vector<MenuElement> tmp;
    int selectionSize;

    SwingUtilities.convertPointToScreen(p, source);

    screenX = p.x;
    screenY = p.y;

    tmp = (Vector<MenuElement>) selection.clone();
    selectionSize = tmp.size();
    for (i = selectionSize - 1; i >= 0; i--) {
      menuElement = (MenuElement) tmp.elementAt(i);
      subElements = menuElement.getSubElements();

      for (j = 0, d = subElements.length; j < d; j++) {
        if (subElements[j] == null) continue;
        mc = subElements[j].getComponent();
        if (!mc.isShowing()) continue;
        if (mc instanceof JComponent) {
          cWidth = mc.getWidth();
          cHeight = mc.getHeight();
        } else {
          r2 = mc.getBounds();
          cWidth = r2.width;
          cHeight = r2.height;
        }
        p.x = screenX;
        p.y = screenY;
        SwingUtilities.convertPointFromScreen(p, mc);

        /**
         * Return the deepest component on the selection path in whose bounds the event's point
         * occurs
         */
        if (p.x >= 0 && p.x < cWidth && p.y >= 0 && p.y < cHeight) {
          return mc;
        }
      }
    }
    return null;
  }
  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 #27
0
  // Works the exact same way as rangeSize(). Simply checks if sub-tree possibly contains points in
  // query
  private void rangeQuery(Point sw, Point ne, Collection<Point> result, TreeNode t) {
    if (t == null) return;

    if (subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.minX.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.maxX.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.minY.p)
        || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.maxY.p)) {
      rangeQuery(sw, ne, result, t.left);
      rangeQuery(sw, ne, result, t.right);
    } else return;

    if (inRange(sw, ne, t.p)) result.add(t.p);
  }
  /**
   * Shows the appropriate user interface that would allow the user to add the given
   * <tt>SourceUIContact</tt> to their contact list.
   *
   * @param contact the contact to add
   */
  private void addContact(SourceUIContact contact) {
    SourceContact sourceContact = (SourceContact) contact.getDescriptor();

    List<ContactDetail> details =
        sourceContact.getContactDetails(OperationSetPersistentPresence.class);
    int detailsCount = details.size();

    if (detailsCount > 1) {
      JMenuItem addContactMenu =
          TreeContactList.createAddContactMenu((SourceContact) contact.getDescriptor());

      JPopupMenu popupMenu = ((JMenu) addContactMenu).getPopupMenu();

      // Add a title label.
      JLabel infoLabel = new JLabel();
      infoLabel.setText(
          "<html><b>"
              + GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT")
              + "</b></html>");

      popupMenu.insert(infoLabel, 0);
      popupMenu.insert(new Separator(), 1);

      popupMenu.setFocusable(true);
      popupMenu.setInvoker(treeContactList);

      Point location =
          new Point(
              addContactButton.getX(), addContactButton.getY() + addContactButton.getHeight());

      SwingUtilities.convertPointToScreen(location, treeContactList);

      location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y;

      popupMenu.setLocation(location.x + 8, location.y - 8);
      popupMenu.setVisible(true);
    } else if (details.size() == 1) {
      TreeContactList.showAddContactDialog(details.get(0), sourceContact.getDisplayName());
    }
  }
Beispiel #29
0
    // {{{ mousePressed() method
    @Override
    public void mousePressed(MouseEvent evt) {
      Point p = evt.getPoint();
      if (evt.getSource() != table) {
        p.x -= table.getX();
        p.y -= table.getY();
      }

      int row = table.rowAtPoint(p);
      int column = table.columnAtPoint(p);
      if (column == 0 && row != -1) {
        VFSDirectoryEntryTableModel.Entry entry =
            (VFSDirectoryEntryTableModel.Entry) table.getModel().getValueAt(row, 0);
        if (FileCellRenderer.ExpansionToggleBorder.isExpansionToggle(entry.level, p.x)) {
          table.toggleExpanded(row);
          return;
        }
      }

      if (GUIUtilities.isMiddleButton(evt.getModifiers())) {
        if (row == -1) /* nothing */ ;
        else if (evt.isShiftDown()) table.getSelectionModel().addSelectionInterval(row, row);
        else table.getSelectionModel().setSelectionInterval(row, row);
      } else if (GUIUtilities.isPopupTrigger(evt)) {
        if (popup != null && popup.isVisible()) {
          popup.setVisible(false);
          popup = null;
          return;
        }

        if (row == -1) showFilePopup(null, table, evt.getPoint());
        else {
          if (!table.getSelectionModel().isSelectedIndex(row))
            table.getSelectionModel().setSelectionInterval(row, row);
          showFilePopup(getSelectedFiles(), table, evt.getPoint());
        }
      }
    } // }}}
Beispiel #30
0
 public void setEditMode(boolean s) {
   if (s) {
     addMouseListener(ml);
     setOpaque(s);
     if (font != null) {
       setFont(font);
       fontH = font.getSize();
       rHeight = fontH;
     }
     defDim = getPreferredSize();
     curLoc.x = defLoc.x;
     curLoc.y = defLoc.y;
     curDim.width = defDim.width;
     curDim.height = defDim.height;
     xRatio = 1.0;
     yRatio = 1.0;
   } else {
     removeMouseListener(ml);
     if ((bg != null) || (isActive < 1)) setOpaque(true);
     else setOpaque(false);
   }
   inEditMode = s;
 }