Commit ab644367 authored by Drahomír Karchňák's avatar Drahomír Karchňák

Added variants for other languages.

parent d029ce1e
......@@ -24,6 +24,39 @@ public class ForumBannerGenerator extends AbstractImageGenerator {
private Font primaryFont = null;
private Font secondaryFont = null;
private enum AdditionalValuePositionMapping {
EN("en", 151, 432),
CS("cs", 130, 394),
DE("de", 128, 398);
private static final AdditionalValuePositionMapping FALLBACK = AdditionalValuePositionMapping.EN;
private final String lang;
private final int firstColumnX, secondColumnX;
AdditionalValuePositionMapping(String lang, int firstColumnX, int secondColumnX) {
this.lang = lang;
this.firstColumnX = firstColumnX;
this.secondColumnX = secondColumnX;
}
protected static int getFirstColumnX(String lang) {
for(AdditionalValuePositionMapping item : values()) {
if(item.lang.equals(lang)) return item.firstColumnX;
}
return FALLBACK.firstColumnX;
}
protected static int getSecondColumnX(String lang) {
for(AdditionalValuePositionMapping item : values()) {
if(item.lang.equals(lang)) return item.secondColumnX;
}
return FALLBACK.secondColumnX;
}
}
@Override
public BufferedImage generateImage(String lang, double upload, double download, double ping, String isp, String typ, String signal, String os, String formattedTime, String formattedDate) throws IOException {
//Initial setup of final image
......@@ -38,10 +71,10 @@ public class ForumBannerGenerator extends AbstractImageGenerator {
renderMainValue(formatNumber(upload, lang), 280, 132, finalImageGraphics);
renderMainValue(formatNumber(ping, lang), 469, 132, finalImageGraphics);
renderAdditionalValue(isp, 151, 246, finalImageGraphics);
renderAdditionalValue(typ, 151, 278, finalImageGraphics);
renderAdditionalValue(signal, 432, 246, finalImageGraphics);
renderAdditionalValue(os, 432, 278, finalImageGraphics);
renderAdditionalValue(isp, AdditionalValuePositionMapping.getFirstColumnX(lang), 246, finalImageGraphics);
renderAdditionalValue(typ, AdditionalValuePositionMapping.getFirstColumnX(lang), 278, finalImageGraphics);
renderAdditionalValue(signal, AdditionalValuePositionMapping.getSecondColumnX(lang), 246, finalImageGraphics);
renderAdditionalValue(os, AdditionalValuePositionMapping.getSecondColumnX(lang), 278, finalImageGraphics);
renderTimeDateValue(formattedTime, 550, 16, finalImageGraphics);
renderTimeDateValue(formattedDate, 550, 40, finalImageGraphics);
......
......@@ -50,11 +50,11 @@ import at.alladin.rmbt.statisticServer.ServerResource;
public class ImageExport extends ServerResource {
enum TimeDateFormatting {
en("en", "dd-MM-yyyy", "HH:mm"),
de("de", "dd.MM.yyyy", "HH:mm"),
cs("cs", "dd.MM.yyyy", "HH:mm");
EN("en", "dd-MM-yyyy", "HH:mm"),
DE("de", "dd.MM.yyyy", "HH:mm"),
CS("cs", "dd.MM.yyyy", "HH:mm");
private static final TimeDateFormatting FALLBACK = en;
private static final TimeDateFormatting FALLBACK = TimeDateFormatting.EN;
private final String lang;
private final String date;
......@@ -193,11 +193,6 @@ public class ImageExport extends ServerResource {
return new StringRepresentation("invalid uuid");
}
}
public class ForumBannerSmallGenerator extends AbstractImageGenerator {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment