Commit 81a24dd5 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

map dimension cannot be null

parent 45b2286e
Pipeline #11981 failed with stage
in 8 minutes and 14 seconds
......@@ -621,7 +621,7 @@ public class CellDesignerXmlParser extends Converter {
result.append(functionCollectionXmlParser.toXml(model.getFunctions()));
result.append(unitCollectionXmlParser.toXml(model.getUnits()));
//notes must be inserted here, but we don't know the warnings yet
// notes must be inserted here, but we don't know the warnings yet
int notesPosition = result.length();
result.append(annotationToXml(model, elements));
......@@ -633,7 +633,7 @@ public class CellDesignerXmlParser extends Converter {
result.append(parameterCollectionXmlParser.toXml(model.getParameters()));
result.append(reactionCollectionXmlParser.reactionCollectionToXmlString(model.getReactions()));
if (model.getNotes() != null || !appender.getWarnings().isEmpty()) {
StringBuilder notes = new StringBuilder();
notes.append("<notes>");
......@@ -676,8 +676,8 @@ public class CellDesignerXmlParser extends Converter {
result.append("<annotation>\n");
result.append("<celldesigner:extension>\n");
result.append("<celldesigner:modelVersion>4.0</celldesigner:modelVersion>\n");
result.append("<celldesigner:modelDisplay sizeX=\"" + model.getWidth().intValue() + "\" sizeY=\""
+ model.getHeight().intValue() + "\"/>\n");
result.append("<celldesigner:modelDisplay sizeX=\"" + (int) (model.getWidth()) + "\" sizeY=\""
+ (int) (model.getHeight()) + "\"/>\n");
result.append(speciesCollectionXmlParser.speciesCollectionToXmlIncludedString(model.getSpeciesList()));
......
......@@ -99,7 +99,8 @@ public class SbmlExporter {
compartmentExporter.setProvideDefaults(provideDefaults);
XmlAnnotationParser parser = new XmlAnnotationParser();
String rdf = parser.dataSetToXmlString(model.getMiriamData(), model.getAuthors(), model.getCreationDate(), model.getModificationDates(), model.getIdModel());
String rdf = parser.dataSetToXmlString(model.getMiriamData(), model.getAuthors(), model.getCreationDate(),
model.getModificationDates(), model.getIdModel());
try {
result.setAnnotation(rdf);
} catch (XMLStreamException e1) {
......@@ -141,12 +142,12 @@ public class SbmlExporter {
Layout layout = new Layout();
layout.setId("minerva_layout");
Dimensions dimensions = new Dimensions();
if (model.getHeight() != null) {
if (model.getHeight() > 0) {
dimensions.setHeight(model.getHeight());
} else {
dimensions.setHeight(640);
}
if (model.getWidth() != null) {
if (model.getWidth() > 0) {
dimensions.setWidth(model.getWidth());
} else {
dimensions.setWidth(480);
......
package lcsb.mapviewer.converter.model.sbml;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.*;
import javax.xml.stream.XMLStreamException;
......@@ -18,12 +16,9 @@ import org.sbml.jsbml.ext.multi.MultiModelPlugin;
import lcsb.mapviewer.commands.CommandExecutionException;
import lcsb.mapviewer.commands.layout.ApplySimpleLayoutModelCommand;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.MimeType;
import lcsb.mapviewer.converter.Converter;
import lcsb.mapviewer.converter.ConverterException;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.InvalidInputDataExecption;
import lcsb.mapviewer.converter.ZIndexPopulator;
import lcsb.mapviewer.converter.*;
import lcsb.mapviewer.converter.model.sbml.compartment.SbmlCompartmentParser;
import lcsb.mapviewer.converter.model.sbml.reaction.SbmlReactionParser;
import lcsb.mapviewer.converter.model.sbml.species.SbmlSpeciesParser;
......@@ -33,12 +28,8 @@ import lcsb.mapviewer.model.map.InconsistentModelException;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.modifier.Modulation;
import lcsb.mapviewer.model.map.reaction.AbstractNode;
import lcsb.mapviewer.model.map.reaction.Modifier;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.ModificationResidue;
import lcsb.mapviewer.model.map.species.field.SpeciesWithModificationResidue;
......@@ -165,7 +156,7 @@ public class SbmlParser extends Converter {
private void createLayout(Model model, Layout layout, boolean resize, SbmlReactionParser parser)
throws InvalidInputDataExecption {
if (model.getWidth() == null) {
if (model.getWidth() <= Configuration.EPSILON) {
double maxY = 1;
double maxX = 1;
for (Element element : model.getElements()) {
......
......@@ -139,7 +139,7 @@ public class SbmlCompartmentExporter extends SbmlElementExporter<Compartment, or
boundingBox.setPosition(new Point(element.getX(), element.getY(), 0));
Dimensions dimensions = new Dimensions();
if (getMinervaModel().getWidth() != null) {
if (getMinervaModel().getWidth() > 0) {
dimensions.setWidth(getMinervaModel().getWidth());
dimensions.setHeight(getMinervaModel().getHeight());
}
......
......@@ -58,12 +58,12 @@ public class SbmlReactionExporterTest {
Layout layout = new Layout();
Dimensions dimensions = new Dimensions();
if (model.getHeight() != null) {
if (model.getHeight() > 0) {
dimensions.setHeight(model.getHeight());
} else {
dimensions.setHeight(640);
}
if (model.getWidth() != null) {
if (model.getWidth() > 0) {
dimensions.setWidth(model.getWidth());
} else {
dimensions.setWidth(480);
......
package lcsb.mapviewer.commands.layout;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.awt.geom.*;
import java.util.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -27,23 +18,9 @@ import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.reaction.AbstractNode;
import lcsb.mapviewer.model.map.reaction.AndOperator;
import lcsb.mapviewer.model.map.reaction.AssociationOperator;
import lcsb.mapviewer.model.map.reaction.DissociationOperator;
import lcsb.mapviewer.model.map.reaction.Modifier;
import lcsb.mapviewer.model.map.reaction.NodeOperator;
import lcsb.mapviewer.model.map.reaction.Product;
import lcsb.mapviewer.model.map.reaction.Reactant;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.SplitOperator;
import lcsb.mapviewer.model.map.reaction.TruncationOperator;
import lcsb.mapviewer.model.map.reaction.type.DissociationReaction;
import lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction;
import lcsb.mapviewer.model.map.reaction.type.TruncationReaction;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.reaction.type.*;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.ModificationResidue;
import lcsb.mapviewer.model.map.species.field.SpeciesWithModificationResidue;
......@@ -448,14 +425,8 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
}
protected void modifyModelSize(Model model, Point2D minPoint, Dimension2D dimension) {
double width = 0;
double height = 0;
if (model.getWidth() != null) {
width = model.getWidth();
}
if (model.getHeight() != null) {
height = model.getHeight();
}
double width = model.getWidth();
double height = model.getHeight();
width = Math.max(width, minPoint.getX() + dimension.getWidth());
height = Math.max(height, minPoint.getY() + dimension.getHeight());
model.setWidth(width);
......
......@@ -53,7 +53,7 @@ public interface Model {
*
* @return model width
*/
Double getWidth();
double getWidth();
/**
* Sets model width.
......@@ -61,13 +61,13 @@ public interface Model {
* @param width
* new model width
*/
void setWidth(Double width);
void setWidth(double width);
/**
*
* @return model height
*/
Double getHeight();
double getHeight();
/**
* Sets model height.
......@@ -75,7 +75,7 @@ public interface Model {
* @param height
* new model height
*/
void setHeight(Double height);
void setHeight(double height);
/**
* Sets model width.
......
......@@ -129,12 +129,12 @@ public class ModelData implements Serializable {
/**
* Width of the map.
*/
private Double width;
private double width;
/**
* Height of the map.
*/
private Double height;
private double height;
/**
* X coordinate that should be used when initially showing map.
......@@ -550,7 +550,7 @@ public class ModelData implements Serializable {
* @return the width
* @see #width
*/
public Double getWidth() {
public double getWidth() {
return width;
}
......@@ -559,7 +559,7 @@ public class ModelData implements Serializable {
* the width to set
* @see #width
*/
public void setWidth(Double width) {
public void setWidth(double width) {
this.width = width;
}
......@@ -567,7 +567,7 @@ public class ModelData implements Serializable {
* @return the height
* @see #height
*/
public Double getHeight() {
public double getHeight() {
return height;
}
......@@ -576,7 +576,7 @@ public class ModelData implements Serializable {
* the height to set
* @see #height
*/
public void setHeight(Double height) {
public void setHeight(double height) {
this.height = height;
}
......
......@@ -122,22 +122,22 @@ public class ModelFullIndexed implements Model {
}
@Override
public Double getWidth() {
public double getWidth() {
return modelData.getWidth();
}
@Override
public void setWidth(Double width) {
public void setWidth(double width) {
modelData.setWidth(width);
}
@Override
public Double getHeight() {
public double getHeight() {
return modelData.getHeight();
}
@Override
public void setHeight(Double height) {
public void setHeight(double height) {
modelData.setHeight(height);
}
......
......@@ -672,10 +672,10 @@ public class ModelFullIndexedTest {
try {
Model model = new ModelFullIndexed(null);
Double width = 12.0;
double width = 12.0;
int widthInt = 12;
String widthStr = "12.0";
Double height = 13.0;
double height = 13.0;
String heightStr = "13.0";
int heightInt = 13;
Set<Element> elements = new HashSet<>();
......@@ -684,26 +684,22 @@ public class ModelFullIndexedTest {
String idModel = "model_ID";
model.setWidth(widthStr);
assertEquals(width, model.getWidth());
model.setWidth((Double) null);
assertNull(model.getWidth());
assertEquals(width, model.getWidth(), Configuration.EPSILON);
model.setWidth(0.0);
model.setWidth(width);
assertEquals(width, model.getWidth());
model.setWidth((Double) null);
assertNull(model.getWidth());
assertEquals(width, model.getWidth(), Configuration.EPSILON);
model.setWidth(0.0);
model.setWidth(widthInt);
assertEquals(width, model.getWidth());
assertEquals(width, model.getWidth(), Configuration.EPSILON);
model.setHeight(heightStr);
assertEquals(height, model.getHeight());
model.setHeight((Double) null);
assertNull(model.getHeight());
assertEquals(height, model.getHeight(), Configuration.EPSILON);
model.setHeight(0.0);
model.setHeight(height);
assertEquals(height, model.getHeight());
model.setHeight((Double) null);
assertNull(model.getHeight());
assertEquals(height, model.getHeight(), Configuration.EPSILON);
model.setHeight(0.0);
model.setHeight(heightInt);
assertEquals(height, model.getHeight());
assertEquals(height, model.getHeight(), Configuration.EPSILON);
model.setElements(elements);
assertEquals(elements, model.getElements());
......
update model_data_table set width = 800 where width is null;
update model_data_table set height = 600 where height is null;
ALTER TABLE model_data_table ALTER COLUMN width SET NOT NULL;
ALTER TABLE model_data_table ALTER COLUMN height SET NOT 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