]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.district.network/src/org/simantics/district/network/visualisations/triggers/VisualisationTrigger.java
Amendment to 165a995bf446be802c4623b46706a257a5367c69
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / visualisations / triggers / VisualisationTrigger.java
1 package org.simantics.district.network.visualisations.triggers;
2
3 import java.awt.Color;
4
5 public class VisualisationTrigger {
6
7     private String moduleName;
8     private String attributeName;
9     private double threshold;
10     private Color color;
11
12     public VisualisationTrigger(String moduleName, String attributeName, double threshold, String colorHex) {
13         this.moduleName = moduleName;
14         this.attributeName = attributeName;
15         this.threshold = threshold;
16         this.color = hex2Rgb(colorHex);
17     }
18
19     public String getModuleName() {
20         return moduleName;
21     }
22
23     public String getAttributeName() {
24         return attributeName;
25     }
26
27     public double getThreshold() {
28         return threshold;
29     }
30
31     public Color getColor() {
32         return color;
33     }
34
35     /**
36      * 
37      * @param colorStr e.g. "#FFFFFF"
38      * @return 
39      */
40     private static Color hex2Rgb(String colorStr) {
41         return new Color(
42                 Integer.valueOf( colorStr.substring( 1, 3 ), 16 ),
43                 Integer.valueOf( colorStr.substring( 3, 5 ), 16 ),
44                 Integer.valueOf( colorStr.substring( 5, 7 ), 16 ) );
45     }
46 }