Commit dddbd3f8 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

fix on export to image

issue #46 solved
parent f36820f1
package lcsb.mapviewer.converter.graphics;
import java.awt.Color;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
......@@ -14,6 +15,7 @@ import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.user.ConfigurationElementType;
/**
* This class is a util class containing information about all currently
......@@ -49,6 +51,8 @@ public class ImageGenerators {
AbstractImageGenerator.Params params = new AbstractImageGenerator.Params().//
model(model).//
width(1).//
minColor(Color.WHITE).
maxColor(Color.WHITE).
height(1);
generatorInstances = new ArrayList<>();
generatorInstances.add(new PngImageGenerator(params));
......
......@@ -2,6 +2,7 @@ package lcsb.mapviewer.commands;
import java.awt.Color;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.model.map.layout.ColorSchema;
/**
......@@ -34,6 +35,9 @@ public class ColorExtractor {
* {@link ColorSchema#value}
*/
public ColorExtractor(Color minColor, Color maxColor) {
if (minColor == null || maxColor == null) {
throw new InvalidArgumentException("Parameters cannot be null");
}
this.minColor = minColor;
this.maxColor = maxColor;
}
......@@ -74,4 +78,19 @@ public class ColorExtractor {
return Color.WHITE;
}
/**
* @return the minColor
* @see #minColor
*/
public Color getMinColor() {
return minColor;
}
/**
* @return the maxColor
* @see #maxColor
*/
public Color getMaxColor() {
return maxColor;
}
}
......@@ -35,6 +35,7 @@ import com.google.gson.reflect.TypeToken;
import lcsb.mapviewer.bean.MapBean.ClientMapData;
import lcsb.mapviewer.commands.ClearColorModelCommand;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.commands.ColorModelCommand;
import lcsb.mapviewer.commands.CopyCommand;
import lcsb.mapviewer.commands.SubModelCommand;
......@@ -1200,6 +1201,8 @@ public class ExportBean extends AbstractManagedBean {
scale /= 2;
}
ColorExtractor colorExtractor = userService.getColorExtractorForUser(userBean.getLoggedUser());
Params params = new Params().//
x(minX).//
y(minY).//
......@@ -1208,7 +1211,9 @@ public class ExportBean extends AbstractManagedBean {
level(level).//
nested(false).// automatically set nested view as invalid
scale(scale).//
minColor(userBean.getLoggedUser().getMinColor()).maxColor(userBean.getLoggedUser().getMaxColor()).model(colorModel);
minColor(colorExtractor.getMinColor()).//
maxColor(colorExtractor.getMaxColor()).//
model(colorModel);
List<Integer> visibleLayoutIds = deserializeIdList(visibleLayouts);
for (Integer integer : visibleLayoutIds) {
Map<Object, ColorSchema> map = getLayoutService().getElementsForLayout(colorModel, integer);
......
Supports Markdown
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