idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
146,300
public static Polygon calculateBounds ( final MapfishMapContext context ) { double rotation = context . getRootContext ( ) . getRotation ( ) ; ReferencedEnvelope env = context . getRootContext ( ) . toReferencedEnvelope ( ) ; Coordinate centre = env . centre ( ) ; AffineTransform rotateInstance = AffineTransform . getR...
Create a polygon that represents in world space the exact area that will be visible on the printed map .
146,301
public static SimpleFeatureType createGridFeatureType ( final MapfishMapContext mapContext , final Class < ? extends Geometry > geomClass ) { final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder ( ) ; CoordinateReferenceSystem projection = mapContext . getBounds ( ) . getProjection ( ) ; typeBuilde...
Create the grid feature type .
146,302
public static String createLabel ( final double value , final String unit , final GridLabelFormat format ) { final double zero = 0.000000001 ; if ( format != null ) { return format . format ( value , unit ) ; } else { if ( Math . abs ( value - Math . round ( value ) ) < zero ) { return String . format ( "%d %s" , Math ...
Create the label for a grid line .
146,303
public static Object parsePrimitive ( final String fieldName , final PrimitiveAttribute < ? > pAtt , final PObject requestData ) { Class < ? > valueClass = pAtt . getValueClass ( ) ; Object value ; try { value = parseValue ( false , new String [ 0 ] , valueClass , fieldName , requestData ) ; } catch ( UnsupportedTypeEx...
Get the value of a primitive type from the request data .
146,304
protected URL getDefinitionsURL ( ) { try { URL url = CustomEPSGCodes . class . getResource ( CUSTOM_EPSG_CODES_FILE ) ; try ( InputStream stream = url . openStream ( ) ) { stream . read ( ) ; } return url ; } catch ( Throwable e ) { throw new AssertionError ( "Unable to load /epsg.properties file from root of classpat...
Returns the URL to the property file that contains CRS definitions .
146,305
public synchronized void addMapStats ( final MapfishMapContext mapContext , final MapAttribute . MapAttributeValues mapValues ) { this . mapStats . add ( new MapStats ( mapContext , mapValues ) ) ; }
Add statistics about a created map .
146,306
public void addEmailStats ( final InternetAddress [ ] recipients , final boolean storageUsed ) { this . storageUsed = storageUsed ; for ( InternetAddress recipient : recipients ) { emailDests . add ( recipient . getAddress ( ) ) ; } }
Add statistics about sent emails .
146,307
public String calculateLabelUnit ( final CoordinateReferenceSystem mapCrs ) { String unit ; if ( this . labelProjection != null ) { unit = this . labelCRS . getCoordinateSystem ( ) . getAxis ( 0 ) . getUnit ( ) . toString ( ) ; } else { unit = mapCrs . getCoordinateSystem ( ) . getAxis ( 0 ) . getUnit ( ) . toString ( ...
Determine which unit to use when creating grid labels .
146,308
public MathTransform calculateLabelTransform ( final CoordinateReferenceSystem mapCrs ) { MathTransform labelTransform ; if ( this . labelProjection != null ) { try { labelTransform = CRS . findMathTransform ( mapCrs , this . labelCRS , true ) ; } catch ( FactoryException e ) { throw new RuntimeException ( e ) ; } } el...
Determine which math transform to use when creating the coordinate of the label .
146,309
public static GridLabelFormat fromConfig ( final GridParam param ) { if ( param . labelFormat != null ) { return new GridLabelFormat . Simple ( param . labelFormat ) ; } else if ( param . valueFormat != null ) { return new GridLabelFormat . Detailed ( param . valueFormat , param . unitFormat , param . formatDecimalSepa...
Create an instance from the given config .
146,310
public final Credentials toCredentials ( final AuthScope authscope ) { try { if ( ! matches ( MatchInfo . fromAuthScope ( authscope ) ) ) { return null ; } } catch ( UnknownHostException | MalformedURLException | SocketException e ) { throw new RuntimeException ( e ) ; } if ( this . username == null ) { return null ; }...
Check if this applies to the provided authorization scope and return the credentials for that scope or null if it doesn t apply to the scope .
146,311
public final PJsonObject getJSONObject ( final int i ) { JSONObject val = this . array . optJSONObject ( i ) ; final String context = "[" + i + "]" ; if ( val == null ) { throw new ObjectMissingException ( this , context ) ; } return new PJsonObject ( this , val , context ) ; }
Get the element at the index as a json object .
146,312
public final PJsonArray getJSONArray ( final int i ) { JSONArray val = this . array . optJSONArray ( i ) ; final String context = "[" + i + "]" ; if ( val == null ) { throw new ObjectMissingException ( this , context ) ; } return new PJsonArray ( this , val , context ) ; }
Get the element at the index as a json array .
146,313
public final int getInt ( final int i ) { int val = this . array . optInt ( i , Integer . MIN_VALUE ) ; if ( val == Integer . MIN_VALUE ) { throw new ObjectMissingException ( this , "[" + i + "]" ) ; } return val ; }
Get the element at the index as an integer .
146,314
public final float getFloat ( final int i ) { double val = this . array . optDouble ( i , Double . MAX_VALUE ) ; if ( val == Double . MAX_VALUE ) { throw new ObjectMissingException ( this , "[" + i + "]" ) ; } return ( float ) val ; }
Get the element at the index as a float .
146,315
public final String getString ( final int i ) { String val = this . array . optString ( i , null ) ; if ( val == null ) { throw new ObjectMissingException ( this , "[" + i + "]" ) ; } return val ; }
Get the element at the index as a string .
146,316
public final boolean getBool ( final int i ) { try { return this . array . getBoolean ( i ) ; } catch ( JSONException e ) { throw new ObjectMissingException ( this , "[" + i + "]" ) ; } }
Get the element as a boolean .
146,317
public final String getString ( final String key ) { String result = optString ( key ) ; if ( result == null ) { throw new ObjectMissingException ( this , key ) ; } return result ; }
Get a property as a string or throw an exception .
146,318
public final String optString ( final String key , final String defaultValue ) { String result = optString ( key ) ; return result == null ? defaultValue : result ; }
Get a property as a string or defaultValue .
146,319
public final int getInt ( final String key ) { Integer result = optInt ( key ) ; if ( result == null ) { throw new ObjectMissingException ( this , key ) ; } return result ; }
Get a property as an int or throw an exception .
146,320
public final Integer optInt ( final String key , final Integer defaultValue ) { Integer result = optInt ( key ) ; return result == null ? defaultValue : result ; }
Get a property as an int or default value .
146,321
public final long getLong ( final String key ) { Long result = optLong ( key ) ; if ( result == null ) { throw new ObjectMissingException ( this , key ) ; } return result ; }
Get a property as an long or throw an exception .
146,322
public final long optLong ( final String key , final long defaultValue ) { Long result = optLong ( key ) ; return result == null ? defaultValue : result ; }
Get a property as an long or default value .
146,323
public final double getDouble ( final String key ) { Double result = optDouble ( key ) ; if ( result == null ) { throw new ObjectMissingException ( this , key ) ; } return result ; }
Get a property as a double or throw an exception .
146,324
public final Double optDouble ( final String key , final Double defaultValue ) { Double result = optDouble ( key ) ; return result == null ? defaultValue : result ; }
Get a property as a double or defaultValue .
146,325
public final float getFloat ( final String key ) { Float result = optFloat ( key ) ; if ( result == null ) { throw new ObjectMissingException ( this , key ) ; } return result ; }
Get a property as a float or throw an exception .
146,326
public final Float optFloat ( final String key , final Float defaultValue ) { Float result = optFloat ( key ) ; return result == null ? defaultValue : result ; }
Get a property as a float or Default value .
146,327
public final boolean getBool ( final String key ) { Boolean result = optBool ( key ) ; if ( result == null ) { throw new ObjectMissingException ( this , key ) ; } return result ; }
Get a property as a boolean or throw exception .
146,328
public final Boolean optBool ( final String key , final Boolean defaultValue ) { Boolean result = optBool ( key ) ; return result == null ? defaultValue : result ; }
Get a property as a boolean or default value .
146,329
public final PObject getObject ( final String key ) { PObject result = optObject ( key ) ; if ( result == null ) { throw new ObjectMissingException ( this , key ) ; } return result ; }
Get a property as a object or throw exception .
146,330
public final PArray getArray ( final String key ) { PArray result = optArray ( key ) ; if ( result == null ) { throw new ObjectMissingException ( this , key ) ; } return result ; }
Get a property as a array or throw exception .
146,331
public AccessAssertion unmarshal ( final JSONObject encodedAssertion ) { final String className ; try { className = encodedAssertion . getString ( JSON_CLASS_NAME ) ; final Class < ? > assertionClass = Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; final AccessAssertion assertion = (...
Load assertion from the provided json or throw exception if not possible .
146,332
public JSONObject marshal ( final AccessAssertion assertion ) { final JSONObject jsonObject = assertion . marshal ( ) ; if ( jsonObject . has ( JSON_CLASS_NAME ) ) { throw new AssertionError ( "The toJson method in AccessAssertion: '" + assertion . getClass ( ) + "' defined a JSON field " + JSON_CLASS_NAME + " which is...
Marshal the assertion as a JSON object .
146,333
public static MfClientHttpRequestFactory createFactoryWrapper ( final MfClientHttpRequestFactory requestFactory , final UriMatchers matchers , final Map < String , List < String > > headers ) { return new AbstractMfClientHttpRequestFactoryWrapper ( requestFactory , matchers , false ) { protected ClientHttpRequest creat...
Create a MfClientHttpRequestFactory for adding the specified headers .
146,334
@ SuppressWarnings ( "unchecked" ) public void setHeaders ( final Map < String , Object > headers ) { this . headers . clear ( ) ; for ( Map . Entry < String , Object > entry : headers . entrySet ( ) ) { if ( entry . getValue ( ) instanceof List ) { List value = ( List ) entry . getValue ( ) ; for ( Object o : value ) ...
A map of the header key value pairs . Keys are strings and values are either list of strings or a string .
146,335
public static void writeProcessorOutputToValues ( final Object output , final Processor < ? , ? > processor , final Values values ) { Map < String , String > mapper = processor . getOutputMapperBiMap ( ) ; if ( mapper == null ) { mapper = Collections . emptyMap ( ) ; } final Collection < Field > fields = getAllAttribut...
Read the values from the output object and write them to the values object .
146,336
public static String getInputValueName ( final String inputPrefix , final BiMap < String , String > inputMapper , final String field ) { String name = inputMapper == null ? null : inputMapper . inverse ( ) . get ( field ) ; if ( name == null ) { if ( inputMapper != null && inputMapper . containsKey ( field ) ) { throw ...
Calculate the name of the input value .
146,337
public static String getOutputValueName ( final String outputPrefix , final Map < String , String > outputMapper , final Field field ) { String name = outputMapper . get ( field . getName ( ) ) ; if ( name == null ) { name = field . getName ( ) ; if ( ! StringUtils . isEmpty ( outputPrefix ) && ! outputPrefix . trim ( ...
Calculate the name of the output value .
146,338
public static Dimension rectangleDoubleToDimension ( final Rectangle2D . Double rectangle ) { return new Dimension ( ( int ) Math . round ( rectangle . width ) , ( int ) Math . round ( rectangle . height ) ) ; }
Round the size of a rectangle with double values .
146,339
public MapBounds getRotatedBounds ( final Rectangle2D . Double paintAreaPrecise , final Rectangle paintArea ) { final MapBounds rotatedBounds = this . getRotatedBounds ( ) ; if ( rotatedBounds instanceof CenterScaleMapBounds ) { return rotatedBounds ; } final ReferencedEnvelope envelope = ( ( BBoxMapBounds ) rotatedBou...
Return the map bounds rotated with the set rotation . The bounds are adapted to rounding changes of the size of the paint area .
146,340
public MapBounds getRotatedBoundsAdjustedForPreciseRotatedMapSize ( ) { Rectangle2D . Double paintAreaPrecise = getRotatedMapSizePrecise ( ) ; Rectangle paintArea = new Rectangle ( MapfishMapContext . rectangleDoubleToDimension ( paintAreaPrecise ) ) ; return getRotatedBounds ( paintAreaPrecise , paintArea ) ; }
Return the map bounds rotated with the set rotation . The bounds are adapted to rounding changes of the size of the set paint area .
146,341
public static void runMain ( final String [ ] args ) throws Exception { final CliHelpDefinition helpCli = new CliHelpDefinition ( ) ; try { Args . parse ( helpCli , args ) ; if ( helpCli . help ) { printUsage ( 0 ) ; return ; } } catch ( IllegalArgumentException invalidOption ) { } final CliDefinition cli = new CliDefi...
Runs the print .
146,342
public GridCoverage2D call ( ) { try { BufferedImage coverageImage = this . tiledLayer . createBufferedImage ( this . tilePreparationInfo . getImageWidth ( ) , this . tilePreparationInfo . getImageHeight ( ) ) ; Graphics2D graphics = coverageImage . createGraphics ( ) ; try { for ( SingleTilePreparationInfo tileInfo : ...
Call the Coverage Task .
146,343
public final void shutdown ( ) { this . timer . shutdownNow ( ) ; this . executor . shutdownNow ( ) ; if ( this . cleanUpTimer != null ) { this . cleanUpTimer . shutdownNow ( ) ; } }
Called by spring when application context is being destroyed .
146,344
private boolean isAbandoned ( final SubmittedPrintJob printJob ) { final long duration = ThreadPoolJobManager . this . jobQueue . timeSinceLastStatusCheck ( printJob . getEntry ( ) . getReferenceId ( ) ) ; final boolean abandoned = duration > TimeUnit . SECONDS . toMillis ( ThreadPoolJobManager . this . abandonedTimeou...
If the status of a print job is not checked for a while we assume that the user is no longer interested in the report and we cancel the job .
146,345
private boolean isAcceptingNewJobs ( ) { if ( this . requestedToStop ) { return false ; } else if ( new File ( this . workingDirectories . getWorking ( ) , "stop" ) . exists ( ) ) { LOGGER . info ( "The print has been requested to stop" ) ; this . requestedToStop = true ; notifyIfStopped ( ) ; return false ; } else { r...
Check if the print has not been asked to stop taking new jobs .
146,346
private void notifyIfStopped ( ) { if ( isAcceptingNewJobs ( ) || ! this . runningTasksFutures . isEmpty ( ) ) { return ; } final File stoppedFile = new File ( this . workingDirectories . getWorking ( ) , "stopped" ) ; try { LOGGER . info ( "The print has finished processing jobs and can now stop" ) ; stoppedFile . cre...
Add a file to notify the script that asked to stop the print that it is now done processing the remain jobs .
146,347
public void postConstruct ( ) { parseGeometry ( ) ; Assert . isTrue ( this . polygon != null , "Polygon is null. 'area' string is: '" + this . area + "'" ) ; Assert . isTrue ( this . display != null , "'display' is null" ) ; Assert . isTrue ( this . style == null || this . display == AoiDisplay . RENDER , "'style' does...
Tests that the area is valid geojson the style ref is valid or null and the display is non - null .
146,348
public SimpleFeatureCollection areaToFeatureCollection ( final MapAttribute . MapAttributeValues mapAttributes ) { Assert . isTrue ( mapAttributes . areaOfInterest == this , "map attributes passed in does not contain this area of interest object" ) ; final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBui...
Return the area polygon as the only feature in the feature collection .
146,349
public AreaOfInterest copy ( ) { AreaOfInterest aoi = new AreaOfInterest ( ) ; aoi . display = this . display ; aoi . area = this . area ; aoi . polygon = this . polygon ; aoi . style = this . style ; aoi . renderAsSvg = this . renderAsSvg ; return aoi ; }
Make a copy of this Area of Interest .
146,350
public static void fillProcessorAttributes ( final List < Processor > processors , final Map < String , Attribute > initialAttributes ) { Map < String , Attribute > currentAttributes = new HashMap < > ( initialAttributes ) ; for ( Processor processor : processors ) { if ( processor instanceof RequireAttributes ) { for ...
Fill the attributes in the processor .
146,351
public void checkAllGroupsSatisfied ( final String currentPath ) { StringBuilder errors = new StringBuilder ( ) ; for ( OneOfGroup group : this . mapping . values ( ) ) { if ( group . satisfiedBy . isEmpty ( ) ) { errors . append ( "\n" ) ; errors . append ( "\t* The OneOf choice: " ) . append ( group . name ) . append...
Check that each group is satisfied by one and only one field .
146,352
public final void addMetricsAppenderToLogback ( ) { final LoggerContext factory = ( LoggerContext ) LoggerFactory . getILoggerFactory ( ) ; final Logger root = factory . getLogger ( Logger . ROOT_LOGGER_NAME ) ; final InstrumentedAppender metrics = new InstrumentedAppender ( this . metricRegistry ) ; metrics . setConte...
Add an appender to Logback logging framework that will track the types of log messages made .
146,353
public void checkAllRequirementsSatisfied ( final String currentPath ) { StringBuilder errors = new StringBuilder ( ) ; for ( Field field : this . dependantsInJson ) { final Collection < String > requirements = this . dependantToRequirementsMap . get ( field ) ; if ( ! requirements . isEmpty ( ) ) { errors . append ( "...
Check that each requirement is satisfied .
146,354
public final void printClientConfig ( final JSONWriter json ) throws JSONException { json . key ( "layouts" ) ; json . array ( ) ; final Map < String , Template > accessibleTemplates = getTemplates ( ) ; accessibleTemplates . entrySet ( ) . stream ( ) . sorted ( Comparator . comparing ( Map . Entry :: getKey ) ) . forE...
Print out the configuration that the client needs to make a request .
146,355
public final Template getTemplate ( final String name ) { final Template template = this . templates . get ( name ) ; if ( template != null ) { this . accessAssertion . assertAccess ( "Configuration" , this ) ; template . assertAccessible ( name ) ; } else { throw new IllegalArgumentException ( String . format ( "Templ...
Retrieve the configuration of the named template .
146,356
public final Style getDefaultStyle ( final String geometryType ) { String normalizedGeomName = GEOMETRY_NAME_ALIASES . get ( geometryType . toLowerCase ( ) ) ; if ( normalizedGeomName == null ) { normalizedGeomName = geometryType . toLowerCase ( ) ; } Style style = this . defaultStyle . get ( normalizedGeomName . toLow...
Get a default style . If null a simple black line style will be returned .
146,357
public final void setDefaultStyle ( final Map < String , Style > defaultStyle ) { this . defaultStyle = new HashMap < > ( defaultStyle . size ( ) ) ; for ( Map . Entry < String , Style > entry : defaultStyle . entrySet ( ) ) { String normalizedName = GEOMETRY_NAME_ALIASES . get ( entry . getKey ( ) . toLowerCase ( ) ) ...
Set the default styles . the case of the keys are not important . The retrieval will be case insensitive .
146,358
public final List < Throwable > validate ( ) { List < Throwable > validationErrors = new ArrayList < > ( ) ; this . accessAssertion . validate ( validationErrors , this ) ; for ( String jdbcDriver : this . jdbcDrivers ) { try { Class . forName ( jdbcDriver ) ; } catch ( ClassNotFoundException e ) { try { Configuration ...
Validate that the configuration is valid .
146,359
public void addDependency ( final ProcessorGraphNode node ) { Assert . isTrue ( node != this , "A processor can't depends on himself" ) ; this . dependencies . add ( node ) ; node . addRequirement ( this ) ; }
Add a dependency to this node .
146,360
public BiMap < String , String > getOutputMapper ( ) { final BiMap < String , String > outputMapper = this . processor . getOutputMapperBiMap ( ) ; if ( outputMapper == null ) { return HashBiMap . create ( ) ; } return outputMapper ; }
Get the output mapper from processor .
146,361
public BiMap < String , String > getInputMapper ( ) { final BiMap < String , String > inputMapper = this . processor . getInputMapperBiMap ( ) ; if ( inputMapper == null ) { return HashBiMap . create ( ) ; } return inputMapper ; }
Return input mapper from processor .
146,362
public Set < ? extends Processor < ? , ? > > getAllProcessors ( ) { IdentityHashMap < Processor < ? , ? > , Void > all = new IdentityHashMap < > ( ) ; all . put ( this . getProcessor ( ) , null ) ; for ( ProcessorGraphNode < ? , ? > dependency : this . dependencies ) { for ( Processor < ? , ? > p : dependency . getAllP...
Create a set containing all the processor at the current node and the entire subgraph .
146,363
public static String findReplacement ( final String variableName , final Date date ) { if ( variableName . equalsIgnoreCase ( "date" ) ) { return cleanUpName ( DateFormat . getDateInstance ( ) . format ( date ) ) ; } else if ( variableName . equalsIgnoreCase ( "datetime" ) ) { return cleanUpName ( DateFormat . getDateT...
Update a variable name with a date if the variable is detected as being a date .
146,364
protected static void error ( final HttpServletResponse httpServletResponse , final String message , final HttpStatus code ) { try { httpServletResponse . setContentType ( "text/plain" ) ; httpServletResponse . setStatus ( code . value ( ) ) ; setNoCache ( httpServletResponse ) ; try ( PrintWriter out = httpServletResp...
Send an error to the client with a message .
146,365
protected final void error ( final HttpServletResponse httpServletResponse , final Throwable e ) { httpServletResponse . setContentType ( "text/plain" ) ; httpServletResponse . setStatus ( HttpStatus . INTERNAL_SERVER_ERROR . value ( ) ) ; try ( PrintWriter out = httpServletResponse . getWriter ( ) ) { out . println ( ...
Send an error to the client with an exception .
146,366
protected final StringBuilder getBaseUrl ( final HttpServletRequest httpServletRequest ) { StringBuilder baseURL = new StringBuilder ( ) ; if ( httpServletRequest . getContextPath ( ) != null && ! httpServletRequest . getContextPath ( ) . isEmpty ( ) ) { baseURL . append ( httpServletRequest . getContextPath ( ) ) ; } ...
Returns the base URL of the print servlet .
146,367
protected static Dimension getSize ( final ScalebarAttributeValues scalebarParams , final ScaleBarRenderSettings settings , final Dimension maxLabelSize ) { final float width ; final float height ; if ( scalebarParams . getOrientation ( ) . isHorizontal ( ) ) { width = 2 * settings . getPadding ( ) + settings . getInte...
Get the size of the painting area required to draw the scalebar with labels .
146,368
protected static Dimension getMaxLabelSize ( final ScaleBarRenderSettings settings ) { float maxLabelHeight = 0.0f ; float maxLabelWidth = 0.0f ; for ( final Label label : settings . getLabels ( ) ) { maxLabelHeight = Math . max ( maxLabelHeight , label . getHeight ( ) ) ; maxLabelWidth = Math . max ( maxLabelWidth , l...
Get the maximum width and height of the labels .
146,369
protected static String createLabelText ( final DistanceUnit scaleUnit , final double value , final DistanceUnit intervalUnit ) { double scaledValue = scaleUnit . convertTo ( value , intervalUnit ) ; scaledValue = Math . round ( scaledValue * 10000 ) / 10000 ; String decimals = Double . toString ( scaledValue ) . split...
Format the label text .
146,370
protected static double getNearestNiceValue ( final double value , final DistanceUnit scaleUnit , final boolean lockUnits ) { DistanceUnit bestUnit = bestUnit ( scaleUnit , value , lockUnits ) ; double factor = scaleUnit . convertTo ( 1.0 , bestUnit ) ; int digits = ( int ) Math . floor ( ( Math . log ( value * factor ...
Reduce the given value to the nearest smaller 1 significant digit number starting with 1 2 or 5 .
146,371
protected static int getBarSize ( final ScaleBarRenderSettings settings ) { if ( settings . getParams ( ) . barSize != null ) { return settings . getParams ( ) . barSize ; } else { if ( settings . getParams ( ) . getOrientation ( ) . isHorizontal ( ) ) { return settings . getMaxSize ( ) . height / 4 ; } else { return s...
Get the bar size .
146,372
protected static int getLabelDistance ( final ScaleBarRenderSettings settings ) { if ( settings . getParams ( ) . labelDistance != null ) { return settings . getParams ( ) . labelDistance ; } else { if ( settings . getParams ( ) . getOrientation ( ) . isHorizontal ( ) ) { return settings . getMaxSize ( ) . width / 40 ;...
Get the label distance ..
146,373
public final URI render ( final MapfishMapContext mapContext , final ScalebarAttributeValues scalebarParams , final File tempFolder , final Template template ) throws IOException , ParserConfigurationException { final double dpi = mapContext . getDPI ( ) ; final Rectangle paintArea = new Rectangle ( mapContext . getMap...
Render the scalebar .
146,374
public static PJsonObject parseSpec ( final String spec ) { final JSONObject jsonSpec ; try { jsonSpec = new JSONObject ( spec ) ; } catch ( JSONException e ) { throw new RuntimeException ( "Cannot parse the spec file: " + spec , e ) ; } return new PJsonObject ( jsonSpec , "spec" ) ; }
Parse the JSON string and return the object . The string is expected to be the JSON print data from the client .
146,375
public final OutputFormat getOutputFormat ( final PJsonObject specJson ) { final String format = specJson . getString ( MapPrinterServlet . JSON_OUTPUT_FORMAT ) ; final boolean mapExport = this . configuration . getTemplate ( specJson . getString ( Constants . JSON_LAYOUT_KEY ) ) . isMapExport ( ) ; final String beanNa...
Get the object responsible for printing to the correct output format .
146,376
public final Processor . ExecutionContext print ( final String jobId , final PJsonObject specJson , final OutputStream out ) throws Exception { final OutputFormat format = getOutputFormat ( specJson ) ; final File taskDirectory = this . workingDirectories . getTaskDirectory ( ) ; try { return format . print ( jobId , s...
Start a print .
146,377
public final Set < String > getOutputFormatsNames ( ) { SortedSet < String > formats = new TreeSet < > ( ) ; for ( String formatBeanName : this . outputFormat . keySet ( ) ) { int endingIndex = formatBeanName . indexOf ( MAP_OUTPUT_FORMAT_BEAN_NAME_ENDING ) ; if ( endingIndex < 0 ) { endingIndex = formatBeanName . inde...
Return the available format ids .
146,378
public Scale getNearestScale ( final ZoomLevels zoomLevels , final double tolerance , final ZoomLevelSnapStrategy zoomLevelSnapStrategy , final boolean geodetic , final Rectangle paintArea , final double dpi ) { final Scale scale = getScale ( paintArea , dpi ) ; final Scale correctedScale ; final double scaleRatio ; if...
Get the nearest scale .
146,379
public final void init ( ) { this . cleanUpTimer = Executors . newScheduledThreadPool ( 1 , timerTask -> { final Thread thread = new Thread ( timerTask , "Clean up old job records" ) ; thread . setDaemon ( true ) ; return thread ; } ) ; this . cleanUpTimer . scheduleAtFixedRate ( this :: cleanup , this . cleanupInterva...
Called by spring on initialization .
146,380
public static Collection < Field > getAllAttributes ( final Class < ? > classToInspect ) { Set < Field > allFields = new HashSet < > ( ) ; getAllAttributes ( classToInspect , allFields , Function . identity ( ) , field -> true ) ; return allFields ; }
Inspects the object and all superclasses for public non - final accessible methods and returns a collection containing all the attributes found .
146,381
public static Collection < Field > getAttributes ( final Class < ? > classToInspect , final Predicate < Field > filter ) { Set < Field > allFields = new HashSet < > ( ) ; getAllAttributes ( classToInspect , allFields , Function . identity ( ) , filter ) ; return allFields ; }
Get a subset of the attributes of the provided class . An attribute is each public field in the class or super class .
146,382
private static URI createRaster ( final Dimension targetSize , final RasterReference rasterReference , final Double rotation , final Color backgroundColor , final File workingDir ) throws IOException { final File path = File . createTempFile ( "north-arrow-" , ".png" , workingDir ) ; final BufferedImage newImage = new ...
Renders a given graphic into a new image scaled to fit the new size and rotated .
146,383
private static URI createSvg ( final Dimension targetSize , final RasterReference rasterReference , final Double rotation , final Color backgroundColor , final File workingDir ) throws IOException { final SVGElement svgRoot = parseSvg ( rasterReference . inputStream ) ; DOMImplementation impl = SVGDOMImplementation . g...
With the Batik SVG library it is only possible to create new SVG graphics but you can not modify an existing graphic . So we are loading the SVG file as plain XML and doing the modifications by hand .
146,384
private static void embedSvgGraphic ( final SVGElement svgRoot , final SVGElement newSvgRoot , final Document newDocument , final Dimension targetSize , final Double rotation ) { final String originalWidth = svgRoot . getAttributeNS ( null , "width" ) ; final String originalHeight = svgRoot . getAttributeNS ( null , "h...
Embeds the given SVG element into a new SVG element scaling the graphic to the given dimension and applying the given rotation .
146,385
public void setDirectory ( final String directory ) { this . directory = new File ( this . configuration . getDirectory ( ) , directory ) ; if ( ! this . directory . exists ( ) ) { throw new IllegalArgumentException ( String . format ( "Directory does not exist: %s.\n" + "Configuration contained value %s which is suppo...
Set the directory and test that the directory exists and is contained within the Configuration directory .
146,386
public void setAttribute ( final String name , final Attribute attribute ) { if ( name . equals ( MAP_KEY ) ) { this . mapAttribute = ( MapAttribute ) attribute ; } }
Set the map attribute .
146,387
public Map < String , Attribute > getAttributes ( ) { Map < String , Attribute > result = new HashMap < > ( ) ; DataSourceAttribute datasourceAttribute = new DataSourceAttribute ( ) ; Map < String , Attribute > dsResult = new HashMap < > ( ) ; dsResult . put ( MAP_KEY , this . mapAttribute ) ; datasourceAttribute . set...
Gets the attributes provided by the processor .
146,388
public final void printClientConfig ( final JSONWriter json ) throws JSONException { json . key ( "attributes" ) ; json . array ( ) ; for ( Map . Entry < String , Attribute > entry : this . attributes . entrySet ( ) ) { Attribute attribute = entry . getValue ( ) ; if ( attribute . getClass ( ) . getAnnotation ( Interna...
Print out the template information that the client needs for performing a request .
146,389
public final void setAttributes ( final Map < String , Attribute > attributes ) { for ( Map . Entry < String , Attribute > entry : attributes . entrySet ( ) ) { Object attribute = entry . getValue ( ) ; if ( ! ( attribute instanceof Attribute ) ) { final String msg = "Attribute: '" + entry . getKey ( ) + "' is not an a...
Set the attributes for this template .
146,390
public final ProcessorDependencyGraph getProcessorGraph ( ) { if ( this . processorGraph == null ) { synchronized ( this ) { if ( this . processorGraph == null ) { final Map < String , Class < ? > > attcls = new HashMap < > ( ) ; for ( Map . Entry < String , Attribute > attribute : this . attributes . entrySet ( ) ) { ...
Get the processor graph to use for executing all the processors for the template .
146,391
@ SuppressWarnings ( "unchecked" ) public final java . util . Optional < Style > getStyle ( final String styleName ) { final String styleRef = this . styles . get ( styleName ) ; Optional < Style > style ; if ( styleRef != null ) { style = ( Optional < Style > ) this . styleParser . loadStyle ( getConfiguration ( ) , t...
Look for a style in the named styles provided in the configuration .
146,392
public void init ( ) { this . metricRegistry . register ( name ( "gc" ) , new GarbageCollectorMetricSet ( ) ) ; this . metricRegistry . register ( name ( "memory" ) , new MemoryUsageGaugeSet ( ) ) ; this . metricRegistry . register ( name ( "thread-states" ) , new ThreadStatesGaugeSet ( ) ) ; this . metricRegistry . re...
Add several jvm metrics .
146,393
public void postConstruct ( ) throws URISyntaxException { WmsVersion . lookup ( this . version ) ; Assert . isTrue ( validateBaseUrl ( ) , "invalid baseURL" ) ; Assert . isTrue ( this . layers . length > 0 , "There must be at least one layer defined for a WMS request" + " to make sense" ) ; if ( this . styles != null &...
Validate some of the properties of this layer .
146,394
public BufferedImage createBufferedImage ( final int imageWidth , final int imageHeight ) { return new BufferedImage ( imageWidth , imageHeight , BufferedImage . TYPE_4BYTE_ABGR ) ; }
Create a buffered image with the correct image bands etc ... for the tiles being loaded .
146,395
public void setKeywords ( final List < String > keywords ) { StringBuilder builder = new StringBuilder ( ) ; for ( String keyword : keywords ) { if ( builder . length ( ) > 0 ) { builder . append ( ',' ) ; } builder . append ( keyword . trim ( ) ) ; } this . keywords = Optional . of ( builder . toString ( ) ) ; }
The keywords to include in the PDF metadata .
146,396
protected String getKey ( final String ref , final String filename , final String extension ) { return prefix + ref + "/" + filename + "." + extension ; }
Compute the key to use .
146,397
private Object tryConvert ( final MfClientHttpRequestFactory clientHttpRequestFactory , final Object rowValue ) throws URISyntaxException , IOException { if ( this . converters . isEmpty ( ) ) { return rowValue ; } String value = String . valueOf ( rowValue ) ; for ( TableColumnConverter < ? > converter : this . conver...
If converters are set on a table this function tests if these can convert a cell value . The first converter which claims that it can convert will be used to do the conversion .
146,398
public final Integer optInt ( final String key ) { final int result = this . obj . optInt ( key , Integer . MIN_VALUE ) ; return result == Integer . MIN_VALUE ? null : result ; }
Get a property as a int or null .
146,399
public final Double optDouble ( final String key ) { double result = this . obj . optDouble ( key , Double . NaN ) ; if ( Double . isNaN ( result ) ) { return null ; } return result ; }
Get a property as a double or null .