protected Iterator getShapes ( java . awt . Graphics2D g , AffineTransform normal2device ) { long startTime = System . currentTimeMillis ( ) ; if ( featSetList == null ) { initFeatSetList ( ) ; assert ! featSetList . isEmpty ( ) ; } // which featureSet should we ue? FeatureSet fs = ( FeatureSet ) featSetList . get ( 0 ) ; if ( featSetList . size ( ) > 1 ) { // compute scale double scale = 1.0 ; try { AffineTransform world2device = g . getTransform ( ) ; AffineTransform world2normal = normal2device . createInverse ( ) ; world2normal . concatenate ( world2device ) ; scale = Math . max ( Math . abs ( world2normal . getScaleX ( ) ) , Math . abs ( world2normal . getShearX ( ) ) ) ; // drawing or printing if ( Debug . isSet ( "GisFeature/showTransform" ) ) { System . out . println ( "GisFeature/showTransform: " + world2normal + "\n scale = " + scale ) ; } } catch ( java . awt . geom . NoninvertibleTransformException e ) { System . out . println ( " GisRenderFeature: NoninvertibleTransformException on " + normal2device ) ; } if ( ! displayProject . isLatLon ( ) ) scale *= 111.0 ; // km/deg double minD = Double . MAX_VALUE ; for ( Object aFeatSetList : featSetList ) { FeatureSet tryfs = ( FeatureSet ) aFeatSetList ; double d = Math . abs ( scale * tryfs . minDist - pixelMatch ) ; // we want min features ~ 2 pixels if ( d < minD ) { minD = d ; fs = tryfs ; } } if ( Debug . isSet ( "GisFeature/MapResolution" ) ) { System . out . println ( "GisFeature/MapResolution: scale = " + scale + " minDist = " + fs . minDist ) ; } } // we may have deferred the actual creation of the points if ( fs . featureList == null ) fs . createFeatures ( ) ; // ok, now see if we need to project if ( ! displayProject . equals ( fs . project ) ) { fs . setProjection ( displayProject ) ; } else { // deal with LatLon if ( fs . newProjection && displayProject . isLatLon ( ) ) { fs . setProjection ( displayProject ) ; } } fs . newProjection = false ; if ( Debug . isSet ( "GisFeature/timing/getShapes" ) ) { long tookTime = System . currentTimeMillis ( ) - startTime ; System . out . println ( "timing.getShapes: " + tookTime * .001 + " seconds" ) ; } // so return it, already return fs . getShapes ( ) ; }
we have to deal with both projections and resolution - dependence