Skip to content
Snippets Groups Projects
Commit 12de5196 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when creating hierarchy consider also pathways

parent 8ed0aa54
No related branches found
No related tags found
2 merge requests!1871Resolve "problem with websocket connection",!1858Resolve "for some translocations the reactant and product are the same species in CellDesigner or SBML exports"
......@@ -42,11 +42,11 @@ public class CreateHierarchyCommand extends ModelCommand {
/**
* Top left corner x coordinate of the text associated with compartment.
*/
private static final double DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT = 10;
private static final double DEFAULT_TITLE_X_COORD_IN_ARTIFICIAL_COMPARTMENT = 10;
/**
* Top left corner y coordinate of the text associated with compartment.
*/
private static final double DEFAULT_TITLE_Y_COORD_IN_ARTIFITIAL_COMPARTMENT = 10;
private static final double DEFAULT_TITLE_Y_COORD_IN_ARTIFICIAL_COMPARTMENT = 10;
/**
* Default class logger.
*/
......@@ -168,10 +168,10 @@ public class CreateHierarchyCommand extends ModelCommand {
if (rect.getFillColor() != null) {
compartment.setFillColor(rect.getFillColor());
}
compartment.setNameX(rect.getX() + DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT);
compartment.setNameY(rect.getY() + DEFAULT_TITLE_Y_COORD_IN_ARTIFITIAL_COMPARTMENT);
compartment.setNameWidth(rect.getWidth() - 2 * DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT);
compartment.setNameHeight(rect.getHeight() - 2 * DEFAULT_TITLE_Y_COORD_IN_ARTIFITIAL_COMPARTMENT);
compartment.setNameX(rect.getX() + DEFAULT_TITLE_X_COORD_IN_ARTIFICIAL_COMPARTMENT);
compartment.setNameY(rect.getY() + DEFAULT_TITLE_Y_COORD_IN_ARTIFICIAL_COMPARTMENT);
compartment.setNameWidth(rect.getWidth() - 2 * DEFAULT_TITLE_X_COORD_IN_ARTIFICIAL_COMPARTMENT);
compartment.setNameHeight(rect.getHeight() - 2 * DEFAULT_TITLE_Y_COORD_IN_ARTIFICIAL_COMPARTMENT);
compartment.setNameHorizontalAlign(HorizontalAlign.LEFT);
compartment.setNameVerticalAlign(VerticalAlign.TOP);
compartment.setZ(rect.getZ());
......@@ -196,10 +196,10 @@ public class CreateHierarchyCommand extends ModelCommand {
rap.processNotes(compartment);
text.setNotes(compartment.getName() + "\n" + compartment.getNotes());
compartment.setNameX(text.getX() + DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT);
compartment.setNameY(text.getY() + DEFAULT_TITLE_Y_COORD_IN_ARTIFITIAL_COMPARTMENT);
compartment.setNameWidth(text.getWidth() - 2 * DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT);
compartment.setNameHeight(text.getHeight() - 2 * DEFAULT_TITLE_Y_COORD_IN_ARTIFITIAL_COMPARTMENT);
compartment.setNameX(text.getX() + DEFAULT_TITLE_X_COORD_IN_ARTIFICIAL_COMPARTMENT);
compartment.setNameY(text.getY() + DEFAULT_TITLE_Y_COORD_IN_ARTIFICIAL_COMPARTMENT);
compartment.setNameWidth(text.getWidth() - 2 * DEFAULT_TITLE_X_COORD_IN_ARTIFICIAL_COMPARTMENT);
compartment.setNameHeight(text.getHeight() - 2 * DEFAULT_TITLE_Y_COORD_IN_ARTIFICIAL_COMPARTMENT);
compartment.setNameHorizontalAlign(HorizontalAlign.LEFT);
compartment.setNameVerticalAlign(VerticalAlign.TOP);
......@@ -292,12 +292,49 @@ public class CreateHierarchyCommand extends ModelCommand {
compartment.setTransparencyLevel(maxVisibilityLevel + "");
}
for (final Element child : compartment.getElements()) {
if (child.getVisibilityLevel() == null || child.getVisibilityLevel().isEmpty()) {
if (!isExcludedChildVisibility(child)) {
child.setVisibilityLevel(compartment.getTransparencyLevel());
}
}
}
private boolean isExcludedChildVisibility(final Element child) {
return excluded.contains(child);
}
private void settingTransparencyLevelForPathway(final PathwayCompartment pathway) {
Set<Element> pathwayChildren = getPathwayChildren(pathway);
if (pathway.getTransparencyLevel() == null || pathway.getTransparencyLevel().isEmpty()) {
double rate = computeRate(pathway, Configuration.MAX_VISIBLE_OBJECT_SIZE);
int maxVisibilityLevel = (int) ((int) Math.ceil(Math.log(rate)) / LOG_4);
for (final Element child : pathwayChildren) {
maxVisibilityLevel = Math.min(maxVisibilityLevel, computeVisibility(child));
}
if (maxVisibilityLevel >= zoomLevels) {
maxVisibilityLevel = zoomLevels;
}
if (maxVisibilityLevel <= 0) {
maxVisibilityLevel = 1;
}
pathway.setTransparencyLevel(maxVisibilityLevel + "");
}
for (final Element child : pathwayChildren) {
if (!isExcludedChildVisibility(child)) {
child.setVisibilityLevel(pathway.getTransparencyLevel());
}
}
}
private Set<Element> getPathwayChildren(final PathwayCompartment pathway) {
Set<Element> children = new HashSet<>();
for (Element element : pathway.getModel().getElements()) {
if (element.getPathway() == pathway) {
children.add(element);
}
}
return children;
}
/**
* Sets transparency level in hierarchical view for complex alias.
*
......@@ -320,20 +357,32 @@ public class CreateHierarchyCommand extends ModelCommand {
complex.setTransparencyLevel(maxVisibilityLevel + "");
}
for (final Element child : complex.getElements()) {
if (child.getVisibilityLevel() == null || child.getVisibilityLevel().isEmpty()) {
if (!isExcludedChildVisibility(child)) {
child.setVisibilityLevel(complex.getTransparencyLevel());
}
}
}
private final Set<Element> excluded = new HashSet<>();
/**
* Sets transparency level in hierarchical view for all elements.
*
* @param sortedAliases list of aliases
*/
private void settingOfTransparencyLevel(final List<Element> sortedAliases) {
excluded.clear();
for (final Element alias : sortedAliases) {
if (alias.getVisibilityLevel() != null && !alias.getVisibilityLevel().isEmpty()) {
excluded.add(alias);
}
}
for (final Element alias : sortedAliases) {
if (alias instanceof Compartment) {
if (alias instanceof PathwayCompartment) {
settingTransparencyLevelForPathway((PathwayCompartment) alias);
} else if (alias instanceof Compartment) {
settingTransparencyLevelForCompartment((Compartment) alias);
} else if (alias instanceof Complex) {
settingTransparencyLevelForComplex((Complex) alias);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment