repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java
GridUtils.calculateBounds
public static Polygon calculateBounds(final MapfishMapContext context) { double rotation = context.getRootContext().getRotation(); ReferencedEnvelope env = context.getRootContext().toReferencedEnvelope(); Coordinate centre = env.centre(); AffineTransform rotateInstance = AffineTransform.getRotateInstance(rotation, centre.x, centre.y); double[] dstPts = new double[8]; double[] srcPts = { env.getMinX(), env.getMinY(), env.getMinX(), env.getMaxY(), env.getMaxX(), env.getMaxY(), env.getMaxX(), env.getMinY() }; rotateInstance.transform(srcPts, 0, dstPts, 0, 4); return new GeometryFactory().createPolygon(new Coordinate[]{ new Coordinate(dstPts[0], dstPts[1]), new Coordinate(dstPts[2], dstPts[3]), new Coordinate(dstPts[4], dstPts[5]), new Coordinate(dstPts[6], dstPts[7]), new Coordinate(dstPts[0], dstPts[1]) }); }
java
public static Polygon calculateBounds(final MapfishMapContext context) { double rotation = context.getRootContext().getRotation(); ReferencedEnvelope env = context.getRootContext().toReferencedEnvelope(); Coordinate centre = env.centre(); AffineTransform rotateInstance = AffineTransform.getRotateInstance(rotation, centre.x, centre.y); double[] dstPts = new double[8]; double[] srcPts = { env.getMinX(), env.getMinY(), env.getMinX(), env.getMaxY(), env.getMaxX(), env.getMaxY(), env.getMaxX(), env.getMinY() }; rotateInstance.transform(srcPts, 0, dstPts, 0, 4); return new GeometryFactory().createPolygon(new Coordinate[]{ new Coordinate(dstPts[0], dstPts[1]), new Coordinate(dstPts[2], dstPts[3]), new Coordinate(dstPts[4], dstPts[5]), new Coordinate(dstPts[6], dstPts[7]), new Coordinate(dstPts[0], dstPts[1]) }); }
[ "public", "static", "Polygon", "calculateBounds", "(", "final", "MapfishMapContext", "context", ")", "{", "double", "rotation", "=", "context", ".", "getRootContext", "(", ")", ".", "getRotation", "(", ")", ";", "ReferencedEnvelope", "env", "=", "context", ".", ...
Create a polygon that represents in world space the exact area that will be visible on the printed map. @param context map context
[ "Create", "a", "polygon", "that", "represents", "in", "world", "space", "the", "exact", "area", "that", "will", "be", "visible", "on", "the", "printed", "map", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java#L42-L62
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java
GridUtils.createGridFeatureType
public static SimpleFeatureType createGridFeatureType( @Nonnull final MapfishMapContext mapContext, @Nonnull final Class<? extends Geometry> geomClass) { final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); CoordinateReferenceSystem projection = mapContext.getBounds().getProjection(); typeBuilder.add(Constants.Style.Grid.ATT_GEOM, geomClass, projection); typeBuilder.setName(Constants.Style.Grid.NAME_LINES); return typeBuilder.buildFeatureType(); }
java
public static SimpleFeatureType createGridFeatureType( @Nonnull final MapfishMapContext mapContext, @Nonnull final Class<? extends Geometry> geomClass) { final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); CoordinateReferenceSystem projection = mapContext.getBounds().getProjection(); typeBuilder.add(Constants.Style.Grid.ATT_GEOM, geomClass, projection); typeBuilder.setName(Constants.Style.Grid.NAME_LINES); return typeBuilder.buildFeatureType(); }
[ "public", "static", "SimpleFeatureType", "createGridFeatureType", "(", "@", "Nonnull", "final", "MapfishMapContext", "mapContext", ",", "@", "Nonnull", "final", "Class", "<", "?", "extends", "Geometry", ">", "geomClass", ")", "{", "final", "SimpleFeatureTypeBuilder", ...
Create the grid feature type. @param mapContext the map context containing the information about the map the grid will be added to. @param geomClass the geometry type
[ "Create", "the", "grid", "feature", "type", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java#L89-L98
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java
GridUtils.createLabel
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.round(value), unit); } else if ("m".equals(unit)) { // meter: no decimals return String.format("%1.0f %s", value, unit); } else if (NonSI.DEGREE_ANGLE.toString().equals(unit)) { // degree: by default 6 decimals return String.format("%1.6f %s", value, unit); } else { return String.format("%f %s", value, unit); } } }
java
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.round(value), unit); } else if ("m".equals(unit)) { // meter: no decimals return String.format("%1.0f %s", value, unit); } else if (NonSI.DEGREE_ANGLE.toString().equals(unit)) { // degree: by default 6 decimals return String.format("%1.6f %s", value, unit); } else { return String.format("%f %s", value, unit); } } }
[ "public", "static", "String", "createLabel", "(", "final", "double", "value", ",", "final", "String", "unit", ",", "final", "GridLabelFormat", "format", ")", "{", "final", "double", "zero", "=", "0.000000001", ";", "if", "(", "format", "!=", "null", ")", "...
Create the label for a grid line. @param value the value of the line @param unit the unit that the value is in
[ "Create", "the", "label", "for", "a", "grid", "line", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java#L106-L123
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/parser/MapfishParser.java
MapfishParser.parsePrimitive
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 (UnsupportedTypeException e) { String type = e.type.getName(); if (e.type.isArray()) { type = e.type.getComponentType().getName() + "[]"; } throw new RuntimeException( "The type '" + type + "' is not a supported type when parsing json. " + "See documentation for supported types.\n\nUnsupported type found in attribute " + fieldName + "\n\nTo support more types add the type to " + "parseValue and parseArrayValue in this class and add a test to the test class", e); } pAtt.validateValue(value); return value; }
java
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 (UnsupportedTypeException e) { String type = e.type.getName(); if (e.type.isArray()) { type = e.type.getComponentType().getName() + "[]"; } throw new RuntimeException( "The type '" + type + "' is not a supported type when parsing json. " + "See documentation for supported types.\n\nUnsupported type found in attribute " + fieldName + "\n\nTo support more types add the type to " + "parseValue and parseArrayValue in this class and add a test to the test class", e); } pAtt.validateValue(value); return value; }
[ "public", "static", "Object", "parsePrimitive", "(", "final", "String", "fieldName", ",", "final", "PrimitiveAttribute", "<", "?", ">", "pAtt", ",", "final", "PObject", "requestData", ")", "{", "Class", "<", "?", ">", "valueClass", "=", "pAtt", ".", "getValu...
Get the value of a primitive type from the request data. @param fieldName the name of the attribute to get from the request data. @param pAtt the primitive attribute. @param requestData the data to retrieve the value from.
[ "Get", "the", "value", "of", "a", "primitive", "type", "from", "the", "request", "data", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/parser/MapfishParser.java#L333-L355
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/CustomEPSGCodes.java
CustomEPSGCodes.getDefinitionsURL
@Override protected URL getDefinitionsURL() { try { URL url = CustomEPSGCodes.class.getResource(CUSTOM_EPSG_CODES_FILE); // quickly test url try (InputStream stream = url.openStream()) { //noinspection ResultOfMethodCallIgnored stream.read(); } return url; } catch (Throwable e) { throw new AssertionError("Unable to load /epsg.properties file from root of classpath."); } }
java
@Override protected URL getDefinitionsURL() { try { URL url = CustomEPSGCodes.class.getResource(CUSTOM_EPSG_CODES_FILE); // quickly test url try (InputStream stream = url.openStream()) { //noinspection ResultOfMethodCallIgnored stream.read(); } return url; } catch (Throwable e) { throw new AssertionError("Unable to load /epsg.properties file from root of classpath."); } }
[ "@", "Override", "protected", "URL", "getDefinitionsURL", "(", ")", "{", "try", "{", "URL", "url", "=", "CustomEPSGCodes", ".", "class", ".", "getResource", "(", "CUSTOM_EPSG_CODES_FILE", ")", ";", "// quickly test url", "try", "(", "InputStream", "stream", "=",...
Returns the URL to the property file that contains CRS definitions. @return The URL to the epsg file containing custom EPSG codes
[ "Returns", "the", "URL", "to", "the", "property", "file", "that", "contains", "CRS", "definitions", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/CustomEPSGCodes.java#L40-L53
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ExecutionStats.java
ExecutionStats.addMapStats
public synchronized void addMapStats( final MapfishMapContext mapContext, final MapAttribute.MapAttributeValues mapValues) { this.mapStats.add(new MapStats(mapContext, mapValues)); }
java
public synchronized void addMapStats( final MapfishMapContext mapContext, final MapAttribute.MapAttributeValues mapValues) { this.mapStats.add(new MapStats(mapContext, mapValues)); }
[ "public", "synchronized", "void", "addMapStats", "(", "final", "MapfishMapContext", "mapContext", ",", "final", "MapAttribute", ".", "MapAttributeValues", "mapValues", ")", "{", "this", ".", "mapStats", ".", "add", "(", "new", "MapStats", "(", "mapContext", ",", ...
Add statistics about a created map. @param mapContext the @param mapValues the
[ "Add", "statistics", "about", "a", "created", "map", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ExecutionStats.java#L30-L33
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ExecutionStats.java
ExecutionStats.addEmailStats
public void addEmailStats(final InternetAddress[] recipients, final boolean storageUsed) { this.storageUsed = storageUsed; for (InternetAddress recipient: recipients) { emailDests.add(recipient.getAddress()); } }
java
public void addEmailStats(final InternetAddress[] recipients, final boolean storageUsed) { this.storageUsed = storageUsed; for (InternetAddress recipient: recipients) { emailDests.add(recipient.getAddress()); } }
[ "public", "void", "addEmailStats", "(", "final", "InternetAddress", "[", "]", "recipients", ",", "final", "boolean", "storageUsed", ")", "{", "this", ".", "storageUsed", "=", "storageUsed", ";", "for", "(", "InternetAddress", "recipient", ":", "recipients", ")",...
Add statistics about sent emails. @param recipients The list of recipients. @param storageUsed If a remote storage was used.
[ "Add", "statistics", "about", "sent", "emails", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ExecutionStats.java#L50-L55
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridParam.java
GridParam.calculateLabelUnit
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(); } return unit; }
java
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(); } return unit; }
[ "public", "String", "calculateLabelUnit", "(", "final", "CoordinateReferenceSystem", "mapCrs", ")", "{", "String", "unit", ";", "if", "(", "this", ".", "labelProjection", "!=", "null", ")", "{", "unit", "=", "this", ".", "labelCRS", ".", "getCoordinateSystem", ...
Determine which unit to use when creating grid labels. @param mapCrs the crs of the map, used if the {@link #labelProjection} is not defined.
[ "Determine", "which", "unit", "to", "use", "when", "creating", "grid", "labels", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridParam.java#L244-L253
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridParam.java
GridParam.calculateLabelTransform
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); } } else { labelTransform = IdentityTransform.create(2); } return labelTransform; }
java
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); } } else { labelTransform = IdentityTransform.create(2); } return labelTransform; }
[ "public", "MathTransform", "calculateLabelTransform", "(", "final", "CoordinateReferenceSystem", "mapCrs", ")", "{", "MathTransform", "labelTransform", ";", "if", "(", "this", ".", "labelProjection", "!=", "null", ")", "{", "try", "{", "labelTransform", "=", "CRS", ...
Determine which math transform to use when creating the coordinate of the label. @param mapCrs the crs of the map, used if the {@link #labelProjection} is not defined.
[ "Determine", "which", "math", "transform", "to", "use", "when", "creating", "the", "coordinate", "of", "the", "label", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridParam.java#L260-L273
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridLabelFormat.java
GridLabelFormat.fromConfig
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.formatDecimalSeparator, param.formatGroupingSeparator); } return null; }
java
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.formatDecimalSeparator, param.formatGroupingSeparator); } return null; }
[ "public", "static", "GridLabelFormat", "fromConfig", "(", "final", "GridParam", "param", ")", "{", "if", "(", "param", ".", "labelFormat", "!=", "null", ")", "{", "return", "new", "GridLabelFormat", ".", "Simple", "(", "param", ".", "labelFormat", ")", ";", ...
Create an instance from the given config. @param param Grid param from the request.
[ "Create", "an", "instance", "from", "the", "given", "config", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridLabelFormat.java#L16-L25
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/http/HttpCredential.java
HttpCredential.toCredentials
@Nullable 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; } final String passwordString; if (this.password != null) { passwordString = new String(this.password); } else { passwordString = null; } return new UsernamePasswordCredentials(this.username, passwordString); }
java
@Nullable 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; } final String passwordString; if (this.password != null) { passwordString = new String(this.password); } else { passwordString = null; } return new UsernamePasswordCredentials(this.username, passwordString); }
[ "@", "Nullable", "public", "final", "Credentials", "toCredentials", "(", "final", "AuthScope", "authscope", ")", "{", "try", "{", "if", "(", "!", "matches", "(", "MatchInfo", ".", "fromAuthScope", "(", "authscope", ")", ")", ")", "{", "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. @param authscope the scope to test against.
[ "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", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/http/HttpCredential.java#L104-L125
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getJSONObject
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); }
java
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); }
[ "public", "final", "PJsonObject", "getJSONObject", "(", "final", "int", "i", ")", "{", "JSONObject", "val", "=", "this", ".", "array", ".", "optJSONObject", "(", "i", ")", ";", "final", "String", "context", "=", "\"[\"", "+", "i", "+", "\"]\"", ";", "i...
Get the element at the index as a json object. @param i the index of the object to access
[ "Get", "the", "element", "at", "the", "index", "as", "a", "json", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L52-L59
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getJSONArray
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); }
java
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); }
[ "public", "final", "PJsonArray", "getJSONArray", "(", "final", "int", "i", ")", "{", "JSONArray", "val", "=", "this", ".", "array", ".", "optJSONArray", "(", "i", ")", ";", "final", "String", "context", "=", "\"[\"", "+", "i", "+", "\"]\"", ";", "if", ...
Get the element at the index as a json array. @param i the index of the element to access
[ "Get", "the", "element", "at", "the", "index", "as", "a", "json", "array", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L76-L83
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getInt
@Override 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; }
java
@Override 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; }
[ "@", "Override", "public", "final", "int", "getInt", "(", "final", "int", "i", ")", "{", "int", "val", "=", "this", ".", "array", ".", "optInt", "(", "i", ",", "Integer", ".", "MIN_VALUE", ")", ";", "if", "(", "val", "==", "Integer", ".", "MIN_VALU...
Get the element at the index as an integer. @param i the index of the element to access
[ "Get", "the", "element", "at", "the", "index", "as", "an", "integer", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L90-L97
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getFloat
@Override 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; }
java
@Override 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; }
[ "@", "Override", "public", "final", "float", "getFloat", "(", "final", "int", "i", ")", "{", "double", "val", "=", "this", ".", "array", ".", "optDouble", "(", "i", ",", "Double", ".", "MAX_VALUE", ")", ";", "if", "(", "val", "==", "Double", ".", "...
Get the element at the index as a float. @param i the index of the element to access
[ "Get", "the", "element", "at", "the", "index", "as", "a", "float", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L113-L120
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getString
@Override public final String getString(final int i) { String val = this.array.optString(i, null); if (val == null) { throw new ObjectMissingException(this, "[" + i + "]"); } return val; }
java
@Override public final String getString(final int i) { String val = this.array.optString(i, null); if (val == null) { throw new ObjectMissingException(this, "[" + i + "]"); } return val; }
[ "@", "Override", "public", "final", "String", "getString", "(", "final", "int", "i", ")", "{", "String", "val", "=", "this", ".", "array", ".", "optString", "(", "i", ",", "null", ")", ";", "if", "(", "val", "==", "null", ")", "{", "throw", "new", ...
Get the element at the index as a string. @param i the index of the element to access
[ "Get", "the", "element", "at", "the", "index", "as", "a", "string", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L141-L148
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getBool
@Override public final boolean getBool(final int i) { try { return this.array.getBoolean(i); } catch (JSONException e) { throw new ObjectMissingException(this, "[" + i + "]"); } }
java
@Override public final boolean getBool(final int i) { try { return this.array.getBoolean(i); } catch (JSONException e) { throw new ObjectMissingException(this, "[" + i + "]"); } }
[ "@", "Override", "public", "final", "boolean", "getBool", "(", "final", "int", "i", ")", "{", "try", "{", "return", "this", ".", "array", ".", "getBoolean", "(", "i", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "throw", "new", "Objec...
Get the element as a boolean. @param i the index of the element to access
[ "Get", "the", "element", "as", "a", "boolean", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L162-L169
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getString
@Override public final String getString(final String key) { String result = optString(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final String getString(final String key) { String result = optString(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "String", "getString", "(", "final", "String", "key", ")", "{", "String", "result", "=", "optString", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "t...
Get a property as a string or throw an exception. @param key the property name
[ "Get", "a", "property", "as", "a", "string", "or", "throw", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L24-L31
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optString
@Override public final String optString(final String key, final String defaultValue) { String result = optString(key); return result == null ? defaultValue : result; }
java
@Override public final String optString(final String key, final String defaultValue) { String result = optString(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "String", "optString", "(", "final", "String", "key", ",", "final", "String", "defaultValue", ")", "{", "String", "result", "=", "optString", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", "...
Get a property as a string or defaultValue. @param key the property name @param defaultValue the default value
[ "Get", "a", "property", "as", "a", "string", "or", "defaultValue", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L39-L43
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getInt
@Override public final int getInt(final String key) { Integer result = optInt(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final int getInt(final String key) { Integer result = optInt(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "int", "getInt", "(", "final", "String", "key", ")", "{", "Integer", "result", "=", "optInt", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ...
Get a property as an int or throw an exception. @param key the property name
[ "Get", "a", "property", "as", "an", "int", "or", "throw", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L50-L57
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optInt
@Override public final Integer optInt(final String key, final Integer defaultValue) { Integer result = optInt(key); return result == null ? defaultValue : result; }
java
@Override public final Integer optInt(final String key, final Integer defaultValue) { Integer result = optInt(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "Integer", "optInt", "(", "final", "String", "key", ",", "final", "Integer", "defaultValue", ")", "{", "Integer", "result", "=", "optInt", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", ":",...
Get a property as an int or default value. @param key the property name @param defaultValue the default value
[ "Get", "a", "property", "as", "an", "int", "or", "default", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L65-L69
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getLong
@Override public final long getLong(final String key) { Long result = optLong(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final long getLong(final String key) { Long result = optLong(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "long", "getLong", "(", "final", "String", "key", ")", "{", "Long", "result", "=", "optLong", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ...
Get a property as an long or throw an exception. @param key the property name
[ "Get", "a", "property", "as", "an", "long", "or", "throw", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L76-L83
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optLong
@Override public final long optLong(final String key, final long defaultValue) { Long result = optLong(key); return result == null ? defaultValue : result; }
java
@Override public final long optLong(final String key, final long defaultValue) { Long result = optLong(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "long", "optLong", "(", "final", "String", "key", ",", "final", "long", "defaultValue", ")", "{", "Long", "result", "=", "optLong", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", ":", "res...
Get a property as an long or default value. @param key the property name @param defaultValue the default value
[ "Get", "a", "property", "as", "an", "long", "or", "default", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L91-L95
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getDouble
@Override public final double getDouble(final String key) { Double result = optDouble(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final double getDouble(final String key) { Double result = optDouble(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "double", "getDouble", "(", "final", "String", "key", ")", "{", "Double", "result", "=", "optDouble", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "t...
Get a property as a double or throw an exception. @param key the property name
[ "Get", "a", "property", "as", "a", "double", "or", "throw", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L102-L109
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optDouble
@Override public final Double optDouble(final String key, final Double defaultValue) { Double result = optDouble(key); return result == null ? defaultValue : result; }
java
@Override public final Double optDouble(final String key, final Double defaultValue) { Double result = optDouble(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "Double", "optDouble", "(", "final", "String", "key", ",", "final", "Double", "defaultValue", ")", "{", "Double", "result", "=", "optDouble", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", "...
Get a property as a double or defaultValue. @param key the property name @param defaultValue the default value
[ "Get", "a", "property", "as", "a", "double", "or", "defaultValue", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L117-L121
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getFloat
@Override public final float getFloat(final String key) { Float result = optFloat(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final float getFloat(final String key) { Float result = optFloat(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "float", "getFloat", "(", "final", "String", "key", ")", "{", "Float", "result", "=", "optFloat", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this"...
Get a property as a float or throw an exception. @param key the property name
[ "Get", "a", "property", "as", "a", "float", "or", "throw", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L128-L135
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optFloat
@Override public final Float optFloat(final String key, final Float defaultValue) { Float result = optFloat(key); return result == null ? defaultValue : result; }
java
@Override public final Float optFloat(final String key, final Float defaultValue) { Float result = optFloat(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "Float", "optFloat", "(", "final", "String", "key", ",", "final", "Float", "defaultValue", ")", "{", "Float", "result", "=", "optFloat", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", ":", ...
Get a property as a float or Default value. @param key the property name @param defaultValue default value
[ "Get", "a", "property", "as", "a", "float", "or", "Default", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L143-L147
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getBool
@Override public final boolean getBool(final String key) { Boolean result = optBool(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final boolean getBool(final String key) { Boolean result = optBool(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "boolean", "getBool", "(", "final", "String", "key", ")", "{", "Boolean", "result", "=", "optBool", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "thi...
Get a property as a boolean or throw exception. @param key the property name
[ "Get", "a", "property", "as", "a", "boolean", "or", "throw", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L154-L161
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optBool
@Override public final Boolean optBool(final String key, final Boolean defaultValue) { Boolean result = optBool(key); return result == null ? defaultValue : result; }
java
@Override public final Boolean optBool(final String key, final Boolean defaultValue) { Boolean result = optBool(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "Boolean", "optBool", "(", "final", "String", "key", ",", "final", "Boolean", "defaultValue", ")", "{", "Boolean", "result", "=", "optBool", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", ":...
Get a property as a boolean or default value. @param key the property name @param defaultValue the default
[ "Get", "a", "property", "as", "a", "boolean", "or", "default", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L169-L173
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getObject
@Override public final PObject getObject(final String key) { PObject result = optObject(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final PObject getObject(final String key) { PObject result = optObject(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "PObject", "getObject", "(", "final", "String", "key", ")", "{", "PObject", "result", "=", "optObject", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", ...
Get a property as a object or throw exception. @param key the property name
[ "Get", "a", "property", "as", "a", "object", "or", "throw", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L180-L187
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getArray
@Override public final PArray getArray(final String key) { PArray result = optArray(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final PArray getArray(final String key) { PArray result = optArray(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "PArray", "getArray", "(", "final", "String", "key", ")", "{", "PArray", "result", "=", "optArray", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "thi...
Get a property as a array or throw exception. @param key the property name
[ "Get", "a", "property", "as", "a", "array", "or", "throw", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L206-L213
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/access/AccessAssertionPersister.java
AccessAssertionPersister.unmarshal
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 = (AccessAssertion) this.applicationContext.getBean(assertionClass); assertion.unmarshal(encodedAssertion); return assertion; } catch (JSONException | ClassNotFoundException e) { throw new RuntimeException(e); } }
java
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 = (AccessAssertion) this.applicationContext.getBean(assertionClass); assertion.unmarshal(encodedAssertion); return assertion; } catch (JSONException | ClassNotFoundException e) { throw new RuntimeException(e); } }
[ "public", "AccessAssertion", "unmarshal", "(", "final", "JSONObject", "encodedAssertion", ")", "{", "final", "String", "className", ";", "try", "{", "className", "=", "encodedAssertion", ".", "getString", "(", "JSON_CLASS_NAME", ")", ";", "final", "Class", "<", ...
Load assertion from the provided json or throw exception if not possible. @param encodedAssertion the assertion as it was encoded in JSON.
[ "Load", "assertion", "from", "the", "provided", "json", "or", "throw", "exception", "if", "not", "possible", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/access/AccessAssertionPersister.java#L21-L35
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/access/AccessAssertionPersister.java
AccessAssertionPersister.marshal
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 a reserved keyword and is not permitted to be used " + "in toJSON method"); } try { jsonObject.put(JSON_CLASS_NAME, assertion.getClass().getName()); } catch (JSONException e) { throw new RuntimeException(e); } return jsonObject; }
java
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 a reserved keyword and is not permitted to be used " + "in toJSON method"); } try { jsonObject.put(JSON_CLASS_NAME, assertion.getClass().getName()); } catch (JSONException e) { throw new RuntimeException(e); } return jsonObject; }
[ "public", "JSONObject", "marshal", "(", "final", "AccessAssertion", "assertion", ")", "{", "final", "JSONObject", "jsonObject", "=", "assertion", ".", "marshal", "(", ")", ";", "if", "(", "jsonObject", ".", "has", "(", "JSON_CLASS_NAME", ")", ")", "{", "thro...
Marshal the assertion as a JSON object. @param assertion the assertion to marshal
[ "Marshal", "the", "assertion", "as", "a", "JSON", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/access/AccessAssertionPersister.java#L42-L57
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/http/AddHeadersProcessor.java
AddHeadersProcessor.createFactoryWrapper
public static MfClientHttpRequestFactory createFactoryWrapper( final MfClientHttpRequestFactory requestFactory, final UriMatchers matchers, final Map<String, List<String>> headers) { return new AbstractMfClientHttpRequestFactoryWrapper(requestFactory, matchers, false) { @Override protected ClientHttpRequest createRequest( final URI uri, final HttpMethod httpMethod, final MfClientHttpRequestFactory requestFactory) throws IOException { final ClientHttpRequest request = requestFactory.createRequest(uri, httpMethod); request.getHeaders().putAll(headers); return request; } }; }
java
public static MfClientHttpRequestFactory createFactoryWrapper( final MfClientHttpRequestFactory requestFactory, final UriMatchers matchers, final Map<String, List<String>> headers) { return new AbstractMfClientHttpRequestFactoryWrapper(requestFactory, matchers, false) { @Override protected ClientHttpRequest createRequest( final URI uri, final HttpMethod httpMethod, final MfClientHttpRequestFactory requestFactory) throws IOException { final ClientHttpRequest request = requestFactory.createRequest(uri, httpMethod); request.getHeaders().putAll(headers); return request; } }; }
[ "public", "static", "MfClientHttpRequestFactory", "createFactoryWrapper", "(", "final", "MfClientHttpRequestFactory", "requestFactory", ",", "final", "UriMatchers", "matchers", ",", "final", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "headers", ")", ...
Create a MfClientHttpRequestFactory for adding the specified headers. @param requestFactory the basic request factory. It should be unmodified and just wrapped with a proxy class. @param matchers The matchers. @param headers The headers. @return
[ "Create", "a", "MfClientHttpRequestFactory", "for", "adding", "the", "specified", "headers", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/AddHeadersProcessor.java#L44-L58
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/http/AddHeadersProcessor.java
AddHeadersProcessor.setHeaders
@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(); // verify they are all strings for (Object o: value) { Assert.isTrue(o instanceof String, o + " is not a string it is a: '" + o.getClass() + "'"); } this.headers.put(entry.getKey(), (List<String>) entry.getValue()); } else if (entry.getValue() instanceof String) { final List<String> value = Collections.singletonList((String) entry.getValue()); this.headers.put(entry.getKey(), value); } else { throw new IllegalArgumentException("Only strings and list of strings may be headers"); } } }
java
@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(); // verify they are all strings for (Object o: value) { Assert.isTrue(o instanceof String, o + " is not a string it is a: '" + o.getClass() + "'"); } this.headers.put(entry.getKey(), (List<String>) entry.getValue()); } else if (entry.getValue() instanceof String) { final List<String> value = Collections.singletonList((String) entry.getValue()); this.headers.put(entry.getKey(), value); } else { throw new IllegalArgumentException("Only strings and list of strings may be headers"); } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "setHeaders", "(", "final", "Map", "<", "String", ",", "Object", ">", "headers", ")", "{", "this", ".", "headers", ".", "clear", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", ...
A map of the header key value pairs. Keys are strings and values are either list of strings or a string. @param headers the header map
[ "A", "map", "of", "the", "header", "key", "value", "pairs", ".", "Keys", "are", "strings", "and", "values", "are", "either", "list", "of", "strings", "or", "a", "string", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/AddHeadersProcessor.java#L66-L85
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java
ProcessorUtils.writeProcessorOutputToValues
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 = getAllAttributes(output.getClass()); for (Field field: fields) { String name = getOutputValueName(processor.getOutputPrefix(), mapper, field); try { final Object value = field.get(output); if (value != null) { values.put(name, value); } else { values.remove(name); } } catch (IllegalAccessException e) { throw ExceptionUtils.getRuntimeException(e); } } }
java
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 = getAllAttributes(output.getClass()); for (Field field: fields) { String name = getOutputValueName(processor.getOutputPrefix(), mapper, field); try { final Object value = field.get(output); if (value != null) { values.put(name, value); } else { values.remove(name); } } catch (IllegalAccessException e) { throw ExceptionUtils.getRuntimeException(e); } } }
[ "public", "static", "void", "writeProcessorOutputToValues", "(", "final", "Object", "output", ",", "final", "Processor", "<", "?", ",", "?", ">", "processor", ",", "final", "Values", "values", ")", "{", "Map", "<", "String", ",", "String", ">", "mapper", "...
Read the values from the output object and write them to the values object. @param output the output object from a processor @param processor the processor the output if from @param values the object for sharing values between processors
[ "Read", "the", "values", "from", "the", "output", "object", "and", "write", "them", "to", "the", "values", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java#L78-L101
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java
ProcessorUtils.getInputValueName
public static String getInputValueName( @Nullable final String inputPrefix, @Nonnull final BiMap<String, String> inputMapper, @Nonnull final String field) { String name = inputMapper == null ? null : inputMapper.inverse().get(field); if (name == null) { if (inputMapper != null && inputMapper.containsKey(field)) { throw new RuntimeException("field in keys"); } final String[] defaultValues = { Values.TASK_DIRECTORY_KEY, Values.CLIENT_HTTP_REQUEST_FACTORY_KEY, Values.TEMPLATE_KEY, Values.PDF_CONFIG_KEY, Values.SUBREPORT_DIR_KEY, Values.OUTPUT_FORMAT_KEY, Values.JOB_ID_KEY }; if (inputPrefix == null || Arrays.asList(defaultValues).contains(field)) { name = field; } else { name = inputPrefix.trim() + Character.toUpperCase(field.charAt(0)) + field.substring(1); } } return name; }
java
public static String getInputValueName( @Nullable final String inputPrefix, @Nonnull final BiMap<String, String> inputMapper, @Nonnull final String field) { String name = inputMapper == null ? null : inputMapper.inverse().get(field); if (name == null) { if (inputMapper != null && inputMapper.containsKey(field)) { throw new RuntimeException("field in keys"); } final String[] defaultValues = { Values.TASK_DIRECTORY_KEY, Values.CLIENT_HTTP_REQUEST_FACTORY_KEY, Values.TEMPLATE_KEY, Values.PDF_CONFIG_KEY, Values.SUBREPORT_DIR_KEY, Values.OUTPUT_FORMAT_KEY, Values.JOB_ID_KEY }; if (inputPrefix == null || Arrays.asList(defaultValues).contains(field)) { name = field; } else { name = inputPrefix.trim() + Character.toUpperCase(field.charAt(0)) + field.substring(1); } } return name; }
[ "public", "static", "String", "getInputValueName", "(", "@", "Nullable", "final", "String", "inputPrefix", ",", "@", "Nonnull", "final", "BiMap", "<", "String", ",", "String", ">", "inputMapper", ",", "@", "Nonnull", "final", "String", "field", ")", "{", "St...
Calculate the name of the input value. @param inputPrefix a nullable prefix to prepend to the name if non-null and non-empty @param inputMapper the name mapper @param field the field containing the value
[ "Calculate", "the", "name", "of", "the", "input", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java#L110-L133
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java
ProcessorUtils.getOutputValueName
public static String getOutputValueName( @Nullable final String outputPrefix, @Nonnull final Map<String, String> outputMapper, @Nonnull final Field field) { String name = outputMapper.get(field.getName()); if (name == null) { name = field.getName(); if (!StringUtils.isEmpty(outputPrefix) && !outputPrefix.trim().isEmpty()) { name = outputPrefix.trim() + Character.toUpperCase(name.charAt(0)) + name.substring(1); } } return name; }
java
public static String getOutputValueName( @Nullable final String outputPrefix, @Nonnull final Map<String, String> outputMapper, @Nonnull final Field field) { String name = outputMapper.get(field.getName()); if (name == null) { name = field.getName(); if (!StringUtils.isEmpty(outputPrefix) && !outputPrefix.trim().isEmpty()) { name = outputPrefix.trim() + Character.toUpperCase(name.charAt(0)) + name.substring(1); } } return name; }
[ "public", "static", "String", "getOutputValueName", "(", "@", "Nullable", "final", "String", "outputPrefix", ",", "@", "Nonnull", "final", "Map", "<", "String", ",", "String", ">", "outputMapper", ",", "@", "Nonnull", "final", "Field", "field", ")", "{", "St...
Calculate the name of the output value. @param outputPrefix a nullable prefix to prepend to the name if non-null and non-empty @param outputMapper the name mapper @param field the field containing the value
[ "Calculate", "the", "name", "of", "the", "output", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java#L142-L155
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java
MapfishMapContext.rectangleDoubleToDimension
public static Dimension rectangleDoubleToDimension(final Rectangle2D.Double rectangle) { return new Dimension( (int) Math.round(rectangle.width), (int) Math.round(rectangle.height)); }
java
public static Dimension rectangleDoubleToDimension(final Rectangle2D.Double rectangle) { return new Dimension( (int) Math.round(rectangle.width), (int) Math.round(rectangle.height)); }
[ "public", "static", "Dimension", "rectangleDoubleToDimension", "(", "final", "Rectangle2D", ".", "Double", "rectangle", ")", "{", "return", "new", "Dimension", "(", "(", "int", ")", "Math", ".", "round", "(", "rectangle", ".", "width", ")", ",", "(", "int", ...
Round the size of a rectangle with double values. @param rectangle The rectangle. @return
[ "Round", "the", "size", "of", "a", "rectangle", "with", "double", "values", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java#L109-L113
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java
MapfishMapContext.getRotatedBounds
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) rotatedBounds).toReferencedEnvelope(null); // the paint area size and the map bounds are rotated independently. because // the paint area size is rounded to integers, the map bounds have to be adjusted // to these rounding changes. final double widthRatio = paintArea.getWidth() / paintAreaPrecise.getWidth(); final double heightRatio = paintArea.getHeight() / paintAreaPrecise.getHeight(); final double adaptedWidth = envelope.getWidth() * widthRatio; final double adaptedHeight = envelope.getHeight() * heightRatio; final double widthDiff = adaptedWidth - envelope.getWidth(); final double heigthDiff = adaptedHeight - envelope.getHeight(); envelope.expandBy(widthDiff / 2.0, heigthDiff / 2.0); return new BBoxMapBounds(envelope); }
java
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) rotatedBounds).toReferencedEnvelope(null); // the paint area size and the map bounds are rotated independently. because // the paint area size is rounded to integers, the map bounds have to be adjusted // to these rounding changes. final double widthRatio = paintArea.getWidth() / paintAreaPrecise.getWidth(); final double heightRatio = paintArea.getHeight() / paintAreaPrecise.getHeight(); final double adaptedWidth = envelope.getWidth() * widthRatio; final double adaptedHeight = envelope.getHeight() * heightRatio; final double widthDiff = adaptedWidth - envelope.getWidth(); final double heigthDiff = adaptedHeight - envelope.getHeight(); envelope.expandBy(widthDiff / 2.0, heigthDiff / 2.0); return new BBoxMapBounds(envelope); }
[ "public", "MapBounds", "getRotatedBounds", "(", "final", "Rectangle2D", ".", "Double", "paintAreaPrecise", ",", "final", "Rectangle", "paintArea", ")", "{", "final", "MapBounds", "rotatedBounds", "=", "this", ".", "getRotatedBounds", "(", ")", ";", "if", "(", "r...
Return the map bounds rotated with the set rotation. The bounds are adapted to rounding changes of the size of the paint area. @param paintAreaPrecise The exact size of the paint area. @param paintArea The rounded size of the paint area. @return Rotated bounds.
[ "Return", "the", "map", "bounds", "rotated", "with", "the", "set", "rotation", ".", "The", "bounds", "are", "adapted", "to", "rounding", "changes", "of", "the", "size", "of", "the", "paint", "area", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java#L150-L172
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java
MapfishMapContext.getRotatedBoundsAdjustedForPreciseRotatedMapSize
public MapBounds getRotatedBoundsAdjustedForPreciseRotatedMapSize() { Rectangle2D.Double paintAreaPrecise = getRotatedMapSizePrecise(); Rectangle paintArea = new Rectangle(MapfishMapContext.rectangleDoubleToDimension(paintAreaPrecise)); return getRotatedBounds(paintAreaPrecise, paintArea); }
java
public MapBounds getRotatedBoundsAdjustedForPreciseRotatedMapSize() { Rectangle2D.Double paintAreaPrecise = getRotatedMapSizePrecise(); Rectangle paintArea = new Rectangle(MapfishMapContext.rectangleDoubleToDimension(paintAreaPrecise)); return getRotatedBounds(paintAreaPrecise, paintArea); }
[ "public", "MapBounds", "getRotatedBoundsAdjustedForPreciseRotatedMapSize", "(", ")", "{", "Rectangle2D", ".", "Double", "paintAreaPrecise", "=", "getRotatedMapSizePrecise", "(", ")", ";", "Rectangle", "paintArea", "=", "new", "Rectangle", "(", "MapfishMapContext", ".", ...
Return the map bounds rotated with the set rotation. The bounds are adapted to rounding changes of the size of the set paint area. @return Rotated bounds.
[ "Return", "the", "map", "bounds", "rotated", "with", "the", "set", "rotation", ".", "The", "bounds", "are", "adapted", "to", "rounding", "changes", "of", "the", "size", "of", "the", "set", "paint", "area", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java#L180-L184
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/cli/Main.java
Main.runMain
@VisibleForTesting 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) { // Ignore because it is probably one of the non-help options. } final CliDefinition cli = new CliDefinition(); try { List<String> unusedArguments = Args.parse(cli, args); if (!unusedArguments.isEmpty()) { System.out.println("\n\nThe following arguments are not recognized: " + unusedArguments); printUsage(1); return; } } catch (IllegalArgumentException invalidOption) { System.out.println("\n\n" + invalidOption.getMessage()); printUsage(1); return; } configureLogs(cli.verbose); AbstractXmlApplicationContext context = new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT); if (cli.springConfig != null) { context = new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT, cli.springConfig); } try { context.getBean(Main.class).run(cli); } finally { context.close(); } }
java
@VisibleForTesting 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) { // Ignore because it is probably one of the non-help options. } final CliDefinition cli = new CliDefinition(); try { List<String> unusedArguments = Args.parse(cli, args); if (!unusedArguments.isEmpty()) { System.out.println("\n\nThe following arguments are not recognized: " + unusedArguments); printUsage(1); return; } } catch (IllegalArgumentException invalidOption) { System.out.println("\n\n" + invalidOption.getMessage()); printUsage(1); return; } configureLogs(cli.verbose); AbstractXmlApplicationContext context = new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT); if (cli.springConfig != null) { context = new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT, cli.springConfig); } try { context.getBean(Main.class).run(cli); } finally { context.close(); } }
[ "@", "VisibleForTesting", "public", "static", "void", "runMain", "(", "final", "String", "[", "]", "args", ")", "throws", "Exception", "{", "final", "CliHelpDefinition", "helpCli", "=", "new", "CliHelpDefinition", "(", ")", ";", "try", "{", "Args", ".", "par...
Runs the print. @param args the cli arguments @throws Exception
[ "Runs", "the", "print", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/cli/Main.java#L75-L115
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/tiled/CoverageTask.java
CoverageTask.call
public GridCoverage2D call() { try { BufferedImage coverageImage = this.tiledLayer.createBufferedImage( this.tilePreparationInfo.getImageWidth(), this.tilePreparationInfo.getImageHeight()); Graphics2D graphics = coverageImage.createGraphics(); try { for (SingleTilePreparationInfo tileInfo: this.tilePreparationInfo.getSingleTiles()) { final TileTask task; if (tileInfo.getTileRequest() != null) { task = new SingleTileLoaderTask( tileInfo.getTileRequest(), this.errorImage, tileInfo.getTileIndexX(), tileInfo.getTileIndexY(), this.failOnError, this.registry, this.context); } else { task = new PlaceHolderImageTask(this.tiledLayer.getMissingTileImage(), tileInfo.getTileIndexX(), tileInfo.getTileIndexY()); } Tile tile = task.call(); if (tile.getImage() != null) { graphics.drawImage(tile.getImage(), tile.getxIndex() * this.tiledLayer.getTileSize().width, tile.getyIndex() * this.tiledLayer.getTileSize().height, null); } } } finally { graphics.dispose(); } GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); GeneralEnvelope gridEnvelope = new GeneralEnvelope(this.tilePreparationInfo.getMapProjection()); gridEnvelope.setEnvelope(this.tilePreparationInfo.getGridCoverageOrigin().x, this.tilePreparationInfo.getGridCoverageOrigin().y, this.tilePreparationInfo.getGridCoverageMaxX(), this.tilePreparationInfo.getGridCoverageMaxY()); return factory.create(this.tiledLayer.createCommonUrl(), coverageImage, gridEnvelope, null, null, null); } catch (Exception e) { throw ExceptionUtils.getRuntimeException(e); } }
java
public GridCoverage2D call() { try { BufferedImage coverageImage = this.tiledLayer.createBufferedImage( this.tilePreparationInfo.getImageWidth(), this.tilePreparationInfo.getImageHeight()); Graphics2D graphics = coverageImage.createGraphics(); try { for (SingleTilePreparationInfo tileInfo: this.tilePreparationInfo.getSingleTiles()) { final TileTask task; if (tileInfo.getTileRequest() != null) { task = new SingleTileLoaderTask( tileInfo.getTileRequest(), this.errorImage, tileInfo.getTileIndexX(), tileInfo.getTileIndexY(), this.failOnError, this.registry, this.context); } else { task = new PlaceHolderImageTask(this.tiledLayer.getMissingTileImage(), tileInfo.getTileIndexX(), tileInfo.getTileIndexY()); } Tile tile = task.call(); if (tile.getImage() != null) { graphics.drawImage(tile.getImage(), tile.getxIndex() * this.tiledLayer.getTileSize().width, tile.getyIndex() * this.tiledLayer.getTileSize().height, null); } } } finally { graphics.dispose(); } GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); GeneralEnvelope gridEnvelope = new GeneralEnvelope(this.tilePreparationInfo.getMapProjection()); gridEnvelope.setEnvelope(this.tilePreparationInfo.getGridCoverageOrigin().x, this.tilePreparationInfo.getGridCoverageOrigin().y, this.tilePreparationInfo.getGridCoverageMaxX(), this.tilePreparationInfo.getGridCoverageMaxY()); return factory.create(this.tiledLayer.createCommonUrl(), coverageImage, gridEnvelope, null, null, null); } catch (Exception e) { throw ExceptionUtils.getRuntimeException(e); } }
[ "public", "GridCoverage2D", "call", "(", ")", "{", "try", "{", "BufferedImage", "coverageImage", "=", "this", ".", "tiledLayer", ".", "createBufferedImage", "(", "this", ".", "tilePreparationInfo", ".", "getImageWidth", "(", ")", ",", "this", ".", "tilePreparati...
Call the Coverage Task.
[ "Call", "the", "Coverage", "Task", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/CoverageTask.java#L84-L123
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java
ThreadPoolJobManager.shutdown
@PreDestroy public final void shutdown() { this.timer.shutdownNow(); this.executor.shutdownNow(); if (this.cleanUpTimer != null) { this.cleanUpTimer.shutdownNow(); } }
java
@PreDestroy public final void shutdown() { this.timer.shutdownNow(); this.executor.shutdownNow(); if (this.cleanUpTimer != null) { this.cleanUpTimer.shutdownNow(); } }
[ "@", "PreDestroy", "public", "final", "void", "shutdown", "(", ")", "{", "this", ".", "timer", ".", "shutdownNow", "(", ")", ";", "this", ".", "executor", ".", "shutdownNow", "(", ")", ";", "if", "(", "this", ".", "cleanUpTimer", "!=", "null", ")", "...
Called by spring when application context is being destroyed.
[ "Called", "by", "spring", "when", "application", "context", "is", "being", "destroyed", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java#L273-L280
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java
ThreadPoolJobManager.isAbandoned
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.abandonedTimeout); if (abandoned) { LOGGER.info("Job {} is abandoned (no status check within the last {} seconds)", printJob.getEntry().getReferenceId(), ThreadPoolJobManager.this.abandonedTimeout); } return abandoned; }
java
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.abandonedTimeout); if (abandoned) { LOGGER.info("Job {} is abandoned (no status check within the last {} seconds)", printJob.getEntry().getReferenceId(), ThreadPoolJobManager.this.abandonedTimeout); } return abandoned; }
[ "private", "boolean", "isAbandoned", "(", "final", "SubmittedPrintJob", "printJob", ")", "{", "final", "long", "duration", "=", "ThreadPoolJobManager", ".", "this", ".", "jobQueue", ".", "timeSinceLastStatusCheck", "(", "printJob", ".", "getEntry", "(", ")", ".", ...
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. @param printJob @return is the abandoned timeout exceeded?
[ "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", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java#L479-L489
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java
ThreadPoolJobManager.isAcceptingNewJobs
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 { return true; } }
java
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 { return true; } }
[ "private", "boolean", "isAcceptingNewJobs", "(", ")", "{", "if", "(", "this", ".", "requestedToStop", ")", "{", "return", "false", ";", "}", "else", "if", "(", "new", "File", "(", "this", ".", "workingDirectories", ".", "getWorking", "(", ")", ",", "\"st...
Check if the print has not been asked to stop taking new jobs. @return true if it's OK to take new jobs.
[ "Check", "if", "the", "print", "has", "not", "been", "asked", "to", "stop", "taking", "new", "jobs", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java#L496-L507
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java
ThreadPoolJobManager.notifyIfStopped
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.createNewFile(); } catch (IOException e) { LOGGER.warn("Cannot create the {} file", stoppedFile, e); } }
java
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.createNewFile(); } catch (IOException e) { LOGGER.warn("Cannot create the {} file", stoppedFile, e); } }
[ "private", "void", "notifyIfStopped", "(", ")", "{", "if", "(", "isAcceptingNewJobs", "(", ")", "||", "!", "this", ".", "runningTasksFutures", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "final", "File", "stoppedFile", "=", "new", "File", "("...
Add a file to notify the script that asked to stop the print that it is now done processing the remain jobs.
[ "Add", "a", "file", "to", "notify", "the", "script", "that", "asked", "to", "stop", "the", "print", "that", "it", "is", "now", "done", "processing", "the", "remain", "jobs", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java#L513-L524
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/AreaOfInterest.java
AreaOfInterest.postConstruct
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 not make sense unless 'display' == RENDER. In this case 'display' == " + this.display); }
java
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 not make sense unless 'display' == RENDER. In this case 'display' == " + this.display); }
[ "public", "void", "postConstruct", "(", ")", "{", "parseGeometry", "(", ")", ";", "Assert", ".", "isTrue", "(", "this", ".", "polygon", "!=", "null", ",", "\"Polygon is null. 'area' string is: '\"", "+", "this", ".", "area", "+", "\"'\"", ")", ";", "Assert",...
Tests that the area is valid geojson, the style ref is valid or null and the display is non-null.
[ "Tests", "that", "the", "area", "is", "valid", "geojson", "the", "style", "ref", "is", "valid", "or", "null", "and", "the", "display", "is", "non", "-", "null", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/AreaOfInterest.java#L57-L66
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/AreaOfInterest.java
AreaOfInterest.areaToFeatureCollection
public SimpleFeatureCollection areaToFeatureCollection( @Nonnull 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 SimpleFeatureTypeBuilder(); typeBuilder.setName("aoi"); CoordinateReferenceSystem crs = mapAttributes.getMapBounds().getProjection(); typeBuilder.add("geom", this.polygon.getClass(), crs); final SimpleFeature feature = SimpleFeatureBuilder.build(typeBuilder.buildFeatureType(), new Object[]{this.polygon}, "aoi"); final DefaultFeatureCollection features = new DefaultFeatureCollection(); features.add(feature); return features; }
java
public SimpleFeatureCollection areaToFeatureCollection( @Nonnull 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 SimpleFeatureTypeBuilder(); typeBuilder.setName("aoi"); CoordinateReferenceSystem crs = mapAttributes.getMapBounds().getProjection(); typeBuilder.add("geom", this.polygon.getClass(), crs); final SimpleFeature feature = SimpleFeatureBuilder.build(typeBuilder.buildFeatureType(), new Object[]{this.polygon}, "aoi"); final DefaultFeatureCollection features = new DefaultFeatureCollection(); features.add(feature); return features; }
[ "public", "SimpleFeatureCollection", "areaToFeatureCollection", "(", "@", "Nonnull", "final", "MapAttribute", ".", "MapAttributeValues", "mapAttributes", ")", "{", "Assert", ".", "isTrue", "(", "mapAttributes", ".", "areaOfInterest", "==", "this", ",", "\"map attributes...
Return the area polygon as the only feature in the feature collection. @param mapAttributes the attributes that this aoi is part of.
[ "Return", "the", "area", "polygon", "as", "the", "only", "feature", "in", "the", "feature", "collection", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/AreaOfInterest.java#L95-L109
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/AreaOfInterest.java
AreaOfInterest.copy
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; }
java
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; }
[ "public", "AreaOfInterest", "copy", "(", ")", "{", "AreaOfInterest", "aoi", "=", "new", "AreaOfInterest", "(", ")", ";", "aoi", ".", "display", "=", "this", ".", "display", ";", "aoi", ".", "area", "=", "this", ".", "area", ";", "aoi", ".", "polygon", ...
Make a copy of this Area of Interest.
[ "Make", "a", "copy", "of", "this", "Area", "of", "Interest", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/AreaOfInterest.java#L118-L126
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorDependencyGraphFactory.java
ProcessorDependencyGraphFactory.fillProcessorAttributes
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 (ProcessorDependencyGraphFactory.InputValue inputValue: ProcessorDependencyGraphFactory.getInputs(processor)) { if (inputValue.type == Values.class) { if (processor instanceof CustomDependencies) { for (String attributeName: ((CustomDependencies) processor).getDependencies()) { Attribute attribute = currentAttributes.get(attributeName); if (attribute != null) { ((RequireAttributes) processor).setAttribute( attributeName, currentAttributes.get(attributeName)); } } } else { for (Map.Entry<String, Attribute> attribute: currentAttributes.entrySet()) { ((RequireAttributes) processor).setAttribute( attribute.getKey(), attribute.getValue()); } } } else { try { ((RequireAttributes) processor).setAttribute( inputValue.internalName, currentAttributes.get(inputValue.name)); } catch (ClassCastException e) { throw new IllegalArgumentException(String.format("The processor '%s' requires " + "the attribute '%s' " + "(%s) but he has the " + "wrong type:\n%s", processor, inputValue.name, inputValue.internalName, e.getMessage()), e); } } } } if (processor instanceof ProvideAttributes) { Map<String, Attribute> newAttributes = ((ProvideAttributes) processor).getAttributes(); for (ProcessorDependencyGraphFactory.OutputValue ouputValue: ProcessorDependencyGraphFactory.getOutputValues(processor)) { currentAttributes.put( ouputValue.name, newAttributes.get(ouputValue.internalName)); } } } }
java
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 (ProcessorDependencyGraphFactory.InputValue inputValue: ProcessorDependencyGraphFactory.getInputs(processor)) { if (inputValue.type == Values.class) { if (processor instanceof CustomDependencies) { for (String attributeName: ((CustomDependencies) processor).getDependencies()) { Attribute attribute = currentAttributes.get(attributeName); if (attribute != null) { ((RequireAttributes) processor).setAttribute( attributeName, currentAttributes.get(attributeName)); } } } else { for (Map.Entry<String, Attribute> attribute: currentAttributes.entrySet()) { ((RequireAttributes) processor).setAttribute( attribute.getKey(), attribute.getValue()); } } } else { try { ((RequireAttributes) processor).setAttribute( inputValue.internalName, currentAttributes.get(inputValue.name)); } catch (ClassCastException e) { throw new IllegalArgumentException(String.format("The processor '%s' requires " + "the attribute '%s' " + "(%s) but he has the " + "wrong type:\n%s", processor, inputValue.name, inputValue.internalName, e.getMessage()), e); } } } } if (processor instanceof ProvideAttributes) { Map<String, Attribute> newAttributes = ((ProvideAttributes) processor).getAttributes(); for (ProcessorDependencyGraphFactory.OutputValue ouputValue: ProcessorDependencyGraphFactory.getOutputValues(processor)) { currentAttributes.put( ouputValue.name, newAttributes.get(ouputValue.internalName)); } } } }
[ "public", "static", "void", "fillProcessorAttributes", "(", "final", "List", "<", "Processor", ">", "processors", ",", "final", "Map", "<", "String", ",", "Attribute", ">", "initialAttributes", ")", "{", "Map", "<", "String", ",", "Attribute", ">", "currentAtt...
Fill the attributes in the processor. @param processors The processors @param initialAttributes The attributes @see RequireAttributes @see ProvideAttributes
[ "Fill", "the", "attributes", "in", "the", "processor", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorDependencyGraphFactory.java#L91-L141
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/parser/OneOfTracker.java
OneOfTracker.checkAllGroupsSatisfied
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(" was not satisfied. One (and only one) of the "); errors.append("following fields is required in the request data: ") .append(toNames(group.choices)); } Collection<OneOfSatisfier> oneOfSatisfiers = Collections2.filter(group.satisfiedBy, input -> !input.isCanSatisfy); if (oneOfSatisfiers.size() > 1) { errors.append("\n"); errors.append("\t* The OneOf choice: ").append(group.name) .append(" was satisfied by too many fields. Only one choice "); errors.append("may be in the request data. The fields found were: ") .append(toNames(toFields(group.satisfiedBy))); } } Assert.equals(0, errors.length(), "\nErrors were detected when analysing the @OneOf dependencies of '" + currentPath + "': \n" + errors); }
java
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(" was not satisfied. One (and only one) of the "); errors.append("following fields is required in the request data: ") .append(toNames(group.choices)); } Collection<OneOfSatisfier> oneOfSatisfiers = Collections2.filter(group.satisfiedBy, input -> !input.isCanSatisfy); if (oneOfSatisfiers.size() > 1) { errors.append("\n"); errors.append("\t* The OneOf choice: ").append(group.name) .append(" was satisfied by too many fields. Only one choice "); errors.append("may be in the request data. The fields found were: ") .append(toNames(toFields(group.satisfiedBy))); } } Assert.equals(0, errors.length(), "\nErrors were detected when analysing the @OneOf dependencies of '" + currentPath + "': \n" + errors); }
[ "public", "void", "checkAllGroupsSatisfied", "(", "final", "String", "currentPath", ")", "{", "StringBuilder", "errors", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "OneOfGroup", "group", ":", "this", ".", "mapping", ".", "values", "(", ")", ")",...
Check that each group is satisfied by one and only one field. @param currentPath the json path to the element being checked
[ "Check", "that", "each", "group", "is", "satisfied", "by", "one", "and", "only", "one", "field", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/parser/OneOfTracker.java#L74-L101
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/metrics/LoggingMetricsConfigurator.java
LoggingMetricsConfigurator.addMetricsAppenderToLogback
@PostConstruct 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.setContext(root.getLoggerContext()); metrics.start(); root.addAppender(metrics); }
java
@PostConstruct 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.setContext(root.getLoggerContext()); metrics.start(); root.addAppender(metrics); }
[ "@", "PostConstruct", "public", "final", "void", "addMetricsAppenderToLogback", "(", ")", "{", "final", "LoggerContext", "factory", "=", "(", "LoggerContext", ")", "LoggerFactory", ".", "getILoggerFactory", "(", ")", ";", "final", "Logger", "root", "=", "factory",...
Add an appender to Logback logging framework that will track the types of log messages made.
[ "Add", "an", "appender", "to", "Logback", "logging", "framework", "that", "will", "track", "the", "types", "of", "log", "messages", "made", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/metrics/LoggingMetricsConfigurator.java#L22-L31
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/parser/RequiresTracker.java
RequiresTracker.checkAllRequirementsSatisfied
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("\n"); String type = field.getType().getName(); if (field.getType().isArray()) { type = field.getType().getComponentType().getName() + "[]"; } errors.append("\t* ").append(type).append(' ').append(field.getName()).append(" depends on ") .append(requirements); } } Assert.equals(0, errors.length(), "\nErrors were detected when analysing the @Requires dependencies of '" + currentPath + "': " + errors); }
java
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("\n"); String type = field.getType().getName(); if (field.getType().isArray()) { type = field.getType().getComponentType().getName() + "[]"; } errors.append("\t* ").append(type).append(' ').append(field.getName()).append(" depends on ") .append(requirements); } } Assert.equals(0, errors.length(), "\nErrors were detected when analysing the @Requires dependencies of '" + currentPath + "': " + errors); }
[ "public", "void", "checkAllRequirementsSatisfied", "(", "final", "String", "currentPath", ")", "{", "StringBuilder", "errors", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Field", "field", ":", "this", ".", "dependantsInJson", ")", "{", "final", "C...
Check that each requirement is satisfied. @param currentPath the json path to the element being checked
[ "Check", "that", "each", "requirement", "is", "satisfied", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/parser/RequiresTracker.java#L64-L82
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/Configuration.java
Configuration.printClientConfig
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)) .forEach(entry -> { json.object(); json.key("name").value(entry.getKey()); entry.getValue().printClientConfig(json); json.endObject(); }); json.endArray(); json.key("smtp").object(); json.key("enabled").value(smtp != null); if (smtp != null) { json.key("storage").object(); json.key("enabled").value(smtp.getStorage() != null); json.endObject(); } json.endObject(); }
java
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)) .forEach(entry -> { json.object(); json.key("name").value(entry.getKey()); entry.getValue().printClientConfig(json); json.endObject(); }); json.endArray(); json.key("smtp").object(); json.key("enabled").value(smtp != null); if (smtp != null) { json.key("storage").object(); json.key("enabled").value(smtp.getStorage() != null); json.endObject(); } json.endObject(); }
[ "public", "final", "void", "printClientConfig", "(", "final", "JSONWriter", "json", ")", "throws", "JSONException", "{", "json", ".", "key", "(", "\"layouts\"", ")", ";", "json", ".", "array", "(", ")", ";", "final", "Map", "<", "String", ",", "Template", ...
Print out the configuration that the client needs to make a request. @param json the output writer. @throws JSONException
[ "Print", "out", "the", "configuration", "that", "the", "client", "needs", "to", "make", "a", "request", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/Configuration.java#L234-L254
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/Configuration.java
Configuration.getTemplate
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("Template '%s' does not exist. Options are: " + "%s", name, this.templates.keySet())); } return template; }
java
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("Template '%s' does not exist. Options are: " + "%s", name, this.templates.keySet())); } return template; }
[ "public", "final", "Template", "getTemplate", "(", "final", "String", "name", ")", "{", "final", "Template", "template", "=", "this", ".", "templates", ".", "get", "(", "name", ")", ";", "if", "(", "template", "!=", "null", ")", "{", "this", ".", "acce...
Retrieve the configuration of the named template. @param name the template name;
[ "Retrieve", "the", "configuration", "of", "the", "named", "template", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/Configuration.java#L312-L322
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/Configuration.java
Configuration.getDefaultStyle
@Nonnull public final Style getDefaultStyle(@Nonnull final String geometryType) { String normalizedGeomName = GEOMETRY_NAME_ALIASES.get(geometryType.toLowerCase()); if (normalizedGeomName == null) { normalizedGeomName = geometryType.toLowerCase(); } Style style = this.defaultStyle.get(normalizedGeomName.toLowerCase()); if (style == null) { style = this.namedStyles.get(normalizedGeomName.toLowerCase()); } if (style == null) { StyleBuilder builder = new StyleBuilder(); final Symbolizer symbolizer; if (isPointType(normalizedGeomName)) { symbolizer = builder.createPointSymbolizer(); } else if (isLineType(normalizedGeomName)) { symbolizer = builder.createLineSymbolizer(Color.black, 2); } else if (isPolygonType(normalizedGeomName)) { symbolizer = builder.createPolygonSymbolizer(Color.lightGray, Color.black, 2); } else if (normalizedGeomName.equalsIgnoreCase(Constants.Style.Raster.NAME)) { symbolizer = builder.createRasterSymbolizer(); } else if (normalizedGeomName.startsWith(Constants.Style.OverviewMap.NAME)) { symbolizer = createMapOverviewStyle(normalizedGeomName, builder); } else { final Style geomStyle = this.defaultStyle.get(Geometry.class.getSimpleName().toLowerCase()); if (geomStyle != null) { return geomStyle; } else { symbolizer = builder.createPointSymbolizer(); } } style = builder.createStyle(symbolizer); } return style; }
java
@Nonnull public final Style getDefaultStyle(@Nonnull final String geometryType) { String normalizedGeomName = GEOMETRY_NAME_ALIASES.get(geometryType.toLowerCase()); if (normalizedGeomName == null) { normalizedGeomName = geometryType.toLowerCase(); } Style style = this.defaultStyle.get(normalizedGeomName.toLowerCase()); if (style == null) { style = this.namedStyles.get(normalizedGeomName.toLowerCase()); } if (style == null) { StyleBuilder builder = new StyleBuilder(); final Symbolizer symbolizer; if (isPointType(normalizedGeomName)) { symbolizer = builder.createPointSymbolizer(); } else if (isLineType(normalizedGeomName)) { symbolizer = builder.createLineSymbolizer(Color.black, 2); } else if (isPolygonType(normalizedGeomName)) { symbolizer = builder.createPolygonSymbolizer(Color.lightGray, Color.black, 2); } else if (normalizedGeomName.equalsIgnoreCase(Constants.Style.Raster.NAME)) { symbolizer = builder.createRasterSymbolizer(); } else if (normalizedGeomName.startsWith(Constants.Style.OverviewMap.NAME)) { symbolizer = createMapOverviewStyle(normalizedGeomName, builder); } else { final Style geomStyle = this.defaultStyle.get(Geometry.class.getSimpleName().toLowerCase()); if (geomStyle != null) { return geomStyle; } else { symbolizer = builder.createPointSymbolizer(); } } style = builder.createStyle(symbolizer); } return style; }
[ "@", "Nonnull", "public", "final", "Style", "getDefaultStyle", "(", "@", "Nonnull", "final", "String", "geometryType", ")", "{", "String", "normalizedGeomName", "=", "GEOMETRY_NAME_ALIASES", ".", "get", "(", "geometryType", ".", "toLowerCase", "(", ")", ")", ";"...
Get a default style. If null a simple black line style will be returned. @param geometryType the name of the geometry type (point, line, polygon)
[ "Get", "a", "default", "style", ".", "If", "null", "a", "simple", "black", "line", "style", "will", "be", "returned", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/Configuration.java#L362-L397
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/Configuration.java
Configuration.setDefaultStyle
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()); if (normalizedName == null) { normalizedName = entry.getKey().toLowerCase(); } this.defaultStyle.put(normalizedName, entry.getValue()); } }
java
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()); if (normalizedName == null) { normalizedName = entry.getKey().toLowerCase(); } this.defaultStyle.put(normalizedName, entry.getValue()); } }
[ "public", "final", "void", "setDefaultStyle", "(", "final", "Map", "<", "String", ",", "Style", ">", "defaultStyle", ")", "{", "this", ".", "defaultStyle", "=", "new", "HashMap", "<>", "(", "defaultStyle", ".", "size", "(", ")", ")", ";", "for", "(", "...
Set the default styles. the case of the keys are not important. The retrieval will be case insensitive. @param defaultStyle the mapping from geometry type name (point, polygon, etc...) to the style to use for that type.
[ "Set", "the", "default", "styles", ".", "the", "case", "of", "the", "keys", "are", "not", "important", ".", "The", "retrieval", "will", "be", "case", "insensitive", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/Configuration.java#L446-L457
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/Configuration.java
Configuration.validate
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.class.getClassLoader().loadClass(jdbcDriver); } catch (ClassNotFoundException e1) { validationErrors.add(new ConfigurationException(String.format( "Unable to load JDBC driver: %s ensure that the web application has the jar " + "on its classpath", jdbcDriver))); } } } if (this.configurationFile == null) { validationErrors.add(new ConfigurationException("Configuration file is field on configuration " + "object is null")); } if (this.templates.isEmpty()) { validationErrors.add(new ConfigurationException("There are not templates defined.")); } for (Template template: this.templates.values()) { template.validate(validationErrors, this); } for (HttpProxy proxy: this.proxies) { proxy.validate(validationErrors, this); } try { ColorParser.toColor(this.opaqueTileErrorColor); } catch (RuntimeException ex) { validationErrors.add(new ConfigurationException("Cannot parse opaqueTileErrorColor", ex)); } try { ColorParser.toColor(this.transparentTileErrorColor); } catch (RuntimeException ex) { validationErrors.add(new ConfigurationException("Cannot parse transparentTileErrorColor", ex)); } if (smtp != null) { smtp.validate(validationErrors, this); } return validationErrors; }
java
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.class.getClassLoader().loadClass(jdbcDriver); } catch (ClassNotFoundException e1) { validationErrors.add(new ConfigurationException(String.format( "Unable to load JDBC driver: %s ensure that the web application has the jar " + "on its classpath", jdbcDriver))); } } } if (this.configurationFile == null) { validationErrors.add(new ConfigurationException("Configuration file is field on configuration " + "object is null")); } if (this.templates.isEmpty()) { validationErrors.add(new ConfigurationException("There are not templates defined.")); } for (Template template: this.templates.values()) { template.validate(validationErrors, this); } for (HttpProxy proxy: this.proxies) { proxy.validate(validationErrors, this); } try { ColorParser.toColor(this.opaqueTileErrorColor); } catch (RuntimeException ex) { validationErrors.add(new ConfigurationException("Cannot parse opaqueTileErrorColor", ex)); } try { ColorParser.toColor(this.transparentTileErrorColor); } catch (RuntimeException ex) { validationErrors.add(new ConfigurationException("Cannot parse transparentTileErrorColor", ex)); } if (smtp != null) { smtp.validate(validationErrors, this); } return validationErrors; }
[ "public", "final", "List", "<", "Throwable", ">", "validate", "(", ")", "{", "List", "<", "Throwable", ">", "validationErrors", "=", "new", "ArrayList", "<>", "(", ")", ";", "this", ".", "accessAssertion", ".", "validate", "(", "validationErrors", ",", "th...
Validate that the configuration is valid. @return any validation errors.
[ "Validate", "that", "the", "configuration", "is", "valid", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/Configuration.java#L487-L537
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorGraphNode.java
ProcessorGraphNode.addDependency
public void addDependency(final ProcessorGraphNode node) { Assert.isTrue(node != this, "A processor can't depends on himself"); this.dependencies.add(node); node.addRequirement(this); }
java
public void addDependency(final ProcessorGraphNode node) { Assert.isTrue(node != this, "A processor can't depends on himself"); this.dependencies.add(node); node.addRequirement(this); }
[ "public", "void", "addDependency", "(", "final", "ProcessorGraphNode", "node", ")", "{", "Assert", ".", "isTrue", "(", "node", "!=", "this", ",", "\"A processor can't depends on himself\"", ")", ";", "this", ".", "dependencies", ".", "add", "(", "node", ")", "...
Add a dependency to this node. @param node the dependency to add.
[ "Add", "a", "dependency", "to", "this", "node", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorGraphNode.java#L66-L71
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorGraphNode.java
ProcessorGraphNode.getOutputMapper
@Nonnull public BiMap<String, String> getOutputMapper() { final BiMap<String, String> outputMapper = this.processor.getOutputMapperBiMap(); if (outputMapper == null) { return HashBiMap.create(); } return outputMapper; }
java
@Nonnull public BiMap<String, String> getOutputMapper() { final BiMap<String, String> outputMapper = this.processor.getOutputMapperBiMap(); if (outputMapper == null) { return HashBiMap.create(); } return outputMapper; }
[ "@", "Nonnull", "public", "BiMap", "<", "String", ",", "String", ">", "getOutputMapper", "(", ")", "{", "final", "BiMap", "<", "String", ",", "String", ">", "outputMapper", "=", "this", ".", "processor", ".", "getOutputMapperBiMap", "(", ")", ";", "if", ...
Get the output mapper from processor.
[ "Get", "the", "output", "mapper", "from", "processor", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorGraphNode.java#L110-L117
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorGraphNode.java
ProcessorGraphNode.getInputMapper
@Nonnull public BiMap<String, String> getInputMapper() { final BiMap<String, String> inputMapper = this.processor.getInputMapperBiMap(); if (inputMapper == null) { return HashBiMap.create(); } return inputMapper; }
java
@Nonnull public BiMap<String, String> getInputMapper() { final BiMap<String, String> inputMapper = this.processor.getInputMapperBiMap(); if (inputMapper == null) { return HashBiMap.create(); } return inputMapper; }
[ "@", "Nonnull", "public", "BiMap", "<", "String", ",", "String", ">", "getInputMapper", "(", ")", "{", "final", "BiMap", "<", "String", ",", "String", ">", "inputMapper", "=", "this", ".", "processor", ".", "getInputMapperBiMap", "(", ")", ";", "if", "("...
Return input mapper from processor.
[ "Return", "input", "mapper", "from", "processor", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorGraphNode.java#L122-L129
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorGraphNode.java
ProcessorGraphNode.getAllProcessors
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.getAllProcessors()) { all.put(p, null); } } return all.keySet(); }
java
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.getAllProcessors()) { all.put(p, null); } } return all.keySet(); }
[ "public", "Set", "<", "?", "extends", "Processor", "<", "?", ",", "?", ">", ">", "getAllProcessors", "(", ")", "{", "IdentityHashMap", "<", "Processor", "<", "?", ",", "?", ">", ",", "Void", ">", "all", "=", "new", "IdentityHashMap", "<>", "(", ")", ...
Create a set containing all the processor at the current node and the entire subgraph.
[ "Create", "a", "set", "containing", "all", "the", "processor", "at", "the", "current", "node", "and", "the", "entire", "subgraph", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorGraphNode.java#L159-L168
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/BaseMapServlet.java
BaseMapServlet.findReplacement
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.getDateTimeInstance().format(date)); } else if (variableName.equalsIgnoreCase("time")) { return cleanUpName(DateFormat.getTimeInstance().format(date)); } else { try { return new SimpleDateFormat(variableName).format(date); } catch (Exception e) { LOGGER.error("Unable to format timestamp according to pattern: {}", variableName, e); return "${" + variableName + "}"; } } }
java
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.getDateTimeInstance().format(date)); } else if (variableName.equalsIgnoreCase("time")) { return cleanUpName(DateFormat.getTimeInstance().format(date)); } else { try { return new SimpleDateFormat(variableName).format(date); } catch (Exception e) { LOGGER.error("Unable to format timestamp according to pattern: {}", variableName, e); return "${" + variableName + "}"; } } }
[ "public", "static", "String", "findReplacement", "(", "final", "String", "variableName", ",", "final", "Date", "date", ")", "{", "if", "(", "variableName", ".", "equalsIgnoreCase", "(", "\"date\"", ")", ")", "{", "return", "cleanUpName", "(", "DateFormat", "."...
Update a variable name with a date if the variable is detected as being a date. @param variableName the variable name. @param date the date to replace the value with if the variable is a date variable.
[ "Update", "a", "variable", "name", "with", "a", "date", "if", "the", "variable", "is", "detected", "as", "being", "a", "date", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/BaseMapServlet.java#L38-L53
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/BaseMapServlet.java
BaseMapServlet.error
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 = httpServletResponse.getWriter()) { out.println("Error while processing request:"); out.println(message); } LOGGER.error("Error while processing request: {}", message); } catch (IOException ex) { throw ExceptionUtils.getRuntimeException(ex); } }
java
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 = httpServletResponse.getWriter()) { out.println("Error while processing request:"); out.println(message); } LOGGER.error("Error while processing request: {}", message); } catch (IOException ex) { throw ExceptionUtils.getRuntimeException(ex); } }
[ "protected", "static", "void", "error", "(", "final", "HttpServletResponse", "httpServletResponse", ",", "final", "String", "message", ",", "final", "HttpStatus", "code", ")", "{", "try", "{", "httpServletResponse", ".", "setContentType", "(", "\"text/plain\"", ")",...
Send an error to the client with a message. @param httpServletResponse the response to send the error to. @param message the message to send @param code the error code
[ "Send", "an", "error", "to", "the", "client", "with", "a", "message", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/BaseMapServlet.java#L62-L77
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/BaseMapServlet.java
BaseMapServlet.error
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("Error while processing request:"); LOGGER.error("Error while processing request", e); } catch (IOException ex) { throw ExceptionUtils.getRuntimeException(ex); } }
java
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("Error while processing request:"); LOGGER.error("Error while processing request", e); } catch (IOException ex) { throw ExceptionUtils.getRuntimeException(ex); } }
[ "protected", "final", "void", "error", "(", "final", "HttpServletResponse", "httpServletResponse", ",", "final", "Throwable", "e", ")", "{", "httpServletResponse", ".", "setContentType", "(", "\"text/plain\"", ")", ";", "httpServletResponse", ".", "setStatus", "(", ...
Send an error to the client with an exception. @param httpServletResponse the http response to send the error to @param e the error that occurred
[ "Send", "an", "error", "to", "the", "client", "with", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/BaseMapServlet.java#L94-L103
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/BaseMapServlet.java
BaseMapServlet.getBaseUrl
protected final StringBuilder getBaseUrl(final HttpServletRequest httpServletRequest) { StringBuilder baseURL = new StringBuilder(); if (httpServletRequest.getContextPath() != null && !httpServletRequest.getContextPath().isEmpty()) { baseURL.append(httpServletRequest.getContextPath()); } if (httpServletRequest.getServletPath() != null && !httpServletRequest.getServletPath().isEmpty()) { baseURL.append(httpServletRequest.getServletPath()); } return baseURL; }
java
protected final StringBuilder getBaseUrl(final HttpServletRequest httpServletRequest) { StringBuilder baseURL = new StringBuilder(); if (httpServletRequest.getContextPath() != null && !httpServletRequest.getContextPath().isEmpty()) { baseURL.append(httpServletRequest.getContextPath()); } if (httpServletRequest.getServletPath() != null && !httpServletRequest.getServletPath().isEmpty()) { baseURL.append(httpServletRequest.getServletPath()); } return baseURL; }
[ "protected", "final", "StringBuilder", "getBaseUrl", "(", "final", "HttpServletRequest", "httpServletRequest", ")", "{", "StringBuilder", "baseURL", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "httpServletRequest", ".", "getContextPath", "(", ")", "!=", ...
Returns the base URL of the print servlet. @param httpServletRequest the request
[ "Returns", "the", "base", "URL", "of", "the", "print", "servlet", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/BaseMapServlet.java#L110-L119
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java
ScalebarGraphic.getSize
@VisibleForTesting 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.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getLeftLabelMargin() + settings.getRightLabelMargin(); height = 2 * settings.getPadding() + settings.getBarSize() + settings.getLabelDistance() + Label.getRotatedHeight(maxLabelSize, scalebarParams.getLabelRotation()); } else { width = 2 * settings.getPadding() + settings.getLabelDistance() + settings.getBarSize() + Label.getRotatedWidth(maxLabelSize, scalebarParams.getLabelRotation()); height = 2 * settings.getPadding() + settings.getTopLabelMargin() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getBottomLabelMargin(); } return new Dimension((int) Math.ceil(width), (int) Math.ceil(height)); }
java
@VisibleForTesting 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.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getLeftLabelMargin() + settings.getRightLabelMargin(); height = 2 * settings.getPadding() + settings.getBarSize() + settings.getLabelDistance() + Label.getRotatedHeight(maxLabelSize, scalebarParams.getLabelRotation()); } else { width = 2 * settings.getPadding() + settings.getLabelDistance() + settings.getBarSize() + Label.getRotatedWidth(maxLabelSize, scalebarParams.getLabelRotation()); height = 2 * settings.getPadding() + settings.getTopLabelMargin() + settings.getIntervalLengthInPixels() * scalebarParams.intervals + settings.getBottomLabelMargin(); } return new Dimension((int) Math.ceil(width), (int) Math.ceil(height)); }
[ "@", "VisibleForTesting", "protected", "static", "Dimension", "getSize", "(", "final", "ScalebarAttributeValues", "scalebarParams", ",", "final", "ScaleBarRenderSettings", "settings", ",", "final", "Dimension", "maxLabelSize", ")", "{", "final", "float", "width", ";", ...
Get the size of the painting area required to draw the scalebar with labels. @param scalebarParams Parameters for the scalebar. @param settings Parameters for rendering the scalebar. @param maxLabelSize The max. size of the labels.
[ "Get", "the", "size", "of", "the", "painting", "area", "required", "to", "draw", "the", "scalebar", "with", "labels", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java#L177-L200
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java
ScalebarGraphic.getMaxLabelSize
@VisibleForTesting 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, label.getWidth()); } return new Dimension((int) Math.ceil(maxLabelWidth), (int) Math.ceil(maxLabelHeight)); }
java
@VisibleForTesting 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, label.getWidth()); } return new Dimension((int) Math.ceil(maxLabelWidth), (int) Math.ceil(maxLabelHeight)); }
[ "@", "VisibleForTesting", "protected", "static", "Dimension", "getMaxLabelSize", "(", "final", "ScaleBarRenderSettings", "settings", ")", "{", "float", "maxLabelHeight", "=", "0.0f", ";", "float", "maxLabelWidth", "=", "0.0f", ";", "for", "(", "final", "Label", "l...
Get the maximum width and height of the labels. @param settings Parameters for rendering the scalebar.
[ "Get", "the", "maximum", "width", "and", "height", "of", "the", "labels", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java#L207-L216
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java
ScalebarGraphic.createLabelText
@VisibleForTesting protected static String createLabelText( final DistanceUnit scaleUnit, final double value, final DistanceUnit intervalUnit) { double scaledValue = scaleUnit.convertTo(value, intervalUnit); // assume that there is no interval smaller then 0.0001 scaledValue = Math.round(scaledValue * 10000) / 10000; String decimals = Double.toString(scaledValue).split("\\.")[1]; if (Double.valueOf(decimals) == 0) { return Long.toString(Math.round(scaledValue)); } else { return Double.toString(scaledValue); } }
java
@VisibleForTesting protected static String createLabelText( final DistanceUnit scaleUnit, final double value, final DistanceUnit intervalUnit) { double scaledValue = scaleUnit.convertTo(value, intervalUnit); // assume that there is no interval smaller then 0.0001 scaledValue = Math.round(scaledValue * 10000) / 10000; String decimals = Double.toString(scaledValue).split("\\.")[1]; if (Double.valueOf(decimals) == 0) { return Long.toString(Math.round(scaledValue)); } else { return Double.toString(scaledValue); } }
[ "@", "VisibleForTesting", "protected", "static", "String", "createLabelText", "(", "final", "DistanceUnit", "scaleUnit", ",", "final", "double", "value", ",", "final", "DistanceUnit", "intervalUnit", ")", "{", "double", "scaledValue", "=", "scaleUnit", ".", "convert...
Format the label text. @param scaleUnit The unit used for the scalebar. @param value The scale value. @param intervalUnit The scaled unit for the intervals.
[ "Format", "the", "label", "text", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java#L225-L239
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java
ScalebarGraphic.getNearestNiceValue
@VisibleForTesting 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); // nearest power of 10 lower than value int digits = (int) Math.floor((Math.log(value * factor) / Math.log(10))); double pow10 = Math.pow(10, digits); // ok, find first character double firstChar = value * factor / pow10; // right, put it into the correct bracket int barLen; if (firstChar >= 10.0) { barLen = 10; } else if (firstChar >= 5.0) { barLen = 5; } else if (firstChar >= 2.0) { barLen = 2; } else { barLen = 1; } // scale it up the correct power of 10 return barLen * pow10 / factor; }
java
@VisibleForTesting 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); // nearest power of 10 lower than value int digits = (int) Math.floor((Math.log(value * factor) / Math.log(10))); double pow10 = Math.pow(10, digits); // ok, find first character double firstChar = value * factor / pow10; // right, put it into the correct bracket int barLen; if (firstChar >= 10.0) { barLen = 10; } else if (firstChar >= 5.0) { barLen = 5; } else if (firstChar >= 2.0) { barLen = 2; } else { barLen = 1; } // scale it up the correct power of 10 return barLen * pow10 / factor; }
[ "@", "VisibleForTesting", "protected", "static", "double", "getNearestNiceValue", "(", "final", "double", "value", ",", "final", "DistanceUnit", "scaleUnit", ",", "final", "boolean", "lockUnits", ")", "{", "DistanceUnit", "bestUnit", "=", "bestUnit", "(", "scaleUnit...
Reduce the given value to the nearest smaller 1 significant digit number starting with 1, 2 or 5. @param value the value to find a nice number for. @param scaleUnit the unit of the value. @param lockUnits if set, the values are not scaled to a "nicer" unit.
[ "Reduce", "the", "given", "value", "to", "the", "nearest", "smaller", "1", "significant", "digit", "number", "starting", "with", "1", "2", "or", "5", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java#L257-L284
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java
ScalebarGraphic.getBarSize
@VisibleForTesting 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 settings.getMaxSize().width / 4; } } }
java
@VisibleForTesting 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 settings.getMaxSize().width / 4; } } }
[ "@", "VisibleForTesting", "protected", "static", "int", "getBarSize", "(", "final", "ScaleBarRenderSettings", "settings", ")", "{", "if", "(", "settings", ".", "getParams", "(", ")", ".", "barSize", "!=", "null", ")", "{", "return", "settings", ".", "getParams...
Get the bar size. @param settings Parameters for rendering the scalebar.
[ "Get", "the", "bar", "size", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java#L333-L344
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java
ScalebarGraphic.getLabelDistance
@VisibleForTesting 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; } else { return settings.getMaxSize().height / 40; } } }
java
@VisibleForTesting 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; } else { return settings.getMaxSize().height / 40; } } }
[ "@", "VisibleForTesting", "protected", "static", "int", "getLabelDistance", "(", "final", "ScaleBarRenderSettings", "settings", ")", "{", "if", "(", "settings", ".", "getParams", "(", ")", ".", "labelDistance", "!=", "null", ")", "{", "return", "settings", ".", ...
Get the label distance.. @param settings Parameters for rendering the scalebar.
[ "Get", "the", "label", "distance", ".." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java#L351-L362
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java
ScalebarGraphic.render
public final URI render( final MapfishMapContext mapContext, final ScalebarAttributeValues scalebarParams, final File tempFolder, final Template template) throws IOException, ParserConfigurationException { final double dpi = mapContext.getDPI(); // get the map bounds final Rectangle paintArea = new Rectangle(mapContext.getMapSize()); MapBounds bounds = mapContext.getBounds(); final DistanceUnit mapUnit = getUnit(bounds); final Scale scale = bounds.getScale(paintArea, PDF_DPI); final double scaleDenominator = scale.getDenominator(scalebarParams.geodetic, bounds.getProjection(), dpi, bounds.getCenter()); DistanceUnit scaleUnit = scalebarParams.getUnit(); if (scaleUnit == null) { scaleUnit = mapUnit; } // adjust scalebar width and height to the DPI value final double maxLengthInPixel = (scalebarParams.getOrientation().isHorizontal()) ? scalebarParams.getSize().width : scalebarParams.getSize().height; final double maxIntervalLengthInWorldUnits = DistanceUnit.PX.convertTo(maxLengthInPixel, scaleUnit) * scaleDenominator / scalebarParams.intervals; final double niceIntervalLengthInWorldUnits = getNearestNiceValue(maxIntervalLengthInWorldUnits, scaleUnit, scalebarParams.lockUnits); final ScaleBarRenderSettings settings = new ScaleBarRenderSettings(); settings.setParams(scalebarParams); settings.setMaxSize(scalebarParams.getSize()); settings.setPadding(getPadding(settings)); // start the rendering File path = null; if (template.getConfiguration().renderAsSvg(scalebarParams.renderAsSvg)) { // render scalebar as SVG final SVGGraphics2D graphics2D = CreateMapProcessor.createSvgGraphics(scalebarParams.getSize()); try { tryLayout( graphics2D, scaleUnit, scaleDenominator, niceIntervalLengthInWorldUnits, settings, 0); path = File.createTempFile("scalebar-graphic-", ".svg", tempFolder); CreateMapProcessor.saveSvgFile(graphics2D, path); } finally { graphics2D.dispose(); } } else { // render scalebar as raster graphic double dpiRatio = mapContext.getDPI() / PDF_DPI; final BufferedImage bufferedImage = new BufferedImage( (int) Math.round(scalebarParams.getSize().width * dpiRatio), (int) Math.round(scalebarParams.getSize().height * dpiRatio), TYPE_4BYTE_ABGR); final Graphics2D graphics2D = bufferedImage.createGraphics(); try { AffineTransform saveAF = new AffineTransform(graphics2D.getTransform()); graphics2D.scale(dpiRatio, dpiRatio); tryLayout( graphics2D, scaleUnit, scaleDenominator, niceIntervalLengthInWorldUnits, settings, 0); graphics2D.setTransform(saveAF); path = File.createTempFile("scalebar-graphic-", ".png", tempFolder); ImageUtils.writeImage(bufferedImage, "png", path); } finally { graphics2D.dispose(); } } return path.toURI(); }
java
public final URI render( final MapfishMapContext mapContext, final ScalebarAttributeValues scalebarParams, final File tempFolder, final Template template) throws IOException, ParserConfigurationException { final double dpi = mapContext.getDPI(); // get the map bounds final Rectangle paintArea = new Rectangle(mapContext.getMapSize()); MapBounds bounds = mapContext.getBounds(); final DistanceUnit mapUnit = getUnit(bounds); final Scale scale = bounds.getScale(paintArea, PDF_DPI); final double scaleDenominator = scale.getDenominator(scalebarParams.geodetic, bounds.getProjection(), dpi, bounds.getCenter()); DistanceUnit scaleUnit = scalebarParams.getUnit(); if (scaleUnit == null) { scaleUnit = mapUnit; } // adjust scalebar width and height to the DPI value final double maxLengthInPixel = (scalebarParams.getOrientation().isHorizontal()) ? scalebarParams.getSize().width : scalebarParams.getSize().height; final double maxIntervalLengthInWorldUnits = DistanceUnit.PX.convertTo(maxLengthInPixel, scaleUnit) * scaleDenominator / scalebarParams.intervals; final double niceIntervalLengthInWorldUnits = getNearestNiceValue(maxIntervalLengthInWorldUnits, scaleUnit, scalebarParams.lockUnits); final ScaleBarRenderSettings settings = new ScaleBarRenderSettings(); settings.setParams(scalebarParams); settings.setMaxSize(scalebarParams.getSize()); settings.setPadding(getPadding(settings)); // start the rendering File path = null; if (template.getConfiguration().renderAsSvg(scalebarParams.renderAsSvg)) { // render scalebar as SVG final SVGGraphics2D graphics2D = CreateMapProcessor.createSvgGraphics(scalebarParams.getSize()); try { tryLayout( graphics2D, scaleUnit, scaleDenominator, niceIntervalLengthInWorldUnits, settings, 0); path = File.createTempFile("scalebar-graphic-", ".svg", tempFolder); CreateMapProcessor.saveSvgFile(graphics2D, path); } finally { graphics2D.dispose(); } } else { // render scalebar as raster graphic double dpiRatio = mapContext.getDPI() / PDF_DPI; final BufferedImage bufferedImage = new BufferedImage( (int) Math.round(scalebarParams.getSize().width * dpiRatio), (int) Math.round(scalebarParams.getSize().height * dpiRatio), TYPE_4BYTE_ABGR); final Graphics2D graphics2D = bufferedImage.createGraphics(); try { AffineTransform saveAF = new AffineTransform(graphics2D.getTransform()); graphics2D.scale(dpiRatio, dpiRatio); tryLayout( graphics2D, scaleUnit, scaleDenominator, niceIntervalLengthInWorldUnits, settings, 0); graphics2D.setTransform(saveAF); path = File.createTempFile("scalebar-graphic-", ".png", tempFolder); ImageUtils.writeImage(bufferedImage, "png", path); } finally { graphics2D.dispose(); } } return path.toURI(); }
[ "public", "final", "URI", "render", "(", "final", "MapfishMapContext", "mapContext", ",", "final", "ScalebarAttributeValues", "scalebarParams", ",", "final", "File", "tempFolder", ",", "final", "Template", "template", ")", "throws", "IOException", ",", "ParserConfigur...
Render the scalebar. @param mapContext The context of the map for which the scalebar is created. @param scalebarParams The scalebar parameters. @param tempFolder The directory in which the graphic file is created. @param template The template that containts the scalebar processor
[ "Render", "the", "scalebar", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarGraphic.java#L384-L461
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/MapPrinter.java
MapPrinter.parseSpec
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"); }
java
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"); }
[ "public", "static", "PJsonObject", "parseSpec", "(", "final", "String", "spec", ")", "{", "final", "JSONObject", "jsonSpec", ";", "try", "{", "jsonSpec", "=", "new", "JSONObject", "(", "spec", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", ...
Parse the JSON string and return the object. The string is expected to be the JSON print data from the client. @param spec the JSON formatted string. @return The encapsulated JSON object
[ "Parse", "the", "JSON", "string", "and", "return", "the", "object", ".", "The", "string", "is", "expected", "to", "be", "the", "JSON", "print", "data", "from", "the", "client", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/MapPrinter.java#L54-L62
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/MapPrinter.java
MapPrinter.getOutputFormat
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 beanName = format + (mapExport ? MAP_OUTPUT_FORMAT_BEAN_NAME_ENDING : OUTPUT_FORMAT_BEAN_NAME_ENDING); if (!this.outputFormat.containsKey(beanName)) { throw new RuntimeException("Format '" + format + "' with mapExport '" + mapExport + "' is not supported."); } return this.outputFormat.get(beanName); }
java
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 beanName = format + (mapExport ? MAP_OUTPUT_FORMAT_BEAN_NAME_ENDING : OUTPUT_FORMAT_BEAN_NAME_ENDING); if (!this.outputFormat.containsKey(beanName)) { throw new RuntimeException("Format '" + format + "' with mapExport '" + mapExport + "' is not supported."); } return this.outputFormat.get(beanName); }
[ "public", "final", "OutputFormat", "getOutputFormat", "(", "final", "PJsonObject", "specJson", ")", "{", "final", "String", "format", "=", "specJson", ".", "getString", "(", "MapPrinterServlet", ".", "JSON_OUTPUT_FORMAT", ")", ";", "final", "boolean", "mapExport", ...
Get the object responsible for printing to the correct output format. @param specJson the request json from the client
[ "Get", "the", "object", "responsible", "for", "printing", "to", "the", "correct", "output", "format", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/MapPrinter.java#L104-L117
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/MapPrinter.java
MapPrinter.print
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, specJson, getConfiguration(), this.configFile.getParentFile(), taskDirectory, out); } finally { this.workingDirectories.removeDirectory(taskDirectory); } }
java
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, specJson, getConfiguration(), this.configFile.getParentFile(), taskDirectory, out); } finally { this.workingDirectories.removeDirectory(taskDirectory); } }
[ "public", "final", "Processor", ".", "ExecutionContext", "print", "(", "final", "String", "jobId", ",", "final", "PJsonObject", "specJson", ",", "final", "OutputStream", "out", ")", "throws", "Exception", "{", "final", "OutputFormat", "format", "=", "getOutputForm...
Start a print. @param jobId the job ID @param specJson the client json request. @param out the stream to write to.
[ "Start", "a", "print", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/MapPrinter.java#L126-L138
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/MapPrinter.java
MapPrinter.getOutputFormatsNames
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.indexOf(OUTPUT_FORMAT_BEAN_NAME_ENDING); } formats.add(formatBeanName.substring(0, endingIndex)); } return formats; }
java
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.indexOf(OUTPUT_FORMAT_BEAN_NAME_ENDING); } formats.add(formatBeanName.substring(0, endingIndex)); } return formats; }
[ "public", "final", "Set", "<", "String", ">", "getOutputFormatsNames", "(", ")", "{", "SortedSet", "<", "String", ">", "formats", "=", "new", "TreeSet", "<>", "(", ")", ";", "for", "(", "String", "formatBeanName", ":", "this", ".", "outputFormat", ".", "...
Return the available format ids.
[ "Return", "the", "available", "format", "ids", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/MapPrinter.java#L143-L153
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/MapBounds.java
MapBounds.getNearestScale
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 (geodetic) { final double currentScaleDenominator = scale.getGeodeticDenominator( getProjection(), dpi, getCenter()); scaleRatio = scale.getDenominator(dpi) / currentScaleDenominator; correctedScale = scale.toResolution(scale.getResolution() / scaleRatio); } else { scaleRatio = 1; correctedScale = scale; } DistanceUnit unit = DistanceUnit.fromProjection(getProjection()); final ZoomLevelSnapStrategy.SearchResult result = zoomLevelSnapStrategy.search( correctedScale, tolerance, zoomLevels); final Scale newScale; if (geodetic) { newScale = new Scale( result.getScale(unit).getDenominator(PDF_DPI) * scaleRatio, getProjection(), dpi); } else { newScale = result.getScale(unit); } return newScale; }
java
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 (geodetic) { final double currentScaleDenominator = scale.getGeodeticDenominator( getProjection(), dpi, getCenter()); scaleRatio = scale.getDenominator(dpi) / currentScaleDenominator; correctedScale = scale.toResolution(scale.getResolution() / scaleRatio); } else { scaleRatio = 1; correctedScale = scale; } DistanceUnit unit = DistanceUnit.fromProjection(getProjection()); final ZoomLevelSnapStrategy.SearchResult result = zoomLevelSnapStrategy.search( correctedScale, tolerance, zoomLevels); final Scale newScale; if (geodetic) { newScale = new Scale( result.getScale(unit).getDenominator(PDF_DPI) * scaleRatio, getProjection(), dpi); } else { newScale = result.getScale(unit); } return newScale; }
[ "public", "Scale", "getNearestScale", "(", "final", "ZoomLevels", "zoomLevels", ",", "final", "double", "tolerance", ",", "final", "ZoomLevelSnapStrategy", "zoomLevelSnapStrategy", ",", "final", "boolean", "geodetic", ",", "final", "Rectangle", "paintArea", ",", "fina...
Get the nearest scale. @param zoomLevels the list of Zoom Levels. @param tolerance the tolerance to use when considering if two values are equal. For example if 12.0 == 12.001. The tolerance is a percentage. @param zoomLevelSnapStrategy the strategy to use for snapping to the nearest zoom level. @param geodetic snap to geodetic scales. @param paintArea the paint area of the map. @param dpi the DPI.
[ "Get", "the", "nearest", "scale", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/MapBounds.java#L87-L122
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/HibernateJobQueue.java
HibernateJobQueue.init
@PostConstruct 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.cleanupInterval, this.cleanupInterval, TimeUnit.SECONDS); }
java
@PostConstruct 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.cleanupInterval, this.cleanupInterval, TimeUnit.SECONDS); }
[ "@", "PostConstruct", "public", "final", "void", "init", "(", ")", "{", "this", ".", "cleanUpTimer", "=", "Executors", ".", "newScheduledThreadPool", "(", "1", ",", "timerTask", "->", "{", "final", "Thread", "thread", "=", "new", "Thread", "(", "timerTask", ...
Called by spring on initialization.
[ "Called", "by", "spring", "on", "initialization", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/HibernateJobQueue.java#L200-L209
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/parser/ParserUtils.java
ParserUtils.getAllAttributes
public static Collection<Field> getAllAttributes(final Class<?> classToInspect) { Set<Field> allFields = new HashSet<>(); getAllAttributes(classToInspect, allFields, Function.identity(), field -> true); return allFields; }
java
public static Collection<Field> getAllAttributes(final Class<?> classToInspect) { Set<Field> allFields = new HashSet<>(); getAllAttributes(classToInspect, allFields, Function.identity(), field -> true); return allFields; }
[ "public", "static", "Collection", "<", "Field", ">", "getAllAttributes", "(", "final", "Class", "<", "?", ">", "classToInspect", ")", "{", "Set", "<", "Field", ">", "allFields", "=", "new", "HashSet", "<>", "(", ")", ";", "getAllAttributes", "(", "classToI...
Inspects the object and all superclasses for public, non-final, accessible methods and returns a collection containing all the attributes found. @param classToInspect the class under inspection.
[ "Inspects", "the", "object", "and", "all", "superclasses", "for", "public", "non", "-", "final", "accessible", "methods", "and", "returns", "a", "collection", "containing", "all", "the", "attributes", "found", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/parser/ParserUtils.java#L56-L60
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/parser/ParserUtils.java
ParserUtils.getAttributes
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; }
java
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; }
[ "public", "static", "Collection", "<", "Field", ">", "getAttributes", "(", "final", "Class", "<", "?", ">", "classToInspect", ",", "final", "Predicate", "<", "Field", ">", "filter", ")", "{", "Set", "<", "Field", ">", "allFields", "=", "new", "HashSet", ...
Get a subset of the attributes of the provided class. An attribute is each public field in the class or super class. @param classToInspect the class to inspect @param filter a predicate that returns true when a attribute should be kept in resulting collection.
[ "Get", "a", "subset", "of", "the", "attributes", "of", "the", "provided", "class", ".", "An", "attribute", "is", "each", "public", "field", "in", "the", "class", "or", "super", "class", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/parser/ParserUtils.java#L70-L75
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/NorthArrowGraphic.java
NorthArrowGraphic.createRaster
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 BufferedImage(targetSize.width, targetSize.height, BufferedImage.TYPE_4BYTE_ABGR); final Graphics2D graphics2d = newImage.createGraphics(); try { final BufferedImage originalImage = ImageIO.read(rasterReference.inputStream); if (originalImage == null) { LOGGER.warn("Unable to load NorthArrow graphic: {}, it is not an image format that can be " + "decoded", rasterReference.uri); throw new IllegalArgumentException(); } // set background color graphics2d.setColor(backgroundColor); graphics2d.fillRect(0, 0, targetSize.width, targetSize.height); // scale the original image to fit the new size int newWidth; int newHeight; if (originalImage.getWidth() > originalImage.getHeight()) { newWidth = targetSize.width; newHeight = Math.min( targetSize.height, (int) Math.ceil(newWidth / (originalImage.getWidth() / (double) originalImage.getHeight()))); } else { newHeight = targetSize.height; newWidth = Math.min( targetSize.width, (int) Math.ceil(newHeight / (originalImage.getHeight() / (double) originalImage.getWidth()))); } // position the original image in the center of the new int deltaX = (int) Math.floor((targetSize.width - newWidth) / 2.0); int deltaY = (int) Math.floor((targetSize.height - newHeight) / 2.0); if (!FloatingPointUtil.equals(rotation, 0.0)) { final AffineTransform rotate = AffineTransform.getRotateInstance( rotation, targetSize.width / 2.0, targetSize.height / 2.0); graphics2d.setTransform(rotate); } graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); graphics2d.drawImage(originalImage, deltaX, deltaY, newWidth, newHeight, null); ImageUtils.writeImage(newImage, "png", path); } finally { graphics2d.dispose(); } return path.toURI(); }
java
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 BufferedImage(targetSize.width, targetSize.height, BufferedImage.TYPE_4BYTE_ABGR); final Graphics2D graphics2d = newImage.createGraphics(); try { final BufferedImage originalImage = ImageIO.read(rasterReference.inputStream); if (originalImage == null) { LOGGER.warn("Unable to load NorthArrow graphic: {}, it is not an image format that can be " + "decoded", rasterReference.uri); throw new IllegalArgumentException(); } // set background color graphics2d.setColor(backgroundColor); graphics2d.fillRect(0, 0, targetSize.width, targetSize.height); // scale the original image to fit the new size int newWidth; int newHeight; if (originalImage.getWidth() > originalImage.getHeight()) { newWidth = targetSize.width; newHeight = Math.min( targetSize.height, (int) Math.ceil(newWidth / (originalImage.getWidth() / (double) originalImage.getHeight()))); } else { newHeight = targetSize.height; newWidth = Math.min( targetSize.width, (int) Math.ceil(newHeight / (originalImage.getHeight() / (double) originalImage.getWidth()))); } // position the original image in the center of the new int deltaX = (int) Math.floor((targetSize.width - newWidth) / 2.0); int deltaY = (int) Math.floor((targetSize.height - newHeight) / 2.0); if (!FloatingPointUtil.equals(rotation, 0.0)) { final AffineTransform rotate = AffineTransform.getRotateInstance( rotation, targetSize.width / 2.0, targetSize.height / 2.0); graphics2d.setTransform(rotate); } graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); graphics2d.drawImage(originalImage, deltaX, deltaY, newWidth, newHeight, null); ImageUtils.writeImage(newImage, "png", path); } finally { graphics2d.dispose(); } return path.toURI(); }
[ "private", "static", "URI", "createRaster", "(", "final", "Dimension", "targetSize", ",", "final", "RasterReference", "rasterReference", ",", "final", "Double", "rotation", ",", "final", "Color", "backgroundColor", ",", "final", "File", "workingDir", ")", "throws", ...
Renders a given graphic into a new image, scaled to fit the new size and rotated.
[ "Renders", "a", "given", "graphic", "into", "a", "new", "image", "scaled", "to", "fit", "the", "new", "size", "and", "rotated", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/NorthArrowGraphic.java#L113-L171
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/NorthArrowGraphic.java
NorthArrowGraphic.createSvg
private static URI createSvg( final Dimension targetSize, final RasterReference rasterReference, final Double rotation, final Color backgroundColor, final File workingDir) throws IOException { // load SVG graphic final SVGElement svgRoot = parseSvg(rasterReference.inputStream); // create a new SVG graphic in which the existing graphic is embedded (scaled and rotated) DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); Document newDocument = impl.createDocument(SVG_NS, "svg", null); SVGElement newSvgRoot = (SVGElement) newDocument.getDocumentElement(); newSvgRoot.setAttributeNS(null, "width", Integer.toString(targetSize.width)); newSvgRoot.setAttributeNS(null, "height", Integer.toString(targetSize.height)); setSvgBackground(backgroundColor, targetSize, newDocument, newSvgRoot); embedSvgGraphic(svgRoot, newSvgRoot, newDocument, targetSize, rotation); File path = writeSvgToFile(newDocument, workingDir); return path.toURI(); }
java
private static URI createSvg( final Dimension targetSize, final RasterReference rasterReference, final Double rotation, final Color backgroundColor, final File workingDir) throws IOException { // load SVG graphic final SVGElement svgRoot = parseSvg(rasterReference.inputStream); // create a new SVG graphic in which the existing graphic is embedded (scaled and rotated) DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); Document newDocument = impl.createDocument(SVG_NS, "svg", null); SVGElement newSvgRoot = (SVGElement) newDocument.getDocumentElement(); newSvgRoot.setAttributeNS(null, "width", Integer.toString(targetSize.width)); newSvgRoot.setAttributeNS(null, "height", Integer.toString(targetSize.height)); setSvgBackground(backgroundColor, targetSize, newDocument, newSvgRoot); embedSvgGraphic(svgRoot, newSvgRoot, newDocument, targetSize, rotation); File path = writeSvgToFile(newDocument, workingDir); return path.toURI(); }
[ "private", "static", "URI", "createSvg", "(", "final", "Dimension", "targetSize", ",", "final", "RasterReference", "rasterReference", ",", "final", "Double", "rotation", ",", "final", "Color", "backgroundColor", ",", "final", "File", "workingDir", ")", "throws", "...
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.
[ "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",...
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/NorthArrowGraphic.java#L177-L197
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/NorthArrowGraphic.java
NorthArrowGraphic.embedSvgGraphic
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, "height"); /* * To scale the SVG graphic and to apply the rotation, we distinguish two * cases: width and height is set on the original SVG or not. * * Case 1: Width and height is set * If width and height is set, we wrap the original SVG into 2 new SVG elements * and a container element. * * Example: * Original SVG: * <svg width="100" height="100"></svg> * * New SVG (scaled to 300x300 and rotated by 90 degree): * <svg width="300" height="300"> * <g transform="rotate(90.0 150 150)"> * <svg width="100%" height="100%" viewBox="0 0 100 100"> * <svg width="100" height="100"></svg> * </svg> * </g> * </svg> * * The requested size is set on the outermost <svg>. Then, the rotation is applied to the * <g> container and the scaling is achieved with the viewBox parameter on the 2nd <svg>. * * * Case 2: Width and height is not set * In this case the original SVG is wrapped into just one container and one new SVG element. * The rotation is set on the container, and the scaling happens automatically. * * Example: * Original SVG: * <svg viewBox="0 0 61.06 91.83"></svg> * * New SVG (scaled to 300x300 and rotated by 90 degree): * <svg width="300" height="300"> * <g transform="rotate(90.0 150 150)"> * <svg viewBox="0 0 61.06 91.83"></svg> * </g> * </svg> */ if (!StringUtils.isEmpty(originalWidth) && !StringUtils.isEmpty(originalHeight)) { Element wrapperContainer = newDocument.createElementNS(SVG_NS, "g"); wrapperContainer.setAttributeNS( null, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, getRotateTransformation(targetSize, rotation)); newSvgRoot.appendChild(wrapperContainer); Element wrapperSvg = newDocument.createElementNS(SVG_NS, "svg"); wrapperSvg.setAttributeNS(null, "width", "100%"); wrapperSvg.setAttributeNS(null, "height", "100%"); wrapperSvg.setAttributeNS(null, "viewBox", "0 0 " + originalWidth + " " + originalHeight); wrapperContainer.appendChild(wrapperSvg); Node svgRootImported = newDocument.importNode(svgRoot, true); wrapperSvg.appendChild(svgRootImported); } else if (StringUtils.isEmpty(originalWidth) && StringUtils.isEmpty(originalHeight)) { Element wrapperContainer = newDocument.createElementNS(SVG_NS, "g"); wrapperContainer.setAttributeNS( null, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, getRotateTransformation(targetSize, rotation)); newSvgRoot.appendChild(wrapperContainer); Node svgRootImported = newDocument.importNode(svgRoot, true); wrapperContainer.appendChild(svgRootImported); } else { throw new IllegalArgumentException( "Unsupported or invalid north-arrow SVG graphic: The same unit (px, em, %, ...) must be" + " " + "used for `width` and `height`."); } }
java
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, "height"); /* * To scale the SVG graphic and to apply the rotation, we distinguish two * cases: width and height is set on the original SVG or not. * * Case 1: Width and height is set * If width and height is set, we wrap the original SVG into 2 new SVG elements * and a container element. * * Example: * Original SVG: * <svg width="100" height="100"></svg> * * New SVG (scaled to 300x300 and rotated by 90 degree): * <svg width="300" height="300"> * <g transform="rotate(90.0 150 150)"> * <svg width="100%" height="100%" viewBox="0 0 100 100"> * <svg width="100" height="100"></svg> * </svg> * </g> * </svg> * * The requested size is set on the outermost <svg>. Then, the rotation is applied to the * <g> container and the scaling is achieved with the viewBox parameter on the 2nd <svg>. * * * Case 2: Width and height is not set * In this case the original SVG is wrapped into just one container and one new SVG element. * The rotation is set on the container, and the scaling happens automatically. * * Example: * Original SVG: * <svg viewBox="0 0 61.06 91.83"></svg> * * New SVG (scaled to 300x300 and rotated by 90 degree): * <svg width="300" height="300"> * <g transform="rotate(90.0 150 150)"> * <svg viewBox="0 0 61.06 91.83"></svg> * </g> * </svg> */ if (!StringUtils.isEmpty(originalWidth) && !StringUtils.isEmpty(originalHeight)) { Element wrapperContainer = newDocument.createElementNS(SVG_NS, "g"); wrapperContainer.setAttributeNS( null, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, getRotateTransformation(targetSize, rotation)); newSvgRoot.appendChild(wrapperContainer); Element wrapperSvg = newDocument.createElementNS(SVG_NS, "svg"); wrapperSvg.setAttributeNS(null, "width", "100%"); wrapperSvg.setAttributeNS(null, "height", "100%"); wrapperSvg.setAttributeNS(null, "viewBox", "0 0 " + originalWidth + " " + originalHeight); wrapperContainer.appendChild(wrapperSvg); Node svgRootImported = newDocument.importNode(svgRoot, true); wrapperSvg.appendChild(svgRootImported); } else if (StringUtils.isEmpty(originalWidth) && StringUtils.isEmpty(originalHeight)) { Element wrapperContainer = newDocument.createElementNS(SVG_NS, "g"); wrapperContainer.setAttributeNS( null, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, getRotateTransformation(targetSize, rotation)); newSvgRoot.appendChild(wrapperContainer); Node svgRootImported = newDocument.importNode(svgRoot, true); wrapperContainer.appendChild(svgRootImported); } else { throw new IllegalArgumentException( "Unsupported or invalid north-arrow SVG graphic: The same unit (px, em, %, ...) must be" + " " + "used for `width` and `height`."); } }
[ "private", "static", "void", "embedSvgGraphic", "(", "final", "SVGElement", "svgRoot", ",", "final", "SVGElement", "newSvgRoot", ",", "final", "Document", "newDocument", ",", "final", "Dimension", "targetSize", ",", "final", "Double", "rotation", ")", "{", "final"...
Embeds the given SVG element into a new SVG element scaling the graphic to the given dimension and applying the given rotation.
[ "Embeds", "the", "given", "SVG", "element", "into", "a", "new", "SVG", "element", "scaling", "the", "graphic", "to", "the", "given", "dimension", "and", "applying", "the", "given", "rotation", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/NorthArrowGraphic.java#L218-L297
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/jasper/JasperReportBuilder.java
JasperReportBuilder.setDirectory
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 supposed to be relative to " + "configuration directory.", this.directory, directory)); } if (!this.directory.getAbsolutePath() .startsWith(this.configuration.getDirectory().getAbsolutePath())) { throw new IllegalArgumentException(String.format( "All files and directories must be contained in the configuration directory the " + "directory provided in the configuration breaks that contract: %s in config " + "file resolved to %s.", directory, this.directory)); } }
java
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 supposed to be relative to " + "configuration directory.", this.directory, directory)); } if (!this.directory.getAbsolutePath() .startsWith(this.configuration.getDirectory().getAbsolutePath())) { throw new IllegalArgumentException(String.format( "All files and directories must be contained in the configuration directory the " + "directory provided in the configuration breaks that contract: %s in config " + "file resolved to %s.", directory, this.directory)); } }
[ "public", "void", "setDirectory", "(", "final", "String", "directory", ")", "{", "this", ".", "directory", "=", "new", "File", "(", "this", ".", "configuration", ".", "getDirectory", "(", ")", ",", "directory", ")", ";", "if", "(", "!", "this", ".", "d...
Set the directory and test that the directory exists and is contained within the Configuration directory. @param directory the new directory
[ "Set", "the", "directory", "and", "test", "that", "the", "directory", "exists", "and", "is", "contained", "within", "the", "Configuration", "directory", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/jasper/JasperReportBuilder.java#L149-L167
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/CreateMapPagesProcessor.java
CreateMapPagesProcessor.setAttribute
public void setAttribute(final String name, final Attribute attribute) { if (name.equals(MAP_KEY)) { this.mapAttribute = (MapAttribute) attribute; } }
java
public void setAttribute(final String name, final Attribute attribute) { if (name.equals(MAP_KEY)) { this.mapAttribute = (MapAttribute) attribute; } }
[ "public", "void", "setAttribute", "(", "final", "String", "name", ",", "final", "Attribute", "attribute", ")", "{", "if", "(", "name", ".", "equals", "(", "MAP_KEY", ")", ")", "{", "this", ".", "mapAttribute", "=", "(", "MapAttribute", ")", "attribute", ...
Set the map attribute. @param name the attribute name @param attribute the attribute
[ "Set", "the", "map", "attribute", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/CreateMapPagesProcessor.java#L214-L218
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/CreateMapPagesProcessor.java
CreateMapPagesProcessor.getAttributes
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.setAttributes(dsResult); result.put("datasource", datasourceAttribute); return result; }
java
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.setAttributes(dsResult); result.put("datasource", datasourceAttribute); return result; }
[ "public", "Map", "<", "String", ",", "Attribute", ">", "getAttributes", "(", ")", "{", "Map", "<", "String", ",", "Attribute", ">", "result", "=", "new", "HashMap", "<>", "(", ")", ";", "DataSourceAttribute", "datasourceAttribute", "=", "new", "DataSourceAtt...
Gets the attributes provided by the processor. @return the attributes
[ "Gets", "the", "attributes", "provided", "by", "the", "processor", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/CreateMapPagesProcessor.java#L225-L233
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/Template.java
Template.printClientConfig
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(InternalAttribute.class) == null) { json.object(); attribute.printClientConfig(json, this); json.endObject(); } } json.endArray(); }
java
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(InternalAttribute.class) == null) { json.object(); attribute.printClientConfig(json, this); json.endObject(); } } json.endArray(); }
[ "public", "final", "void", "printClientConfig", "(", "final", "JSONWriter", "json", ")", "throws", "JSONException", "{", "json", ".", "key", "(", "\"attributes\"", ")", ";", "json", ".", "array", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "Stri...
Print out the template information that the client needs for performing a request. @param json the writer to write the information to.
[ "Print", "out", "the", "template", "information", "that", "the", "client", "needs", "for", "performing", "a", "request", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/Template.java#L115-L127
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/Template.java
Template.setAttributes
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 attribute. It is a: " + attribute; LOGGER.error("Error setting the Attributes: {}", msg); throw new IllegalArgumentException(msg); } else { ((Attribute) attribute).setConfigName(entry.getKey()); } } this.attributes = attributes; }
java
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 attribute. It is a: " + attribute; LOGGER.error("Error setting the Attributes: {}", msg); throw new IllegalArgumentException(msg); } else { ((Attribute) attribute).setConfigName(entry.getKey()); } } this.attributes = attributes; }
[ "public", "final", "void", "setAttributes", "(", "final", "Map", "<", "String", ",", "Attribute", ">", "attributes", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Attribute", ">", "entry", ":", "attributes", ".", "entrySet", "(", ")", ...
Set the attributes for this template. @param attributes the attribute map
[ "Set", "the", "attributes", "for", "this", "template", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/Template.java#L138-L151
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/Template.java
Template.getProcessorGraph
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()) { attcls.put(attribute.getKey(), attribute.getValue().getValueType()); } this.processorGraph = this.processorGraphFactory.build(this.processors, attcls); } } } return this.processorGraph; }
java
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()) { attcls.put(attribute.getKey(), attribute.getValue().getValueType()); } this.processorGraph = this.processorGraphFactory.build(this.processors, attcls); } } } return this.processorGraph; }
[ "public", "final", "ProcessorDependencyGraph", "getProcessorGraph", "(", ")", "{", "if", "(", "this", ".", "processorGraph", "==", "null", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "this", ".", "processorGraph", "==", "null", ")", "{", "f...
Get the processor graph to use for executing all the processors for the template. @return the processor graph.
[ "Get", "the", "processor", "graph", "to", "use", "for", "executing", "all", "the", "processors", "for", "the", "template", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/Template.java#L228-L241
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/Template.java
Template.getStyle
@SuppressWarnings("unchecked") @Nonnull 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(), this.httpRequestFactory, styleRef); } else { style = Optional.empty(); } return or(style, this.configuration.getStyle(styleName)); }
java
@SuppressWarnings("unchecked") @Nonnull 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(), this.httpRequestFactory, styleRef); } else { style = Optional.empty(); } return or(style, this.configuration.getStyle(styleName)); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Nonnull", "public", "final", "java", ".", "util", ".", "Optional", "<", "Style", ">", "getStyle", "(", "final", "String", "styleName", ")", "{", "final", "String", "styleRef", "=", "this", ".", "sty...
Look for a style in the named styles provided in the configuration. @param styleName the name of the style to look for.
[ "Look", "for", "a", "style", "in", "the", "named", "styles", "provided", "in", "the", "configuration", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/Template.java#L257-L269
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/metrics/JvmMetricsConfigurator.java
JvmMetricsConfigurator.init
@PostConstruct 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.register(name("fd-usage"), new FileDescriptorRatioGauge()); }
java
@PostConstruct 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.register(name("fd-usage"), new FileDescriptorRatioGauge()); }
[ "@", "PostConstruct", "public", "void", "init", "(", ")", "{", "this", ".", "metricRegistry", ".", "register", "(", "name", "(", "\"gc\"", ")", ",", "new", "GarbageCollectorMetricSet", "(", ")", ")", ";", "this", ".", "metricRegistry", ".", "register", "("...
Add several jvm metrics.
[ "Add", "several", "jvm", "metrics", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/metrics/JvmMetricsConfigurator.java#L23-L29
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/image/wms/WmsLayerParam.java
WmsLayerParam.postConstruct
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"); // OpenLayers 2 compatibility. It will post a single empty style no matter how many layers there are if (this.styles != null && this.styles.length != this.layers.length && this.styles.length == 1 && this.styles[0].trim().isEmpty()) { this.styles = null; } else { Assert.isTrue(this.styles == null || this.layers.length == this.styles.length, String.format( "If styles are defined then there must be one for each layer. Number of" + " layers: %s\nStyles: %s", this.layers.length, Arrays.toString(this.styles))); } if (this.imageFormat.indexOf('/') < 0) { LOGGER.warn("The format {} should be a mime type", this.imageFormat); this.imageFormat = "image/" + this.imageFormat; } Assert.isTrue(this.method == HttpMethod.GET || this.method == HttpMethod.POST, String.format("Unsupported method %s for WMS layer", this.method.toString())); }
java
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"); // OpenLayers 2 compatibility. It will post a single empty style no matter how many layers there are if (this.styles != null && this.styles.length != this.layers.length && this.styles.length == 1 && this.styles[0].trim().isEmpty()) { this.styles = null; } else { Assert.isTrue(this.styles == null || this.layers.length == this.styles.length, String.format( "If styles are defined then there must be one for each layer. Number of" + " layers: %s\nStyles: %s", this.layers.length, Arrays.toString(this.styles))); } if (this.imageFormat.indexOf('/') < 0) { LOGGER.warn("The format {} should be a mime type", this.imageFormat); this.imageFormat = "image/" + this.imageFormat; } Assert.isTrue(this.method == HttpMethod.GET || this.method == HttpMethod.POST, String.format("Unsupported method %s for WMS layer", this.method.toString())); }
[ "public", "void", "postConstruct", "(", ")", "throws", "URISyntaxException", "{", "WmsVersion", ".", "lookup", "(", "this", ".", "version", ")", ";", "Assert", ".", "isTrue", "(", "validateBaseUrl", "(", ")", ",", "\"invalid baseURL\"", ")", ";", "Assert", "...
Validate some of the properties of this layer.
[ "Validate", "some", "of", "the", "properties", "of", "this", "layer", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/image/wms/WmsLayerParam.java#L109-L136
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/tiled/TileCacheInformation.java
TileCacheInformation.createBufferedImage
@Nonnull public BufferedImage createBufferedImage(final int imageWidth, final int imageHeight) { return new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_4BYTE_ABGR); }
java
@Nonnull public BufferedImage createBufferedImage(final int imageWidth, final int imageHeight) { return new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_4BYTE_ABGR); }
[ "@", "Nonnull", "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. @param imageWidth width of the image to create @param imageHeight height of the image to create.
[ "Create", "a", "buffered", "image", "with", "the", "correct", "image", "bands", "etc", "...", "for", "the", "tiles", "being", "loaded", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/TileCacheInformation.java#L134-L137
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/PDFConfig.java
PDFConfig.setKeywords
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()); }
java
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()); }
[ "public", "void", "setKeywords", "(", "final", "List", "<", "String", ">", "keywords", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "keyword", ":", "keywords", ")", "{", "if", "(", "builder", "."...
The keywords to include in the PDF metadata. @param keywords the keywords of the PDF.
[ "The", "keywords", "to", "include", "in", "the", "PDF", "metadata", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/PDFConfig.java#L103-L112
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/S3ReportStorage.java
S3ReportStorage.getKey
protected String getKey(final String ref, final String filename, final String extension) { return prefix + ref + "/" + filename + "." + extension; }
java
protected String getKey(final String ref, final String filename, final String extension) { return prefix + ref + "/" + filename + "." + extension; }
[ "protected", "String", "getKey", "(", "final", "String", "ref", ",", "final", "String", "filename", ",", "final", "String", "extension", ")", "{", "return", "prefix", "+", "ref", "+", "\"/\"", "+", "filename", "+", "\".\"", "+", "extension", ";", "}" ]
Compute the key to use. @param ref The reference number. @param filename The filename. @param extension The file extension.
[ "Compute", "the", "key", "to", "use", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/S3ReportStorage.java#L125-L127
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/jasper/TableProcessor.java
TableProcessor.tryConvert
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.converters) { if (converter.canConvert(value)) { return converter.resolve(clientHttpRequestFactory, value); } } return rowValue; }
java
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.converters) { if (converter.canConvert(value)) { return converter.resolve(clientHttpRequestFactory, value); } } return rowValue; }
[ "private", "Object", "tryConvert", "(", "final", "MfClientHttpRequestFactory", "clientHttpRequestFactory", ",", "final", "Object", "rowValue", ")", "throws", "URISyntaxException", ",", "IOException", "{", "if", "(", "this", ".", "converters", ".", "isEmpty", "(", ")...
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.
[ "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...
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/jasper/TableProcessor.java#L308-L323
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
PJsonObject.optInt
@Override public final Integer optInt(final String key) { final int result = this.obj.optInt(key, Integer.MIN_VALUE); return result == Integer.MIN_VALUE ? null : result; }
java
@Override public final Integer optInt(final String key) { final int result = this.obj.optInt(key, Integer.MIN_VALUE); return result == Integer.MIN_VALUE ? null : result; }
[ "@", "Override", "public", "final", "Integer", "optInt", "(", "final", "String", "key", ")", "{", "final", "int", "result", "=", "this", ".", "obj", ".", "optInt", "(", "key", ",", "Integer", ".", "MIN_VALUE", ")", ";", "return", "result", "==", "Integ...
Get a property as a int or null. @param key the property name
[ "Get", "a", "property", "as", "a", "int", "or", "null", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L61-L65
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
PJsonObject.optDouble
@Override public final Double optDouble(final String key) { double result = this.obj.optDouble(key, Double.NaN); if (Double.isNaN(result)) { return null; } return result; }
java
@Override public final Double optDouble(final String key) { double result = this.obj.optDouble(key, Double.NaN); if (Double.isNaN(result)) { return null; } return result; }
[ "@", "Override", "public", "final", "Double", "optDouble", "(", "final", "String", "key", ")", "{", "double", "result", "=", "this", ".", "obj", ".", "optDouble", "(", "key", ",", "Double", ".", "NaN", ")", ";", "if", "(", "Double", ".", "isNaN", "("...
Get a property as a double or null. @param key the property name
[ "Get", "a", "property", "as", "a", "double", "or", "null", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L78-L85
train