1 package org.simantics.district.network.profile;
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;
19 * @author Jani Simomaa
21 public class ActiveDynamicVisualisationsRequest extends ResourceRead<DynamicVisualisation> {
23 public ActiveDynamicVisualisationsRequest(Resource diagram) {
28 public DynamicVisualisation perform(ReadGraph graph) throws DatabaseException {
29 DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
30 Resource visualisationResource = graph.getPossibleObject(resource, DN.Diagram_hasActiveVisualisation);
31 if (visualisationResource != null) {
32 String name = graph.getRelatedValue(visualisationResource, Layer0.getInstance(graph).HasName);
33 Map<String, DynamicColorContribution> colorContributions = DistrictNetworkUtil.colorContributions(graph, visualisationResource);
34 ColorBarOptions colorBarOptions = DistrictNetworkUtil.colorBarOptions(graph, visualisationResource);
35 Map<String, DynamicSizeContribution> sizeContributions = DistrictNetworkUtil.sizeContributions(graph, visualisationResource);
36 SizeBarOptions sizeBarOptions = DistrictNetworkUtil.sizeBarOptions(graph, visualisationResource);
37 DynamicVisualisation visualisation = new DynamicVisualisation(name, visualisationResource, colorContributions, colorBarOptions, sizeContributions, sizeBarOptions);