Search in sources :

Example 6 with ScreenPosition

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();
}
Also used : ScreenPosition(de.fhpotsdam.unfolding.utils.ScreenPosition)

Example 7 with ScreenPosition

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();
}
Also used : ScreenPosition(de.fhpotsdam.unfolding.utils.ScreenPosition)

Example 8 with ScreenPosition

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();
}
Also used : ScreenPosition(de.fhpotsdam.unfolding.utils.ScreenPosition)

Example 9 with ScreenPosition

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();
}
Also used : ScreenPosition(de.fhpotsdam.unfolding.utils.ScreenPosition)

Example 10 with ScreenPosition

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;
}
Also used : PConstants(processing.core.PConstants) List(java.util.List) GaussianBlur(au.gov.asd.tac.constellation.utilities.image.GaussianBlur) ScreenPosition(de.fhpotsdam.unfolding.utils.ScreenPosition) Marker(de.fhpotsdam.unfolding.marker.Marker) PImage(processing.core.PImage) ConstellationAbstractMarker(au.gov.asd.tac.constellation.views.mapview.markers.ConstellationAbstractMarker) Collectors(java.util.stream.Collectors) ConstellationAbstractMarker(au.gov.asd.tac.constellation.views.mapview.markers.ConstellationAbstractMarker) PImage(processing.core.PImage) Marker(de.fhpotsdam.unfolding.marker.Marker) ConstellationAbstractMarker(au.gov.asd.tac.constellation.views.mapview.markers.ConstellationAbstractMarker) ScreenPosition(de.fhpotsdam.unfolding.utils.ScreenPosition)

Aggregations

ScreenPosition (de.fhpotsdam.unfolding.utils.ScreenPosition)10 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 PConstants (processing.core.PConstants)5 PImage (processing.core.PImage)5 MarkerUtilities (au.gov.asd.tac.constellation.views.mapview.utilities.MarkerUtilities)4 Location (de.fhpotsdam.unfolding.geo.Location)4 Marker (de.fhpotsdam.unfolding.marker.Marker)3 ServiceProvider (org.openide.util.lookup.ServiceProvider)3 PGraphics (processing.core.PGraphics)3 Graph (au.gov.asd.tac.constellation.graph.Graph)2 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)2 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)2 ConstellationAbstractMarker (au.gov.asd.tac.constellation.views.mapview.markers.ConstellationAbstractMarker)2 GraphElement (au.gov.asd.tac.constellation.views.mapview.utilities.GraphElement)2 MapPosition (de.fhpotsdam.unfolding.utils.MapPosition)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 SpatialConcept (au.gov.asd.tac.constellation.graph.schema.analytic.concept.SpatialConcept)1