]> gerrit.simantics Code Review - simantics/district.git/blob
c4d9d209a5e70420ffb4fe128a2cf5ed26fba82f
[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 DynamicVisualisationsRequest extends ResourceRead<DynamicVisualisation> {
22
23     public DynamicVisualisationsRequest(Resource diagram) {
24         super(diagram);
25     }
26
27     @Override
28     public DynamicVisualisation perform(ReadGraph graph) throws DatabaseException {
29         DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
30         Resource visualisationResource = graph.getPossibleObject(resource, DN.Diagram_hasVisualisation);
31         if (visualisationResource != null) {
32             String name = graph.getRelatedValue(visualisationResource, Layer0.getInstance(graph).HasName);
33             Map<String, DynamicColorContribution> colorContributions = DistrictNetworkUtil.colorContributions(graph, resource);
34             ColorBarOptions colorBarOptions = DistrictNetworkUtil.colorBarOptions(graph, resource);
35             Map<String, DynamicSizeContribution> sizeContributions = DistrictNetworkUtil.sizeContributions(graph, resource);
36             SizeBarOptions sizeBarOptions = DistrictNetworkUtil.sizeBarOptions(graph, resource);
37             DynamicVisualisation visualisation = new DynamicVisualisation(name, colorContributions, colorBarOptions, sizeContributions, sizeBarOptions);
38             return visualisation; 
39         }
40         return null;
41     }
42
43 }