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

Merge branch '678-layers-not-handled' into 'devel_12.2.x'

layer text can contain information about visibility level

See merge request !622
parents 769de072 9a612ef5
No related branches found
No related tags found
3 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!62712.2.0~beta.1 into master,!622layer text can contain information about visibility level
Pipeline #8630 passed
......@@ -12,6 +12,7 @@ import org.apache.log4j.Logger;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
......@@ -113,8 +114,8 @@ public class CreateHierarchyCommand extends ModelCommand {
}
private void setDefaultVisibilityLevel(List<Element> sortedAliases) {
for (Element element: sortedAliases) {
if (element.getVisibilityLevel()==null||element.getVisibilityLevel().isEmpty()) {
for (Element element : sortedAliases) {
if (element.getVisibilityLevel() == null || element.getVisibilityLevel().isEmpty()) {
element.setVisibilityLevel(0);
}
}
......@@ -151,39 +152,59 @@ public class CreateHierarchyCommand extends ModelCommand {
* additional graphic layers.
*/
private void createArtificials() {
RestAnnotationParser rap = new RestAnnotationParser();
Model model = getModel();
int id = 0;
for (Layer layer : model.getLayers()) {
for (LayerRect rect : layer.getRectangles()) {
PathwayCompartment alias = new PathwayCompartment("art" + (id++));
alias.setX(rect.getX());
alias.setY(rect.getY());
alias.setWidth(rect.getWidth());
alias.setHeight(rect.getHeight());
alias.setFontColor(rect.getColor());
alias.setNamePoint(new Point2D.Double(rect.getX() + DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT,
PathwayCompartment compartment = new PathwayCompartment("art" + (id++));
compartment.setX(rect.getX());
compartment.setY(rect.getY());
compartment.setWidth(rect.getWidth());
compartment.setHeight(rect.getHeight());
compartment.setFontColor(rect.getColor());
compartment.setNamePoint(new Point2D.Double(rect.getX() + DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT,
rect.getY() + DEFAULT_TITLE_Y_COORD_IN_ARTIFITIAL_COMPARTMENT));
model.addElement(alias);
model.addElement(compartment);
}
for (LayerText text : layer.getTexts()) {
PathwayCompartment alias = new PathwayCompartment("art" + (id++));
alias.setX(text.getX());
alias.setY(text.getY());
alias.setWidth(text.getWidth());
alias.setHeight(text.getHeight());
alias.setFontColor(text.getColor());
alias.setColor(text.getBackgroundColor());
alias.setName(text.getNotes().trim());
alias.setNamePoint(new Point2D.Double(text.getX() + DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT,
PathwayCompartment compartment = new PathwayCompartment("art" + (id++));
compartment.setX(text.getX());
compartment.setY(text.getY());
compartment.setWidth(text.getWidth());
compartment.setHeight(text.getHeight());
compartment.setFontColor(text.getColor());
compartment.setColor(text.getBackgroundColor());
compartment.setName(extractNameFromText(text.getNotes()));
compartment.setNotes(extractNotesFromText(text.getNotes()));
rap.processNotes(compartment);
compartment.setNamePoint(new Point2D.Double(text.getX() + DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT,
text.getY() + DEFAULT_TITLE_Y_COORD_IN_ARTIFITIAL_COMPARTMENT));
model.addElement(alias);
model.addElement(compartment);
}
}
}
private String extractNotesFromText(String notes) {
if (notes.indexOf("\n") >= 0) {
return notes.substring(notes.indexOf("\n"));
} else {
return "";
}
}
private String extractNameFromText(String notes) {
if (notes.indexOf("\n") >= 0) {
return notes.substring(0, notes.indexOf("\n"));
} else {
return notes;
}
}
/**
* Assign aliases in hierarchical structure.
*/
......
......@@ -374,4 +374,22 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions {
}
}
@Test
public void testLayerWithNotes() throws Exception {
try {
Model model = getModelForFile("testFiles/layer_text_with_notes.xml", false);
new CreateHierarchyCommand(model, 4, 80).execute();
PathwayCompartment pathway = (PathwayCompartment) model.getCompartments().get(0);
assertEquals("test", pathway.getName());
assertEquals("5", pathway.getVisibilityLevel());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" xmlns:celldesigner="http://www.sbml.org/2001/ns/celldesigner" level="2" version="4">
<model metaid="untitled" id="untitled">
<annotation>
<celldesigner:extension>
<celldesigner:modelVersion>4.0</celldesigner:modelVersion>
<celldesigner:modelDisplay sizeX="600" sizeY="400"/>
<celldesigner:listOfCompartmentAliases/>
<celldesigner:listOfComplexSpeciesAliases/>
<celldesigner:listOfSpeciesAliases>
<celldesigner:speciesAlias id="sa1" species="s1">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="201.0" y="236.0" w="80.0" h="40.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="40.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffccffcc" scheme="Color"/>
</celldesigner:usualView>
<celldesigner:briefView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="60.0"/>
<celldesigner:singleLine width="0.0"/>
<celldesigner:paint color="3fff0000" scheme="Color"/>
</celldesigner:briefView>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:speciesAlias>
</celldesigner:listOfSpeciesAliases>
<celldesigner:listOfGroups/>
<celldesigner:listOfProteins>
<celldesigner:protein id="pr1" name="s1" type="GENERIC"/>
</celldesigner:listOfProteins>
<celldesigner:listOfGenes/>
<celldesigner:listOfRNAs/>
<celldesigner:listOfAntisenseRNAs/>
<celldesigner:listOfLayers>
<celldesigner:layer id="1" name="Layer0001" locked="false" visible="true">
<celldesigner:listOfTexts>
<celldesigner:layerSpeciesAlias x="0.0" y="0.0">
<celldesigner:layerNotes>
test
SemanticZoomLevelVisibility: 5
</celldesigner:layerNotes>
<celldesigner:bounds x="140.0" y="173.0" w="242.0" h="178.0"/>
<celldesigner:paint color="ff000000"/>
<celldesigner:font size="11"/>
</celldesigner:layerSpeciesAlias>
</celldesigner:listOfTexts>
</celldesigner:layer>
</celldesigner:listOfLayers>
<celldesigner:listOfBlockDiagrams/>
</celldesigner:extension>
</annotation>
<listOfUnitDefinitions>
<unitDefinition metaid="substance" id="substance" name="substance">
<listOfUnits>
<unit metaid="CDMT00001" kind="mole"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="volume" id="volume" name="volume">
<listOfUnits>
<unit metaid="CDMT00002" kind="litre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="area" id="area" name="area">
<listOfUnits>
<unit metaid="CDMT00003" kind="metre" exponent="2"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="length" id="length" name="length">
<listOfUnits>
<unit metaid="CDMT00004" kind="metre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="time" id="time" name="time">
<listOfUnits>
<unit metaid="CDMT00005" kind="second"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment metaid="default" id="default" size="1" units="volume"/>
</listOfCompartments>
<listOfSpecies>
<species metaid="s1" id="s1" name="s1" compartment="default" initialAmount="0">
<annotation>
<celldesigner:extension>
<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
<celldesigner:speciesIdentity>
<celldesigner:class>PROTEIN</celldesigner:class>
<celldesigner:proteinReference>pr1</celldesigner:proteinReference>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
</listOfSpecies>
</model>
</sbml>
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