3094dcd700d55d46e2a47e14d9db9317df2036f6
[portal/sdk.git] /
1 /*-
2  * ================================================================================
3  * ECOMP Portal SDK
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 package org.openecomp.portalsdk.analytics.gmap.map;
21
22 import java.awt.Color;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.Map;
26
27 public class ColorProperties {
28         private NovaMap map;
29         
30         private Map<String, Object> colorProperties;
31         private ArrayList<String> nodeLegends;
32         private ArrayList<String> lineLegends;
33         
34         public ColorProperties(NovaMap map) {
35                 this.map = map;
36                 colorProperties = new HashMap<String, Object>();
37         }
38         
39         public void setColor(String type, String color) {
40                 //colorProperties.put(type + "_COLOR", color);
41                 String[] rgb = color.split(",");
42                 colorProperties.put(type + "_COLOR", 
43                                 new Color(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), 
44                                                 Integer.parseInt(rgb[2])));
45         }
46         
47 //      public void setColor(String type, int number, String color) {
48 //              Object object = colorProperties.get(type + ":" + number + "_COLOR");
49 //              
50 //              if (object != null) {
51 //                      Color oldColor = (Color) object;
52 //                      
53 //                      if (!color.equals(oldColor.getRed() + "," + oldColor.getGreen() + "," + oldColor.getBlue())) {
54 //                              String[] rgb = color.split(",");
55 //                              colorProperties.put(type + ":" + number + "_COLOR", 
56 //                                              new Color(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), 
57 //                                                              Integer.parseInt(rgb[2])));
58 //                      }
59 //              }
60 //              else {
61 //                      String[] rgb = color.split(",");
62 //                      colorProperties.put(type + ":" + number + "_COLOR", 
63 //                                      new Color(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), 
64 //                                                      Integer.parseInt(rgb[2])));
65 //              }
66 //      }
67         
68 //      public Color getColor(String type, int number) {
69 //              return (Color) colorProperties.get(type + ":" + number + "_COLOR");
70 //      }
71         
72         public Color getColor(String type) {
73                 return (Color) colorProperties.get(type + "_COLOR");
74         }
75         
76         public void setShape(String type, String shape) {
77                 colorProperties.put(type + "_SHAPE", shape);
78         }
79         
80         public void setShape(String type, int number, String shape) {
81                 colorProperties.put(type + ":" + number + "_SHAPE", shape);
82         }
83         
84         public String getShape(String type) {
85                 return (String) colorProperties.get(type + "_SHAPE");
86         }
87         
88         public String getShape(String type, int number) {
89                 return (String) colorProperties.get(type + ":" + number + "_SHAPE");
90         }
91         
92         public void setSize(String type, String size) {
93                 colorProperties.put(type + "_SIZE", size);
94         }
95         
96         public void setSize(String type, int number, String size) {
97                 colorProperties.put(type + ":" + number + "_SIZE", size);
98         }
99         
100         public int getSize(String type) {
101                 Object object = colorProperties.get(type + "_SIZE");
102                 
103                 if (object == null) {
104                         return 0;
105                 }
106         
107                 return Integer.parseInt(object.toString());
108         }
109         
110         public int getSize(String type, int number) {
111                 Object object = colorProperties.get(type + ":" + number + "_SIZE");
112                 
113                 if (object == null) {
114                         return 0;
115                 }
116         
117                 return Integer.parseInt(object.toString());
118         }
119 }