]> gerrit.simantics Code Review - simantics/platform.git/blob - diagram/monitor/RGB.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / diagram / monitor / RGB.java
1 package org.simantics.modeling.ui.diagram.monitor;
2
3 import org.simantics.common.color.Color;
4 import org.simantics.databoard.Bindings;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.exception.DatabaseException;
8
9 public class RGB implements Color {
10         
11         double r,g,b;
12
13         public RGB(double r, double g, double b) {
14                 this.r = r; this.g = g; this.b=b;
15         }
16         
17         public RGB(ReadGraph graph, Resource resource) throws DatabaseException {
18                 double[] array = graph.getValue(resource, Bindings.DOUBLE_ARRAY);
19                 assert(array.length == 3);
20                 r = array[0];
21                 g = array[1];
22                 b = array[2];
23         }
24
25         @Override
26         public double getR() {
27                 return r;
28         }
29
30         @Override
31         public double getG() {
32                 return g;
33         }
34
35         @Override
36         public double getB() {
37                 return b;
38         }
39
40         @Override
41         public double getA() {
42                 throw new UnsupportedOperationException();
43         }
44
45         @Override
46         public double getH() {
47                 throw new UnsupportedOperationException();
48         }
49
50         @Override
51         public double getS() {
52                 throw new UnsupportedOperationException();
53         }
54
55         @Override
56         public double getV() {
57                 throw new UnsupportedOperationException();
58         }
59         
60 }
61