/** * Returns the native view to be given to a newly created {@link ViewsManager}. We can not * returns {@code this} like what {@link GridCoverage2D} does because this class is just a * decorator around a {@linkplain #source}, and the later may not be a native view - it can * be anything like a geophysics, a packed, <cite>etc</cite>. We can hardly call any instance * of this decorator as "native", so the safest approach is to use the native view of the * source. This is needed for proper working of {@link ViewsManager}: if this decorator stands * between it and the views that it creates, it may not realize that a view was already created. */ @Override final GridCoverage2D getNativeView() { return source.view(ViewType.NATIVE); }
/** * Post processing on the coverage resulting from JAI operation. * * @param coverage * {@link GridCoverage2D} resulting from the operation. * @param primarySourceType * Tells if we have to change the "geo-view" for the provided {@link GridCoverage2D}. * * @return the prepared {@link GridCoverage2D}. */ private static GridCoverage2D postProcessResult(GridCoverage2D coverage, final ViewType primarySourceType) { if (primarySourceType != null) { coverage = coverage.view(primarySourceType); } return coverage; }
/** * @deprecated Replaced by {@link #view}. */ @Deprecated public GridCoverage2D geophysics(final boolean geo) { return view(geo ? ViewType.GEOPHYSICS : ViewType.PACKED); }
/** * Returns the set of views that this coverage represents. The same coverage may be used for * more than one view. For example a coverage could be valid both as a {@link ViewType#PACKED * PACKED} and {@link ViewType#RENDERED RENDERED} view. * * @return The set of views that this coverage represents. * * @since 2.5 */ public synchronized Set<ViewType> getViewTypes() { if (viewTypes == null) { final Set<ViewType> vtSet = EnumSet.allOf(ViewType.class); vtSet.remove(ViewType.SAME); // Removes trivial view. for (final Iterator<ViewType> it=vtSet.iterator(); it.hasNext();) { if (view(it.next()) != this) { it.remove(); } } // Assign only in successful. this.viewTypes = Collections.unmodifiableSet(vtSet); } return viewTypes; }
/** * {inheritDoc} */ @Override public void show(String title, final int xAxis, final int yAxis) { final GridCoverage2D displayable = view(ViewType.RENDERED); if (displayable != this) { displayable.show(title, xAxis, yAxis); return; } if (title == null || (title = title.trim()).length() == 0) { final StringBuilder buffer = new StringBuilder(String.valueOf(getName())); final int visibleBandIndex = CoverageUtilities.getVisibleBand(this); final SampleDimension visibleBand = getSampleDimension(visibleBandIndex); final Unit<?> unit = visibleBand.getUnits(); buffer.append(" - ").append(String.valueOf(visibleBand.getDescription())); if (unit != null) { buffer.append(" (").append(unit).append(')'); } title = buffer.toString(); } super.show(title, xAxis, yAxis); }
coverage = coverage.view(finalView); return coverage;
private static void view(RenderedImage ri, GridGeometry2D gg, GridSampleDimension[] gsd) { final GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); GridCoverage2D rendered = factory.create("Merged coverage", ri, gg, gsd, null, null); rendered.view(ViewType.RENDERED).show(); }
final GridCoverage2D candidate = coverage.view(ViewType.NATIVE); if (candidate != coverage) { final List<RenderedImage> sources = coverage.getRenderedImage().getSources();
renderer.paint((Graphics2D) g, coverage2D.view(ViewType.GEOPHYSICS), symbolizer); } catch (FactoryException ex) { Exceptions.printStackTrace(ex);
if (computeOnGeophysicsValues) { final GridCoverage2D old = source; source = source.view(ViewType.GEOPHYSICS); if (i == PRIMARY_SOURCE_INDEX) { type = (old == source) ? ViewType.GEOPHYSICS : ViewType.PACKED;
renderer.paint(graphics, raster.view(ViewType.GEOPHYSICS), symbolizer); } catch (FactoryException ex) { Exceptions.printStackTrace(ex);
gc2d = gc2d.view(ViewType.GEOPHYSICS);
final GridCoverage2D visual = source.view(ViewType.RENDERED); final RenderedImage image = visual.getRenderedImage(); final GridSampleDimension[] bands = visual.getSampleDimensions();
sourceCoverage, interpolation, false, hints); final ViewType finalView = CoverageUtilities.preferredViewAfterOperation(sourceCoverage); sourceCoverage = sourceCoverage.view(processingView); PlanarImage sourceImage = PlanarImage.wrapRenderedImage(sourceCoverage.getRenderedImage()); assert sourceCoverage.getCoordinateReferenceSystem() == sourceCRS : sourceCoverage; sourceCoverage = sourceCoverage.view(ViewType.NATIVE); sourceImage = PlanarImage.wrapRenderedImage(sourceCoverage.getRenderedImage()); paramBlk.removeSources(); sourceCoverage = sourceCoverage.view(finalView); sourceImage = PlanarImage.wrapRenderedImage(sourceCoverage.getRenderedImage()); return create(sourceCoverage, sourceImage, targetGG, ViewType.SAME, null, null, hints);