]> gerrit.simantics Code Review - simantics/district.git/blob
58499db07e91b6061691bddd38b6a489ead24ba3
[simantics/district.git] /
1 package org.simantics.district.network.profile;
2
3 import java.util.Map;
4
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.common.request.ResourceRead;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.district.network.DistrictNetworkUtil;
10 import org.simantics.district.network.ontology.DistrictNetworkResource;
11 import org.simantics.district.network.visualisations.model.ColorBarOptions;
12 import org.simantics.district.network.visualisations.model.DynamicColorContribution;
13 import org.simantics.district.network.visualisations.model.DynamicSizeContribution;
14 import org.simantics.district.network.visualisations.model.DynamicVisualisation;
15 import org.simantics.district.network.visualisations.model.SizeBarOptions;
16 import org.simantics.layer0.Layer0;
17
18 /**
19  * @author Jani Simomaa
20  */
21 public class ActiveDynamicVisualisationsRequest extends ResourceRead<DynamicVisualisation> {
22
23     public ActiveDynamicVisualisationsRequest(Resource parent) {
24         super(parent);
25     }
26
27     @Override
28     public DynamicVisualisation perform(ReadGraph graph) throws DatabaseException {
29         DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
30         Resource visualisationFolder = DistrictNetworkUtil.getVisualisationFolder(graph, resource);
31         if (visualisationFolder != null) {
32             Resource visualisationResource = graph.getPossibleObject(visualisationFolder, DN.Diagram_hasActiveVisualisation);
33             if (visualisationResource != null) {
34                 String name = graph.getRelatedValue(visualisationResource, Layer0.getInstance(graph).HasName);
35                 Map<String, DynamicColorContribution> colorContributions = DistrictNetworkUtil.colorContributions(graph, visualisationResource);
36                 ColorBarOptions colorBarOptions = DistrictNetworkUtil.colorBarOptions(graph, visualisationResource);
37                 Map<String, DynamicSizeContribution> sizeContributions = DistrictNetworkUtil.sizeContributions(graph, visualisationResource);
38                 SizeBarOptions sizeBarOptions = DistrictNetworkUtil.sizeBarOptions(graph, visualisationResource);
39                 DynamicVisualisation visualisation = new DynamicVisualisation(name, visualisationResource, colorContributions, colorBarOptions, sizeContributions, sizeBarOptions);
40                 return visualisation; 
41             }
42         }
43         return null;
44     }
45
46 }