use of de.fhpotsdam.unfolding.utils.ScreenPosition in project constellation by constellation-app.
the class AbstractPathsLayer method requiresUpdate.
@Override
public boolean requiresUpdate() {
if (drawPathsToOffscreenMarkers()) {
// check the graph isn't null
if (graph == null) {
boolean update = !graphId.isEmpty();
if (update) {
graphId = "";
structureModCount = -1;
}
return update;
}
// check that we have the same graph, and that it hasn't been structurally modified
try {
final Tuple<String, Long> graphTuple = graph.readFromGraph(reader -> Tuple.create(reader.getId(), reader.getStructureModificationCounter()));
if (!graphTuple.getFirst().equals(graphId)) {
graphId = graphTuple.getFirst();
return true;
}
if (graphTuple.getSecond() != structureModCount) {
structureModCount = graphTuple.getSecond();
return true;
}
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
return false;
}
}
final ScreenPosition topLeft = map.getScreenPosition(map.getTopLeftBorder());
final ScreenPosition bottomRight = map.getScreenPosition(map.getBottomRightBorder());
return onScreenMarkerCount != renderer.getMarkerCache().keys().stream().filter(marker -> {
final ScreenPosition markerPosition = map.getScreenPosition(marker.getLocation());
return !marker.isHidden() && markerPosition != null && markerPosition.x > topLeft.x && markerPosition.y > topLeft.y && markerPosition.x < bottomRight.x && markerPosition.y < bottomRight.y;
}).count();
}
use of de.fhpotsdam.unfolding.utils.ScreenPosition in project constellation by constellation-app.
the class ThiessenPolygonsLayer method requiresUpdate.
@Override
public boolean requiresUpdate() {
final ScreenPosition topLeft = map.getScreenPosition(map.getTopLeftBorder());
final ScreenPosition bottomRight = map.getScreenPosition(map.getBottomRightBorder());
return onScreenMarkerCount != map.getMarkers().stream().filter(marker -> {
final ScreenPosition markerPosition = marker.getLocation() != null ? map.getScreenPosition(marker.getLocation()) : null;
return !marker.isHidden() && markerPosition != null && markerPosition.x > topLeft.x && markerPosition.y > topLeft.y && markerPosition.x < bottomRight.x && markerPosition.y < bottomRight.y;
}).count();
}
use of de.fhpotsdam.unfolding.utils.ScreenPosition in project constellation by constellation-app.
the class OverviewOverlay method overlay.
@Override
public void overlay() {
renderer.noStroke();
renderer.fill(BACKGROUND_COLOUR);
renderer.rect(x, y, width, height);
if (!overviewMap.mapDisplay.getMapProvider().equals(map.mapDisplay.getMapProvider())) {
overviewMap.mapDisplay.setMapProvider(map.mapDisplay.getMapProvider());
}
overviewMap.draw();
final ScreenPosition topLeft = overviewMap.getScreenPosition(map.getTopLeftBorder());
final ScreenPosition bottomRight = overviewMap.getScreenPosition(map.getBottomRightBorder());
viewport.setDimension(topLeft, bottomRight);
viewport.draw();
}
use of de.fhpotsdam.unfolding.utils.ScreenPosition in project constellation by constellation-app.
the class AbstractHeatmapLayer method requiresUpdate.
@Override
public boolean requiresUpdate() {
final ScreenPosition topLeft = map.getScreenPosition(map.getTopLeftBorder());
final ScreenPosition bottomRight = map.getScreenPosition(map.getBottomRightBorder());
return onScreenMarkerCount != renderer.getMarkerCache().keys().stream().filter(marker -> {
final ScreenPosition markerPosition = map.getScreenPosition(marker.getLocation());
return !marker.isHidden() && markerPosition != null && markerPosition.x > topLeft.x && markerPosition.y > topLeft.y && markerPosition.x < bottomRight.x && markerPosition.y < bottomRight.y;
}).count();
}
use of de.fhpotsdam.unfolding.utils.ScreenPosition in project constellation by constellation-app.
the class AbstractHeatmapLayer method update.
@Override
public PImage update() {
// update on screen markers
final ScreenPosition topLeft = map.getScreenPosition(map.getTopLeftBorder());
final ScreenPosition bottomRight = map.getScreenPosition(map.getBottomRightBorder());
final List<Marker> onScreenMarkers = renderer.getMarkerCache().keys().stream().filter(marker -> {
final ScreenPosition markerPosition = map.getScreenPosition(marker.getLocation());
return !marker.isHidden() && markerPosition != null && markerPosition.x > topLeft.x && markerPosition.y > topLeft.y && markerPosition.x < bottomRight.x && markerPosition.y < bottomRight.y;
}).collect(Collectors.toList());
onScreenMarkerCount = onScreenMarkers.size();
if (onScreenMarkers.isEmpty()) {
return null;
}
// create point image from markers
final int width = renderer.width - 5;
final int height = renderer.height - 5;
final float[] pointImage = new float[width * height];
onScreenMarkers.forEach(marker -> {
final ConstellationAbstractMarker constellationMarker = (ConstellationAbstractMarker) marker;
final ScreenPosition markerPosition = map.getScreenPosition(constellationMarker.getLocation());
final float markerWeight = getWeight(constellationMarker);
if (markerPosition != null) {
pointImage[(int) markerPosition.y * width + (int) markerPosition.x] = markerWeight;
}
});
// generate gaussian blur around points
final float[] gaussImage = new float[width * height];
GaussianBlur.gaussianBlurBox(pointImage, gaussImage, width, height, RADIUS, PASSES, GaussianBlur.BoxBlurType.FASTEST);
final PImage heatmapImage = renderer.createImage(width, height, PConstants.ARGB);
heatmapImage.loadPixels();
GaussianBlur.colorise(gaussImage, heatmapImage.pixels, THRESHOLD, SEVERITY);
heatmapImage.updatePixels();
return heatmapImage;
}
Aggregations