/*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2020 Association for Decentralized Information Management
* in Industry THTH ry.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
*
* Contributors:
* VTT Technical Research Centre of Finland - initial API and implementation
+ * Semantum Oy - gitlab #454
*******************************************************************************/
package org.simantics.g2d.diagram.handler;
import java.util.Comparator;
import java.util.List;
+import org.simantics.g2d.canvas.ICanvasContext;
import org.simantics.g2d.connection.handler.ConnectionHandler;
import org.simantics.g2d.element.IElement;
import org.simantics.g2d.element.handler.BendsHandler;
public PickFilter pickFilter = null;
public PickSorter pickSorter = null;
+ /**
+ * Used to optimize picking if provided via R-tree traversal to find
+ * intersecting elements, not everything.
+ */
+ public ICanvasContext pickContext;
+
public PickRequest(double x, double y)
{
pickArea = new Rectangle2D.Double(x, y, 1, 1);
pickArea = GeometryUtils.transformShape(shape, transform);
}
+ public PickRequest context(ICanvasContext ctx) {
+ this.pickContext = ctx;
+ return this;
+ }
+
public static interface PickFilter {
boolean accept(IElement e);
}
public static interface PickSorter {
+ /**
+ * Sorts the specified element list.
+ *
+ * @param elements the element list to sort
+ */
void sort(List<IElement> elements);
+ /**
+ * Extended interface-method that receives the pick request in addition to the
+ * picked elements to be sorted. Allows e.g. looking at the pick area in the
+ * sorter.
+ *
+ * <p>
+ * The default implementation just invokes {@link #sort(List)} ignoring the pick
+ * request. The default implementation also keeps PickSorter API/ABI-compatible.
+ *
+ * @param request the original pick request that produced the hits listed in
+ * <code>elements</code>
+ * @param elements the element list to sort
+ *
+ * @author Tuukka Lehtonen
+ * @since 1.43.0, 1.35.3
+ */
+ default void sort(PickRequest request, List<IElement> elements) {
+ sort(elements);
+ }
+
//
public static final PickSorter CONNECTIONS_LAST = new PickSorter() {
@Override