use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.
the class AbstractOverlay method getSnapLayers.
protected List<AbstractRecordLayer> getSnapLayers() {
final Project project = getProject();
final MapPanel map = getMap();
final double scale = map.getScale();
return AbstractRecordLayer.getVisibleLayers(project, scale);
}
use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.
the class AbstractOverlay method setSnapLocations.
protected boolean setSnapLocations(final Map<Point, Set<CloseLocation>> snapLocations) {
if (snapLocations.isEmpty()) {
if (!this.snapPointLocationMap.isEmpty()) {
this.snapCentre = null;
this.snapPoint = null;
this.snapPointLocationMap = snapLocations;
this.snapPoints.clear();
clearMapCursor();
this.map.clearToolTipText();
}
return false;
} else {
if (!DataType.equal(snapLocations, this.snapPointLocationMap)) {
this.snapPointIndex = 1;
this.snapPointLocationMap = snapLocations;
this.snapPoints.clear();
this.snapPoints.addAll(snapLocations.keySet());
Collections.sort(this.snapPoints, new Comparator<Point>() {
@Override
public int compare(final Point point1, final Point point2) {
final Collection<CloseLocation> locations1 = snapLocations.get(point1);
final Collection<CloseLocation> locations2 = snapLocations.get(point2);
final boolean hasVertex1 = hasVertex(locations1);
final boolean hasVertex2 = hasVertex(locations2);
if (hasVertex1) {
if (!hasVertex2) {
return -1;
}
} else if (hasVertex2) {
return 0;
}
final double distance1 = AbstractOverlay.this.snapCentre.distancePoint(point1);
final double distance2 = AbstractOverlay.this.snapCentre.distancePoint(point2);
if (distance1 <= distance2) {
return -1;
} else {
return 0;
}
}
private boolean hasVertex(final Collection<CloseLocation> locations) {
for (final CloseLocation location : locations) {
if (location.getVertex() != null) {
return true;
}
}
return false;
}
});
}
final MapPanel map = getMap();
if (this.snapPointIndex == 0) {
this.snapPoint = getEventPoint();
} else {
this.snapPoint = this.snapPoints.get(this.snapPointIndex - 1);
}
boolean nodeSnap = false;
final StringBuilder text = new StringBuilder("<html>");
text.append("<div style=\"padding: 1px;");
if (0 == this.snapPointIndex) {
text.append("background-color: #0000ff;color: #ffffff");
} else {
text.append("background-color: #ffffff");
}
text.append("\"><b>0.</b> ");
final Point mousePoint = getEventPoint();
appendPoint(text, mousePoint);
text.append(" (");
text.append(mousePoint.getCoordinateSystemId());
text.append(")</div>");
int i = 1;
for (final Point snapPoint : this.snapPoints) {
text.append("<div style=\"border-top: 1px solid #666666;");
if (i == this.snapPointIndex) {
text.append("border: 2px solid #0000ff");
} else {
text.append("padding: 2px;background-color: #ffffff2");
}
text.append("\">");
text.append("<div style=\"padding: 1px;");
if (i == this.snapPointIndex) {
text.append("background-color: #0000ff;color: #ffffff");
}
text.append("\"><b>");
text.append(i);
text.append(".</b> ");
appendPoint(text, snapPoint);
text.append(" (");
text.append(snapPoint.getCoordinateSystemId());
text.append(")</div>");
final Map<String, Set<CloseLocation>> typeLocationsMap = new TreeMap<>();
for (final CloseLocation snapLocation : this.snapPointLocationMap.get(snapPoint)) {
final String typePath = snapLocation.getLayerPath();
final String locationType = snapLocation.getType();
if ("Point".equals(locationType) || "End-Vertex".equals(locationType)) {
nodeSnap = true;
}
Maps.addToSet(typeLocationsMap, typePath + " (<b style=\"color:red\">" + locationType + "</b>)", snapLocation);
}
for (final Entry<String, Set<CloseLocation>> typeLocations : typeLocationsMap.entrySet()) {
final String type = typeLocations.getKey();
text.append("<div style=\"padding: 1px;");
if (i == this.snapPointIndex) {
text.append("background-color: #87CEFA");
} else {
// text.append("background-color: #ffffff");
}
text.append("\"> ");
text.append(type);
text.append("</div>");
}
text.append("</div>");
i++;
}
text.append("</html>");
map.setToolTipText(this.snapEventX, this.snapEventY, text);
if (Booleans.getBoolean(nodeSnap)) {
setMapCursor(CURSOR_NODE_SNAP);
} else {
setMapCursor(CURSOR_LINE_SNAP);
}
return true;
}
}
use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.
the class EditRecordGeometryOverlay method modeAddGeometryMove.
protected boolean modeAddGeometryMove(final MouseEvent event) {
if (this.addGeometryEditor != null) {
if (isOverlayAction(ACTION_ADD_GEOMETRY) || isOverlayAction(ACTION_MOVE_GEOMETRY) || isOverlayAction(ACTION_ADD_GEOMETRY_EDIT_VERTICES)) {
final MapPanel map = getMap();
final CloseLocation location = map.findCloseLocation(this.addLayer, null, this.addGeometryEditor);
final List<CloseLocation> locations = new ArrayList<>();
if (location != null) {
locations.add(location);
}
final boolean hasMouseOver = setMouseOverLocations(locations);
if (event != null && event.isAltDown()) {
if (hasMouseOver) {
setOverlayAction(ACTION_MOVE_GEOMETRY);
} else {
clearOverlayAction(ACTION_MOVE_GEOMETRY);
if (!hasMouseOverLocation()) {
clearMapCursor();
}
}
} else {
clearOverlayAction(ACTION_MOVE_GEOMETRY);
// TODO make work with multi-part
if (hasMouseOver) {
setOverlayAction(ACTION_ADD_GEOMETRY_EDIT_VERTICES);
} else {
clearOverlayAction(ACTION_ADD_GEOMETRY_EDIT_VERTICES);
modeAddGeometryUpdateXorGeometry();
}
}
return true;
}
}
return false;
}
use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.
the class EditRecordGeometryOverlay method clearMouseOverLocations.
protected void clearMouseOverLocations() {
setXorGeometry(null);
clearMouseOverGeometry();
final MapPanel map = getMap();
map.clearCloseSelected();
map.clearToolTipText();
repaint();
}
use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.
the class AbstractRecordLayer method panToBoundingBox.
public void panToBoundingBox(final BoundingBox boundingBox) {
final MapPanel mapPanel = getMapPanel();
mapPanel.panToBoundingBox(boundingBox);
}
Aggregations