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

shapes for all species are implemnted in sbml

parent 7428a31a
Pipeline #37518 canceled with stage
in 2 minutes and 6 seconds
......@@ -15,6 +15,8 @@ minerva (16.0.0~alpha.1) stable; urgency=medium
(#1376)
* Small improvement: context menu exporting map is more precise about scope
(#1447)
* Small improvement: SBML render contains information about species shapes
(#1055)
* Bug fix: refreshing page after removing last project on the page redirect to
proper page (#1051)
* Bug fix: removing plugin that does not exist anymore does not raise an error
......
......@@ -26,8 +26,9 @@ import lcsb.mapviewer.model.map.species.field.*;
public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.jsbml.Species> {
private static final double ION_CHANNEL_WIDTH = 20;
private static final double DEGRADED_CROSS_LINE_EXTENDED_LENGTH = 7;
private static final double RECTANGLE_CORNER_ARC_SIZE = 10;
private static final double RECTANGLE_CORNER_ARC_SIZE = 5;
private static final double COMPLEX_TRIMMED_CORNER_SIZE = 5;
private static final double DRUG_OFFSET_BETWEEN_BORDERS = 4;
......@@ -469,10 +470,18 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j
shapes.addAll(createDrugShapes((Drug) element));
} else if (element instanceof GenericProtein) {
shapes.add(createGenericProteinShape((GenericProtein) element));
} else if (element instanceof ReceptorProtein) {
shapes.add(createReceptorProteinShape());
} else if (element instanceof TruncatedProtein) {
shapes.add(createTruncatedProteinShape((TruncatedProtein) element));
} else if (element instanceof IonChannelProtein) {
shapes.addAll(createIonChannelShapes((IonChannelProtein) element));
} else if (element instanceof Complex) {
shapes.add(createComplexShape((Complex) element));
} else if (element instanceof Gene) {
shapes.add(createGeneShape());
} else if (element instanceof Phenotype) {
shapes.add(createPhenotypeShape((Phenotype) element));
} else if (element instanceof AntisenseRna) {
shapes.add(createAntisenseRnaShape());
} else if (element instanceof Degraded) {
......@@ -519,6 +528,19 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j
return result;
}
private List<GraphicalPrimitive1D> createIonChannelShapes(IonChannelProtein ionChannel) {
List<GraphicalPrimitive1D> result = new ArrayList<>();
result.add(createRoundedRect(0, 0,
ionChannel.getWidth() - ION_CHANNEL_WIDTH - 1, ionChannel.getHeight(),
RECTANGLE_CORNER_ARC_SIZE));
result.add(createRoundedRect(ionChannel.getWidth() - ION_CHANNEL_WIDTH, 0,
ION_CHANNEL_WIDTH, ionChannel.getHeight(),
RECTANGLE_CORNER_ARC_SIZE));
return result;
}
private List<GraphicalPrimitive1D> createDrugShapes(Drug drug) {
List<GraphicalPrimitive1D> result = new ArrayList<>();
......@@ -561,25 +583,56 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j
}
private GraphicalPrimitive1D createGenericProteinShape(GenericProtein protein) {
double x = 0;
double y = 0;
double width = protein.getWidth();
double height = protein.getHeight();
double arcSize = RECTANGLE_CORNER_ARC_SIZE;
return createRoundedRect(x, y, width, height, arcSize);
}
private Polygon createRoundedRect(double x, double y, double width, double height, double arcSize) {
Polygon polygon = new Polygon();
createAbsolutePoint(polygon, RECTANGLE_CORNER_ARC_SIZE, 0);
createAbsolutePoint(polygon, protein.getWidth() - RECTANGLE_CORNER_ARC_SIZE, 0);
createArc(polygon, protein.getWidth() - RECTANGLE_CORNER_ARC_SIZE, 0,
protein.getWidth(), RECTANGLE_CORNER_ARC_SIZE,
protein.getWidth() - RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE);
createAbsolutePoint(polygon, protein.getWidth(), protein.getHeight() - RECTANGLE_CORNER_ARC_SIZE);
createArc(polygon, protein.getWidth(), protein.getHeight() - RECTANGLE_CORNER_ARC_SIZE,
protein.getWidth() - RECTANGLE_CORNER_ARC_SIZE, protein.getHeight(),
protein.getWidth() - RECTANGLE_CORNER_ARC_SIZE, protein.getHeight() - RECTANGLE_CORNER_ARC_SIZE);
createAbsolutePoint(polygon, RECTANGLE_CORNER_ARC_SIZE, protein.getHeight());
createArc(polygon, RECTANGLE_CORNER_ARC_SIZE, protein.getHeight(),
0, protein.getHeight() - RECTANGLE_CORNER_ARC_SIZE,
RECTANGLE_CORNER_ARC_SIZE, protein.getHeight() - RECTANGLE_CORNER_ARC_SIZE);
createAbsolutePoint(polygon, 0, RECTANGLE_CORNER_ARC_SIZE);
createArc(polygon, 0, RECTANGLE_CORNER_ARC_SIZE,
RECTANGLE_CORNER_ARC_SIZE, 0,
RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE);
createAbsolutePoint(polygon, x + arcSize, y);
createAbsolutePoint(polygon, x + width - arcSize, y);
createArc(polygon, x + width - arcSize, y,
x + width, y + arcSize,
x + width - arcSize, y + arcSize);
createAbsolutePoint(polygon, x + width, y + height - arcSize);
createArc(polygon, x + width, y + height - arcSize,
x + width - arcSize, y + height,
x + width - arcSize, y + height - arcSize);
createAbsolutePoint(polygon, x + arcSize, y + height);
createArc(polygon, x + arcSize, y + height,
x, y + height - arcSize,
x + arcSize, y + height - arcSize);
createAbsolutePoint(polygon, x, y + arcSize);
createArc(polygon, x, y + arcSize,
x + arcSize, y,
x + arcSize, y + arcSize);
return polygon;
}
private GraphicalPrimitive1D createTruncatedProteinShape(TruncatedProtein protein) {
Polygon polygon = new Polygon();
createAbsolutePoint(polygon, 10, 0);
createAbsolutePoint(polygon, protein.getWidth(), 0);
createAbsolutePoint(polygon, protein.getWidth(), protein.getHeight() * 3 / 5);
createAbsolutePoint(polygon, protein.getWidth() * 4 / 5, protein.getHeight() * 2 / 5);
createAbsolutePoint(polygon, protein.getWidth() * 4 / 5, protein.getHeight());
createAbsolutePoint(polygon, 10, protein.getHeight());
createAbsoluteBezierPoint(polygon, 0, protein.getHeight() - 10,
5, protein.getHeight() - 2,
2, protein.getHeight() - 5);
createAbsolutePoint(polygon, 0, 10);
createAbsoluteBezierPoint(polygon, 10, 0,
2, 5,
5, 2);
return polygon;
}
......@@ -597,6 +650,18 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j
return polygon;
}
private GraphicalPrimitive1D createPhenotypeShape(Phenotype complex) {
Polygon polygon = new Polygon();
createAbsolutePoint(polygon, 0, complex.getHeight() / 2);
createAbsolutePoint(polygon, complex.getHeight() / 2, 0);
createAbsolutePoint(polygon, complex.getWidth() - complex.getHeight() / 2, 0);
createAbsolutePoint(polygon, complex.getWidth(), complex.getHeight() / 2);
createAbsolutePoint(polygon, complex.getWidth() - complex.getHeight() / 2, complex.getHeight());
createAbsolutePoint(polygon, complex.getHeight() / 2, complex.getHeight());
return polygon;
}
private void createArc(Polygon polygon, double x1, double y1, double x4, double y4, double xc, double yc) {
// math taken from https://stackoverflow.com/a/44829356/1127920
double ax = x1 - xc;
......@@ -667,6 +732,17 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j
return polygon;
}
private Polygon createReceptorProteinShape() {
Polygon polygon = new Polygon();
createRelativePoint(polygon, 0, 0);
createRelativePoint(polygon, 50, 20);
createRelativePoint(polygon, 100, 0);
createRelativePoint(polygon, 100, 80);
createRelativePoint(polygon, 50, 100);
createRelativePoint(polygon, 0, 80);
return polygon;
}
private Polygon createAntisenseRnaShape() {
Polygon polygon = new Polygon();
createRelativePoint(polygon, 0, 0);
......
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