id
int32 0
165k
| 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
|
---|---|---|---|---|---|---|---|---|---|---|---|
159,400 |
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",
"=",
"this",
".",
"polygon",
";",
"aoi",
".",
"style",
"=",
"this",
".",
"style",
";",
"aoi",
".",
"renderAsSvg",
"=",
"this",
".",
"renderAsSvg",
";",
"return",
"aoi",
";",
"}"
] |
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
|
159,401 |
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",
">",
"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",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
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
|
159,402 |
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",
"(",
")",
")",
"{",
"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",
")",
";",
"}"
] |
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
|
159,403 |
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",
".",
"getLogger",
"(",
"Logger",
".",
"ROOT_LOGGER_NAME",
")",
";",
"final",
"InstrumentedAppender",
"metrics",
"=",
"new",
"InstrumentedAppender",
"(",
"this",
".",
"metricRegistry",
")",
";",
"metrics",
".",
"setContext",
"(",
"root",
".",
"getLoggerContext",
"(",
")",
")",
";",
"metrics",
".",
"start",
"(",
")",
";",
"root",
".",
"addAppender",
"(",
"metrics",
")",
";",
"}"
] |
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
|
159,404 |
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",
"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",
")",
";",
"}"
] |
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
|
159,405 |
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",
">",
"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",
"(",
")",
";",
"}"
] |
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
|
159,406 |
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",
".",
"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",
";",
"}"
] |
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
|
159,407 |
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",
"(",
")",
")",
";",
"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",
";",
"}"
] |
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
|
159,408 |
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",
"(",
"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",
"(",
")",
")",
";",
"}",
"}"
] |
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
|
159,409 |
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",
",",
"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",
";",
"}"
] |
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
|
159,410 |
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",
")",
";",
"node",
".",
"addRequirement",
"(",
"this",
")",
";",
"}"
] |
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
|
159,411 |
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",
"(",
"outputMapper",
"==",
"null",
")",
"{",
"return",
"HashBiMap",
".",
"create",
"(",
")",
";",
"}",
"return",
"outputMapper",
";",
"}"
] |
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
|
159,412 |
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",
"(",
"inputMapper",
"==",
"null",
")",
"{",
"return",
"HashBiMap",
".",
"create",
"(",
")",
";",
"}",
"return",
"inputMapper",
";",
"}"
] |
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
|
159,413 |
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",
"<>",
"(",
")",
";",
"all",
".",
"put",
"(",
"this",
".",
"getProcessor",
"(",
")",
",",
"null",
")",
";",
"for",
"(",
"ProcessorGraphNode",
"<",
"?",
",",
"?",
">",
"dependency",
":",
"this",
".",
"dependencies",
")",
"{",
"for",
"(",
"Processor",
"<",
"?",
",",
"?",
">",
"p",
":",
"dependency",
".",
"getAllProcessors",
"(",
")",
")",
"{",
"all",
".",
"put",
"(",
"p",
",",
"null",
")",
";",
"}",
"}",
"return",
"all",
".",
"keySet",
"(",
")",
";",
"}"
] |
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
|
159,414 |
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",
".",
"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",
"+",
"\"}\"",
";",
"}",
"}",
"}"
] |
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
|
159,415 |
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\"",
")",
";",
"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",
")",
";",
"}",
"}"
] |
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
|
159,416 |
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",
"(",
"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",
")",
";",
"}",
"}"
] |
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
|
159,417 |
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",
"(",
")",
"!=",
"null",
"&&",
"!",
"httpServletRequest",
".",
"getContextPath",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"baseURL",
".",
"append",
"(",
"httpServletRequest",
".",
"getContextPath",
"(",
")",
")",
";",
"}",
"if",
"(",
"httpServletRequest",
".",
"getServletPath",
"(",
")",
"!=",
"null",
"&&",
"!",
"httpServletRequest",
".",
"getServletPath",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"baseURL",
".",
"append",
"(",
"httpServletRequest",
".",
"getServletPath",
"(",
")",
")",
";",
"}",
"return",
"baseURL",
";",
"}"
] |
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
|
159,418 |
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",
";",
"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",
")",
")",
";",
"}"
] |
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
|
159,419 |
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",
"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",
")",
")",
";",
"}"
] |
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
|
159,420 |
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",
".",
"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",
")",
";",
"}",
"}"
] |
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
|
159,421 |
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",
",",
"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",
";",
"}"
] |
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
|
159,422 |
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",
"(",
")",
".",
"barSize",
";",
"}",
"else",
"{",
"if",
"(",
"settings",
".",
"getParams",
"(",
")",
".",
"getOrientation",
"(",
")",
".",
"isHorizontal",
"(",
")",
")",
"{",
"return",
"settings",
".",
"getMaxSize",
"(",
")",
".",
"height",
"/",
"4",
";",
"}",
"else",
"{",
"return",
"settings",
".",
"getMaxSize",
"(",
")",
".",
"width",
"/",
"4",
";",
"}",
"}",
"}"
] |
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
|
159,423 |
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",
".",
"getParams",
"(",
")",
".",
"labelDistance",
";",
"}",
"else",
"{",
"if",
"(",
"settings",
".",
"getParams",
"(",
")",
".",
"getOrientation",
"(",
")",
".",
"isHorizontal",
"(",
")",
")",
"{",
"return",
"settings",
".",
"getMaxSize",
"(",
")",
".",
"width",
"/",
"40",
";",
"}",
"else",
"{",
"return",
"settings",
".",
"getMaxSize",
"(",
")",
".",
"height",
"/",
"40",
";",
"}",
"}",
"}"
] |
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
|
159,424 |
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",
",",
"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",
"(",
")",
";",
"}"
] |
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
|
159,425 |
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",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Cannot parse the spec file: \"",
"+",
"spec",
",",
"e",
")",
";",
"}",
"return",
"new",
"PJsonObject",
"(",
"jsonSpec",
",",
"\"spec\"",
")",
";",
"}"
] |
Parse the JSON string and return the object. The string is expected to be the JSON print data from the
client.
@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
|
159,426 |
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",
"=",
"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",
")",
";",
"}"
] |
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
|
159,427 |
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",
"=",
"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",
")",
";",
"}",
"}"
] |
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
|
159,428 |
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",
".",
"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",
";",
"}"
] |
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
|
159,429 |
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",
",",
"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",
";",
"}"
] |
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
|
159,430 |
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",
",",
"\"Clean up old job records\"",
")",
";",
"thread",
".",
"setDaemon",
"(",
"true",
")",
";",
"return",
"thread",
";",
"}",
")",
";",
"this",
".",
"cleanUpTimer",
".",
"scheduleAtFixedRate",
"(",
"this",
"::",
"cleanup",
",",
"this",
".",
"cleanupInterval",
",",
"this",
".",
"cleanupInterval",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}"
] |
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
|
159,431 |
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",
"(",
"classToInspect",
",",
"allFields",
",",
"Function",
".",
"identity",
"(",
")",
",",
"field",
"->",
"true",
")",
";",
"return",
"allFields",
";",
"}"
] |
Inspects the object and all superclasses for public, non-final, accessible methods and returns a
collection containing all the attributes found.
@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
|
159,432 |
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",
"<>",
"(",
")",
";",
"getAllAttributes",
"(",
"classToInspect",
",",
"allFields",
",",
"Function",
".",
"identity",
"(",
")",
",",
"filter",
")",
";",
"return",
"allFields",
";",
"}"
] |
Get a subset of the attributes of the provided class. An attribute is each public field in the class
or super class.
@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
|
159,433 |
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",
"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",
"(",
")",
";",
"}"
] |
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
|
159,434 |
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",
"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",
"(",
")",
";",
"}"
] |
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",
"XML",
"and",
"doing",
"the",
"modifications",
"by",
"hand",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/NorthArrowGraphic.java#L177-L197
|
159,435 |
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",
"String",
"originalWidth",
"=",
"svgRoot",
".",
"getAttributeNS",
"(",
"null",
",",
"\"width\"",
")",
";",
"final",
"String",
"originalHeight",
"=",
"svgRoot",
".",
"getAttributeNS",
"(",
"null",
",",
"\"height\"",
")",
";",
"/*\n * To scale the SVG graphic and to apply the rotation, we distinguish two\n * cases: width and height is set on the original SVG or not.\n *\n * Case 1: Width and height is set\n * If width and height is set, we wrap the original SVG into 2 new SVG elements\n * and a container element.\n *\n * Example:\n * Original SVG:\n * <svg width=\"100\" height=\"100\"></svg>\n *\n * New SVG (scaled to 300x300 and rotated by 90 degree):\n * <svg width=\"300\" height=\"300\">\n * <g transform=\"rotate(90.0 150 150)\">\n * <svg width=\"100%\" height=\"100%\" viewBox=\"0 0 100 100\">\n * <svg width=\"100\" height=\"100\"></svg>\n * </svg>\n * </g>\n * </svg>\n *\n * The requested size is set on the outermost <svg>. Then, the rotation is applied to the\n * <g> container and the scaling is achieved with the viewBox parameter on the 2nd <svg>.\n *\n *\n * Case 2: Width and height is not set\n * In this case the original SVG is wrapped into just one container and one new SVG element.\n * The rotation is set on the container, and the scaling happens automatically.\n *\n * Example:\n * Original SVG:\n * <svg viewBox=\"0 0 61.06 91.83\"></svg>\n *\n * New SVG (scaled to 300x300 and rotated by 90 degree):\n * <svg width=\"300\" height=\"300\">\n * <g transform=\"rotate(90.0 150 150)\">\n * <svg viewBox=\"0 0 61.06 91.83\"></svg>\n * </g>\n * </svg>\n */",
"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`.\"",
")",
";",
"}",
"}"
] |
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
|
159,436 |
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",
".",
"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",
")",
")",
";",
"}",
"}"
] |
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
|
159,437 |
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
|
159,438 |
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",
"DataSourceAttribute",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Attribute",
">",
"dsResult",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"dsResult",
".",
"put",
"(",
"MAP_KEY",
",",
"this",
".",
"mapAttribute",
")",
";",
"datasourceAttribute",
".",
"setAttributes",
"(",
"dsResult",
")",
";",
"result",
".",
"put",
"(",
"\"datasource\"",
",",
"datasourceAttribute",
")",
";",
"return",
"result",
";",
"}"
] |
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
|
159,439 |
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",
"<",
"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",
"(",
")",
";",
"}"
] |
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
|
159,440 |
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",
"(",
")",
")",
"{",
"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",
";",
"}"
] |
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
|
159,441 |
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",
")",
"{",
"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",
";",
"}"
] |
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
|
159,442 |
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",
".",
"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",
")",
")",
";",
"}"
] |
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
|
159,443 |
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",
"(",
"name",
"(",
"\"memory\"",
")",
",",
"new",
"MemoryUsageGaugeSet",
"(",
")",
")",
";",
"this",
".",
"metricRegistry",
".",
"register",
"(",
"name",
"(",
"\"thread-states\"",
")",
",",
"new",
"ThreadStatesGaugeSet",
"(",
")",
")",
";",
"this",
".",
"metricRegistry",
".",
"register",
"(",
"name",
"(",
"\"fd-usage\"",
")",
",",
"new",
"FileDescriptorRatioGauge",
"(",
")",
")",
";",
"}"
] |
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
|
159,444 |
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",
".",
"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",
"(",
")",
")",
")",
";",
"}"
] |
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
|
159,445 |
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
|
159,446 |
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",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"builder",
".",
"append",
"(",
"keyword",
".",
"trim",
"(",
")",
")",
";",
"}",
"this",
".",
"keywords",
"=",
"Optional",
".",
"of",
"(",
"builder",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
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
|
159,447 |
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
|
159,448 |
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",
"(",
")",
")",
"{",
"return",
"rowValue",
";",
"}",
"String",
"value",
"=",
"String",
".",
"valueOf",
"(",
"rowValue",
")",
";",
"for",
"(",
"TableColumnConverter",
"<",
"?",
">",
"converter",
":",
"this",
".",
"converters",
")",
"{",
"if",
"(",
"converter",
".",
"canConvert",
"(",
"value",
")",
")",
"{",
"return",
"converter",
".",
"resolve",
"(",
"clientHttpRequestFactory",
",",
"value",
")",
";",
"}",
"}",
"return",
"rowValue",
";",
"}"
] |
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",
"the",
"conversion",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/jasper/TableProcessor.java#L308-L323
|
159,449 |
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",
"==",
"Integer",
".",
"MIN_VALUE",
"?",
"null",
":",
"result",
";",
"}"
] |
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
|
159,450 |
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",
"(",
"result",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"result",
";",
"}"
] |
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
|
159,451 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
|
PJsonObject.optBool
|
@Override
public final Boolean optBool(final String key) {
if (this.obj.optString(key, null) == null) {
return null;
} else {
return this.obj.optBoolean(key);
}
}
|
java
|
@Override
public final Boolean optBool(final String key) {
if (this.obj.optString(key, null) == null) {
return null;
} else {
return this.obj.optBoolean(key);
}
}
|
[
"@",
"Override",
"public",
"final",
"Boolean",
"optBool",
"(",
"final",
"String",
"key",
")",
"{",
"if",
"(",
"this",
".",
"obj",
".",
"optString",
"(",
"key",
",",
"null",
")",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"this",
".",
"obj",
".",
"optBoolean",
"(",
"key",
")",
";",
"}",
"}"
] |
Get a property as a boolean or null.
@param key the property name
|
[
"Get",
"a",
"property",
"as",
"a",
"boolean",
"or",
"null",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L106-L113
|
159,452 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
|
PJsonObject.optJSONObject
|
public final PJsonObject optJSONObject(final String key) {
final JSONObject val = this.obj.optJSONObject(key);
return val != null ? new PJsonObject(this, val, key) : null;
}
|
java
|
public final PJsonObject optJSONObject(final String key) {
final JSONObject val = this.obj.optJSONObject(key);
return val != null ? new PJsonObject(this, val, key) : null;
}
|
[
"public",
"final",
"PJsonObject",
"optJSONObject",
"(",
"final",
"String",
"key",
")",
"{",
"final",
"JSONObject",
"val",
"=",
"this",
".",
"obj",
".",
"optJSONObject",
"(",
"key",
")",
";",
"return",
"val",
"!=",
"null",
"?",
"new",
"PJsonObject",
"(",
"this",
",",
"val",
",",
"key",
")",
":",
"null",
";",
"}"
] |
Get a property as a json object or null.
@param key the property name
|
[
"Get",
"a",
"property",
"as",
"a",
"json",
"object",
"or",
"null",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L145-L148
|
159,453 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
|
PJsonObject.getJSONArray
|
public final PJsonArray getJSONArray(final String key) {
final JSONArray val = this.obj.optJSONArray(key);
if (val == null) {
throw new ObjectMissingException(this, key);
}
return new PJsonArray(this, val, key);
}
|
java
|
public final PJsonArray getJSONArray(final String key) {
final JSONArray val = this.obj.optJSONArray(key);
if (val == null) {
throw new ObjectMissingException(this, key);
}
return new PJsonArray(this, val, key);
}
|
[
"public",
"final",
"PJsonArray",
"getJSONArray",
"(",
"final",
"String",
"key",
")",
"{",
"final",
"JSONArray",
"val",
"=",
"this",
".",
"obj",
".",
"optJSONArray",
"(",
"key",
")",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"throw",
"new",
"ObjectMissingException",
"(",
"this",
",",
"key",
")",
";",
"}",
"return",
"new",
"PJsonArray",
"(",
"this",
",",
"val",
",",
"key",
")",
";",
"}"
] |
Get a property as a json array or throw exception.
@param key the property name
|
[
"Get",
"a",
"property",
"as",
"a",
"json",
"array",
"or",
"throw",
"exception",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L168-L174
|
159,454 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
|
PJsonObject.optJSONArray
|
public final PJsonArray optJSONArray(final String key, final PJsonArray defaultValue) {
PJsonArray result = optJSONArray(key);
return result != null ? result : defaultValue;
}
|
java
|
public final PJsonArray optJSONArray(final String key, final PJsonArray defaultValue) {
PJsonArray result = optJSONArray(key);
return result != null ? result : defaultValue;
}
|
[
"public",
"final",
"PJsonArray",
"optJSONArray",
"(",
"final",
"String",
"key",
",",
"final",
"PJsonArray",
"defaultValue",
")",
"{",
"PJsonArray",
"result",
"=",
"optJSONArray",
"(",
"key",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"result",
":",
"defaultValue",
";",
"}"
] |
Get a property as a json array or default.
@param key the property name
@param defaultValue default
|
[
"Get",
"a",
"property",
"as",
"a",
"json",
"array",
"or",
"default",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L195-L198
|
159,455 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
|
PJsonObject.has
|
@Override
public final boolean has(final String key) {
String result = this.obj.optString(key, null);
return result != null;
}
|
java
|
@Override
public final boolean has(final String key) {
String result = this.obj.optString(key, null);
return result != null;
}
|
[
"@",
"Override",
"public",
"final",
"boolean",
"has",
"(",
"final",
"String",
"key",
")",
"{",
"String",
"result",
"=",
"this",
".",
"obj",
".",
"optString",
"(",
"key",
",",
"null",
")",
";",
"return",
"result",
"!=",
"null",
";",
"}"
] |
Check if the object has a property with the key.
@param key key to check for.
|
[
"Check",
"if",
"the",
"object",
"has",
"a",
"property",
"with",
"the",
"key",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L266-L270
|
159,456 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/jasper/DataSourceProcessor.java
|
DataSourceProcessor.setAttributes
|
public void setAttributes(final Map<String, Attribute> attributes) {
this.internalAttributes = attributes;
this.allAttributes.putAll(attributes);
}
|
java
|
public void setAttributes(final Map<String, Attribute> attributes) {
this.internalAttributes = attributes;
this.allAttributes.putAll(attributes);
}
|
[
"public",
"void",
"setAttributes",
"(",
"final",
"Map",
"<",
"String",
",",
"Attribute",
">",
"attributes",
")",
"{",
"this",
".",
"internalAttributes",
"=",
"attributes",
";",
"this",
".",
"allAttributes",
".",
"putAll",
"(",
"attributes",
")",
";",
"}"
] |
All the attributes needed either by the processors for each datasource row or by the jasper template.
@param attributes the attributes.
|
[
"All",
"the",
"attributes",
"needed",
"either",
"by",
"the",
"processors",
"for",
"each",
"datasource",
"row",
"or",
"by",
"the",
"jasper",
"template",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/jasper/DataSourceProcessor.java#L153-L156
|
159,457 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/jasper/DataSourceProcessor.java
|
DataSourceProcessor.setAttribute
|
public void setAttribute(final String name, final Attribute attribute) {
if (name.equals("datasource")) {
this.allAttributes.putAll(((DataSourceAttribute) attribute).getAttributes());
} else if (this.copyAttributes.contains(name)) {
this.allAttributes.put(name, attribute);
}
}
|
java
|
public void setAttribute(final String name, final Attribute attribute) {
if (name.equals("datasource")) {
this.allAttributes.putAll(((DataSourceAttribute) attribute).getAttributes());
} else if (this.copyAttributes.contains(name)) {
this.allAttributes.put(name, attribute);
}
}
|
[
"public",
"void",
"setAttribute",
"(",
"final",
"String",
"name",
",",
"final",
"Attribute",
"attribute",
")",
"{",
"if",
"(",
"name",
".",
"equals",
"(",
"\"datasource\"",
")",
")",
"{",
"this",
".",
"allAttributes",
".",
"putAll",
"(",
"(",
"(",
"DataSourceAttribute",
")",
"attribute",
")",
".",
"getAttributes",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"copyAttributes",
".",
"contains",
"(",
"name",
")",
")",
"{",
"this",
".",
"allAttributes",
".",
"put",
"(",
"name",
",",
"attribute",
")",
";",
"}",
"}"
] |
All the sub-level attributes.
@param name the attribute name.
@param attribute the attribute.
|
[
"All",
"the",
"sub",
"-",
"level",
"attributes",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/jasper/DataSourceProcessor.java#L188-L194
|
159,458 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/config/SmtpConfig.java
|
SmtpConfig.getBody
|
@Nonnull
public String getBody() {
if (body == null) {
return storage == null ? DEFAULT_BODY : DEFAULT_BODY_STORAGE;
} else {
return body;
}
}
|
java
|
@Nonnull
public String getBody() {
if (body == null) {
return storage == null ? DEFAULT_BODY : DEFAULT_BODY_STORAGE;
} else {
return body;
}
}
|
[
"@",
"Nonnull",
"public",
"String",
"getBody",
"(",
")",
"{",
"if",
"(",
"body",
"==",
"null",
")",
"{",
"return",
"storage",
"==",
"null",
"?",
"DEFAULT_BODY",
":",
"DEFAULT_BODY_STORAGE",
";",
"}",
"else",
"{",
"return",
"body",
";",
"}",
"}"
] |
Returns the configured body or the default value.
|
[
"Returns",
"the",
"configured",
"body",
"or",
"the",
"default",
"value",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/SmtpConfig.java#L188-L195
|
159,459 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/map/tiled/TilePreparationTask.java
|
TilePreparationTask.isTileVisible
|
private boolean isTileVisible(final ReferencedEnvelope tileBounds) {
if (FloatingPointUtil.equals(this.transformer.getRotation(), 0.0)) {
return true;
}
final GeometryFactory gfac = new GeometryFactory();
final Optional<Geometry> rotatedMapBounds = getRotatedMapBounds(gfac);
if (rotatedMapBounds.isPresent()) {
return rotatedMapBounds.get().intersects(gfac.toGeometry(tileBounds));
} else {
// in case of an error, we simply load the tile
return true;
}
}
|
java
|
private boolean isTileVisible(final ReferencedEnvelope tileBounds) {
if (FloatingPointUtil.equals(this.transformer.getRotation(), 0.0)) {
return true;
}
final GeometryFactory gfac = new GeometryFactory();
final Optional<Geometry> rotatedMapBounds = getRotatedMapBounds(gfac);
if (rotatedMapBounds.isPresent()) {
return rotatedMapBounds.get().intersects(gfac.toGeometry(tileBounds));
} else {
// in case of an error, we simply load the tile
return true;
}
}
|
[
"private",
"boolean",
"isTileVisible",
"(",
"final",
"ReferencedEnvelope",
"tileBounds",
")",
"{",
"if",
"(",
"FloatingPointUtil",
".",
"equals",
"(",
"this",
".",
"transformer",
".",
"getRotation",
"(",
")",
",",
"0.0",
")",
")",
"{",
"return",
"true",
";",
"}",
"final",
"GeometryFactory",
"gfac",
"=",
"new",
"GeometryFactory",
"(",
")",
";",
"final",
"Optional",
"<",
"Geometry",
">",
"rotatedMapBounds",
"=",
"getRotatedMapBounds",
"(",
"gfac",
")",
";",
"if",
"(",
"rotatedMapBounds",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
"rotatedMapBounds",
".",
"get",
"(",
")",
".",
"intersects",
"(",
"gfac",
".",
"toGeometry",
"(",
"tileBounds",
")",
")",
";",
"}",
"else",
"{",
"// in case of an error, we simply load the tile",
"return",
"true",
";",
"}",
"}"
] |
When using a map rotation, there might be tiles that are outside the rotated map area. To avoid to load
these tiles, this method checks if a tile is really required to draw the map.
|
[
"When",
"using",
"a",
"map",
"rotation",
"there",
"might",
"be",
"tiles",
"that",
"are",
"outside",
"the",
"rotated",
"map",
"area",
".",
"To",
"avoid",
"to",
"load",
"these",
"tiles",
"this",
"method",
"checks",
"if",
"a",
"tile",
"is",
"really",
"required",
"to",
"draw",
"the",
"map",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/TilePreparationTask.java#L169-L183
|
159,460 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/map/style/json/MapfishJsonStyleVersion1.java
|
MapfishJsonStyleVersion1.getStyleRules
|
private List<Rule> getStyleRules(final String styleProperty) {
final List<Rule> styleRules = new ArrayList<>(this.json.size());
for (Iterator<String> iterator = this.json.keys(); iterator.hasNext(); ) {
String styleKey = iterator.next();
if (styleKey.equals(JSON_STYLE_PROPERTY) ||
styleKey.equals(MapfishStyleParserPlugin.JSON_VERSION)) {
continue;
}
PJsonObject styleJson = this.json.getJSONObject(styleKey);
final List<Rule> currentRules = createStyleRule(styleKey, styleJson, styleProperty);
for (Rule currentRule: currentRules) {
if (currentRule != null) {
styleRules.add(currentRule);
}
}
}
return styleRules;
}
|
java
|
private List<Rule> getStyleRules(final String styleProperty) {
final List<Rule> styleRules = new ArrayList<>(this.json.size());
for (Iterator<String> iterator = this.json.keys(); iterator.hasNext(); ) {
String styleKey = iterator.next();
if (styleKey.equals(JSON_STYLE_PROPERTY) ||
styleKey.equals(MapfishStyleParserPlugin.JSON_VERSION)) {
continue;
}
PJsonObject styleJson = this.json.getJSONObject(styleKey);
final List<Rule> currentRules = createStyleRule(styleKey, styleJson, styleProperty);
for (Rule currentRule: currentRules) {
if (currentRule != null) {
styleRules.add(currentRule);
}
}
}
return styleRules;
}
|
[
"private",
"List",
"<",
"Rule",
">",
"getStyleRules",
"(",
"final",
"String",
"styleProperty",
")",
"{",
"final",
"List",
"<",
"Rule",
">",
"styleRules",
"=",
"new",
"ArrayList",
"<>",
"(",
"this",
".",
"json",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"iterator",
"=",
"this",
".",
"json",
".",
"keys",
"(",
")",
";",
"iterator",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"styleKey",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"styleKey",
".",
"equals",
"(",
"JSON_STYLE_PROPERTY",
")",
"||",
"styleKey",
".",
"equals",
"(",
"MapfishStyleParserPlugin",
".",
"JSON_VERSION",
")",
")",
"{",
"continue",
";",
"}",
"PJsonObject",
"styleJson",
"=",
"this",
".",
"json",
".",
"getJSONObject",
"(",
"styleKey",
")",
";",
"final",
"List",
"<",
"Rule",
">",
"currentRules",
"=",
"createStyleRule",
"(",
"styleKey",
",",
"styleJson",
",",
"styleProperty",
")",
";",
"for",
"(",
"Rule",
"currentRule",
":",
"currentRules",
")",
"{",
"if",
"(",
"currentRule",
"!=",
"null",
")",
"{",
"styleRules",
".",
"add",
"(",
"currentRule",
")",
";",
"}",
"}",
"}",
"return",
"styleRules",
";",
"}"
] |
Creates SLD rules for each old style.
|
[
"Creates",
"SLD",
"rules",
"for",
"each",
"old",
"style",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/style/json/MapfishJsonStyleVersion1.java#L74-L93
|
159,461 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/http/ForwardHeadersProcessor.java
|
ForwardHeadersProcessor.setHeaders
|
public void setHeaders(final Set<String> names) {
// transform to lower-case because header names should be case-insensitive
Set<String> lowerCaseNames = new HashSet<>();
for (String name: names) {
lowerCaseNames.add(name.toLowerCase());
}
this.headerNames = lowerCaseNames;
}
|
java
|
public void setHeaders(final Set<String> names) {
// transform to lower-case because header names should be case-insensitive
Set<String> lowerCaseNames = new HashSet<>();
for (String name: names) {
lowerCaseNames.add(name.toLowerCase());
}
this.headerNames = lowerCaseNames;
}
|
[
"public",
"void",
"setHeaders",
"(",
"final",
"Set",
"<",
"String",
">",
"names",
")",
"{",
"// transform to lower-case because header names should be case-insensitive",
"Set",
"<",
"String",
">",
"lowerCaseNames",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"name",
":",
"names",
")",
"{",
"lowerCaseNames",
".",
"add",
"(",
"name",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"this",
".",
"headerNames",
"=",
"lowerCaseNames",
";",
"}"
] |
Set the header names to forward from the request. Should not be defined if all is set to true
@param names the header names.
|
[
"Set",
"the",
"header",
"names",
"to",
"forward",
"from",
"the",
"request",
".",
"Should",
"not",
"be",
"defined",
"if",
"all",
"is",
"set",
"to",
"true"
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/ForwardHeadersProcessor.java#L56-L63
|
159,462 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/map/tiled/osm/OsmLayerParam.java
|
OsmLayerParam.convertToMultiMap
|
public static Multimap<String, String> convertToMultiMap(final PObject objectParams) {
Multimap<String, String> params = HashMultimap.create();
if (objectParams != null) {
Iterator<String> customParamsIter = objectParams.keys();
while (customParamsIter.hasNext()) {
String key = customParamsIter.next();
if (objectParams.isArray(key)) {
final PArray array = objectParams.optArray(key);
for (int i = 0; i < array.size(); i++) {
params.put(key, array.getString(i));
}
} else {
params.put(key, objectParams.optString(key, ""));
}
}
}
return params;
}
|
java
|
public static Multimap<String, String> convertToMultiMap(final PObject objectParams) {
Multimap<String, String> params = HashMultimap.create();
if (objectParams != null) {
Iterator<String> customParamsIter = objectParams.keys();
while (customParamsIter.hasNext()) {
String key = customParamsIter.next();
if (objectParams.isArray(key)) {
final PArray array = objectParams.optArray(key);
for (int i = 0; i < array.size(); i++) {
params.put(key, array.getString(i));
}
} else {
params.put(key, objectParams.optString(key, ""));
}
}
}
return params;
}
|
[
"public",
"static",
"Multimap",
"<",
"String",
",",
"String",
">",
"convertToMultiMap",
"(",
"final",
"PObject",
"objectParams",
")",
"{",
"Multimap",
"<",
"String",
",",
"String",
">",
"params",
"=",
"HashMultimap",
".",
"create",
"(",
")",
";",
"if",
"(",
"objectParams",
"!=",
"null",
")",
"{",
"Iterator",
"<",
"String",
">",
"customParamsIter",
"=",
"objectParams",
".",
"keys",
"(",
")",
";",
"while",
"(",
"customParamsIter",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"key",
"=",
"customParamsIter",
".",
"next",
"(",
")",
";",
"if",
"(",
"objectParams",
".",
"isArray",
"(",
"key",
")",
")",
"{",
"final",
"PArray",
"array",
"=",
"objectParams",
".",
"optArray",
"(",
"key",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"params",
".",
"put",
"(",
"key",
",",
"array",
".",
"getString",
"(",
"i",
")",
")",
";",
"}",
"}",
"else",
"{",
"params",
".",
"put",
"(",
"key",
",",
"objectParams",
".",
"optString",
"(",
"key",
",",
"\"\"",
")",
")",
";",
"}",
"}",
"}",
"return",
"params",
";",
"}"
] |
convert a param object to a multimap.
@param objectParams the parameters to convert.
@return the corresponding Multimap.
|
[
"convert",
"a",
"param",
"object",
"to",
"a",
"multimap",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/osm/OsmLayerParam.java#L117-L135
|
159,463 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/map/tiled/osm/OsmLayerParam.java
|
OsmLayerParam.getMaxExtent
|
public Envelope getMaxExtent() {
final int minX = 0;
final int maxX = 1;
final int minY = 2;
final int maxY = 3;
return new Envelope(this.maxExtent[minX], this.maxExtent[minY], this.maxExtent[maxX],
this.maxExtent[maxY]);
}
|
java
|
public Envelope getMaxExtent() {
final int minX = 0;
final int maxX = 1;
final int minY = 2;
final int maxY = 3;
return new Envelope(this.maxExtent[minX], this.maxExtent[minY], this.maxExtent[maxX],
this.maxExtent[maxY]);
}
|
[
"public",
"Envelope",
"getMaxExtent",
"(",
")",
"{",
"final",
"int",
"minX",
"=",
"0",
";",
"final",
"int",
"maxX",
"=",
"1",
";",
"final",
"int",
"minY",
"=",
"2",
";",
"final",
"int",
"maxY",
"=",
"3",
";",
"return",
"new",
"Envelope",
"(",
"this",
".",
"maxExtent",
"[",
"minX",
"]",
",",
"this",
".",
"maxExtent",
"[",
"minY",
"]",
",",
"this",
".",
"maxExtent",
"[",
"maxX",
"]",
",",
"this",
".",
"maxExtent",
"[",
"maxY",
"]",
")",
";",
"}"
] |
Get the max extent as a envelop object.
|
[
"Get",
"the",
"max",
"extent",
"as",
"a",
"envelop",
"object",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/osm/OsmLayerParam.java#L176-L183
|
159,464 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/servlet/ServletMapPrinterFactory.java
|
ServletMapPrinterFactory.setConfigurationFiles
|
public final void setConfigurationFiles(final Map<String, String> configurationFiles)
throws URISyntaxException {
this.configurationFiles.clear();
this.configurationFileLastModifiedTimes.clear();
for (Map.Entry<String, String> entry: configurationFiles.entrySet()) {
if (!entry.getValue().contains(":/")) {
// assume is a file
this.configurationFiles.put(entry.getKey(), new File(entry.getValue()).toURI());
} else {
this.configurationFiles.put(entry.getKey(), new URI(entry.getValue()));
}
}
if (this.configFileLoader != null) {
this.validateConfigurationFiles();
}
}
|
java
|
public final void setConfigurationFiles(final Map<String, String> configurationFiles)
throws URISyntaxException {
this.configurationFiles.clear();
this.configurationFileLastModifiedTimes.clear();
for (Map.Entry<String, String> entry: configurationFiles.entrySet()) {
if (!entry.getValue().contains(":/")) {
// assume is a file
this.configurationFiles.put(entry.getKey(), new File(entry.getValue()).toURI());
} else {
this.configurationFiles.put(entry.getKey(), new URI(entry.getValue()));
}
}
if (this.configFileLoader != null) {
this.validateConfigurationFiles();
}
}
|
[
"public",
"final",
"void",
"setConfigurationFiles",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"configurationFiles",
")",
"throws",
"URISyntaxException",
"{",
"this",
".",
"configurationFiles",
".",
"clear",
"(",
")",
";",
"this",
".",
"configurationFileLastModifiedTimes",
".",
"clear",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"configurationFiles",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"entry",
".",
"getValue",
"(",
")",
".",
"contains",
"(",
"\":/\"",
")",
")",
"{",
"// assume is a file",
"this",
".",
"configurationFiles",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"new",
"File",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
".",
"toURI",
"(",
")",
")",
";",
"}",
"else",
"{",
"this",
".",
"configurationFiles",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"new",
"URI",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"}",
"if",
"(",
"this",
".",
"configFileLoader",
"!=",
"null",
")",
"{",
"this",
".",
"validateConfigurationFiles",
"(",
")",
";",
"}",
"}"
] |
The setter for setting configuration file. It will convert the value to a URI.
@param configurationFiles the configuration file map.
|
[
"The",
"setter",
"for",
"setting",
"configuration",
"file",
".",
"It",
"will",
"convert",
"the",
"value",
"to",
"a",
"URI",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/ServletMapPrinterFactory.java#L149-L165
|
159,465 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/attribute/map/ZoomToFeatures.java
|
ZoomToFeatures.copy
|
public final ZoomToFeatures copy() {
ZoomToFeatures obj = new ZoomToFeatures();
obj.zoomType = this.zoomType;
obj.minScale = this.minScale;
obj.minMargin = this.minMargin;
return obj;
}
|
java
|
public final ZoomToFeatures copy() {
ZoomToFeatures obj = new ZoomToFeatures();
obj.zoomType = this.zoomType;
obj.minScale = this.minScale;
obj.minMargin = this.minMargin;
return obj;
}
|
[
"public",
"final",
"ZoomToFeatures",
"copy",
"(",
")",
"{",
"ZoomToFeatures",
"obj",
"=",
"new",
"ZoomToFeatures",
"(",
")",
";",
"obj",
".",
"zoomType",
"=",
"this",
".",
"zoomType",
";",
"obj",
".",
"minScale",
"=",
"this",
".",
"minScale",
";",
"obj",
".",
"minMargin",
"=",
"this",
".",
"minMargin",
";",
"return",
"obj",
";",
"}"
] |
Make a copy.
|
[
"Make",
"a",
"copy",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/ZoomToFeatures.java#L45-L51
|
159,466 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/url/data/DataUrlConnection.java
|
DataUrlConnection.getFullContentType
|
public String getFullContentType() {
final String url = this.url.toExternalForm().substring("data:".length());
final int endIndex = url.indexOf(',');
if (endIndex >= 0) {
final String contentType = url.substring(0, endIndex);
if (!contentType.isEmpty()) {
return contentType;
}
}
return "text/plain;charset=US-ASCII";
}
|
java
|
public String getFullContentType() {
final String url = this.url.toExternalForm().substring("data:".length());
final int endIndex = url.indexOf(',');
if (endIndex >= 0) {
final String contentType = url.substring(0, endIndex);
if (!contentType.isEmpty()) {
return contentType;
}
}
return "text/plain;charset=US-ASCII";
}
|
[
"public",
"String",
"getFullContentType",
"(",
")",
"{",
"final",
"String",
"url",
"=",
"this",
".",
"url",
".",
"toExternalForm",
"(",
")",
".",
"substring",
"(",
"\"data:\"",
".",
"length",
"(",
")",
")",
";",
"final",
"int",
"endIndex",
"=",
"url",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"endIndex",
">=",
"0",
")",
"{",
"final",
"String",
"contentType",
"=",
"url",
".",
"substring",
"(",
"0",
",",
"endIndex",
")",
";",
"if",
"(",
"!",
"contentType",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"contentType",
";",
"}",
"}",
"return",
"\"text/plain;charset=US-ASCII\"",
";",
"}"
] |
Get the content-type, including the optional ";base64".
|
[
"Get",
"the",
"content",
"-",
"type",
"including",
"the",
"optional",
";",
"base64",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/url/data/DataUrlConnection.java#L61-L71
|
159,467 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/http/matcher/DnsHostMatcher.java
|
DnsHostMatcher.tryOverrideValidation
|
@Override
public final Optional<Boolean> tryOverrideValidation(final MatchInfo matchInfo) throws SocketException,
UnknownHostException, MalformedURLException {
for (AddressHostMatcher addressHostMatcher: this.matchersForHost) {
if (addressHostMatcher.matches(matchInfo)) {
return Optional.empty();
}
}
return Optional.of(false);
}
|
java
|
@Override
public final Optional<Boolean> tryOverrideValidation(final MatchInfo matchInfo) throws SocketException,
UnknownHostException, MalformedURLException {
for (AddressHostMatcher addressHostMatcher: this.matchersForHost) {
if (addressHostMatcher.matches(matchInfo)) {
return Optional.empty();
}
}
return Optional.of(false);
}
|
[
"@",
"Override",
"public",
"final",
"Optional",
"<",
"Boolean",
">",
"tryOverrideValidation",
"(",
"final",
"MatchInfo",
"matchInfo",
")",
"throws",
"SocketException",
",",
"UnknownHostException",
",",
"MalformedURLException",
"{",
"for",
"(",
"AddressHostMatcher",
"addressHostMatcher",
":",
"this",
".",
"matchersForHost",
")",
"{",
"if",
"(",
"addressHostMatcher",
".",
"matches",
"(",
"matchInfo",
")",
")",
"{",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"}",
"}",
"return",
"Optional",
".",
"of",
"(",
"false",
")",
";",
"}"
] |
Check the given URI to see if it matches.
@param matchInfo the matchInfo to validate.
@return True if it matches.
|
[
"Check",
"the",
"given",
"URI",
"to",
"see",
"if",
"it",
"matches",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/matcher/DnsHostMatcher.java#L58-L68
|
159,468 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/http/matcher/DnsHostMatcher.java
|
DnsHostMatcher.setHost
|
public final void setHost(final String host) throws UnknownHostException {
this.host = host;
final InetAddress[] inetAddresses = InetAddress.getAllByName(host);
for (InetAddress address: inetAddresses) {
final AddressHostMatcher matcher = new AddressHostMatcher();
matcher.setIp(address.getHostAddress());
this.matchersForHost.add(matcher);
}
}
|
java
|
public final void setHost(final String host) throws UnknownHostException {
this.host = host;
final InetAddress[] inetAddresses = InetAddress.getAllByName(host);
for (InetAddress address: inetAddresses) {
final AddressHostMatcher matcher = new AddressHostMatcher();
matcher.setIp(address.getHostAddress());
this.matchersForHost.add(matcher);
}
}
|
[
"public",
"final",
"void",
"setHost",
"(",
"final",
"String",
"host",
")",
"throws",
"UnknownHostException",
"{",
"this",
".",
"host",
"=",
"host",
";",
"final",
"InetAddress",
"[",
"]",
"inetAddresses",
"=",
"InetAddress",
".",
"getAllByName",
"(",
"host",
")",
";",
"for",
"(",
"InetAddress",
"address",
":",
"inetAddresses",
")",
"{",
"final",
"AddressHostMatcher",
"matcher",
"=",
"new",
"AddressHostMatcher",
"(",
")",
";",
"matcher",
".",
"setIp",
"(",
"address",
".",
"getHostAddress",
"(",
")",
")",
";",
"this",
".",
"matchersForHost",
".",
"add",
"(",
"matcher",
")",
";",
"}",
"}"
] |
Set the host.
@param host the host
|
[
"Set",
"the",
"host",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/matcher/DnsHostMatcher.java#L82-L91
|
159,469 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/ProcessorDependencyGraph.java
|
ProcessorDependencyGraph.getAllRequiredAttributes
|
@SuppressWarnings("unchecked")
public Multimap<String, Processor> getAllRequiredAttributes() {
Multimap<String, Processor> requiredInputs = HashMultimap.create();
for (ProcessorGraphNode root: this.roots) {
final BiMap<String, String> inputMapper = root.getInputMapper();
for (String attr: inputMapper.keySet()) {
requiredInputs.put(attr, root.getProcessor());
}
final Object inputParameter = root.getProcessor().createInputParameter();
if (inputParameter instanceof Values) {
continue;
} else if (inputParameter != null) {
final Class<?> inputParameterClass = inputParameter.getClass();
final Set<String> requiredAttributesDefinedInInputParameter =
getAttributeNames(inputParameterClass,
FILTER_ONLY_REQUIRED_ATTRIBUTES);
for (String attName: requiredAttributesDefinedInInputParameter) {
try {
if (inputParameterClass.getField(attName).getType() == Values.class) {
continue;
}
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
String mappedName = ProcessorUtils.getInputValueName(
root.getProcessor().getInputPrefix(),
inputMapper, attName);
requiredInputs.put(mappedName, root.getProcessor());
}
}
}
return requiredInputs;
}
|
java
|
@SuppressWarnings("unchecked")
public Multimap<String, Processor> getAllRequiredAttributes() {
Multimap<String, Processor> requiredInputs = HashMultimap.create();
for (ProcessorGraphNode root: this.roots) {
final BiMap<String, String> inputMapper = root.getInputMapper();
for (String attr: inputMapper.keySet()) {
requiredInputs.put(attr, root.getProcessor());
}
final Object inputParameter = root.getProcessor().createInputParameter();
if (inputParameter instanceof Values) {
continue;
} else if (inputParameter != null) {
final Class<?> inputParameterClass = inputParameter.getClass();
final Set<String> requiredAttributesDefinedInInputParameter =
getAttributeNames(inputParameterClass,
FILTER_ONLY_REQUIRED_ATTRIBUTES);
for (String attName: requiredAttributesDefinedInInputParameter) {
try {
if (inputParameterClass.getField(attName).getType() == Values.class) {
continue;
}
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
String mappedName = ProcessorUtils.getInputValueName(
root.getProcessor().getInputPrefix(),
inputMapper, attName);
requiredInputs.put(mappedName, root.getProcessor());
}
}
}
return requiredInputs;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Multimap",
"<",
"String",
",",
"Processor",
">",
"getAllRequiredAttributes",
"(",
")",
"{",
"Multimap",
"<",
"String",
",",
"Processor",
">",
"requiredInputs",
"=",
"HashMultimap",
".",
"create",
"(",
")",
";",
"for",
"(",
"ProcessorGraphNode",
"root",
":",
"this",
".",
"roots",
")",
"{",
"final",
"BiMap",
"<",
"String",
",",
"String",
">",
"inputMapper",
"=",
"root",
".",
"getInputMapper",
"(",
")",
";",
"for",
"(",
"String",
"attr",
":",
"inputMapper",
".",
"keySet",
"(",
")",
")",
"{",
"requiredInputs",
".",
"put",
"(",
"attr",
",",
"root",
".",
"getProcessor",
"(",
")",
")",
";",
"}",
"final",
"Object",
"inputParameter",
"=",
"root",
".",
"getProcessor",
"(",
")",
".",
"createInputParameter",
"(",
")",
";",
"if",
"(",
"inputParameter",
"instanceof",
"Values",
")",
"{",
"continue",
";",
"}",
"else",
"if",
"(",
"inputParameter",
"!=",
"null",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"inputParameterClass",
"=",
"inputParameter",
".",
"getClass",
"(",
")",
";",
"final",
"Set",
"<",
"String",
">",
"requiredAttributesDefinedInInputParameter",
"=",
"getAttributeNames",
"(",
"inputParameterClass",
",",
"FILTER_ONLY_REQUIRED_ATTRIBUTES",
")",
";",
"for",
"(",
"String",
"attName",
":",
"requiredAttributesDefinedInInputParameter",
")",
"{",
"try",
"{",
"if",
"(",
"inputParameterClass",
".",
"getField",
"(",
"attName",
")",
".",
"getType",
"(",
")",
"==",
"Values",
".",
"class",
")",
"{",
"continue",
";",
"}",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"String",
"mappedName",
"=",
"ProcessorUtils",
".",
"getInputValueName",
"(",
"root",
".",
"getProcessor",
"(",
")",
".",
"getInputPrefix",
"(",
")",
",",
"inputMapper",
",",
"attName",
")",
";",
"requiredInputs",
".",
"put",
"(",
"mappedName",
",",
"root",
".",
"getProcessor",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"requiredInputs",
";",
"}"
] |
Get all the names of inputs that are required to be in the Values object when this graph is executed.
|
[
"Get",
"all",
"the",
"names",
"of",
"inputs",
"that",
"are",
"required",
"to",
"be",
"in",
"the",
"Values",
"object",
"when",
"this",
"graph",
"is",
"executed",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorDependencyGraph.java#L104-L137
|
159,470 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/ProcessorDependencyGraph.java
|
ProcessorDependencyGraph.getAllProcessors
|
public Set<Processor<?, ?>> getAllProcessors() {
IdentityHashMap<Processor<?, ?>, Void> all = new IdentityHashMap<>();
for (ProcessorGraphNode<?, ?> root: this.roots) {
for (Processor p: root.getAllProcessors()) {
all.put(p, null);
}
}
return all.keySet();
}
|
java
|
public Set<Processor<?, ?>> getAllProcessors() {
IdentityHashMap<Processor<?, ?>, Void> all = new IdentityHashMap<>();
for (ProcessorGraphNode<?, ?> root: this.roots) {
for (Processor p: root.getAllProcessors()) {
all.put(p, null);
}
}
return all.keySet();
}
|
[
"public",
"Set",
"<",
"Processor",
"<",
"?",
",",
"?",
">",
">",
"getAllProcessors",
"(",
")",
"{",
"IdentityHashMap",
"<",
"Processor",
"<",
"?",
",",
"?",
">",
",",
"Void",
">",
"all",
"=",
"new",
"IdentityHashMap",
"<>",
"(",
")",
";",
"for",
"(",
"ProcessorGraphNode",
"<",
"?",
",",
"?",
">",
"root",
":",
"this",
".",
"roots",
")",
"{",
"for",
"(",
"Processor",
"p",
":",
"root",
".",
"getAllProcessors",
"(",
")",
")",
"{",
"all",
".",
"put",
"(",
"p",
",",
"null",
")",
";",
"}",
"}",
"return",
"all",
".",
"keySet",
"(",
")",
";",
"}"
] |
Create a set containing all the processors in the graph.
|
[
"Create",
"a",
"set",
"containing",
"all",
"the",
"processors",
"in",
"the",
"graph",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorDependencyGraph.java#L170-L178
|
159,471 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/http/matcher/UriMatchers.java
|
UriMatchers.validate
|
public void validate(final List<Throwable> validationErrors) {
if (this.matchers == null) {
validationErrors.add(new IllegalArgumentException(
"Matchers cannot be null. There should be at least a !acceptAll matcher"));
}
if (this.matchers != null && this.matchers.isEmpty()) {
validationErrors.add(new IllegalArgumentException(
"There are no url matchers defined. There should be at least a " +
"!acceptAll matcher"));
}
}
|
java
|
public void validate(final List<Throwable> validationErrors) {
if (this.matchers == null) {
validationErrors.add(new IllegalArgumentException(
"Matchers cannot be null. There should be at least a !acceptAll matcher"));
}
if (this.matchers != null && this.matchers.isEmpty()) {
validationErrors.add(new IllegalArgumentException(
"There are no url matchers defined. There should be at least a " +
"!acceptAll matcher"));
}
}
|
[
"public",
"void",
"validate",
"(",
"final",
"List",
"<",
"Throwable",
">",
"validationErrors",
")",
"{",
"if",
"(",
"this",
".",
"matchers",
"==",
"null",
")",
"{",
"validationErrors",
".",
"add",
"(",
"new",
"IllegalArgumentException",
"(",
"\"Matchers cannot be null. There should be at least a !acceptAll matcher\"",
")",
")",
";",
"}",
"if",
"(",
"this",
".",
"matchers",
"!=",
"null",
"&&",
"this",
".",
"matchers",
".",
"isEmpty",
"(",
")",
")",
"{",
"validationErrors",
".",
"add",
"(",
"new",
"IllegalArgumentException",
"(",
"\"There are no url matchers defined. There should be at least a \"",
"+",
"\"!acceptAll matcher\"",
")",
")",
";",
"}",
"}"
] |
Validate the configuration.
@param validationErrors where to put the errors.
|
[
"Validate",
"the",
"configuration",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/matcher/UriMatchers.java#L83-L93
|
159,472 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/metrics/StatsDReporterInit.java
|
StatsDReporterInit.init
|
@PostConstruct
public final void init() throws URISyntaxException {
final String address = getConfig(ADDRESS, null);
if (address != null) {
final URI uri = new URI("udp://" + address);
final String prefix = getConfig(PREFIX, "mapfish-print").replace("%h", getHostname());
final int period = Integer.parseInt(getConfig(PERIOD, "10"));
LOGGER.info("Starting a StatsD reporter targeting {} with prefix {} and period {}s",
uri, prefix, period);
this.reporter = StatsDReporter.forRegistry(this.metricRegistry)
.prefixedWith(prefix)
.build(uri.getHost(), uri.getPort());
this.reporter.start(period, TimeUnit.SECONDS);
}
}
|
java
|
@PostConstruct
public final void init() throws URISyntaxException {
final String address = getConfig(ADDRESS, null);
if (address != null) {
final URI uri = new URI("udp://" + address);
final String prefix = getConfig(PREFIX, "mapfish-print").replace("%h", getHostname());
final int period = Integer.parseInt(getConfig(PERIOD, "10"));
LOGGER.info("Starting a StatsD reporter targeting {} with prefix {} and period {}s",
uri, prefix, period);
this.reporter = StatsDReporter.forRegistry(this.metricRegistry)
.prefixedWith(prefix)
.build(uri.getHost(), uri.getPort());
this.reporter.start(period, TimeUnit.SECONDS);
}
}
|
[
"@",
"PostConstruct",
"public",
"final",
"void",
"init",
"(",
")",
"throws",
"URISyntaxException",
"{",
"final",
"String",
"address",
"=",
"getConfig",
"(",
"ADDRESS",
",",
"null",
")",
";",
"if",
"(",
"address",
"!=",
"null",
")",
"{",
"final",
"URI",
"uri",
"=",
"new",
"URI",
"(",
"\"udp://\"",
"+",
"address",
")",
";",
"final",
"String",
"prefix",
"=",
"getConfig",
"(",
"PREFIX",
",",
"\"mapfish-print\"",
")",
".",
"replace",
"(",
"\"%h\"",
",",
"getHostname",
"(",
")",
")",
";",
"final",
"int",
"period",
"=",
"Integer",
".",
"parseInt",
"(",
"getConfig",
"(",
"PERIOD",
",",
"\"10\"",
")",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"Starting a StatsD reporter targeting {} with prefix {} and period {}s\"",
",",
"uri",
",",
"prefix",
",",
"period",
")",
";",
"this",
".",
"reporter",
"=",
"StatsDReporter",
".",
"forRegistry",
"(",
"this",
".",
"metricRegistry",
")",
".",
"prefixedWith",
"(",
"prefix",
")",
".",
"build",
"(",
"uri",
".",
"getHost",
"(",
")",
",",
"uri",
".",
"getPort",
"(",
")",
")",
";",
"this",
".",
"reporter",
".",
"start",
"(",
"period",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"}"
] |
Start the StatsD reporter, if configured.
@throws URISyntaxException
|
[
"Start",
"the",
"StatsD",
"reporter",
"if",
"configured",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/metrics/StatsDReporterInit.java#L63-L77
|
159,473 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java
|
CreateMapProcessor.adjustBoundsToScaleAndMapSize
|
public static MapBounds adjustBoundsToScaleAndMapSize(
final GenericMapAttributeValues mapValues,
final Rectangle paintArea,
final MapBounds bounds,
final double dpi) {
MapBounds newBounds = bounds;
if (mapValues.isUseNearestScale()) {
newBounds = newBounds.adjustBoundsToNearestScale(
mapValues.getZoomLevels(),
mapValues.getZoomSnapTolerance(),
mapValues.getZoomLevelSnapStrategy(),
mapValues.getZoomSnapGeodetic(),
paintArea, dpi);
}
newBounds = new BBoxMapBounds(newBounds.toReferencedEnvelope(paintArea));
if (mapValues.isUseAdjustBounds()) {
newBounds = newBounds.adjustedEnvelope(paintArea);
}
return newBounds;
}
|
java
|
public static MapBounds adjustBoundsToScaleAndMapSize(
final GenericMapAttributeValues mapValues,
final Rectangle paintArea,
final MapBounds bounds,
final double dpi) {
MapBounds newBounds = bounds;
if (mapValues.isUseNearestScale()) {
newBounds = newBounds.adjustBoundsToNearestScale(
mapValues.getZoomLevels(),
mapValues.getZoomSnapTolerance(),
mapValues.getZoomLevelSnapStrategy(),
mapValues.getZoomSnapGeodetic(),
paintArea, dpi);
}
newBounds = new BBoxMapBounds(newBounds.toReferencedEnvelope(paintArea));
if (mapValues.isUseAdjustBounds()) {
newBounds = newBounds.adjustedEnvelope(paintArea);
}
return newBounds;
}
|
[
"public",
"static",
"MapBounds",
"adjustBoundsToScaleAndMapSize",
"(",
"final",
"GenericMapAttributeValues",
"mapValues",
",",
"final",
"Rectangle",
"paintArea",
",",
"final",
"MapBounds",
"bounds",
",",
"final",
"double",
"dpi",
")",
"{",
"MapBounds",
"newBounds",
"=",
"bounds",
";",
"if",
"(",
"mapValues",
".",
"isUseNearestScale",
"(",
")",
")",
"{",
"newBounds",
"=",
"newBounds",
".",
"adjustBoundsToNearestScale",
"(",
"mapValues",
".",
"getZoomLevels",
"(",
")",
",",
"mapValues",
".",
"getZoomSnapTolerance",
"(",
")",
",",
"mapValues",
".",
"getZoomLevelSnapStrategy",
"(",
")",
",",
"mapValues",
".",
"getZoomSnapGeodetic",
"(",
")",
",",
"paintArea",
",",
"dpi",
")",
";",
"}",
"newBounds",
"=",
"new",
"BBoxMapBounds",
"(",
"newBounds",
".",
"toReferencedEnvelope",
"(",
"paintArea",
")",
")",
";",
"if",
"(",
"mapValues",
".",
"isUseAdjustBounds",
"(",
")",
")",
"{",
"newBounds",
"=",
"newBounds",
".",
"adjustedEnvelope",
"(",
"paintArea",
")",
";",
"}",
"return",
"newBounds",
";",
"}"
] |
If requested, adjust the bounds to the nearest scale and the map size.
@param mapValues Map parameters.
@param paintArea The size of the painting area.
@param bounds The map bounds.
@param dpi the DPI.
|
[
"If",
"requested",
"adjust",
"the",
"bounds",
"to",
"the",
"nearest",
"scale",
"and",
"the",
"map",
"size",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java#L161-L182
|
159,474 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java
|
CreateMapProcessor.createSvgGraphics
|
public static SVGGraphics2D createSvgGraphics(final Dimension size)
throws ParserConfigurationException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.getDOMImplementation().createDocument(null, "svg", null);
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
ctx.setStyleHandler(new OpacityAdjustingStyleHandler());
ctx.setComment("Generated by GeoTools2 with Batik SVG Generator");
SVGGraphics2D g2d = new SVGGraphics2D(ctx, true);
g2d.setSVGCanvasSize(size);
return g2d;
}
|
java
|
public static SVGGraphics2D createSvgGraphics(final Dimension size)
throws ParserConfigurationException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.getDOMImplementation().createDocument(null, "svg", null);
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
ctx.setStyleHandler(new OpacityAdjustingStyleHandler());
ctx.setComment("Generated by GeoTools2 with Batik SVG Generator");
SVGGraphics2D g2d = new SVGGraphics2D(ctx, true);
g2d.setSVGCanvasSize(size);
return g2d;
}
|
[
"public",
"static",
"SVGGraphics2D",
"createSvgGraphics",
"(",
"final",
"Dimension",
"size",
")",
"throws",
"ParserConfigurationException",
"{",
"DocumentBuilderFactory",
"dbf",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"DocumentBuilder",
"db",
"=",
"dbf",
".",
"newDocumentBuilder",
"(",
")",
";",
"Document",
"document",
"=",
"db",
".",
"getDOMImplementation",
"(",
")",
".",
"createDocument",
"(",
"null",
",",
"\"svg\"",
",",
"null",
")",
";",
"SVGGeneratorContext",
"ctx",
"=",
"SVGGeneratorContext",
".",
"createDefault",
"(",
"document",
")",
";",
"ctx",
".",
"setStyleHandler",
"(",
"new",
"OpacityAdjustingStyleHandler",
"(",
")",
")",
";",
"ctx",
".",
"setComment",
"(",
"\"Generated by GeoTools2 with Batik SVG Generator\"",
")",
";",
"SVGGraphics2D",
"g2d",
"=",
"new",
"SVGGraphics2D",
"(",
"ctx",
",",
"true",
")",
";",
"g2d",
".",
"setSVGCanvasSize",
"(",
"size",
")",
";",
"return",
"g2d",
";",
"}"
] |
Create a SVG graphic with the give dimensions.
@param size The size of the SVG graphic.
|
[
"Create",
"a",
"SVG",
"graphic",
"with",
"the",
"give",
"dimensions",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java#L189-L203
|
159,475 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java
|
CreateMapProcessor.saveSvgFile
|
public static void saveSvgFile(final SVGGraphics2D graphics2d, final File path) throws IOException {
try (FileOutputStream fs = new FileOutputStream(path);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fs, StandardCharsets.UTF_8);
Writer osw = new BufferedWriter(outputStreamWriter)
) {
graphics2d.stream(osw, true);
}
}
|
java
|
public static void saveSvgFile(final SVGGraphics2D graphics2d, final File path) throws IOException {
try (FileOutputStream fs = new FileOutputStream(path);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fs, StandardCharsets.UTF_8);
Writer osw = new BufferedWriter(outputStreamWriter)
) {
graphics2d.stream(osw, true);
}
}
|
[
"public",
"static",
"void",
"saveSvgFile",
"(",
"final",
"SVGGraphics2D",
"graphics2d",
",",
"final",
"File",
"path",
")",
"throws",
"IOException",
"{",
"try",
"(",
"FileOutputStream",
"fs",
"=",
"new",
"FileOutputStream",
"(",
"path",
")",
";",
"OutputStreamWriter",
"outputStreamWriter",
"=",
"new",
"OutputStreamWriter",
"(",
"fs",
",",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"Writer",
"osw",
"=",
"new",
"BufferedWriter",
"(",
"outputStreamWriter",
")",
")",
"{",
"graphics2d",
".",
"stream",
"(",
"osw",
",",
"true",
")",
";",
"}",
"}"
] |
Save a SVG graphic to the given path.
@param graphics2d The SVG graphic to save.
@param path The file.
|
[
"Save",
"a",
"SVG",
"graphic",
"to",
"the",
"given",
"path",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java#L211-L218
|
159,476 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java
|
CreateMapProcessor.getFeatureBounds
|
@Nonnull
private ReferencedEnvelope getFeatureBounds(
final MfClientHttpRequestFactory clientHttpRequestFactory,
final MapAttributeValues mapValues, final ExecutionContext context) {
final MapfishMapContext mapContext = createMapContext(mapValues);
String layerName = mapValues.zoomToFeatures.layer;
ReferencedEnvelope bounds = new ReferencedEnvelope();
for (MapLayer layer: mapValues.getLayers()) {
context.stopIfCanceled();
if ((!StringUtils.isEmpty(layerName) && layerName.equals(layer.getName())) ||
(StringUtils.isEmpty(layerName) && layer instanceof AbstractFeatureSourceLayer)) {
AbstractFeatureSourceLayer featureLayer = (AbstractFeatureSourceLayer) layer;
FeatureSource<?, ?> featureSource =
featureLayer.getFeatureSource(clientHttpRequestFactory, mapContext);
FeatureCollection<?, ?> features;
try {
features = featureSource.getFeatures();
} catch (IOException e) {
throw ExceptionUtils.getRuntimeException(e);
}
if (!features.isEmpty()) {
final ReferencedEnvelope curBounds = features.getBounds();
bounds.expandToInclude(curBounds);
}
}
}
return bounds;
}
|
java
|
@Nonnull
private ReferencedEnvelope getFeatureBounds(
final MfClientHttpRequestFactory clientHttpRequestFactory,
final MapAttributeValues mapValues, final ExecutionContext context) {
final MapfishMapContext mapContext = createMapContext(mapValues);
String layerName = mapValues.zoomToFeatures.layer;
ReferencedEnvelope bounds = new ReferencedEnvelope();
for (MapLayer layer: mapValues.getLayers()) {
context.stopIfCanceled();
if ((!StringUtils.isEmpty(layerName) && layerName.equals(layer.getName())) ||
(StringUtils.isEmpty(layerName) && layer instanceof AbstractFeatureSourceLayer)) {
AbstractFeatureSourceLayer featureLayer = (AbstractFeatureSourceLayer) layer;
FeatureSource<?, ?> featureSource =
featureLayer.getFeatureSource(clientHttpRequestFactory, mapContext);
FeatureCollection<?, ?> features;
try {
features = featureSource.getFeatures();
} catch (IOException e) {
throw ExceptionUtils.getRuntimeException(e);
}
if (!features.isEmpty()) {
final ReferencedEnvelope curBounds = features.getBounds();
bounds.expandToInclude(curBounds);
}
}
}
return bounds;
}
|
[
"@",
"Nonnull",
"private",
"ReferencedEnvelope",
"getFeatureBounds",
"(",
"final",
"MfClientHttpRequestFactory",
"clientHttpRequestFactory",
",",
"final",
"MapAttributeValues",
"mapValues",
",",
"final",
"ExecutionContext",
"context",
")",
"{",
"final",
"MapfishMapContext",
"mapContext",
"=",
"createMapContext",
"(",
"mapValues",
")",
";",
"String",
"layerName",
"=",
"mapValues",
".",
"zoomToFeatures",
".",
"layer",
";",
"ReferencedEnvelope",
"bounds",
"=",
"new",
"ReferencedEnvelope",
"(",
")",
";",
"for",
"(",
"MapLayer",
"layer",
":",
"mapValues",
".",
"getLayers",
"(",
")",
")",
"{",
"context",
".",
"stopIfCanceled",
"(",
")",
";",
"if",
"(",
"(",
"!",
"StringUtils",
".",
"isEmpty",
"(",
"layerName",
")",
"&&",
"layerName",
".",
"equals",
"(",
"layer",
".",
"getName",
"(",
")",
")",
")",
"||",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"layerName",
")",
"&&",
"layer",
"instanceof",
"AbstractFeatureSourceLayer",
")",
")",
"{",
"AbstractFeatureSourceLayer",
"featureLayer",
"=",
"(",
"AbstractFeatureSourceLayer",
")",
"layer",
";",
"FeatureSource",
"<",
"?",
",",
"?",
">",
"featureSource",
"=",
"featureLayer",
".",
"getFeatureSource",
"(",
"clientHttpRequestFactory",
",",
"mapContext",
")",
";",
"FeatureCollection",
"<",
"?",
",",
"?",
">",
"features",
";",
"try",
"{",
"features",
"=",
"featureSource",
".",
"getFeatures",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"ExceptionUtils",
".",
"getRuntimeException",
"(",
"e",
")",
";",
"}",
"if",
"(",
"!",
"features",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"ReferencedEnvelope",
"curBounds",
"=",
"features",
".",
"getBounds",
"(",
")",
";",
"bounds",
".",
"expandToInclude",
"(",
"curBounds",
")",
";",
"}",
"}",
"}",
"return",
"bounds",
";",
"}"
] |
Get the bounding-box containing all features of all layers.
|
[
"Get",
"the",
"bounding",
"-",
"box",
"containing",
"all",
"features",
"of",
"all",
"layers",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java#L591-L622
|
159,477 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/config/WorkingDirectories.java
|
WorkingDirectories.getJasperCompilation
|
public final File getJasperCompilation(final Configuration configuration) {
File jasperCompilation = new File(getWorking(configuration), "jasper-bin");
createIfMissing(jasperCompilation, "Jasper Compilation");
return jasperCompilation;
}
|
java
|
public final File getJasperCompilation(final Configuration configuration) {
File jasperCompilation = new File(getWorking(configuration), "jasper-bin");
createIfMissing(jasperCompilation, "Jasper Compilation");
return jasperCompilation;
}
|
[
"public",
"final",
"File",
"getJasperCompilation",
"(",
"final",
"Configuration",
"configuration",
")",
"{",
"File",
"jasperCompilation",
"=",
"new",
"File",
"(",
"getWorking",
"(",
"configuration",
")",
",",
"\"jasper-bin\"",
")",
";",
"createIfMissing",
"(",
"jasperCompilation",
",",
"\"Jasper Compilation\"",
")",
";",
"return",
"jasperCompilation",
";",
"}"
] |
Get the directory where the compiled jasper reports should be put.
@param configuration the configuration for the current app.
|
[
"Get",
"the",
"directory",
"where",
"the",
"compiled",
"jasper",
"reports",
"should",
"be",
"put",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/WorkingDirectories.java#L81-L85
|
159,478 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/config/WorkingDirectories.java
|
WorkingDirectories.getTaskDirectory
|
public final File getTaskDirectory() {
createIfMissing(this.working, "Working");
try {
return Files.createTempDirectory(this.working.toPath(), TASK_DIR_PREFIX).toFile();
} catch (IOException e) {
throw new AssertionError("Unable to create temporary directory in '" + this.working + "'");
}
}
|
java
|
public final File getTaskDirectory() {
createIfMissing(this.working, "Working");
try {
return Files.createTempDirectory(this.working.toPath(), TASK_DIR_PREFIX).toFile();
} catch (IOException e) {
throw new AssertionError("Unable to create temporary directory in '" + this.working + "'");
}
}
|
[
"public",
"final",
"File",
"getTaskDirectory",
"(",
")",
"{",
"createIfMissing",
"(",
"this",
".",
"working",
",",
"\"Working\"",
")",
";",
"try",
"{",
"return",
"Files",
".",
"createTempDirectory",
"(",
"this",
".",
"working",
".",
"toPath",
"(",
")",
",",
"TASK_DIR_PREFIX",
")",
".",
"toFile",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"\"Unable to create temporary directory in '\"",
"+",
"this",
".",
"working",
"+",
"\"'\"",
")",
";",
"}",
"}"
] |
Creates and returns a temporary directory for a printing task.
|
[
"Creates",
"and",
"returns",
"a",
"temporary",
"directory",
"for",
"a",
"printing",
"task",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/WorkingDirectories.java#L99-L106
|
159,479 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/config/WorkingDirectories.java
|
WorkingDirectories.removeDirectory
|
public final void removeDirectory(final File directory) {
try {
FileUtils.deleteDirectory(directory);
} catch (IOException e) {
LOGGER.error("Unable to delete directory '{}'", directory);
}
}
|
java
|
public final void removeDirectory(final File directory) {
try {
FileUtils.deleteDirectory(directory);
} catch (IOException e) {
LOGGER.error("Unable to delete directory '{}'", directory);
}
}
|
[
"public",
"final",
"void",
"removeDirectory",
"(",
"final",
"File",
"directory",
")",
"{",
"try",
"{",
"FileUtils",
".",
"deleteDirectory",
"(",
"directory",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Unable to delete directory '{}'\"",
",",
"directory",
")",
";",
"}",
"}"
] |
Deletes the given directory.
@param directory The directory to delete.
|
[
"Deletes",
"the",
"given",
"directory",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/WorkingDirectories.java#L113-L119
|
159,480 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/config/WorkingDirectories.java
|
WorkingDirectories.getBuildFileFor
|
public final File getBuildFileFor(
final Configuration configuration, final File jasperFileXml,
final String extension, final Logger logger) {
final String configurationAbsolutePath = configuration.getDirectory().getPath();
final int prefixToConfiguration = configurationAbsolutePath.length() + 1;
final String parentDir = jasperFileXml.getAbsoluteFile().getParent();
final String relativePathToFile;
if (configurationAbsolutePath.equals(parentDir)) {
relativePathToFile = FilenameUtils.getBaseName(jasperFileXml.getName());
} else {
final String relativePathToContainingDirectory = parentDir.substring(prefixToConfiguration);
relativePathToFile = relativePathToContainingDirectory + File.separator +
FilenameUtils.getBaseName(jasperFileXml.getName());
}
final File buildFile = new File(getJasperCompilation(configuration), relativePathToFile + extension);
if (!buildFile.getParentFile().exists() && !buildFile.getParentFile().mkdirs()) {
logger.error("Unable to create directory for containing compiled jasper report templates: {}",
buildFile.getParentFile());
}
return buildFile;
}
|
java
|
public final File getBuildFileFor(
final Configuration configuration, final File jasperFileXml,
final String extension, final Logger logger) {
final String configurationAbsolutePath = configuration.getDirectory().getPath();
final int prefixToConfiguration = configurationAbsolutePath.length() + 1;
final String parentDir = jasperFileXml.getAbsoluteFile().getParent();
final String relativePathToFile;
if (configurationAbsolutePath.equals(parentDir)) {
relativePathToFile = FilenameUtils.getBaseName(jasperFileXml.getName());
} else {
final String relativePathToContainingDirectory = parentDir.substring(prefixToConfiguration);
relativePathToFile = relativePathToContainingDirectory + File.separator +
FilenameUtils.getBaseName(jasperFileXml.getName());
}
final File buildFile = new File(getJasperCompilation(configuration), relativePathToFile + extension);
if (!buildFile.getParentFile().exists() && !buildFile.getParentFile().mkdirs()) {
logger.error("Unable to create directory for containing compiled jasper report templates: {}",
buildFile.getParentFile());
}
return buildFile;
}
|
[
"public",
"final",
"File",
"getBuildFileFor",
"(",
"final",
"Configuration",
"configuration",
",",
"final",
"File",
"jasperFileXml",
",",
"final",
"String",
"extension",
",",
"final",
"Logger",
"logger",
")",
"{",
"final",
"String",
"configurationAbsolutePath",
"=",
"configuration",
".",
"getDirectory",
"(",
")",
".",
"getPath",
"(",
")",
";",
"final",
"int",
"prefixToConfiguration",
"=",
"configurationAbsolutePath",
".",
"length",
"(",
")",
"+",
"1",
";",
"final",
"String",
"parentDir",
"=",
"jasperFileXml",
".",
"getAbsoluteFile",
"(",
")",
".",
"getParent",
"(",
")",
";",
"final",
"String",
"relativePathToFile",
";",
"if",
"(",
"configurationAbsolutePath",
".",
"equals",
"(",
"parentDir",
")",
")",
"{",
"relativePathToFile",
"=",
"FilenameUtils",
".",
"getBaseName",
"(",
"jasperFileXml",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"final",
"String",
"relativePathToContainingDirectory",
"=",
"parentDir",
".",
"substring",
"(",
"prefixToConfiguration",
")",
";",
"relativePathToFile",
"=",
"relativePathToContainingDirectory",
"+",
"File",
".",
"separator",
"+",
"FilenameUtils",
".",
"getBaseName",
"(",
"jasperFileXml",
".",
"getName",
"(",
")",
")",
";",
"}",
"final",
"File",
"buildFile",
"=",
"new",
"File",
"(",
"getJasperCompilation",
"(",
"configuration",
")",
",",
"relativePathToFile",
"+",
"extension",
")",
";",
"if",
"(",
"!",
"buildFile",
".",
"getParentFile",
"(",
")",
".",
"exists",
"(",
")",
"&&",
"!",
"buildFile",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
")",
"{",
"logger",
".",
"error",
"(",
"\"Unable to create directory for containing compiled jasper report templates: {}\"",
",",
"buildFile",
".",
"getParentFile",
"(",
")",
")",
";",
"}",
"return",
"buildFile",
";",
"}"
] |
Calculate the file to compile a jasper report template to.
@param configuration the configuration for the current app.
@param jasperFileXml the jasper report template in xml format.
@param extension the extension of the compiled report template.
@param logger the logger to log errors to if an occur.
|
[
"Calculate",
"the",
"file",
"to",
"compile",
"a",
"jasper",
"report",
"template",
"to",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/WorkingDirectories.java#L139-L161
|
159,481 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/map/tiled/wmts/WMTSLayer.java
|
WMTSLayer.createRestURI
|
public static URI createRestURI(
final String matrixId, final int row, final int col,
final WMTSLayerParam layerParam) throws URISyntaxException {
String path = layerParam.baseURL;
if (layerParam.dimensions != null) {
for (int i = 0; i < layerParam.dimensions.length; i++) {
String dimension = layerParam.dimensions[i];
String value = layerParam.dimensionParams.optString(dimension);
if (value == null) {
value = layerParam.dimensionParams.getString(dimension.toUpperCase());
}
path = path.replace("{" + dimension + "}", value);
}
}
path = path.replace("{TileMatrixSet}", layerParam.matrixSet);
path = path.replace("{TileMatrix}", matrixId);
path = path.replace("{TileRow}", String.valueOf(row));
path = path.replace("{TileCol}", String.valueOf(col));
path = path.replace("{style}", layerParam.style);
path = path.replace("{Layer}", layerParam.layer);
return new URI(path);
}
|
java
|
public static URI createRestURI(
final String matrixId, final int row, final int col,
final WMTSLayerParam layerParam) throws URISyntaxException {
String path = layerParam.baseURL;
if (layerParam.dimensions != null) {
for (int i = 0; i < layerParam.dimensions.length; i++) {
String dimension = layerParam.dimensions[i];
String value = layerParam.dimensionParams.optString(dimension);
if (value == null) {
value = layerParam.dimensionParams.getString(dimension.toUpperCase());
}
path = path.replace("{" + dimension + "}", value);
}
}
path = path.replace("{TileMatrixSet}", layerParam.matrixSet);
path = path.replace("{TileMatrix}", matrixId);
path = path.replace("{TileRow}", String.valueOf(row));
path = path.replace("{TileCol}", String.valueOf(col));
path = path.replace("{style}", layerParam.style);
path = path.replace("{Layer}", layerParam.layer);
return new URI(path);
}
|
[
"public",
"static",
"URI",
"createRestURI",
"(",
"final",
"String",
"matrixId",
",",
"final",
"int",
"row",
",",
"final",
"int",
"col",
",",
"final",
"WMTSLayerParam",
"layerParam",
")",
"throws",
"URISyntaxException",
"{",
"String",
"path",
"=",
"layerParam",
".",
"baseURL",
";",
"if",
"(",
"layerParam",
".",
"dimensions",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"layerParam",
".",
"dimensions",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"dimension",
"=",
"layerParam",
".",
"dimensions",
"[",
"i",
"]",
";",
"String",
"value",
"=",
"layerParam",
".",
"dimensionParams",
".",
"optString",
"(",
"dimension",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"layerParam",
".",
"dimensionParams",
".",
"getString",
"(",
"dimension",
".",
"toUpperCase",
"(",
")",
")",
";",
"}",
"path",
"=",
"path",
".",
"replace",
"(",
"\"{\"",
"+",
"dimension",
"+",
"\"}\"",
",",
"value",
")",
";",
"}",
"}",
"path",
"=",
"path",
".",
"replace",
"(",
"\"{TileMatrixSet}\"",
",",
"layerParam",
".",
"matrixSet",
")",
";",
"path",
"=",
"path",
".",
"replace",
"(",
"\"{TileMatrix}\"",
",",
"matrixId",
")",
";",
"path",
"=",
"path",
".",
"replace",
"(",
"\"{TileRow}\"",
",",
"String",
".",
"valueOf",
"(",
"row",
")",
")",
";",
"path",
"=",
"path",
".",
"replace",
"(",
"\"{TileCol}\"",
",",
"String",
".",
"valueOf",
"(",
"col",
")",
")",
";",
"path",
"=",
"path",
".",
"replace",
"(",
"\"{style}\"",
",",
"layerParam",
".",
"style",
")",
";",
"path",
"=",
"path",
".",
"replace",
"(",
"\"{Layer}\"",
",",
"layerParam",
".",
"layer",
")",
";",
"return",
"new",
"URI",
"(",
"path",
")",
";",
"}"
] |
Prepare the baseURL to make a request.
@param matrixId matrixId
@param row row
@param col cold
@param layerParam layerParam
|
[
"Prepare",
"the",
"baseURL",
"to",
"make",
"a",
"request",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/wmts/WMTSLayer.java#L66-L88
|
159,482 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/wrapper/PElement.java
|
PElement.getPath
|
public final String getPath(final String key) {
StringBuilder result = new StringBuilder();
addPathTo(result);
result.append(".");
result.append(getPathElement(key));
return result.toString();
}
|
java
|
public final String getPath(final String key) {
StringBuilder result = new StringBuilder();
addPathTo(result);
result.append(".");
result.append(getPathElement(key));
return result.toString();
}
|
[
"public",
"final",
"String",
"getPath",
"(",
"final",
"String",
"key",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"addPathTo",
"(",
"result",
")",
";",
"result",
".",
"append",
"(",
"\".\"",
")",
";",
"result",
".",
"append",
"(",
"getPathElement",
"(",
"key",
")",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Gets the string representation of the path to the current JSON element.
@param key the leaf key
|
[
"Gets",
"the",
"string",
"representation",
"of",
"the",
"path",
"to",
"the",
"current",
"JSON",
"element",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PElement.java#L39-L45
|
159,483 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/wrapper/PElement.java
|
PElement.addPathTo
|
protected final void addPathTo(final StringBuilder result) {
if (this.parent != null) {
this.parent.addPathTo(result);
if (!(this.parent instanceof PJsonArray)) {
result.append(".");
}
}
result.append(getPathElement(this.contextName));
}
|
java
|
protected final void addPathTo(final StringBuilder result) {
if (this.parent != null) {
this.parent.addPathTo(result);
if (!(this.parent instanceof PJsonArray)) {
result.append(".");
}
}
result.append(getPathElement(this.contextName));
}
|
[
"protected",
"final",
"void",
"addPathTo",
"(",
"final",
"StringBuilder",
"result",
")",
"{",
"if",
"(",
"this",
".",
"parent",
"!=",
"null",
")",
"{",
"this",
".",
"parent",
".",
"addPathTo",
"(",
"result",
")",
";",
"if",
"(",
"!",
"(",
"this",
".",
"parent",
"instanceof",
"PJsonArray",
")",
")",
"{",
"result",
".",
"append",
"(",
"\".\"",
")",
";",
"}",
"}",
"result",
".",
"append",
"(",
"getPathElement",
"(",
"this",
".",
"contextName",
")",
")",
";",
"}"
] |
Append the path to the StringBuilder.
@param result the string builder to add the path to.
|
[
"Append",
"the",
"path",
"to",
"the",
"StringBuilder",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PElement.java#L65-L73
|
159,484 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/WaitDB.java
|
WaitDB.main
|
public static void main(final String[] args) {
if (System.getProperty("db.name") == null) {
System.out.println("Not running in multi-instance mode: no DB to connect to");
System.exit(1);
}
while (true) {
try {
Class.forName("org.postgresql.Driver");
DriverManager.getConnection("jdbc:postgresql://" + System.getProperty("db.host") + ":5432/" +
System.getProperty("db.name"),
System.getProperty("db.username"),
System.getProperty("db.password"));
System.out.println("Opened database successfully. Running in multi-instance mode");
System.exit(0);
return;
} catch (Exception e) {
System.out.println("Failed to connect to the DB: " + e.toString());
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
//ignored
}
}
}
}
|
java
|
public static void main(final String[] args) {
if (System.getProperty("db.name") == null) {
System.out.println("Not running in multi-instance mode: no DB to connect to");
System.exit(1);
}
while (true) {
try {
Class.forName("org.postgresql.Driver");
DriverManager.getConnection("jdbc:postgresql://" + System.getProperty("db.host") + ":5432/" +
System.getProperty("db.name"),
System.getProperty("db.username"),
System.getProperty("db.password"));
System.out.println("Opened database successfully. Running in multi-instance mode");
System.exit(0);
return;
} catch (Exception e) {
System.out.println("Failed to connect to the DB: " + e.toString());
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
//ignored
}
}
}
}
|
[
"public",
"static",
"void",
"main",
"(",
"final",
"String",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"System",
".",
"getProperty",
"(",
"\"db.name\"",
")",
"==",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Not running in multi-instance mode: no DB to connect to\"",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"Class",
".",
"forName",
"(",
"\"org.postgresql.Driver\"",
")",
";",
"DriverManager",
".",
"getConnection",
"(",
"\"jdbc:postgresql://\"",
"+",
"System",
".",
"getProperty",
"(",
"\"db.host\"",
")",
"+",
"\":5432/\"",
"+",
"System",
".",
"getProperty",
"(",
"\"db.name\"",
")",
",",
"System",
".",
"getProperty",
"(",
"\"db.username\"",
")",
",",
"System",
".",
"getProperty",
"(",
"\"db.password\"",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Opened database successfully. Running in multi-instance mode\"",
")",
";",
"System",
".",
"exit",
"(",
"0",
")",
";",
"return",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Failed to connect to the DB: \"",
"+",
"e",
".",
"toString",
"(",
")",
")",
";",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"1000",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e1",
")",
"{",
"//ignored",
"}",
"}",
"}",
"}"
] |
A comment.
@param args the parameters
|
[
"A",
"comment",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/WaitDB.java#L16-L40
|
159,485 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java
|
ProcessorExecutionContext.started
|
private void started(final ProcessorGraphNode processorGraphNode) {
this.processorLock.lock();
try {
this.runningProcessors.put(processorGraphNode.getProcessor(), null);
} finally {
this.processorLock.unlock();
}
}
|
java
|
private void started(final ProcessorGraphNode processorGraphNode) {
this.processorLock.lock();
try {
this.runningProcessors.put(processorGraphNode.getProcessor(), null);
} finally {
this.processorLock.unlock();
}
}
|
[
"private",
"void",
"started",
"(",
"final",
"ProcessorGraphNode",
"processorGraphNode",
")",
"{",
"this",
".",
"processorLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"this",
".",
"runningProcessors",
".",
"put",
"(",
"processorGraphNode",
".",
"getProcessor",
"(",
")",
",",
"null",
")",
";",
"}",
"finally",
"{",
"this",
".",
"processorLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Flag that the processor has started execution.
@param processorGraphNode the node that has started.
|
[
"Flag",
"that",
"the",
"processor",
"has",
"started",
"execution",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java#L71-L78
|
159,486 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java
|
ProcessorExecutionContext.isRunning
|
public boolean isRunning(final ProcessorGraphNode processorGraphNode) {
this.processorLock.lock();
try {
return this.runningProcessors.containsKey(processorGraphNode.getProcessor());
} finally {
this.processorLock.unlock();
}
}
|
java
|
public boolean isRunning(final ProcessorGraphNode processorGraphNode) {
this.processorLock.lock();
try {
return this.runningProcessors.containsKey(processorGraphNode.getProcessor());
} finally {
this.processorLock.unlock();
}
}
|
[
"public",
"boolean",
"isRunning",
"(",
"final",
"ProcessorGraphNode",
"processorGraphNode",
")",
"{",
"this",
".",
"processorLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"return",
"this",
".",
"runningProcessors",
".",
"containsKey",
"(",
"processorGraphNode",
".",
"getProcessor",
"(",
")",
")",
";",
"}",
"finally",
"{",
"this",
".",
"processorLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Return true if the processor of the node is currently being executed.
@param processorGraphNode the node to test.
|
[
"Return",
"true",
"if",
"the",
"processor",
"of",
"the",
"node",
"is",
"currently",
"being",
"executed",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java#L85-L92
|
159,487 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java
|
ProcessorExecutionContext.isFinished
|
public boolean isFinished(final ProcessorGraphNode processorGraphNode) {
this.processorLock.lock();
try {
return this.executedProcessors.containsKey(processorGraphNode.getProcessor());
} finally {
this.processorLock.unlock();
}
}
|
java
|
public boolean isFinished(final ProcessorGraphNode processorGraphNode) {
this.processorLock.lock();
try {
return this.executedProcessors.containsKey(processorGraphNode.getProcessor());
} finally {
this.processorLock.unlock();
}
}
|
[
"public",
"boolean",
"isFinished",
"(",
"final",
"ProcessorGraphNode",
"processorGraphNode",
")",
"{",
"this",
".",
"processorLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"return",
"this",
".",
"executedProcessors",
".",
"containsKey",
"(",
"processorGraphNode",
".",
"getProcessor",
"(",
")",
")",
";",
"}",
"finally",
"{",
"this",
".",
"processorLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Return true if the processor of the node has previously been executed.
@param processorGraphNode the node to test.
|
[
"Return",
"true",
"if",
"the",
"processor",
"of",
"the",
"node",
"has",
"previously",
"been",
"executed",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java#L99-L106
|
159,488 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java
|
ProcessorExecutionContext.finished
|
public void finished(final ProcessorGraphNode processorGraphNode) {
this.processorLock.lock();
try {
this.runningProcessors.remove(processorGraphNode.getProcessor());
this.executedProcessors.put(processorGraphNode.getProcessor(), null);
} finally {
this.processorLock.unlock();
}
}
|
java
|
public void finished(final ProcessorGraphNode processorGraphNode) {
this.processorLock.lock();
try {
this.runningProcessors.remove(processorGraphNode.getProcessor());
this.executedProcessors.put(processorGraphNode.getProcessor(), null);
} finally {
this.processorLock.unlock();
}
}
|
[
"public",
"void",
"finished",
"(",
"final",
"ProcessorGraphNode",
"processorGraphNode",
")",
"{",
"this",
".",
"processorLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"this",
".",
"runningProcessors",
".",
"remove",
"(",
"processorGraphNode",
".",
"getProcessor",
"(",
")",
")",
";",
"this",
".",
"executedProcessors",
".",
"put",
"(",
"processorGraphNode",
".",
"getProcessor",
"(",
")",
",",
"null",
")",
";",
"}",
"finally",
"{",
"this",
".",
"processorLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Flag that the processor has completed execution.
@param processorGraphNode the node that has finished.
|
[
"Flag",
"that",
"the",
"processor",
"has",
"completed",
"execution",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java#L113-L121
|
159,489 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarDrawer.java
|
ScalebarDrawer.draw
|
public final void draw() {
AffineTransform transform = new AffineTransform(this.transform);
transform.concatenate(getAlignmentTransform());
// draw the background box
this.graphics2d.setTransform(transform);
this.graphics2d.setColor(this.params.getBackgroundColor());
this.graphics2d.fillRect(0, 0, this.settings.getSize().width, this.settings.getSize().height);
//draw the labels
this.graphics2d.setColor(this.params.getFontColor());
drawLabels(transform, this.params.getOrientation(), this.params.getLabelRotation());
//sets the transformation for drawing the bar and do it
final AffineTransform lineTransform = new AffineTransform(transform);
setLineTranslate(lineTransform);
if (this.params.getOrientation() == Orientation.VERTICAL_LABELS_LEFT ||
this.params.getOrientation() == Orientation.VERTICAL_LABELS_RIGHT) {
final AffineTransform rotate = AffineTransform.getQuadrantRotateInstance(1);
lineTransform.concatenate(rotate);
}
this.graphics2d.setTransform(lineTransform);
this.graphics2d.setStroke(new BasicStroke(this.settings.getLineWidth()));
this.graphics2d.setColor(this.params.getColor());
drawBar();
}
|
java
|
public final void draw() {
AffineTransform transform = new AffineTransform(this.transform);
transform.concatenate(getAlignmentTransform());
// draw the background box
this.graphics2d.setTransform(transform);
this.graphics2d.setColor(this.params.getBackgroundColor());
this.graphics2d.fillRect(0, 0, this.settings.getSize().width, this.settings.getSize().height);
//draw the labels
this.graphics2d.setColor(this.params.getFontColor());
drawLabels(transform, this.params.getOrientation(), this.params.getLabelRotation());
//sets the transformation for drawing the bar and do it
final AffineTransform lineTransform = new AffineTransform(transform);
setLineTranslate(lineTransform);
if (this.params.getOrientation() == Orientation.VERTICAL_LABELS_LEFT ||
this.params.getOrientation() == Orientation.VERTICAL_LABELS_RIGHT) {
final AffineTransform rotate = AffineTransform.getQuadrantRotateInstance(1);
lineTransform.concatenate(rotate);
}
this.graphics2d.setTransform(lineTransform);
this.graphics2d.setStroke(new BasicStroke(this.settings.getLineWidth()));
this.graphics2d.setColor(this.params.getColor());
drawBar();
}
|
[
"public",
"final",
"void",
"draw",
"(",
")",
"{",
"AffineTransform",
"transform",
"=",
"new",
"AffineTransform",
"(",
"this",
".",
"transform",
")",
";",
"transform",
".",
"concatenate",
"(",
"getAlignmentTransform",
"(",
")",
")",
";",
"// draw the background box",
"this",
".",
"graphics2d",
".",
"setTransform",
"(",
"transform",
")",
";",
"this",
".",
"graphics2d",
".",
"setColor",
"(",
"this",
".",
"params",
".",
"getBackgroundColor",
"(",
")",
")",
";",
"this",
".",
"graphics2d",
".",
"fillRect",
"(",
"0",
",",
"0",
",",
"this",
".",
"settings",
".",
"getSize",
"(",
")",
".",
"width",
",",
"this",
".",
"settings",
".",
"getSize",
"(",
")",
".",
"height",
")",
";",
"//draw the labels",
"this",
".",
"graphics2d",
".",
"setColor",
"(",
"this",
".",
"params",
".",
"getFontColor",
"(",
")",
")",
";",
"drawLabels",
"(",
"transform",
",",
"this",
".",
"params",
".",
"getOrientation",
"(",
")",
",",
"this",
".",
"params",
".",
"getLabelRotation",
"(",
")",
")",
";",
"//sets the transformation for drawing the bar and do it",
"final",
"AffineTransform",
"lineTransform",
"=",
"new",
"AffineTransform",
"(",
"transform",
")",
";",
"setLineTranslate",
"(",
"lineTransform",
")",
";",
"if",
"(",
"this",
".",
"params",
".",
"getOrientation",
"(",
")",
"==",
"Orientation",
".",
"VERTICAL_LABELS_LEFT",
"||",
"this",
".",
"params",
".",
"getOrientation",
"(",
")",
"==",
"Orientation",
".",
"VERTICAL_LABELS_RIGHT",
")",
"{",
"final",
"AffineTransform",
"rotate",
"=",
"AffineTransform",
".",
"getQuadrantRotateInstance",
"(",
"1",
")",
";",
"lineTransform",
".",
"concatenate",
"(",
"rotate",
")",
";",
"}",
"this",
".",
"graphics2d",
".",
"setTransform",
"(",
"lineTransform",
")",
";",
"this",
".",
"graphics2d",
".",
"setStroke",
"(",
"new",
"BasicStroke",
"(",
"this",
".",
"settings",
".",
"getLineWidth",
"(",
")",
")",
")",
";",
"this",
".",
"graphics2d",
".",
"setColor",
"(",
"this",
".",
"params",
".",
"getColor",
"(",
")",
")",
";",
"drawBar",
"(",
")",
";",
"}"
] |
Start the rendering of the scalebar.
|
[
"Start",
"the",
"rendering",
"of",
"the",
"scalebar",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarDrawer.java#L43-L70
|
159,490 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarDrawer.java
|
ScalebarDrawer.getAlignmentTransform
|
private AffineTransform getAlignmentTransform() {
final int offsetX;
switch (this.settings.getParams().getAlign()) {
case LEFT:
offsetX = 0;
break;
case RIGHT:
offsetX = this.settings.getMaxSize().width - this.settings.getSize().width;
break;
case CENTER:
default:
offsetX = (int) Math
.floor(this.settings.getMaxSize().width / 2.0 - this.settings.getSize().width / 2.0);
break;
}
final int offsetY;
switch (this.settings.getParams().getVerticalAlign()) {
case TOP:
offsetY = 0;
break;
case BOTTOM:
offsetY = this.settings.getMaxSize().height - this.settings.getSize().height;
break;
case MIDDLE:
default:
offsetY = (int) Math.floor(this.settings.getMaxSize().height / 2.0 -
this.settings.getSize().height / 2.0);
break;
}
return AffineTransform.getTranslateInstance(Math.round(offsetX), Math.round(offsetY));
}
|
java
|
private AffineTransform getAlignmentTransform() {
final int offsetX;
switch (this.settings.getParams().getAlign()) {
case LEFT:
offsetX = 0;
break;
case RIGHT:
offsetX = this.settings.getMaxSize().width - this.settings.getSize().width;
break;
case CENTER:
default:
offsetX = (int) Math
.floor(this.settings.getMaxSize().width / 2.0 - this.settings.getSize().width / 2.0);
break;
}
final int offsetY;
switch (this.settings.getParams().getVerticalAlign()) {
case TOP:
offsetY = 0;
break;
case BOTTOM:
offsetY = this.settings.getMaxSize().height - this.settings.getSize().height;
break;
case MIDDLE:
default:
offsetY = (int) Math.floor(this.settings.getMaxSize().height / 2.0 -
this.settings.getSize().height / 2.0);
break;
}
return AffineTransform.getTranslateInstance(Math.round(offsetX), Math.round(offsetY));
}
|
[
"private",
"AffineTransform",
"getAlignmentTransform",
"(",
")",
"{",
"final",
"int",
"offsetX",
";",
"switch",
"(",
"this",
".",
"settings",
".",
"getParams",
"(",
")",
".",
"getAlign",
"(",
")",
")",
"{",
"case",
"LEFT",
":",
"offsetX",
"=",
"0",
";",
"break",
";",
"case",
"RIGHT",
":",
"offsetX",
"=",
"this",
".",
"settings",
".",
"getMaxSize",
"(",
")",
".",
"width",
"-",
"this",
".",
"settings",
".",
"getSize",
"(",
")",
".",
"width",
";",
"break",
";",
"case",
"CENTER",
":",
"default",
":",
"offsetX",
"=",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"this",
".",
"settings",
".",
"getMaxSize",
"(",
")",
".",
"width",
"/",
"2.0",
"-",
"this",
".",
"settings",
".",
"getSize",
"(",
")",
".",
"width",
"/",
"2.0",
")",
";",
"break",
";",
"}",
"final",
"int",
"offsetY",
";",
"switch",
"(",
"this",
".",
"settings",
".",
"getParams",
"(",
")",
".",
"getVerticalAlign",
"(",
")",
")",
"{",
"case",
"TOP",
":",
"offsetY",
"=",
"0",
";",
"break",
";",
"case",
"BOTTOM",
":",
"offsetY",
"=",
"this",
".",
"settings",
".",
"getMaxSize",
"(",
")",
".",
"height",
"-",
"this",
".",
"settings",
".",
"getSize",
"(",
")",
".",
"height",
";",
"break",
";",
"case",
"MIDDLE",
":",
"default",
":",
"offsetY",
"=",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"this",
".",
"settings",
".",
"getMaxSize",
"(",
")",
".",
"height",
"/",
"2.0",
"-",
"this",
".",
"settings",
".",
"getSize",
"(",
")",
".",
"height",
"/",
"2.0",
")",
";",
"break",
";",
"}",
"return",
"AffineTransform",
".",
"getTranslateInstance",
"(",
"Math",
".",
"round",
"(",
"offsetX",
")",
",",
"Math",
".",
"round",
"(",
"offsetY",
")",
")",
";",
"}"
] |
Create a transformation which takes the alignment settings into account.
|
[
"Create",
"a",
"transformation",
"which",
"takes",
"the",
"alignment",
"settings",
"into",
"account",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarDrawer.java#L75-L107
|
159,491 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/map/geotools/AbstractGeotoolsLayer.java
|
AbstractGeotoolsLayer.getLayerTransformer
|
protected final MapfishMapContext getLayerTransformer(final MapfishMapContext transformer) {
MapfishMapContext layerTransformer = transformer;
if (!FloatingPointUtil.equals(transformer.getRotation(), 0.0) && !this.supportsNativeRotation()) {
// if a rotation is set and the rotation can not be handled natively
// by the layer, we have to adjust the bounds and map size
layerTransformer = new MapfishMapContext(
transformer,
transformer.getRotatedBoundsAdjustedForPreciseRotatedMapSize(),
transformer.getRotatedMapSize(),
0,
transformer.getDPI(),
transformer.isForceLongitudeFirst(),
transformer.isDpiSensitiveStyle());
}
return layerTransformer;
}
|
java
|
protected final MapfishMapContext getLayerTransformer(final MapfishMapContext transformer) {
MapfishMapContext layerTransformer = transformer;
if (!FloatingPointUtil.equals(transformer.getRotation(), 0.0) && !this.supportsNativeRotation()) {
// if a rotation is set and the rotation can not be handled natively
// by the layer, we have to adjust the bounds and map size
layerTransformer = new MapfishMapContext(
transformer,
transformer.getRotatedBoundsAdjustedForPreciseRotatedMapSize(),
transformer.getRotatedMapSize(),
0,
transformer.getDPI(),
transformer.isForceLongitudeFirst(),
transformer.isDpiSensitiveStyle());
}
return layerTransformer;
}
|
[
"protected",
"final",
"MapfishMapContext",
"getLayerTransformer",
"(",
"final",
"MapfishMapContext",
"transformer",
")",
"{",
"MapfishMapContext",
"layerTransformer",
"=",
"transformer",
";",
"if",
"(",
"!",
"FloatingPointUtil",
".",
"equals",
"(",
"transformer",
".",
"getRotation",
"(",
")",
",",
"0.0",
")",
"&&",
"!",
"this",
".",
"supportsNativeRotation",
"(",
")",
")",
"{",
"// if a rotation is set and the rotation can not be handled natively",
"// by the layer, we have to adjust the bounds and map size",
"layerTransformer",
"=",
"new",
"MapfishMapContext",
"(",
"transformer",
",",
"transformer",
".",
"getRotatedBoundsAdjustedForPreciseRotatedMapSize",
"(",
")",
",",
"transformer",
".",
"getRotatedMapSize",
"(",
")",
",",
"0",
",",
"transformer",
".",
"getDPI",
"(",
")",
",",
"transformer",
".",
"isForceLongitudeFirst",
"(",
")",
",",
"transformer",
".",
"isDpiSensitiveStyle",
"(",
")",
")",
";",
"}",
"return",
"layerTransformer",
";",
"}"
] |
If the layer transformer has not been prepared yet, do it.
@param transformer the transformer
|
[
"If",
"the",
"layer",
"transformer",
"has",
"not",
"been",
"prepared",
"yet",
"do",
"it",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/AbstractGeotoolsLayer.java#L186-L203
|
159,492 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/output/ValuesLogger.java
|
ValuesLogger.log
|
public static void log(final String templateName, final Template template, final Values values) {
new ValuesLogger().doLog(templateName, template, values);
}
|
java
|
public static void log(final String templateName, final Template template, final Values values) {
new ValuesLogger().doLog(templateName, template, values);
}
|
[
"public",
"static",
"void",
"log",
"(",
"final",
"String",
"templateName",
",",
"final",
"Template",
"template",
",",
"final",
"Values",
"values",
")",
"{",
"new",
"ValuesLogger",
"(",
")",
".",
"doLog",
"(",
"templateName",
",",
"template",
",",
"values",
")",
";",
"}"
] |
Log the values for the provided template.
@param templateName the name of the template the values came from
@param template the template object
@param values the resultant values
|
[
"Log",
"the",
"values",
"for",
"the",
"provided",
"template",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/output/ValuesLogger.java#L34-L36
|
159,493 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java
|
PrintJob.getFileName
|
private static String getFileName(@Nullable final MapPrinter mapPrinter, final PJsonObject spec) {
String fileName = spec.optString(Constants.OUTPUT_FILENAME_KEY);
if (fileName != null) {
return fileName;
}
if (mapPrinter != null) {
final Configuration config = mapPrinter.getConfiguration();
final String templateName = spec.getString(Constants.JSON_LAYOUT_KEY);
final Template template = config.getTemplate(templateName);
if (template.getOutputFilename() != null) {
return template.getOutputFilename();
}
if (config.getOutputFilename() != null) {
return config.getOutputFilename();
}
}
return "mapfish-print-report";
}
|
java
|
private static String getFileName(@Nullable final MapPrinter mapPrinter, final PJsonObject spec) {
String fileName = spec.optString(Constants.OUTPUT_FILENAME_KEY);
if (fileName != null) {
return fileName;
}
if (mapPrinter != null) {
final Configuration config = mapPrinter.getConfiguration();
final String templateName = spec.getString(Constants.JSON_LAYOUT_KEY);
final Template template = config.getTemplate(templateName);
if (template.getOutputFilename() != null) {
return template.getOutputFilename();
}
if (config.getOutputFilename() != null) {
return config.getOutputFilename();
}
}
return "mapfish-print-report";
}
|
[
"private",
"static",
"String",
"getFileName",
"(",
"@",
"Nullable",
"final",
"MapPrinter",
"mapPrinter",
",",
"final",
"PJsonObject",
"spec",
")",
"{",
"String",
"fileName",
"=",
"spec",
".",
"optString",
"(",
"Constants",
".",
"OUTPUT_FILENAME_KEY",
")",
";",
"if",
"(",
"fileName",
"!=",
"null",
")",
"{",
"return",
"fileName",
";",
"}",
"if",
"(",
"mapPrinter",
"!=",
"null",
")",
"{",
"final",
"Configuration",
"config",
"=",
"mapPrinter",
".",
"getConfiguration",
"(",
")",
";",
"final",
"String",
"templateName",
"=",
"spec",
".",
"getString",
"(",
"Constants",
".",
"JSON_LAYOUT_KEY",
")",
";",
"final",
"Template",
"template",
"=",
"config",
".",
"getTemplate",
"(",
"templateName",
")",
";",
"if",
"(",
"template",
".",
"getOutputFilename",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"template",
".",
"getOutputFilename",
"(",
")",
";",
"}",
"if",
"(",
"config",
".",
"getOutputFilename",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"config",
".",
"getOutputFilename",
"(",
")",
";",
"}",
"}",
"return",
"\"mapfish-print-report\"",
";",
"}"
] |
Read filename from spec.
|
[
"Read",
"filename",
"from",
"spec",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java#L72-L93
|
159,494 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java
|
PrintJob.withOpenOutputStream
|
protected PrintResult withOpenOutputStream(final PrintAction function) throws Exception {
final File reportFile = getReportFile();
final Processor.ExecutionContext executionContext;
try (FileOutputStream out = new FileOutputStream(reportFile);
BufferedOutputStream bout = new BufferedOutputStream(out)) {
executionContext = function.run(bout);
}
return new PrintResult(reportFile.length(), executionContext);
}
|
java
|
protected PrintResult withOpenOutputStream(final PrintAction function) throws Exception {
final File reportFile = getReportFile();
final Processor.ExecutionContext executionContext;
try (FileOutputStream out = new FileOutputStream(reportFile);
BufferedOutputStream bout = new BufferedOutputStream(out)) {
executionContext = function.run(bout);
}
return new PrintResult(reportFile.length(), executionContext);
}
|
[
"protected",
"PrintResult",
"withOpenOutputStream",
"(",
"final",
"PrintAction",
"function",
")",
"throws",
"Exception",
"{",
"final",
"File",
"reportFile",
"=",
"getReportFile",
"(",
")",
";",
"final",
"Processor",
".",
"ExecutionContext",
"executionContext",
";",
"try",
"(",
"FileOutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"reportFile",
")",
";",
"BufferedOutputStream",
"bout",
"=",
"new",
"BufferedOutputStream",
"(",
"out",
")",
")",
"{",
"executionContext",
"=",
"function",
".",
"run",
"(",
"bout",
")",
";",
"}",
"return",
"new",
"PrintResult",
"(",
"reportFile",
".",
"length",
"(",
")",
",",
"executionContext",
")",
";",
"}"
] |
Open an OutputStream and execute the function using the OutputStream.
@param function the function to execute
@return the URI and the file size
|
[
"Open",
"an",
"OutputStream",
"and",
"execute",
"the",
"function",
"using",
"the",
"OutputStream",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java#L113-L121
|
159,495 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/map/geotools/grid/PointGridStyle.java
|
PointGridStyle.get
|
static Style get(final GridParam params) {
final StyleBuilder builder = new StyleBuilder();
final Symbolizer pointSymbolizer = crossSymbolizer("shape://plus", builder, CROSS_SIZE,
params.gridColor);
final Style style = builder.createStyle(pointSymbolizer);
final List<Symbolizer> symbolizers = style.featureTypeStyles().get(0).rules().get(0).symbolizers();
if (params.haloRadius > 0.0) {
Symbolizer halo = crossSymbolizer("cross", builder, CROSS_SIZE + params.haloRadius * 2.0,
params.haloColor);
symbolizers.add(0, halo);
}
return style;
}
|
java
|
static Style get(final GridParam params) {
final StyleBuilder builder = new StyleBuilder();
final Symbolizer pointSymbolizer = crossSymbolizer("shape://plus", builder, CROSS_SIZE,
params.gridColor);
final Style style = builder.createStyle(pointSymbolizer);
final List<Symbolizer> symbolizers = style.featureTypeStyles().get(0).rules().get(0).symbolizers();
if (params.haloRadius > 0.0) {
Symbolizer halo = crossSymbolizer("cross", builder, CROSS_SIZE + params.haloRadius * 2.0,
params.haloColor);
symbolizers.add(0, halo);
}
return style;
}
|
[
"static",
"Style",
"get",
"(",
"final",
"GridParam",
"params",
")",
"{",
"final",
"StyleBuilder",
"builder",
"=",
"new",
"StyleBuilder",
"(",
")",
";",
"final",
"Symbolizer",
"pointSymbolizer",
"=",
"crossSymbolizer",
"(",
"\"shape://plus\"",
",",
"builder",
",",
"CROSS_SIZE",
",",
"params",
".",
"gridColor",
")",
";",
"final",
"Style",
"style",
"=",
"builder",
".",
"createStyle",
"(",
"pointSymbolizer",
")",
";",
"final",
"List",
"<",
"Symbolizer",
">",
"symbolizers",
"=",
"style",
".",
"featureTypeStyles",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"rules",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"symbolizers",
"(",
")",
";",
"if",
"(",
"params",
".",
"haloRadius",
">",
"0.0",
")",
"{",
"Symbolizer",
"halo",
"=",
"crossSymbolizer",
"(",
"\"cross\"",
",",
"builder",
",",
"CROSS_SIZE",
"+",
"params",
".",
"haloRadius",
"*",
"2.0",
",",
"params",
".",
"haloColor",
")",
";",
"symbolizers",
".",
"add",
"(",
"0",
",",
"halo",
")",
";",
"}",
"return",
"style",
";",
"}"
] |
Create the Grid Point style.
|
[
"Create",
"the",
"Grid",
"Point",
"style",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/PointGridStyle.java#L27-L42
|
159,496 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/attribute/map/ZoomLevels.java
|
ZoomLevels.get
|
public Scale get(final int index, final DistanceUnit unit) {
return new Scale(this.scaleDenominators[index], unit, PDF_DPI);
}
|
java
|
public Scale get(final int index, final DistanceUnit unit) {
return new Scale(this.scaleDenominators[index], unit, PDF_DPI);
}
|
[
"public",
"Scale",
"get",
"(",
"final",
"int",
"index",
",",
"final",
"DistanceUnit",
"unit",
")",
"{",
"return",
"new",
"Scale",
"(",
"this",
".",
"scaleDenominators",
"[",
"index",
"]",
",",
"unit",
",",
"PDF_DPI",
")",
";",
"}"
] |
Get the scale at the given index.
@param index the index of the zoom level to access.
@param unit the unit.
|
[
"Get",
"the",
"scale",
"at",
"the",
"given",
"index",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/ZoomLevels.java#L76-L78
|
159,497 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/attribute/map/ZoomLevels.java
|
ZoomLevels.getScaleDenominators
|
public double[] getScaleDenominators() {
double[] dest = new double[this.scaleDenominators.length];
System.arraycopy(this.scaleDenominators, 0, dest, 0, this.scaleDenominators.length);
return dest;
}
|
java
|
public double[] getScaleDenominators() {
double[] dest = new double[this.scaleDenominators.length];
System.arraycopy(this.scaleDenominators, 0, dest, 0, this.scaleDenominators.length);
return dest;
}
|
[
"public",
"double",
"[",
"]",
"getScaleDenominators",
"(",
")",
"{",
"double",
"[",
"]",
"dest",
"=",
"new",
"double",
"[",
"this",
".",
"scaleDenominators",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"scaleDenominators",
",",
"0",
",",
"dest",
",",
"0",
",",
"this",
".",
"scaleDenominators",
".",
"length",
")",
";",
"return",
"dest",
";",
"}"
] |
Return a copy of the zoom level scale denominators. Scales are sorted greatest to least.
|
[
"Return",
"a",
"copy",
"of",
"the",
"zoom",
"level",
"scale",
"denominators",
".",
"Scales",
"are",
"sorted",
"greatest",
"to",
"least",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/ZoomLevels.java#L117-L121
|
159,498 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java
|
FeaturesParser.autoTreat
|
public final SimpleFeatureCollection autoTreat(final Template template, final String features)
throws IOException {
SimpleFeatureCollection featuresCollection = treatStringAsURL(template, features);
if (featuresCollection == null) {
featuresCollection = treatStringAsGeoJson(features);
}
return featuresCollection;
}
|
java
|
public final SimpleFeatureCollection autoTreat(final Template template, final String features)
throws IOException {
SimpleFeatureCollection featuresCollection = treatStringAsURL(template, features);
if (featuresCollection == null) {
featuresCollection = treatStringAsGeoJson(features);
}
return featuresCollection;
}
|
[
"public",
"final",
"SimpleFeatureCollection",
"autoTreat",
"(",
"final",
"Template",
"template",
",",
"final",
"String",
"features",
")",
"throws",
"IOException",
"{",
"SimpleFeatureCollection",
"featuresCollection",
"=",
"treatStringAsURL",
"(",
"template",
",",
"features",
")",
";",
"if",
"(",
"featuresCollection",
"==",
"null",
")",
"{",
"featuresCollection",
"=",
"treatStringAsGeoJson",
"(",
"features",
")",
";",
"}",
"return",
"featuresCollection",
";",
"}"
] |
Get the features collection from a GeoJson inline string or URL.
@param template the template
@param features what to parse
@return the feature collection
@throws IOException
|
[
"Get",
"the",
"features",
"collection",
"from",
"a",
"GeoJson",
"inline",
"string",
"or",
"URL",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java#L151-L158
|
159,499 |
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java
|
FeaturesParser.treatStringAsURL
|
public final SimpleFeatureCollection treatStringAsURL(final Template template, final String geoJsonUrl)
throws IOException {
URL url;
try {
url = FileUtils.testForLegalFileUrl(template.getConfiguration(), new URL(geoJsonUrl));
} catch (MalformedURLException e) {
return null;
}
final String geojsonString;
if (url.getProtocol().equalsIgnoreCase("file")) {
geojsonString = IOUtils.toString(url, Constants.DEFAULT_CHARSET.name());
} else {
geojsonString = URIUtils.toString(this.httpRequestFactory, url);
}
return treatStringAsGeoJson(geojsonString);
}
|
java
|
public final SimpleFeatureCollection treatStringAsURL(final Template template, final String geoJsonUrl)
throws IOException {
URL url;
try {
url = FileUtils.testForLegalFileUrl(template.getConfiguration(), new URL(geoJsonUrl));
} catch (MalformedURLException e) {
return null;
}
final String geojsonString;
if (url.getProtocol().equalsIgnoreCase("file")) {
geojsonString = IOUtils.toString(url, Constants.DEFAULT_CHARSET.name());
} else {
geojsonString = URIUtils.toString(this.httpRequestFactory, url);
}
return treatStringAsGeoJson(geojsonString);
}
|
[
"public",
"final",
"SimpleFeatureCollection",
"treatStringAsURL",
"(",
"final",
"Template",
"template",
",",
"final",
"String",
"geoJsonUrl",
")",
"throws",
"IOException",
"{",
"URL",
"url",
";",
"try",
"{",
"url",
"=",
"FileUtils",
".",
"testForLegalFileUrl",
"(",
"template",
".",
"getConfiguration",
"(",
")",
",",
"new",
"URL",
"(",
"geoJsonUrl",
")",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"final",
"String",
"geojsonString",
";",
"if",
"(",
"url",
".",
"getProtocol",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"\"file\"",
")",
")",
"{",
"geojsonString",
"=",
"IOUtils",
".",
"toString",
"(",
"url",
",",
"Constants",
".",
"DEFAULT_CHARSET",
".",
"name",
"(",
")",
")",
";",
"}",
"else",
"{",
"geojsonString",
"=",
"URIUtils",
".",
"toString",
"(",
"this",
".",
"httpRequestFactory",
",",
"url",
")",
";",
"}",
"return",
"treatStringAsGeoJson",
"(",
"geojsonString",
")",
";",
"}"
] |
Get the features collection from a GeoJson URL.
@param template the template
@param geoJsonUrl what to parse
@return the feature collection
|
[
"Get",
"the",
"features",
"collection",
"from",
"a",
"GeoJson",
"URL",
"."
] |
25a452cb39f592bd8a53b20db1037703898e1e22
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java#L167-L184
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.