public void selectRenderables(DrawContext dc, Sector vs) { // Select our renderables if (this.gridElements == null) createRenderables(); boolean drawMetricLabels = getSizeInPixels(dc) > MIN_CELL_SIZE_PIXELS * 2; String graticuleType = getTypeFor((int) this.size); for (GridElement ge : this.gridElements) { if (ge.isInView(dc, vs)) { if (ge.type.equals(GridElement.TYPE_LINE_NORTH) && this.isNorthNeighborInView(dc)) continue; if (ge.type.equals(GridElement.TYPE_LINE_EAST) && this.isEastNeighborInView(dc)) continue; if (drawMetricLabels) metricScaleSupport.computeMetricScaleExtremes( this.UTMZone, this.hemisphere, ge, this.size * 10); addRenderable(ge.renderable, graticuleType); } } if (getSizeInPixels(dc) <= MIN_CELL_SIZE_PIXELS * 2) return; // Select grid renderables if (this.squareGrid == null) this.squareGrid = new SquareGrid( this.UTMZone, this.hemisphere, this.UTMZoneSector, this.SWEasting, this.SWNorthing, this.size); if (this.squareGrid.isInView(dc)) { this.squareGrid.selectRenderables(dc, vs); } else this.squareGrid.clearRenderables(); }
public void selectRenderables(DrawContext dc, Sector vs) { // Select our renderables if (this.gridElements == null) createRenderables(); int gridStep = (int) this.size / 10; boolean drawMetricLabels = getSizeInPixels(dc) > MIN_CELL_SIZE_PIXELS * 4 * 1.7; String graticuleType = getTypeFor(gridStep); for (GridElement ge : this.gridElements) { if (ge.isInView(dc, vs)) { if (drawMetricLabels) metricScaleSupport.computeMetricScaleExtremes( this.UTMZone, this.hemisphere, ge, this.size); addRenderable(ge.renderable, graticuleType); } } if (getSizeInPixels(dc) <= MIN_CELL_SIZE_PIXELS * 4 * 2) return; // Select sub grids renderables if (this.subGrids == null) createSubGrids(); for (SquareGrid sg : this.subGrids) { if (sg.isInView(dc)) { sg.selectRenderables(dc, vs); } else sg.clearRenderables(); } }
/** * Select the visible grid elements * * @param dc the current <code>DrawContext</code>. */ protected void selectRenderables(DrawContext dc) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } Sector vs = dc.getVisibleSector(); OrbitView view = (OrbitView) dc.getView(); // Compute labels offset from view center Position centerPos = view.getCenterPosition(); Double pixelSizeDegrees = Angle.fromRadians( view.computePixelSizeAtDistance(view.getZoom()) / dc.getGlobe().getEquatorialRadius()) .degrees; Double labelOffsetDegrees = pixelSizeDegrees * view.getViewport().getWidth() / 4; Position labelPos = Position.fromDegrees( centerPos.getLatitude().degrees - labelOffsetDegrees, centerPos.getLongitude().degrees - labelOffsetDegrees, 0); Double labelLatDegrees = labelPos.getLatitude().normalizedLatitude().degrees; labelLatDegrees = Math.min(Math.max(labelLatDegrees, -76), 78); labelPos = new Position( Angle.fromDegrees(labelLatDegrees), labelPos.getLongitude().normalizedLongitude(), 0); if (vs != null) { for (GridElement ge : this.gridElements) { if (ge.isInView(dc)) { if (ge.renderable instanceof GeographicText) { GeographicText gt = (GeographicText) ge.renderable; if (labelPos.getLatitude().degrees < 72 || "*32*34*36*".indexOf("*" + gt.getText() + "*") == -1) { // Adjust label position according to eye position Position pos = gt.getPosition(); if (ge.type.equals(GridElement.TYPE_LATITUDE_LABEL)) pos = Position.fromDegrees( pos.getLatitude().degrees, labelPos.getLongitude().degrees, pos.getElevation()); else if (ge.type.equals(GridElement.TYPE_LONGITUDE_LABEL)) pos = Position.fromDegrees( labelPos.getLatitude().degrees, pos.getLongitude().degrees, pos.getElevation()); gt.setPosition(pos); } } this.graticuleSupport.addRenderable(ge.renderable, GRATICULE_UTM); } } // System.out.println("Total elements: " + count + " visible sector: " + vs); } }