private Iterable<GeographicText> makeIterable(DrawContext dc) { // get dispay dist for this service for use in label annealing double maxDisplayDistance = this.getPlaceNameService().getMaxDisplayDistance(); ArrayList<GeographicText> list = new ArrayList<GeographicText>(); for (int i = 0; i < this.numEntries; i++) { CharSequence str = getText(i); Position pos = getPosition(i); GeographicText text = new UserFacingText(str, pos); text.setFont(this.placeNameService.getFont()); text.setColor(this.placeNameService.getColor()); text.setBackgroundColor(this.placeNameService.getBackgroundColor()); text.setVisible(isNameVisible(dc, this.placeNameService, pos)); text.setPriority(maxDisplayDistance); list.add(text); } return list; }
public Iterable<GeographicText> makeIterable(DrawContext dc) { double maxDisplayDistance = this.geoNames.getMaxDisplayDistance(); ArrayList<GeographicText> list = new ArrayList<GeographicText>(); for (GeoName geoName : getGeoNameList()) { CharSequence str = getText(geoName); Position pos = getPosition(geoName); GeographicText text = new UserFacingText(str, pos); text.setFont(this.geoNames.font); text.setColor(this.geoNames.getColor()); text.setBackgroundColor(this.geoNames.getBackgroundColor()); text.setVisible(GeoNameLayer.isNameVisible(dc, this.geoNames, pos)); text.setPriority(maxDisplayDistance); list.add(text); } return list; }
public void createRenderables() { this.gridElements = new ArrayList<GridElement>(); ArrayList<Position> positions = new ArrayList<Position>(); Position p1, p2; Object polyline; Sector lineSector; // left segment positions.clear(); if (this.isTruncated) { computeTruncatedSegment(sw, nw, this.UTMZoneSector, positions); } else { positions.add(sw); positions.add(nw); } if (positions.size() > 0) { p1 = positions.get(0); p2 = positions.get(1); polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE); lineSector = Sector.boundingSector(p1, p2); GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_WEST); ge.setValue(this.SWEasting); this.gridElements.add(ge); } // right segment positions.clear(); if (this.isTruncated) { computeTruncatedSegment(se, ne, this.UTMZoneSector, positions); } else { positions.add(se); positions.add(ne); } if (positions.size() > 0) { p1 = positions.get(0); p2 = positions.get(1); polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE); lineSector = Sector.boundingSector(p1, p2); GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_EAST); ge.setValue(this.SWEasting + this.size); this.gridElements.add(ge); } // bottom segment positions.clear(); if (this.isTruncated) { computeTruncatedSegment(sw, se, this.UTMZoneSector, positions); } else { positions.add(sw); positions.add(se); } if (positions.size() > 0) { p1 = positions.get(0); p2 = positions.get(1); polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE); lineSector = Sector.boundingSector(p1, p2); GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_SOUTH); ge.setValue(this.SWNorthing); this.gridElements.add(ge); } // top segment positions.clear(); if (this.isTruncated) { computeTruncatedSegment(nw, ne, this.UTMZoneSector, positions); } else { positions.add(nw); positions.add(ne); } if (positions.size() > 0) { p1 = positions.get(0); p2 = positions.get(1); polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE); lineSector = Sector.boundingSector(p1, p2); GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_NORTH); ge.setValue(this.SWNorthing + this.size); this.gridElements.add(ge); } // Label if (this.name != null) { // Only add a label to squares above some dimension if (this.boundingSector.getDeltaLon().degrees * Math.cos(this.centroid.getLatitude().radians) > .2 && this.boundingSector.getDeltaLat().degrees > .2) { LatLon labelPos = null; if (this.UTMZone != 0) // Not at poles { labelPos = this.centroid; } else if (this.isPositionInside(new Position(this.squareCenter, 0))) { labelPos = this.squareCenter; } else if (this.squareCenter.getLatitude().degrees <= this.UTMZoneSector.getMaxLatitude().degrees && this.squareCenter.getLatitude().degrees >= this.UTMZoneSector.getMinLatitude().degrees) { labelPos = this.centroid; } if (labelPos != null) { GeographicText text = new UserFacingText(this.name, new Position(labelPos, 0)); text.setPriority(this.size * 10); this.gridElements.add( new GridElement(this.boundingSector, text, GridElement.TYPE_GRIDZONE_LABEL)); } } } }
public void selectRenderables(DrawContext dc) { try { OrbitView view = (OrbitView) dc.getView(); // Compute easting and northing label offsets Double pixelSize = view.computePixelSizeAtDistance(view.getZoom()); Double eastingOffset = view.getViewport().width * pixelSize * offsetFactorX / 2; Double northingOffset = view.getViewport().height * pixelSize * offsetFactorY / 2; // Derive labels center pos from the view center Position centerPos = view.getCenterPosition(); double labelEasting; double labelNorthing; String labelHemisphere; if (this.zone > 0) { UTMCoord UTM = UTMCoord.fromLatLon(centerPos.getLatitude(), centerPos.getLongitude(), dc.getGlobe()); labelEasting = UTM.getEasting() + eastingOffset; labelNorthing = UTM.getNorthing() + northingOffset; labelHemisphere = UTM.getHemisphere(); if (labelNorthing < 0) { labelNorthing = 10e6 + labelNorthing; labelHemisphere = AVKey.SOUTH; } } else { UPSCoord UPS = UPSCoord.fromLatLon(centerPos.getLatitude(), centerPos.getLongitude(), dc.getGlobe()); labelEasting = UPS.getEasting() + eastingOffset; labelNorthing = UPS.getNorthing() + northingOffset; labelHemisphere = UPS.getHemisphere(); } Position labelPos; for (int i = 0; i < this.extremes.length; i++) { UTMExtremes levelExtremes = this.extremes[i]; double gridStep = Math.pow(10, i); double gridStepTimesTen = gridStep * 10; String graticuleType = getTypeFor((int) gridStep); if (levelExtremes.minX <= levelExtremes.maxX) { // Process easting scale labels for this level for (double easting = levelExtremes.minX; easting <= levelExtremes.maxX; easting += gridStep) { // Skip multiples of ten grid steps except for last (higher) level if (i == this.extremes.length - 1 || easting % gridStepTimesTen != 0) { try { labelPos = computePosition(this.zone, labelHemisphere, easting, labelNorthing); if (labelPos == null) continue; Angle lat = labelPos.getLatitude(); Angle lon = labelPos.getLongitude(); Vec4 surfacePoint = getSurfacePoint(dc, lat, lon); if (viewFrustum.contains(surfacePoint) && isPointInRange(dc, surfacePoint)) { String text = String.valueOf((int) (easting % this.scaleModulo)); GeographicText gt = new UserFacingText(text, new Position(lat, lon, 0)); gt.setPriority(gridStepTimesTen); addRenderable(gt, graticuleType); } } catch (IllegalArgumentException ignore) { } } } } if (!(levelExtremes.maxYHemisphere.equals(AVKey.SOUTH) && levelExtremes.maxY == 0)) { // Process northing scale labels for this level String currentHemisphere = levelExtremes.minYHemisphere; for (double northing = levelExtremes.minY; (northing <= levelExtremes.maxY) || !currentHemisphere.equals(levelExtremes.maxYHemisphere); northing += gridStep) { // Skip multiples of ten grid steps except for last (higher) level if (i == this.extremes.length - 1 || northing % gridStepTimesTen != 0) { try { labelPos = computePosition(this.zone, currentHemisphere, labelEasting, northing); if (labelPos == null) continue; Angle lat = labelPos.getLatitude(); Angle lon = labelPos.getLongitude(); Vec4 surfacePoint = getSurfacePoint(dc, lat, lon); if (viewFrustum.contains(surfacePoint) && isPointInRange(dc, surfacePoint)) { String text = String.valueOf((int) (northing % this.scaleModulo)); GeographicText gt = new UserFacingText(text, new Position(lat, lon, 0)); gt.setPriority(gridStepTimesTen); addRenderable(gt, graticuleType); } } catch (IllegalArgumentException ignore) { } if (!currentHemisphere.equals(levelExtremes.maxYHemisphere) && northing >= 10e6 - gridStep) { // Switch hemisphere currentHemisphere = levelExtremes.maxYHemisphere; northing = -gridStep; } } } } // end northing } // for levels } catch (IllegalArgumentException ignore) { } }