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

Merge branch '326-re-organize-compartments-in-the-generated-layout' into 'master'

Resolve "Re-organize compartments in the generated layout"

Closes #326

See merge request !987
parents df5cff44 8c0a96c8
Pipeline #15838 passed with stage
in 13 minutes and 37 seconds
minerva (15.0.0~alpha.0) stable; urgency=medium
* Improvement: logs provided for validation data model are structurized (#325)
* Small improvement: compartments in not layouted SBML file are more
scattered (#326)
* Small improvement: when downloading a map results in too big file (>1MB)
the content is compressed and returned as a zip file (#348)
* Small improvement: confirmation dialog when removing "general view"
......
......@@ -31,6 +31,8 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
private static final int SPECIES_WIDTH = 90;
private static final int SPECIES_HEIGHT = 30;
private static final double COMPLEX_PADDING = 5;
private double borderOffset = COMPARTMENT_BORDER;
/**
* Default class logger.
*/
......@@ -113,7 +115,7 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
Compartment compartment = compartments.iterator().next();
Rectangle2D border = computeCompartmentBorder(compartment, elements, minPoint, dimension);
compartment.setBorder(border);
compartment.setNamePoint(border.getX() + COMPARTMENT_BORDER, border.getY() + COMPARTMENT_BORDER);
compartment.setNamePoint(border.getX() + COMPARTMENT_BORDER * 2, border.getY() + COMPARTMENT_BORDER * 2);
Point2D point = new Point2D.Double(border.getX(), border.getY());
Dimension2D recursiveDimension = new DoubleDimension(border.getWidth(), border.getHeight());
Set<Element> elementsToModify = new HashSet<>(compartment.getElements());
......@@ -170,9 +172,9 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
private Rectangle2D computeCompartmentBorder(Compartment compartment, Collection<Element> elements, Point2D minPoint,
Dimension2D dimension) {
Rectangle2D border = new Rectangle2D.Double(minPoint.getX() + COMPARTMENT_BORDER,
minPoint.getY() + COMPARTMENT_BORDER, dimension.getWidth() - COMPARTMENT_BORDER * 2,
dimension.getHeight() - COMPARTMENT_BORDER * 2);
Rectangle2D border = new Rectangle2D.Double(minPoint.getX() + borderOffset,
minPoint.getY() + borderOffset, dimension.getWidth() - borderOffset * 2,
dimension.getHeight() - borderOffset * 2);
for (Element element : compartment.getElements()) {
if (!elements.contains(element) && element.getBorder() != null && element.getX() != 0 && element.getY() != 0) {
border.add(element.getBorder());
......@@ -405,6 +407,7 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
height = Math.max(height, minPoint.getY() + dimension.getHeight());
model.setWidth(width);
model.setHeight(height);
borderOffset = Math.max(borderOffset, Math.max(width, height) * 0.01);
}
protected Point2D estimateLayoutMinPoint(Model model) {
......
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