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

comments on submaps are centered correctly

parent a3543194
......@@ -15,7 +15,6 @@ 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
......@@ -29,7 +28,7 @@ public class ImageGenerators {
* Default class logger.
*/
@SuppressWarnings("unused")
private final Logger logger = Logger.getLogger(ImageGenerators.class);
private final Logger logger = Logger.getLogger(ImageGenerators.class);
/**
* List of {@link AbstractImageGenerator} classes available in the system.
*/
......@@ -39,7 +38,7 @@ public class ImageGenerators {
* List of all possible objects extending {@link AbstractImageGenerator}
* interface that are available in the system.
*/
private List<AbstractImageGenerator> generatorInstances = null;
private List<AbstractImageGenerator> generatorInstances = null;
/**
* Default constructor.
......@@ -51,17 +50,15 @@ public class ImageGenerators {
AbstractImageGenerator.Params params = new AbstractImageGenerator.Params().//
model(model).//
width(1).//
minColor(Color.WHITE).
maxColor(Color.WHITE).
height(1);
minColor(Color.WHITE).maxColor(Color.WHITE).height(1);
generatorInstances = new ArrayList<>();
generatorInstances.add(new PngImageGenerator(params));
generatorInstances.add(new PdfImageGenerator(params));
// generatorInstances.add(new SvgImageGenerator(params));
// generatorInstances.add(new JpgImageGenerator(params));
// generatorInstances.add(new SvgImageGenerator(params));
// generatorInstances.add(new JpgImageGenerator(params));
for (AbstractImageGenerator abstractImageGenerator : generatorInstances) {
availableGenerators.add(new Pair<String, Class<? extends AbstractImageGenerator>>(abstractImageGenerator.getFormatName(), abstractImageGenerator
.getClass()));
availableGenerators
.add(new Pair<String, Class<? extends AbstractImageGenerator>>(abstractImageGenerator.getFormatName(), abstractImageGenerator.getClass()));
}
} catch (DrawingException e) {
......
......@@ -12,11 +12,11 @@ import lcsb.mapviewer.model.map.Comment;
*/
public class CommentView extends AbstractView<Comment> implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/**
* Author of the comment.
......@@ -63,7 +63,10 @@ public class CommentView extends AbstractView<Comment> implements Serializable {
* details).
*/
private String zoom;
/**
* Submap on which comment was placed.
*/
private String submap;
/**
......@@ -279,7 +282,8 @@ public class CommentView extends AbstractView<Comment> implements Serializable {
}
/**
* @param submap the submap to set
* @param submap
* the submap to set
* @see #submap
*/
public void setSubmap(String submap) {
......
......@@ -7,6 +7,7 @@ import org.apache.log4j.Logger;
import com.google.gson.Gson;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.Comment;
import lcsb.mapviewer.model.map.model.Model;
......@@ -50,15 +51,22 @@ public class CommentViewFactory extends AbstractViewFactory<Comment, CommentView
return result;
}
result.setAuthor((comment.getName()));
result.setContent((comment.getContent()));
result.setEmail((comment.getEmail()));
result.setAuthor(comment.getName());
result.setContent(comment.getContent());
result.setEmail(comment.getEmail());
result.setPinned(comment.isPinned());
if (comment.isDeleted()) {
result.setRemoved("YES (" + comment.getRemoveReason() + ")");
} else {
result.setRemoved("NO");
}
if (comment.getSubmodelData() != null) {
result.setSubmap(comment.getSubmodelData().getId() + "");
model = model.getSubmodelById(comment.getSubmodelData().getId());
if (model == null) {
throw new InvalidArgumentException("Cannot find submodel with id: " + comment.getSubmodelData().getId());
}
}
String title = "";
Point2D coordinates = null;
......@@ -88,9 +96,6 @@ public class CommentViewFactory extends AbstractViewFactory<Comment, CommentView
}
}
result.setTitle(title);
if (comment.getSubmodelData() != null) {
result.setSubmap(comment.getSubmodelData().getId() + "");
}
if (coordinates != null) {
result.setxCoord(coordinates.getX());
result.setyCoord(coordinates.getY());
......
package lcsb.mapviewer.services.view;
import static org.junit.Assert.assertNotNull;
import lcsb.mapviewer.services.ServiceTestFunctions;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class CommentViewFactoryTest extends ServiceTestFunctions{
@Autowired
CommentViewFactory commentViewFactory;
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testCreateEmpty() throws Exception {
try {
Object object = commentViewFactory.create(null);
assertNotNull(object);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testCreateGson() throws Exception {
try {
CommentView object = commentViewFactory.create(null);
assertNotNull(commentViewFactory.createGson(object));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
package lcsb.mapviewer.services.view;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.model.map.Comment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.model.ModelSubmodelConnection;
import lcsb.mapviewer.model.map.model.SubmodelType;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.services.ServiceTestFunctions;
public class CommentViewFactoryTest extends ServiceTestFunctions {
Logger logger = Logger.getLogger(CommentViewFactoryTest.class);
@Autowired
CommentViewFactory commentViewFactory;
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testCreateEmpty() throws Exception {
try {
Object object = commentViewFactory.create(null);
assertNotNull(object);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testCreateGson() throws Exception {
try {
CommentView object = commentViewFactory.create(null);
assertNotNull(commentViewFactory.createGson(object));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testCreateOnSubmap() throws Exception {
try {
Model model = new ModelFullIndexed(null);
Model submodel = new ModelFullIndexed(null);
submodel.setId(1);
Species species = new GenericProtein("id");
species.setId(23);
species.setName("ProteinName");
submodel.addElement(species);
model.addSubmodelConnection(new ModelSubmodelConnection(submodel, SubmodelType.UNKNOWN));
Comment comment = new Comment();
comment.setModel(model);
comment.setSubmodel(submodel);
comment.setTableName(species.getClass());
comment.setTableId(species.getId());
CommentView object = commentViewFactory.create(comment,model);
assertTrue(object.getTitle().contains(species.getName()));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
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