Calculates a drop location in this component, representing where a drop at the given point should insert data. @param p the point to calculate a drop location for @return the drop location, or null
(Point p)
| 1300 | * @return the drop location, or <code>null</code> |
| 1301 | */ |
| 1302 | DropLocation dropLocationForPoint(Point p) { |
| 1303 | DropLocation location = null; |
| 1304 | |
| 1305 | int row = getClosestRowForLocation(p.x, p.y); |
| 1306 | Rectangle bounds = getRowBounds(row); |
| 1307 | TreeModel model = getModel(); |
| 1308 | Object root = (model == null) ? null : model.getRoot(); |
| 1309 | TreePath rootPath = (root == null) ? null : new TreePath(root); |
| 1310 | |
| 1311 | TreePath child; |
| 1312 | TreePath parent; |
| 1313 | boolean outside = row == -1 |
| 1314 | || p.y < bounds.y |
| 1315 | || p.y >= bounds.y + bounds.height; |
| 1316 | |
| 1317 | switch(dropMode) { |
| 1318 | case USE_SELECTION: |
| 1319 | case ON: |
| 1320 | if (outside) { |
| 1321 | location = new DropLocation(p, null, -1); |
| 1322 | } else { |
| 1323 | location = new DropLocation(p, getPathForRow(row), -1); |
| 1324 | } |
| 1325 | |
| 1326 | break; |
| 1327 | case INSERT: |
| 1328 | case ON_OR_INSERT: |
| 1329 | if (row == -1) { |
| 1330 | if (root != null && !model.isLeaf(root) && isExpanded(rootPath)) { |
| 1331 | location = new DropLocation(p, rootPath, 0); |
| 1332 | } else { |
| 1333 | location = new DropLocation(p, null, -1); |
| 1334 | } |
| 1335 | |
| 1336 | break; |
| 1337 | } |
| 1338 | |
| 1339 | boolean checkOn = dropMode == DropMode.ON_OR_INSERT |
| 1340 | || !model.isLeaf(getPathForRow(row).getLastPathComponent()); |
| 1341 | |
| 1342 | Section section = SwingUtilities2.liesInVertical(bounds, p, checkOn); |
| 1343 | if(section == LEADING) { |
| 1344 | child = getPathForRow(row); |
| 1345 | parent = child.getParentPath(); |
| 1346 | } else if (section == TRAILING) { |
| 1347 | int index = row + 1; |
| 1348 | if (index >= getRowCount()) { |
| 1349 | if (model.isLeaf(root) || !isExpanded(rootPath)) { |
| 1350 | location = new DropLocation(p, null, -1); |
| 1351 | } else { |
| 1352 | parent = rootPath; |
| 1353 | index = model.getChildCount(root); |
| 1354 | location = new DropLocation(p, parent, index); |
| 1355 | } |
| 1356 | |
| 1357 | break; |
| 1358 | } |
| 1359 |
nothing calls this directly
no test coverage detected