Commit 8c785c7d authored by Piotr Gawron's avatar Piotr Gawron
Browse files

class type is more specific

parent e890f8e6
......@@ -5,8 +5,9 @@ import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -685,7 +686,7 @@ public abstract class AbstractImageGenerator {
* and {@link ColorSchema} used to visualize the element.
*
*/
private List<Map<Object, ColorSchema>> visibleLayouts = new ArrayList<>();
private List<Map<BioEntity, ColorSchema>> visibleLayouts = new ArrayList<>();
/**
* Color that should be used for drawing overlays with minimum value.
......@@ -979,7 +980,7 @@ public abstract class AbstractImageGenerator {
* {@link Reaction} and {@link ColorSchema} used for coloring specific
* element
*/
public void addVisibleLayout(Map<Object, ColorSchema> map) {
public void addVisibleLayout(Map<BioEntity, ColorSchema> map) {
visibleLayouts.add(map);
}
......@@ -987,7 +988,7 @@ public abstract class AbstractImageGenerator {
* @return the visibleLayouts
* @see #visibleLayouts
*/
public List<Map<Object, ColorSchema>> getVisibleLayouts() {
public List<Map<BioEntity, ColorSchema>> getVisibleLayouts() {
return visibleLayouts;
}
......@@ -1004,7 +1005,7 @@ public abstract class AbstractImageGenerator {
*/
public List<ColorSchema> getVisibleLayoutsForElement(Object object) {
List<ColorSchema> result = new ArrayList<>();
for (Map<Object, ColorSchema> map : visibleLayouts) {
for (Map<BioEntity, ColorSchema> map : visibleLayouts) {
result.add(map.get(object));
}
return result;
......
......@@ -284,8 +284,8 @@ public class ColorModelCommand extends ModelCommand {
* @throws InvalidColorSchemaException
* thrown when more than one {@link ColorSchema} match an element
*/
public Map<Object, ColorSchema> getModifiedElements() throws InvalidColorSchemaException {
Map<Object, ColorSchema> result = new HashMap<>();
public Map<BioEntity, ColorSchema> getModifiedElements() throws InvalidColorSchemaException {
Map<BioEntity, ColorSchema> result = new HashMap<>();
List<Model> models = new ArrayList<>();
models.add(getModel());
......
......@@ -190,9 +190,9 @@ public class ColorModelCommandTest extends CommandTestFunctions {
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
Map<BioEntity, ColorSchema> map = factory.getModifiedElements();
assertEquals(2, map.size());
for (Map.Entry<Object, ColorSchema> entry : map.entrySet()) {
for (Map.Entry<BioEntity, ColorSchema> entry : map.entrySet()) {
assertTrue(entry.getKey() instanceof Element);
}
}
......@@ -210,7 +210,7 @@ public class ColorModelCommandTest extends CommandTestFunctions {
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
Map<BioEntity, ColorSchema> map = factory.getModifiedElements();
assertEquals(0, map.size());
}
......@@ -227,9 +227,9 @@ public class ColorModelCommandTest extends CommandTestFunctions {
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
Map<BioEntity, ColorSchema> map = factory.getModifiedElements();
assertEquals(1, map.size());
for (Map.Entry<Object, ColorSchema> entry : map.entrySet()) {
for (Map.Entry<BioEntity, ColorSchema> entry : map.entrySet()) {
assertTrue(entry.getKey() instanceof Reaction);
assertEquals("re1", ((Reaction) entry.getKey()).getIdReaction());
assertEquals(entry.getValue(), schema);
......@@ -358,7 +358,7 @@ public class ColorModelCommandTest extends CommandTestFunctions {
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
Map<BioEntity, ColorSchema> map = factory.getModifiedElements();
assertEquals(0, map.values().size());
}
......@@ -375,7 +375,7 @@ public class ColorModelCommandTest extends CommandTestFunctions {
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
Map<BioEntity, ColorSchema> map = factory.getModifiedElements();
assertEquals(1, map.values().size());
}
......@@ -391,7 +391,7 @@ public class ColorModelCommandTest extends CommandTestFunctions {
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
Map<BioEntity, ColorSchema> map = factory.getModifiedElements();
assertEquals(0, map.values().size());
}
......@@ -407,7 +407,7 @@ public class ColorModelCommandTest extends CommandTestFunctions {
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
Map<BioEntity, ColorSchema> map = factory.getModifiedElements();
assertEquals(1, map.values().size());
}
......@@ -421,7 +421,7 @@ public class ColorModelCommandTest extends CommandTestFunctions {
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
Map<BioEntity, ColorSchema> map = factory.getModifiedElements();
assertEquals(0, map.values().size());
}
......@@ -436,7 +436,7 @@ public class ColorModelCommandTest extends CommandTestFunctions {
schemas.add(schema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
Map<Object, ColorSchema> map = factory.getModifiedElements();
Map<BioEntity, ColorSchema> map = factory.getModifiedElements();
assertEquals(1, map.values().size());
}
......
......@@ -23,6 +23,7 @@ import lcsb.mapviewer.converter.graphics.ImageGenerators;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.cache.FileEntry;
import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.InconsistentModelException;
import lcsb.mapviewer.model.map.layout.*;
import lcsb.mapviewer.model.map.model.*;
......@@ -362,7 +363,7 @@ public class ModelRestImpl extends BaseRestImpl {
}
List<Integer> visibleLayoutIds = deserializeIdList(overlayIds);
for (Integer integer : visibleLayoutIds) {
Map<Object, ColorSchema> map = layoutService.getElementsForLayout(colorModel, integer);
Map<BioEntity, ColorSchema> map = layoutService.getElementsForLayout(colorModel, integer);
params.addVisibleLayout(map);
}
......
......@@ -367,7 +367,7 @@ public class LayoutService implements ILayoutService {
ColorModelCommand command = new ColorModelCommand(model, schemas,
new ColorExtractor(Color.BLACK, Color.BLACK, Color.BLACK));
List<Pair<Element, ColorSchema>> result = new ArrayList<>();
for (Map.Entry<Object, ColorSchema> entry : command.getModifiedElements().entrySet()) {
for (Map.Entry<BioEntity, ColorSchema> entry : command.getModifiedElements().entrySet()) {
if (entry.getKey() instanceof Element) {
result.add(new Pair<>((Element) entry.getKey(), entry.getValue()));
}
......@@ -387,7 +387,7 @@ public class LayoutService implements ILayoutService {
ColorModelCommand command = new ColorModelCommand(model, schemas,
new ColorExtractor(Color.BLACK, Color.BLACK, Color.BLACK));
List<Pair<Reaction, ColorSchema>> result = new ArrayList<>();
for (Map.Entry<Object, ColorSchema> entry : command.getModifiedElements().entrySet()) {
for (Map.Entry<BioEntity, ColorSchema> entry : command.getModifiedElements().entrySet()) {
if (entry.getKey() instanceof Reaction) {
result.add(new Pair<>((Reaction) entry.getKey(), entry.getValue()));
}
......@@ -400,7 +400,7 @@ public class LayoutService implements ILayoutService {
}
@Override
public Map<Object, ColorSchema> getElementsForLayout(Model model, Integer layoutId) {
public Map<BioEntity, ColorSchema> getElementsForLayout(Model model, Integer layoutId) {
try {
Collection<ColorSchema> schemas = createColorSchemaCollection(layoutId);
// colors here are not important
......@@ -420,7 +420,7 @@ public class LayoutService implements ILayoutService {
ColorModelCommand command = new ColorModelCommand(model, schemas,
new ColorExtractor(Color.BLACK, Color.BLACK, Color.BLACK));
for (Map.Entry<Object, ColorSchema> entry : command.getModifiedElements().entrySet()) {
for (Map.Entry<BioEntity, ColorSchema> entry : command.getModifiedElements().entrySet()) {
if (entry.getKey() instanceof Element) {
Element alias = (Element) entry.getKey();
if (id.equals(alias.getId())) {
......@@ -442,7 +442,7 @@ public class LayoutService implements ILayoutService {
ColorModelCommand command = new ColorModelCommand(model, schemas,
new ColorExtractor(Color.BLACK, Color.BLACK, Color.BLACK));
for (Map.Entry<Object, ColorSchema> entry : command.getModifiedElements().entrySet()) {
for (Map.Entry<BioEntity, ColorSchema> entry : command.getModifiedElements().entrySet()) {
if (entry.getKey() instanceof Reaction) {
Reaction alias = (Reaction) entry.getKey();
if (id.equals(alias.getId())) {
......
......@@ -7,6 +7,7 @@ import java.util.Map;
import lcsb.mapviewer.commands.CommandExecutionException;
import lcsb.mapviewer.common.Pair;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.layout.*;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.reaction.Reaction;
......@@ -112,7 +113,7 @@ public interface ILayoutService {
* @return a list of pairs {@link Element} - {@link ColorSchema} that are
* visualized in a {@link lcsb.mapviewer.model.map.layout.Layout}
*/
Map<Object, ColorSchema> getElementsForLayout(Model model, Integer layoutId);
Map<BioEntity, ColorSchema> getElementsForLayout(Model model, Integer layoutId);
Pair<Element, ColorSchema> getFullAliasForLayout(Model model, Integer id, int layoutId);
......
......@@ -2,11 +2,10 @@ package lcsb.mapviewer.services.impl;
import static org.junit.Assert.*;
import java.awt.*;
import java.awt.Color;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
......@@ -21,6 +20,7 @@ import lcsb.mapviewer.common.TextFileUtils;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.layout.*;
import lcsb.mapviewer.model.map.model.*;
import lcsb.mapviewer.model.user.User;
......@@ -329,7 +329,7 @@ public class LayoutServiceTest extends ServiceTestFunctions {
.colorSchemaType(ColorSchemaType.GENETIC_VARIANT);
Layout layout = layoutService.createLayout(params);
Map<Object, ColorSchema> result = layoutService.getElementsForLayout(model, layout.getId());
Map<BioEntity, ColorSchema> result = layoutService.getElementsForLayout(model, layout.getId());
assertNotNull(result);
layoutService.removeLayout(layout, null);
}
......@@ -342,7 +342,7 @@ public class LayoutServiceTest extends ServiceTestFunctions {
.colorSchemaType(ColorSchemaType.GENERIC);
Layout layout = layoutService.createLayout(params);
Map<Object, ColorSchema> result = layoutService.getElementsForLayout(model, layout.getId());
Map<BioEntity, ColorSchema> result = layoutService.getElementsForLayout(model, layout.getId());
assertNotNull(result);
layoutService.removeLayout(layout, null);
}
......
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