use of com.revolsys.swing.map.overlay.CloseLocation in project com.revolsys.open by revolsys.
the class MapPanel method mouseMovedCloseSelected.
public boolean mouseMovedCloseSelected(final MouseEvent event) {
if (isOverlayAction(SelectRecordsOverlay.ACTION_SELECT_RECORDS) || isOverlayAction(ZoomOverlay.ACTION_ZOOM_BOX) || isOverlayAction(ZoomOverlay.ACTION_PAN)) {
clearCloseSelected();
return false;
} else {
final double scale = getViewport().getScale();
final Point point = MouseOverlay.getEventPoint();
final double x = point.getX();
final double y = point.getY();
final double maxDistance = this.viewport.getHotspotMapUnits();
final GeometryFactory geometryFactory = this.viewport.getGeometryFactory2dFloating();
final BoundingBox boundingBox = point.newBoundingBox().expand(maxDistance);
final List<LayerRecord> closeRecords = new ArrayList<>();
final List<CloseLocation> closeLocations = new ArrayList<>();
for (final LayerRecord closeRecord : getSelectedRecords(boundingBox)) {
final AbstractRecordLayer layer = closeRecord.getLayer();
if (layer.isVisible(scale) && layer.isVisible(closeRecord)) {
final Geometry geometry = closeRecord.getGeometry();
final CloseLocation closeLocation = findCloseLocation(geometryFactory, layer, closeRecord, geometry, x, y, maxDistance);
if (closeLocation != null) {
closeRecords.add(closeRecord);
closeLocations.add(closeLocation);
}
}
}
this.closeSelectedRecords = closeRecords;
this.closeSelectedLocations = closeLocations;
repaint();
return true;
}
}
use of com.revolsys.swing.map.overlay.CloseLocation in project com.revolsys.open by revolsys.
the class EditRecordGeometryOverlay method modeEditGeometryVerticesFinish.
protected boolean modeEditGeometryVerticesFinish(final MouseEvent event) {
if (this.editGeometryVerticesStart && clearOverlayAction(ACTION_EDIT_GEOMETRY_VERTICES)) {
if (this.dragged && event.getButton() == MouseEvent.BUTTON1) {
try {
final MultipleUndo edit = new MultipleUndo();
final List<CloseLocation> locations = getMouseOverLocations();
for (final CloseLocation location : locations) {
final GeometryEditor<?> geometryEditor = geometryEdit(event, location);
if (geometryEditor.isModified()) {
final Geometry newGeometry = geometryEditor.newGeometry();
final UndoableEdit geometryEdit = setGeometry(location, newGeometry);
edit.addEdit(geometryEdit);
}
}
if (!edit.isEmpty()) {
addUndo(edit);
}
} finally {
modeEditGeometryVerticesClear();
}
return true;
}
}
return false;
}
use of com.revolsys.swing.map.overlay.CloseLocation in project com.revolsys.open by revolsys.
the class EditRecordGeometryOverlay method modePopupMenu.
private boolean modePopupMenu(final MouseEvent event) {
if (event.isPopupTrigger()) {
for (final CloseLocation location : getMouseOverLocations()) {
final LayerRecord record = location.getRecord();
if (record != null) {
final LayerRecordMenu menu = record.getMenu();
menu.showMenu(record, event);
}
return true;
}
}
return false;
}
use of com.revolsys.swing.map.overlay.CloseLocation in project com.revolsys.open by revolsys.
the class EditRecordGeometryOverlay method modeEditGeometryVerticesMove.
protected boolean modeEditGeometryVerticesMove(final MouseEvent event) {
if (canOverrideOverlayAction(ACTION_EDIT_GEOMETRY_VERTICES) || isOverlayAction(ACTION_MOVE_GEOMETRY)) {
final double scale = getViewportScale();
final List<CloseLocation> closeLocations = new ArrayList<>();
final MapPanel map = getMap();
for (final CloseLocation location : map.getCloseSelectedLocations()) {
final AbstractRecordLayer layer = location.getLayer();
if (layer.isEditable(scale)) {
closeLocations.add(location);
}
}
if (closeLocations.isEmpty()) {
modeMoveGeometryClear();
modeEditGeometryVerticesClear();
} else if (event.isAltDown()) {
setOverlayAction(ACTION_MOVE_GEOMETRY);
} else {
setOverlayAction(ACTION_EDIT_GEOMETRY_VERTICES);
}
return setMouseOverLocations(closeLocations);
}
return false;
}
use of com.revolsys.swing.map.overlay.CloseLocation in project com.revolsys.open by revolsys.
the class EditRecordGeometryOverlay method updateMouseOverLocations.
private boolean updateMouseOverLocations() {
final MapPanel map = getMap();
if (hasMouseOverLocation()) {
if (isOverlayAction(ACTION_MOVE_GEOMETRY)) {
map.clearToolTipText();
} else {
final Map<String, Set<CloseLocation>> vertexLocations = new TreeMap<>();
final Map<String, Set<CloseLocation>> segmentLocations = new TreeMap<>();
for (final CloseLocation location : getMouseOverLocations()) {
final String typePath = location.getLayerPath();
if (location.getVertexId() == null) {
Maps.addToSet(segmentLocations, typePath, location);
} else {
Maps.addToSet(vertexLocations, typePath, location);
}
}
final StringBuilder text = new StringBuilder("<html>");
appendLocations(text, "Move Vertices", vertexLocations);
appendLocations(text, "Insert Vertices", segmentLocations);
text.append("</html>");
final Point2D eventPoint = getEventPosition();
map.setToolTipText(eventPoint, text);
}
return true;
} else {
map.clearToolTipText();
return false;
}
}
Aggregations