From 7f535078ef80a7b7efa3e3325bfccb994fbd00e8 Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Thu, 31 Aug 2017 15:16:38 -0400 Subject: Rename packages to org.onap in 1.4.0-SNAPSHOT 19 - remove openecomp 72 - remediate Sonar scan issues 79 - removed unwanted left menu under Report 90 - apply approved license text Issue: PORTAL-19, PORTAL-72, PORTAL-79, PORTAL-90 Change-Id: I41a0ef5fba623d2242574bd15f2d9fb8029a496c Signed-off-by: Christopher Lott (cl778h) --- .../onap/portalsdk/analytics/gmap/line/Line.java | 104 ++++ .../analytics/gmap/line/LineCollection.java | 176 +++++++ .../portalsdk/analytics/gmap/line/LineInfo.java | 208 ++++++++ .../analytics/gmap/map/ColorProperties.java | 137 ++++++ .../analytics/gmap/map/GMapProperties.java | 67 +++ .../analytics/gmap/map/GeoCoordinate.java | 43 ++ .../portalsdk/analytics/gmap/map/MapConstant.java | 62 +++ .../onap/portalsdk/analytics/gmap/map/NovaMap.java | 521 +++++++++++++++++++++ .../analytics/gmap/map/layer/SwingLayer.java | 253 ++++++++++ .../onap/portalsdk/analytics/gmap/node/Node.java | 196 ++++++++ .../analytics/gmap/node/NodeCollection.java | 211 +++++++++ .../portalsdk/analytics/gmap/node/NodeInfo.java | 228 +++++++++ .../portalsdk/analytics/gmap/utils/MapUtils.java | 88 ++++ .../analytics/gmap/utils/SwingWorker.java | 173 +++++++ 14 files changed, 2467 insertions(+) create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/Line.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineCollection.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineInfo.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/ColorProperties.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/GMapProperties.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/GeoCoordinate.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/MapConstant.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/NovaMap.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayer.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/Node.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeInfo.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/MapUtils.java create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/SwingWorker.java (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap') diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/Line.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/Line.java new file mode 100644 index 00000000..31bfa81b --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/Line.java @@ -0,0 +1,104 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.line; + +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +import org.onap.portalsdk.analytics.gmap.map.NovaMap; + +public class Line { + private NovaMap map; + private LineCollection lineCollection; + private ArrayList selectionList; + private Set lineIDSet; + + public Line(NovaMap map) { + this.map = map; + lineCollection = new LineCollection(); + lineIDSet = new HashSet(); + selectionList = new ArrayList(); + } + + public ArrayList lineExist(Point2D screenPoint) { + ArrayList existLineInfo = null; + String selectedLine = null; + String selectedType = null; + int nearest = -1; + int nodeSize = map.getShapeWidth(); + nodeSize = nodeSize > 20 ? 20 : nodeSize; + int x0 = (int) screenPoint.getX(); + int y0 = (int) screenPoint.getY(); + + ArrayList lineInfos = lineCollection.getLineCollection(); + + for (LineInfo lineInfo : lineInfos) { + Point2D point1 = map.getScreenPointFromLonLat(lineInfo.geoCoordinate1.longitude, lineInfo.geoCoordinate1.latitude); + Point2D point2 = map.getScreenPointFromLonLat(lineInfo.geoCoordinate2.longitude, lineInfo.geoCoordinate2.latitude); + int x1 = (int) point1.getX(); + int y1 = (int) point1.getY(); + int x2 = (int) point2.getX(); + int y2 = (int) point2.getY(); + int diff = Math.abs((x0 - x1) * (y0 - y2) - (x0 - x2) * (y0 - y1)); + + if (((x1 - x0) * (x2 - x0) <= (nodeSize * 2)) && ((y1 - y0) * (y2 - y0) <= (nodeSize * 2)) && + diff < (Math.abs(y1 - y2) + Math.abs(x1 - x2)) * (int) (nodeSize * .2)) { + if (nearest == -1) { + nearest = diff; + selectedLine = lineInfo.getLineID(); + selectedType = lineInfo.getLineType(); + } + else if (diff <= nearest) { + nearest = diff; + selectedLine = lineInfo.getLineID(); + selectedType = lineInfo.getLineType(); + } + + if (existLineInfo == null) { + existLineInfo = new ArrayList(); + } + + existLineInfo.add(lineInfo); + } + } + + return existLineInfo; + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineCollection.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineCollection.java new file mode 100644 index 00000000..cead8219 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineCollection.java @@ -0,0 +1,176 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.line; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +public class LineCollection { + private Set selectedLine; // all selected node + private String lineID; // last clicked node + private ArrayList lineCollection; + + public LineCollection() { + lineCollection = new ArrayList(20000); + selectedLine = new HashSet(); + } + + public void addSelectedLine(String lineID) { + selectedLine.add(lineID); + } + + public void removeSelectedLine(String lineID) { + selectedLine.remove(lineID); + } + + public Set getSelectedLine() { + return selectedLine; + } + + public boolean containSelectedLine(String lineID) { + return selectedLine.contains(lineID); + } + + public void clearSelectedLine() { + selectedLine.clear(); + } + + public void addLine(LineInfo lineInfo) { + lineCollection.add(lineInfo); + } + + public ArrayList getLineCollection() { + return lineCollection; + } + + public LineInfo getLine(String lineID) { + for (LineInfo lineInfo : lineCollection) { + if (lineInfo.getLineID().equalsIgnoreCase(lineID)) { + return lineInfo; + } + } + + return null; + } + + public LineInfo getLine(String lineID, String lineType) { + for (LineInfo lineInfo : lineCollection) { + if (lineInfo.getLineID().equalsIgnoreCase(lineID) && lineInfo.getLineType().equalsIgnoreCase(lineType)) { + return lineInfo; + } + } + + return null; + } + + public LineInfo getLine(String nodeID1, String nodeID2, boolean dummy) { + for (LineInfo lineInfo : lineCollection) { + if ((lineInfo.getNodeID1().equalsIgnoreCase(nodeID1) && lineInfo.getNodeID2().equalsIgnoreCase(nodeID2)) || + (lineInfo.getNodeID1().equalsIgnoreCase(nodeID2) && lineInfo.getNodeID2().equalsIgnoreCase(nodeID1))) { + return lineInfo; + } + } + + return null; + } + + public LineInfo removeLine(String lineID) { + for (int i = 0; i < lineCollection.size(); i++) { + if (lineCollection.get(i).getLineID().equalsIgnoreCase(lineID)) { + return lineCollection.remove(i); + } + } + + removeSelectedLine(lineID); + return null; + } + + public LineInfo removeLine(String lineID, String lineType) { + for (int i = 0; i < lineCollection.size(); i++) { + if (lineCollection.get(i).getLineID().equalsIgnoreCase(lineID) && + lineCollection.get(i).getLineType().equalsIgnoreCase(lineType)) { + return lineCollection.remove(i); + } + } + + removeSelectedLine(lineID); + return null; + } + + public void clearLine() { + lineCollection.clear(); + selectedLine.clear(); + } + + public int getSize() { + return lineCollection.size(); + } + + public String getLineID() { + return lineID; + } + + public void setLineID(String lineID) { + this.lineID = lineID; + } + + public void clearAllCollection () { + clearLine(); + clearSelectedLine(); + this.lineID = null; + } + + public String[] getWildCardLine(String lineID) { + ArrayList list = new ArrayList(); + + for (LineInfo lineInfo : lineCollection) { + if (lineInfo.getLineID().toLowerCase().indexOf(lineID.toLowerCase()) != -1) { + list.add(lineInfo.getLineID()); + } + } + + String[] result = new String[list.size()]; + + for (int i = 0; i < list.size(); i++) { + result[i] = list.get(i); + } + + return result; + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineInfo.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineInfo.java new file mode 100644 index 00000000..e19fe349 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineInfo.java @@ -0,0 +1,208 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.line; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.onap.portalsdk.analytics.gmap.map.GeoCoordinate; + +public class LineInfo { + public GeoCoordinate geoCoordinate1; + public GeoCoordinate geoCoordinate2; + + private String nodeID1; + private String nodeID2; + + private String lineID; + private String lineType; + private String lineDescription; + + private boolean moveable; + private boolean deleteable; + + private int state; + + private Map lineAttributes; + + public LineInfo(String nodeID1, String nodeID2) { + this.nodeID1 = nodeID1; + this.nodeID2 = nodeID2; + lineAttributes = new HashMap(); + } + + public LineInfo clone() { + LineInfo lineInfo = new LineInfo(nodeID1, nodeID2); + lineInfo.geoCoordinate1.longitude = geoCoordinate1.longitude; + lineInfo.geoCoordinate1.latitude = geoCoordinate1.latitude; + lineInfo.geoCoordinate2.longitude = geoCoordinate2.longitude; + lineInfo.geoCoordinate2.latitude = geoCoordinate2.latitude; + lineInfo.setDescription(lineDescription); + lineInfo.setLineID(lineID); + lineInfo.setLineType(lineType); + lineInfo.setMoveable(moveable); + lineInfo.setDeleteable(deleteable); + lineInfo.setState(state); + lineInfo.initializeAttributes(lineAttributes); + + return lineInfo; + } + + public void setLineID(String lineID) { + this.lineID = lineID; + geoCoordinate1 = new GeoCoordinate(); + geoCoordinate2 = new GeoCoordinate(); + } + + public String getLineID() { + return lineID; + } + + public void setLineType(String lineType) { + this.lineType = lineType; + } + + public String getLineType() { + return lineType; + } + + public int getState() { + return state; + } + + public void setState(int state) { + this.state = state; + } + + public String getDescription() { + return lineDescription; + } + + public void setDescription(String lineDescription) { + this.lineDescription = lineDescription; + } + + public boolean isMoveable() { + return moveable; + } + + public void setMoveable(boolean moveable) { + this.moveable = moveable; + } + + public String getNodeID1() { + return nodeID1; + } + + public void setNodeID1(String nodeID1) { + this.nodeID1 = nodeID1; + } + + public String getNodeID2() { + return nodeID2; + } + + public void setNodeID2(String nodeID2) { + this.nodeID2 = nodeID2; + } + + public void initializeAttributes(Map lineAttributes) { + this.lineAttributes.clear(); + Set keySet = lineAttributes.keySet(); + Iterator iter = keySet.iterator(); + + while (iter.hasNext()) { + String key = iter.next(); + this.lineAttributes.put(key, lineAttributes.get(key)); + } + } + + public void setAttribute(String key, String value) { + lineAttributes.put(key, value); + } + + public String getAttribute(String key) { + String value = lineAttributes.get(key); + return value; + } + + public List getAttributeKeys() { + Set keySet = lineAttributes.keySet(); + List keys = new ArrayList(keySet.size()); + Iterator iter = keySet.iterator(); + + while (iter.hasNext()) { + String key = iter.next(); + + if (key.indexOf("x_") != 0) { + keys.add(key); + } + } + + return keys; + } + + public List getAttributeInternalKeys() { + Set keySet = lineAttributes.keySet(); + List internalKeys = new ArrayList(); + Iterator iter = keySet.iterator(); + + while (iter.hasNext()) { + String key = iter.next(); + + if (key.indexOf("x_") == 0) { + key = key.substring(2); + internalKeys.add(key); + } + } + + return internalKeys; + } + + public boolean isDeleteable() { + return deleteable; + } + + public void setDeleteable(boolean deleteable) { + this.deleteable = deleteable; + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/ColorProperties.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/ColorProperties.java new file mode 100644 index 00000000..d620fbd7 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/ColorProperties.java @@ -0,0 +1,137 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.map; + +import java.awt.Color; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class ColorProperties { + private NovaMap map; + + private Map colorProperties; + private ArrayList nodeLegends; + private ArrayList lineLegends; + + public ColorProperties(NovaMap map) { + this.map = map; + colorProperties = new HashMap(); + } + + public void setColor(String type, String color) { + //colorProperties.put(type + "_COLOR", color); + String[] rgb = color.split(","); + colorProperties.put(type + "_COLOR", + new Color(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), + Integer.parseInt(rgb[2]))); + } + +// public void setColor(String type, int number, String color) { +// Object object = colorProperties.get(type + ":" + number + "_COLOR"); +// +// if (object != null) { +// Color oldColor = (Color) object; +// +// if (!color.equals(oldColor.getRed() + "," + oldColor.getGreen() + "," + oldColor.getBlue())) { +// String[] rgb = color.split(","); +// colorProperties.put(type + ":" + number + "_COLOR", +// new Color(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), +// Integer.parseInt(rgb[2]))); +// } +// } +// else { +// String[] rgb = color.split(","); +// colorProperties.put(type + ":" + number + "_COLOR", +// new Color(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), +// Integer.parseInt(rgb[2]))); +// } +// } + +// public Color getColor(String type, int number) { +// return (Color) colorProperties.get(type + ":" + number + "_COLOR"); +// } + + public Color getColor(String type) { + return (Color) colorProperties.get(type + "_COLOR"); + } + + public void setShape(String type, String shape) { + colorProperties.put(type + "_SHAPE", shape); + } + + public void setShape(String type, int number, String shape) { + colorProperties.put(type + ":" + number + "_SHAPE", shape); + } + + public String getShape(String type) { + return (String) colorProperties.get(type + "_SHAPE"); + } + + public String getShape(String type, int number) { + return (String) colorProperties.get(type + ":" + number + "_SHAPE"); + } + + public void setSize(String type, String size) { + colorProperties.put(type + "_SIZE", size); + } + + public void setSize(String type, int number, String size) { + colorProperties.put(type + ":" + number + "_SIZE", size); + } + + public int getSize(String type) { + Object object = colorProperties.get(type + "_SIZE"); + + if (object == null) { + return 0; + } + + return Integer.parseInt(object.toString()); + } + + public int getSize(String type, int number) { + Object object = colorProperties.get(type + ":" + number + "_SIZE"); + + if (object == null) { + return 0; + } + + return Integer.parseInt(object.toString()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/GMapProperties.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/GMapProperties.java new file mode 100644 index 00000000..412cc813 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/GMapProperties.java @@ -0,0 +1,67 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.map; + +import java.io.InputStream; +import java.util.Properties; + +import org.onap.portalsdk.analytics.system.Globals; + +public class GMapProperties { + + public static String getProjectFolder() { + return Globals.getProjectFolder(); + } + + public static String getMarketShapefileFolder() { + return Globals.getMarketShapefileFolder(); + } + + public static String getTileSize() { + return Globals.getTileSize(); + } + + public static String getOutputFolder() { + return Globals.getOutputFolder(); + } + + public static String getTempFolderURL() { + return Globals.getTempFolderURL(); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/GeoCoordinate.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/GeoCoordinate.java new file mode 100644 index 00000000..a7d7d984 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/GeoCoordinate.java @@ -0,0 +1,43 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.map; + +public class GeoCoordinate { + public double longitude; + public double latitude; +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/MapConstant.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/MapConstant.java new file mode 100644 index 00000000..d56194c6 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/MapConstant.java @@ -0,0 +1,62 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.map; + +public class MapConstant { + public static final String CURSOR = "CURSOR"; + public static final String FILLED_TRIANGLE = "FILLED TRIANGLE"; + public static final String FILLED_SQUARE = "FILLED SQUARE"; + public static final String FILLED_CIRCLE = "FILLED CIRCLE"; + public static final String FILLED_DIAMOND = "FILLED DIAMOND"; + public static final String HOLLOW_TRIANGLE = "HOLLOW TRIANGLE"; + public static final String HOLLOW_SQUARE = "HOLLOW SQUARE"; + public static final String HOLLOW_CIRCLE = "HOLLOW CIRCLE"; + public static final String HOLLOW_DIAMOND = "HOLLOW DIAMOND"; + + public static int NORMAL_STATE = 1; + public static int FORCE_STATE = 2; + public static int EXCLUDE_STATE = 3; + public static int ANY_STATE = 4; + + public static int ZOOM_MIN = 1; + public static int ZOOM_MAX = 22; + + public static final double ARROW_ANGLE_HIGH = .75; + public static final double ARROW_ANGLE_LOW = .45; + public static final double ZOOMING_INDEX = .6; +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/NovaMap.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/NovaMap.java new file mode 100644 index 00000000..6938273f --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/NovaMap.java @@ -0,0 +1,521 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.map; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.geom.AffineTransform; +import java.awt.geom.NoninvertibleTransformException; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.HashSet; + +import javax.servlet.http.HttpServletRequest; + +import org.onap.portalsdk.analytics.gmap.line.Line; +import org.onap.portalsdk.analytics.gmap.line.LineInfo; +import org.onap.portalsdk.analytics.gmap.map.layer.SwingLayer; +import org.onap.portalsdk.analytics.gmap.node.Node; +import org.onap.portalsdk.analytics.gmap.node.NodeInfo; + +public class NovaMap { + private static int[] shapeWidth; + + public static final Font TEXT_FONT = new Font("sans-serif", Font.BOLD, 12); + public static final Font HEADER_FONT = new Font("sans-serif", Font.ITALIC+Font.BOLD, 12); + + private HashSet showList; + private ArrayList swingLayers; + private AffineTransform transform; + + private Node node; + private Line line; + private ColorProperties colorProperties; + + private Rectangle2D defaultBoundary; + + private int zoomLevel; + + private String currentYearMonth; + + private String dataLoaded = ""; + + /** + * size in screen pixel + */ + private Rectangle boundingBox; + + /** + * size in pixel web mercator projection + */ + private Rectangle2D mapArea; + + /** + * size in longitude latitude + */ + private Rectangle2D geoArea; + + public static double[] meter2pixel; + + private boolean showLegend = false; + + static { + initShapeWidth(); + initMeter2Pixel(); + } + + private static void initMeter2Pixel() { + meter2pixel = new double[MapConstant.ZOOM_MAX - MapConstant.ZOOM_MIN+1]; + meter2pixel[0] = 156543.04/2; + for(int i=1; i 4 && i < 10) { + width += 2; + } + else { + width++; + } + + shapeWidth[i] = width; + } + } + + public NovaMap() { + boundingBox = new Rectangle(); + mapArea = new Rectangle2D.Double(); + geoArea = new Rectangle2D.Double(); + showList = new HashSet(); + swingLayers = new ArrayList(); + } + + + + public int getBestZoomLevel(double Latitude1, double Longitude1, + double Latitude2, double Longitude2, + double height, double width) { + + if (height==0) + height=700; + if (width==0) + width=1200; + + double lat1 = Math.min(Latitude1, Latitude1); + double CosLat = Math.cos(Math.toRadians(lat1)); + double Wmeter = getDistance( + lat1, Longitude1, + lat1, Longitude2)/CosLat; + double Hmeter = getDistance( + Latitude1, Longitude1, + Latitude2, Longitude1)/CosLat; + + int zoom = 0; + if(Latitude1 == Latitude2 && Longitude1 == Longitude2) + zoom = 15; + if (zoom <= 0) { + for(; + zoom < meter2pixel.length + && (width*meter2pixel[zoom]) > Wmeter + && (height*meter2pixel[zoom]) > Hmeter; + ++zoom) ; + } + +// && (1200*meter2pixel[zoom]) > Wmeter +// && (700*meter2pixel[zoom]) > Hmeter; + + return zoom + MapConstant.ZOOM_MIN-1; + } + + public static double getDistance(double Latitude1, double Longitude1, + double Latitude2, double Longitude2) { + Latitude1 = Math.toRadians(Latitude1); + Longitude1 = Math.toRadians(Longitude1); + Latitude2 = Math.toRadians(Latitude2); + Longitude2 = Math.toRadians(Longitude2); + + final double R = 6371.0; // earth's mean radius in km + double dSinLat05 = Math.sin( (Latitude2 - Latitude1)/2 ); + double dSinLong05 = Math.sin( (Longitude2 - Longitude1)/2 ); + double a = dSinLat05 * dSinLat05 + + Math.cos(Latitude1) * Math.cos(Latitude2) * dSinLong05 * dSinLong05; + double c = (0==a || 1==a) + ? 0 + : 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0-a)); + return R * c * 1000.0; //in meters + } + + public Rectangle getBoundingBox() { + return boundingBox; + } + + public void setBoundingBox(int width, int height) { + boundingBox.setSize(width, height); + } + + public void setNode(Node node) { + this.node = node; + } + + public Node getNode() { + return node; + } + + public void setLine(Line line) { + this.line = line; + } + + public Line getLine() { + return line; + } + + public void setColorProperties(ColorProperties colorProperties) { + this.colorProperties = colorProperties; + } + + public ColorProperties getColorProperties() { + return colorProperties; + } + + public void setZoomLevel(int zoomLevel) { + this.zoomLevel = zoomLevel; + } + + public int getZoomLevel() { + return zoomLevel; + } + + public void addShowList(String type) { + showList.add(type.toUpperCase()); + } + + public void addShowList(String type, int number) { + showList.add(type.toUpperCase() + ":" + number); + } + + public void removeShowList(String type) { + showList.remove(type.toUpperCase()); + } + + public void removeShowList(String type, int number) { + showList.remove(type.toUpperCase() + ":" + number); + } + + public void clearShowList() { + showList.clear(); + } + + public HashSet getShowList() { + return showList; + } + + public boolean containsShowList(String type) { + return showList.contains(type.toUpperCase()); + } + + public boolean containsShowList(String type, int number) { + return showList.contains(type.toUpperCase() + ":" + number); + } + + public int getShowListSize() { + return showList.size(); + } + + public void addSwingLayer(SwingLayer swingLayer) { + swingLayers.add(swingLayer); + } + + public void removeSwingLayer(SwingLayer swingLayer) { + swingLayers.remove(swingLayer); + } + + public void clearSwingLayers() { + swingLayers.clear(); + } + + public ArrayList getSwingLayers() { + return swingLayers; + } + + public int getShapeWidth() { + return shapeWidth[getZoomLevel()>=22?21:(getZoomLevel()<=8 ? 8:getZoomLevel())]; + } + + public Point2D getPixelPos(double latitude, double longitude) { + double sinLatitude = Math.sin(Math.toRadians(latitude)); + return new Point2D.Double( + ((longitude + 180.0) / 360.0) * 256.0 * (1< existNodeInfo = node.nodeExist(screenPoint); + + if (existNodeInfo == null) { + ArrayList existLineInfo = line.lineExist(screenPoint); + + if (existLineInfo == null) { + + } + else { + System.out.println("%%%%%%map.singleLeftClick end 1"); + return existLineInfo; + } + } + else { +// if (existNodeInfo.size() == 1) { +// NodeInfo nodeInfo = existNodeInfo.get(0); +// node.getNodeCollection().clearSelectedNode(); +// node.getNodeCollection().addSelectedNode(nodeInfo.getID(), nodeInfo.getLegendID()); +// return getSelectedImage(geoArea); +// } +// else { +// return existNodeInfo; +// } + + System.out.println("%%%%%%map.singleLeftClick end 2"); + return existNodeInfo; + } + + System.out.println("%%%%%%map.singleLeftClick end 3"); + return null; + } + + public String getCurrentYearMonth() { + return currentYearMonth; + } + + public void setCurrentYearMonth(String currentYearMonth) { + this.currentYearMonth = currentYearMonth; + } + + public Rectangle2D getDefaultBoundary() { + return defaultBoundary; + } + + public void setDefaultBoundary(Rectangle2D defaultBoundary) { + this.defaultBoundary = defaultBoundary; + } + + public boolean isShowLegend() { + return showLegend; + } + + public void setShowLegend(boolean showLegend) { + this.showLegend = showLegend; + } + + public String getDataLoaded() { + return dataLoaded; + } + + public void setDataLoaded(String dataLoaded) { + this.dataLoaded = dataLoaded; + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayer.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayer.java new file mode 100644 index 00000000..df3623be --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayer.java @@ -0,0 +1,253 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.map.layer; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Stroke; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; + +import org.onap.portalsdk.analytics.gmap.map.ColorProperties; +import org.onap.portalsdk.analytics.gmap.map.MapConstant; +import org.onap.portalsdk.analytics.gmap.map.NovaMap; +import org.onap.portalsdk.analytics.gmap.node.Node; +import org.onap.portalsdk.analytics.gmap.node.NodeInfo; +import org.onap.portalsdk.analytics.system.Globals; + + +public class SwingLayer { + private Rectangle shape; + private NovaMap map; + + public SwingLayer(NovaMap map) { + this.map = map; + } + + public boolean paintLayer(HttpServletRequest request, Graphics2D g2d, Rectangle bounds, Rectangle2D mapArea, Graphics2D g2Legend) { + return paintNodes(request, g2d, bounds, mapArea, g2Legend); + } + + protected boolean paintNodes(HttpServletRequest request, Graphics2D g2d, Rectangle bounds, Rectangle2D mapArea, Graphics2D g2Legend) { + boolean painted = false; + Node node = map.getNode(); + ColorProperties colorProperties = map.getColorProperties(); + int legendSize = 0; + if(map.isShowLegend()) + legendSize = map.getShowListSize(); + Object showListArr[] = ((HashSet)map.getShowList()).toArray(); + HashMap hashMap = node.getNodeCollection().getNodeCollection(); + Set set = hashMap.entrySet(); + int width = map.getShapeWidth(); + ArrayList visibleLabel = new ArrayList(151); + Color oldColor = g2d.getColor(); + Stroke oldStroke = g2d.getStroke(); + int textWidth = 0; + int legendLength = 0; + for (int i = 0; i < showListArr.length; i++) { + legendLength = ((String)showListArr[i]).length(); + if(legendLength > textWidth) textWidth = legendLength; + } + Point2D point = null; + for (Iterator iterator = set.iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + NodeInfo nodeInfo = (NodeInfo) entry.getValue(); + + String id1 = (String) request.getAttribute("server_process_id"); + String id2 = (String) request.getSession().getAttribute("server_process_id"); + + if (!id1.equals(id2)) { + request.setAttribute("server_process_interrupted", true); + System.out.println("swing layer interrupted"); + return false; + } + //System.out.println("%%%%%%%getImage. no of T1%%%%%%" + nodeInfo.getAttribute("x_sequence")); + + + point = map.getPixelPos(nodeInfo.geoCoordinate.latitude, nodeInfo.geoCoordinate.longitude); + + if (!mapArea.contains(point.getX(), point.getY())) { + continue; + } + + painted = true; + + g2d.setColor(colorProperties.getColor(nodeInfo.getNodeType())); + + Point2D xyPoint = map.getScreenPointFromPixel(point.getX(), point.getY()); + int width2 = (colorProperties.getSize(nodeInfo.getNodeType()) * width) / 5; + + if (shape == null) { + shape = new Rectangle((int) xyPoint.getX(), (int) xyPoint.getY(), width2, width2); + } + else { + shape.setRect((int) xyPoint.getX(), (int) xyPoint.getY(), width2, width2); + } + + if (colorProperties.getShape(nodeInfo.getNodeType())!=null && colorProperties.getShape(nodeInfo.getNodeType()).equalsIgnoreCase(MapConstant.FILLED_SQUARE)) { + g2d.fillRect((int) shape.getCenterX() - width2, (int) shape.getCenterY() - width2, width2, width2); + } + else if (colorProperties.getShape(nodeInfo.getNodeType())!=null && colorProperties.getShape(nodeInfo.getNodeType()).equalsIgnoreCase(MapConstant.HOLLOW_SQUARE)) { + g2d.drawRect((int) shape.getCenterX() - width2, (int) shape.getCenterY() - width2, width2, width2); + } + else if (colorProperties.getShape(nodeInfo.getNodeType())!=null && colorProperties.getShape(nodeInfo.getNodeType()).equalsIgnoreCase(MapConstant.FILLED_CIRCLE)) { + g2d.fillOval((int) shape.getCenterX() - width2, (int) shape.getCenterY() - width2, width2, width2); + } + else if (colorProperties.getShape(nodeInfo.getNodeType())!=null && colorProperties.getShape(nodeInfo.getNodeType()).equalsIgnoreCase(MapConstant.HOLLOW_CIRCLE)) { + g2d.drawOval((int) shape.getCenterX() - width2, (int) shape.getCenterY() - width2, width2, width2); + } + else if (colorProperties.getShape(nodeInfo.getNodeType())!=null && colorProperties.getShape(nodeInfo.getNodeType()).equalsIgnoreCase(MapConstant.FILLED_TRIANGLE)) { + int[] xPoints = {(int) shape.getX(), (int) shape.getX() - width2 / 2, (int) shape.getX() + width2 / 2}; + int[] yPoints = {(int) shape.getY() + width2 / 2, (int) shape.getY() - width2 / 2, (int) shape.getY() - width2 / 2}; + g2d.fillPolygon(xPoints, yPoints, xPoints.length); + } + else if (colorProperties.getShape(nodeInfo.getNodeType())!=null && colorProperties.getShape(nodeInfo.getNodeType()).equalsIgnoreCase(MapConstant.HOLLOW_TRIANGLE)) { + int[] xPoints = {(int) shape.getX(), (int) shape.getX() - width2 / 2, (int) shape.getX() + width2 / 2}; + int[] yPoints = {(int) shape.getY() + width2 / 2, (int) shape.getY() - width2 / 2, (int) shape.getY() - width2 / 2}; + g2d.drawPolygon(xPoints, yPoints, xPoints.length); + } + else if (colorProperties.getShape(nodeInfo.getNodeType())!=null && colorProperties.getShape(nodeInfo.getNodeType()).equalsIgnoreCase(MapConstant.FILLED_DIAMOND)) { + int[] xPoints = {(int) shape.getX() - width2 / 2, (int) shape.getX(), (int) shape.getX() + width2 / 2, (int) shape.getX()}; + int[] yPoints = {(int) shape.getY() , (int) shape.getY() - width2 / 2, (int) shape.getY(), (int) shape.getY() + width2 / 2}; + g2d.fillPolygon(xPoints, yPoints, xPoints.length); + } + else if (colorProperties.getShape(nodeInfo.getNodeType())!=null && colorProperties.getShape(nodeInfo.getNodeType()).equalsIgnoreCase(MapConstant.HOLLOW_DIAMOND)) { + int[] xPoints = {(int) shape.getX() - width2 / 2, (int) shape.getX(), (int) shape.getX() + width2 / 2, (int) shape.getX()}; + int[] yPoints = {(int) shape.getY() , (int) shape.getY() - width2 / 2, (int) shape.getY(), (int) shape.getY() + width2 / 2}; + g2d.drawPolygon(xPoints, yPoints, xPoints.length); + } else { + g2d.drawRect((int) shape.getCenterX() - width2, (int) shape.getCenterY() - width2, width2, width2); + } + + if (nodeInfo.isMoveable()) { + int fontSize = width / 2; + fontSize = fontSize > 14 ? 14 : fontSize; + fontSize = (colorProperties.getSize(nodeInfo.getNodeType()) * fontSize) / 5; + Font font = new Font("sans-serif", Font.BOLD, fontSize); + g2d.setFont(font); + g2d.setColor(Color.BLACK); + g2d.drawString("M", shape.x + width2 / 2, shape.y); + } + +// if (map.containsShowLabelList(nodeInfo.getNodeType())) { +// g2d.setColor(Color.BLACK); +// FontMetrics metrics = g2d.getFontMetrics(); +// int x = shape.x - metrics.stringWidth(nodeInfo.getID()) / 2; +// int y = shape.y + width2 * 4 / 3; +// g2d.drawString(nodeInfo.getID(), x, y); +// } + } + String legendName = ""; + int baseY = 0; + baseY = (int)(20*showListArr.length) + 20;//+5; + int baseX = 0; + if(map.isShowLegend()) { + for (int i = showListArr.length-1; i>=0; i--) { + + legendName = (String)showListArr[i]; + //for(int i = 0; i < showListArr.length; i++ ) { + if(i == showListArr.length-1){ + textWidth = (textWidth<="Legend".length())?"Legend".length():textWidth; + g2Legend.setColor(Color.WHITE); + //g2d.draw(new Rectangle2D.Double((int) bounds.getMaxX()*0.1, (int) bounds.getMaxY()*0.75*showListArr.length, (int) bounds.getMaxX()*0.75, (int) bounds.getMaxY()*0.75)); + g2Legend.fill3DRect((int)(0), (int)(0), (int) bounds.getWidth() , (int)(baseY) , true); // (int)(bounds.getMaxX()*0.9)- (int)(bounds.getMaxX()*0.25) + //if(i == 0){ + g2Legend.setColor(Color.BLACK); + g2Legend.setFont(NovaMap.HEADER_FONT); + g2Legend.drawString("Legend", (int) (10), 10); + } + int[] xPointsL = {(int) (10 - width / 2), (int) (10), (int) (10 + width/2), (int) (10)}; + int[] yPointsL = {(int) (15*i+5+20), (int) (15*i+5+20 - width / 2), (int) (15*i+5+20), (int) (15*i+5+20 + width / 2)}; + g2Legend.setColor(colorProperties.getColor( ((String)showListArr[i]).toUpperCase())); + g2Legend.fillPolygon(xPointsL, yPointsL, xPointsL.length); + g2Legend.setFont(NovaMap.TEXT_FONT); + g2Legend.setColor(Color.BLACK); + + g2Legend.drawString(legendName.substring(0, legendName.indexOf("-")), (int) (10) + width+10, (int) (15*i)+10+20); + } + } + +/* g2d.drawString("0", (int) bounds.getMaxX()/2+20 + width+10, 0); + g2d.drawString("50", (int) bounds.getMaxX()/2+20 + width+10, 50); + g2d.drawString("100", (int) bounds.getMaxX()/2+20 + width+10, 100); + g2d.drawString("200", (int) bounds.getMaxX()/2+20 + width+10, 200); + g2d.drawString("400", (int) bounds.getMaxX()/2+20 + width+10, 400); + g2d.drawString("600", (int) bounds.getMaxX()/2+20 + width+10, 600); +*/ +// g2d.setFont(NovaMap.TEXT_FONT); +// g2d.setColor(Color.BLACK); + if(nvl(map.getDataLoaded()).trim().length() > 0) { + g2d.setColor(Color.WHITE); + g2d.fill3DRect(new Double(bounds.getMinX()).intValue(), new Double(bounds.getMaxY()).intValue()-30, (int) bounds.getWidth() , (int)(30) , true); // (int)(bounds.getMaxX()*0.9)- (int)(bounds.getMaxX()*0.25) + g2d.setColor(Color.RED); + g2d.setFont(NovaMap.HEADER_FONT); + g2d.drawString(Globals.getUserDefinedMessageForMemoryLimitReached() + " "+ map.getDataLoaded()+ " were downloaded to Map.", new Double(bounds.getMinX()).intValue()+80, new Double(bounds.getMaxY()).intValue()-15); + } + + //g2d.drawString("Hello", new Double(bounds.getMinX()).intValue()+20, new Double(bounds.getMaxY()).intValue()-50); + FontMetrics metrics = g2d.getFontMetrics(); + + for (int i = 0; i < visibleLabel.size(); i++) { + String[] properties = visibleLabel.get(i).split(">>>"); + int x = Integer.parseInt(properties[1]) - metrics.stringWidth(properties[0]) / 2; + int y = Integer.parseInt(properties[2]) + Integer.parseInt(properties[3]) * 4 / 3; + g2d.drawString(properties[0], x, y); + } + + g2d.setColor(oldColor); + g2d.setStroke(oldStroke); + + return painted; + } + + private String nvl(String s) { + return (s == null) ? "" : s; + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/Node.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/Node.java new file mode 100644 index 00000000..6188cee1 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/Node.java @@ -0,0 +1,196 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.node; + +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import org.onap.portalsdk.analytics.gmap.map.MapConstant; +import org.onap.portalsdk.analytics.gmap.map.NovaMap; + +public class Node { + private Set nodeIDSet; + private NodeCollection nodeCollection; + private ArrayList selectionList; + private NovaMap map; + + public Node(NovaMap map) { + this.map = map; + nodeCollection = new NodeCollection(); + nodeIDSet = new HashSet(); + selectionList = new ArrayList(); + } + + public NodeInfo addNode(double longitude, double latitude, String nodeType, String nodeID, + String nodeAttributes, int state, boolean moveable, boolean deleteable) { + NodeInfo nodeInfo = new NodeInfo(nodeID); + nodeInfo.geoCoordinate.longitude = longitude; + nodeInfo.geoCoordinate.latitude = latitude; + nodeInfo.setNodeType(nodeType); + nodeInfo.setState(state); + nodeInfo.setMoveable(moveable); + nodeInfo.setDeleteable(deleteable); + nodeInfo.initializeAttributes(nodeAttributes); + + //if (nodeCollection.getNode(nodeInfo.getNodeID()+""+nodeInfo.getNodeType()) == null) { + nodeCollection.addNode(nodeInfo); + nodeIDSet.add(nodeID); +/* } + else { + return nodeCollection.getNode(nodeType); + } +*/ + return nodeInfo; + } + + /** + * + */ +/* public void updateNumberT1(String currentYearMonth) { + ArrayList nodeCollection = this.nodeCollection.getNodeCollection(); + + for (NodeInfo nodeInfo : nodeCollection) { + nodeInfo.setAttribute(NodeInfo.NUMBER_OF_T1_KEY, nodeInfo.getAttribute(currentYearMonth)); + } + } +*/ +/* public Set getUniqueNumberT1(String currentYearMonth) { + ArrayList nodeCollection = this.nodeCollection.getNodeCollection(); + Set numberT1Set = new TreeSet(); + + for (NodeInfo nodeInfo : nodeCollection) { + numberT1Set.add(Integer.parseInt(nodeInfo.getAttribute(currentYearMonth).toString())); + } + + return numberT1Set; + } +*/ + public void updateNumberT1(String currentYearMonth) { + HashMap hashMap = this.nodeCollection.getNodeCollection(); + Set set = hashMap.entrySet(); + + for (Iterator iterator = set.iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + NodeInfo nodeInfo = (NodeInfo) entry.getValue(); + nodeInfo.setAttribute(NodeInfo.NUMBER_OF_T1_KEY, nodeInfo.getAttribute(currentYearMonth)); + } + + } + + public Set getUniqueNumberT1(String currentYearMonth) { + HashMap hashMap = this.nodeCollection.getNodeCollection(); + Set set = hashMap.entrySet(); + Set numberT1Set = new TreeSet(); + + for (Iterator iterator = set.iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + NodeInfo nodeInfo = (NodeInfo) entry.getValue(); + numberT1Set.add(Integer.parseInt(nodeInfo.getAttribute(currentYearMonth).toString())); + } + + return numberT1Set; + } + + /** + * + * @param screenPoint + * @return list of NodeInfo within screenPoint. If not found, null is return + */ + public ArrayList nodeExist(Point2D screenPoint) { + ArrayList existNodeInfo = null; + int nearest = 9999; + String selectedNode = null; + String selectedType = null; + int nodeSize = map.getShapeWidth(); + HashMap hashMap = nodeCollection.getNodeCollection(); + Set set = hashMap.entrySet(); + //ArrayList list = nodeCollection.getNodeCollection(); + + for (Iterator iterator = set.iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + NodeInfo nodeInfo = (NodeInfo) entry.getValue(); + + if (!map.containsShowList(nodeInfo.getNodeType())) { + continue; + } + + int width = (map.getColorProperties().getSize(nodeInfo.getNodeType()) * nodeSize) / 5; + int foundFactor = (int) (MapConstant.ZOOMING_INDEX * width); + Point2D nodePoint = map.getScreenPointFromLonLat(nodeInfo.geoCoordinate.longitude, + nodeInfo.geoCoordinate.latitude); + + int lonDiff = (int) Math.abs(screenPoint.getX() - nodePoint.getX()); + int latDiff = (int) Math.abs(screenPoint.getY() - nodePoint.getY()); + + if (lonDiff < foundFactor && latDiff < foundFactor) { + if (lonDiff < nearest) { + nearest = lonDiff; + selectedNode = nodeInfo.getNodeID(); + selectedType = nodeInfo.getNodeType(); + nodeCollection.setNodeID(selectedNode); + } + + if (existNodeInfo == null) { + existNodeInfo = new ArrayList(); + } + + existNodeInfo.add(nodeInfo); + } + } + + return existNodeInfo; + } + + public NodeCollection getNodeCollection() { + return nodeCollection; + } + + public void clearNodeIDSet() { + nodeIDSet.clear(); + } + + public void clearSelectionList() { + selectionList.clear(); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java new file mode 100644 index 00000000..c54b268a --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java @@ -0,0 +1,211 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.node; + + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; + +public class NodeCollection { + + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(NodeCollection.class); + + private Set selectedNode; // all selected node + private String nodeID; // last clicked node + private HashMap nodeCollection; + + public NodeCollection() { + selectedNode = new HashSet(); + nodeCollection = new HashMap(20000); + } + + public void addSelectedNode(String nodeID) { + selectedNode.add(nodeID); + } + + public void removeSelectedNode(String nodeID) { + selectedNode.remove(nodeID); + } + + public boolean containSelectedNode(String nodeID) { + return selectedNode.contains(nodeID); + } + + public void addSelectedNode(String nodeID, String nodeType) { + selectedNode.add(nodeID + ">>" + nodeType); + } + + public void removeSelectedNode(String nodeID, String nodeType) { + selectedNode.remove(nodeID + ">>" + nodeType); + } + + public void clearSelectedNode() { + selectedNode.clear(); + } + + public boolean containSelectedNode(String nodeID, String nodeType) { + return selectedNode.contains(nodeID + ">>" + nodeType); + } + + public Set getSelectedNode() { + return selectedNode; + } + + public void addNode(NodeInfo nodeInfo) { + if (nodeInfo == null) + logger.error("addNode: nodeInfo is null"); + else + nodeCollection.put(nodeInfo.getNodeID()+""+nodeInfo.getNodeType(), nodeInfo); + } + + public HashMap getNodeCollection() { + return nodeCollection; + } + +/* public NodeInfo getNode(String nodeID) { + for (NodeInfo nodeInfo : nodeCollection) { + if (nodeInfo.getNodeID().equalsIgnoreCase(nodeID) ) { + return nodeInfo; + } + } + + return null; + } +*/ +/* public NodeInfo getNode(String nodeID, String nodeType) { + for (NodeInfo nodeInfo : nodeCollection) { + if (nodeInfo.getNodeID().equalsIgnoreCase(nodeID) && nodeInfo.getNodeType().equalsIgnoreCase(nodeType)) { + return nodeInfo; + } + } + + return null; + } +*/ + public NodeInfo getNode(String nodeType) { + return (NodeInfo)nodeCollection.get(nodeType); + } +/* public ArrayList getWildCardNode(String nodeID, String nodeType) { + ArrayList list = new ArrayList(); + + for (NodeInfo nodeInfo : nodeCollection) { + if (nodeInfo.getNodeType().equalsIgnoreCase(nodeType) && + nodeInfo.getNodeID().toLowerCase().indexOf(nodeID.toLowerCase()) != -1) { + list.add(nodeInfo); + } + } + + return list; + }*/ + +/* public NodeInfo removeNode(String nodeID) { + for (int i = 0; i < nodeCollection.size(); i++) { + if (nodeCollection.get(i).getNodeID().equalsIgnoreCase(nodeID)) { + return nodeCollection.remove(i); + } + } + + removeSelectedNode(nodeID); + return null; + } + + public NodeInfo removeNode(String nodeID, String nodeType) { + for (int i = 0; i < nodeCollection.size(); i++) { + if (nodeCollection.get(i).getNodeID().equalsIgnoreCase(nodeID) && + nodeCollection.get(i).getNodeType().equalsIgnoreCase(nodeType)) { + return nodeCollection.remove(i); + } + } + + removeSelectedNode(nodeID, nodeType); + return null; + } +*/ +/* public void removeNode(String nodeType) { + nodeCollection.remove(nodeType); + }*/ + +/* public ArrayList getCellsiteLocation(String location, boolean exactMatch) { + ArrayList list = new ArrayList(); + + for (NodeInfo nodeInfo : nodeCollection) { + if (nodeInfo.getAttribute("Location") == null) { + continue; + } + + if (exactMatch) { + if (nodeInfo.getAttribute("Location").equalsIgnoreCase(location)) { + list.add(nodeInfo); + } + } + else { + if (nodeInfo.getAttribute("Location").toUpperCase().indexOf(location.toUpperCase()) != -1) { + list.add(nodeInfo); + } + } + } + + return list; + } +*/ + public void clearNode() { + nodeCollection.clear(); + selectedNode.clear(); + } + + public int getSize() { + return nodeCollection.size(); + } + + public void setNodeID(String nodeID) { + this.nodeID = nodeID; + } + + public String getNodeID() { + return nodeID; + } + + public void clearAllCollection() { + this.clearNode(); + this.clearSelectedNode(); + this.nodeID = ""; + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeInfo.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeInfo.java new file mode 100644 index 00000000..0ed7b842 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeInfo.java @@ -0,0 +1,228 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.node; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.TreeMap; + +import org.onap.portalsdk.analytics.gmap.map.GeoCoordinate; + +public class NodeInfo { + public static final String NUMBER_OF_T1_KEY = "x_numberOfT1"; + public static final String SEQUENCE_KEY = "x_sequence"; + + public GeoCoordinate geoCoordinate; + + private String nodeID; + private String nodeType; + private int state; + private boolean moveable; + private boolean deleteable; + + private List lineIDS; + private Map nodeAttributes; + + public NodeInfo(String nodeID) { + this.nodeID = nodeID; + lineIDS = new ArrayList(); + nodeAttributes = new TreeMap(); + geoCoordinate = new GeoCoordinate(); + } + + public NodeInfo clone() { + NodeInfo nodeInfo = new NodeInfo(nodeID); + nodeInfo.geoCoordinate.longitude = geoCoordinate.longitude; + nodeInfo.geoCoordinate.latitude = geoCoordinate.latitude; + nodeInfo.setMoveable(moveable); + nodeInfo.setNodeType(nodeType); + nodeInfo.setNodeID(nodeID); + nodeInfo.setState(state); + nodeInfo.setLineIDS(cloneLineIDS()); + nodeInfo.setDeleteable(deleteable); + nodeInfo.initializeAttributes(nodeAttributes); + + return nodeInfo; + } + + public void addLineID(String lineID, String lineType) { + if (!lineIDS.contains(lineID + ">>" + lineType)) { + lineIDS.add(lineID + ">>" + lineType); + } + } + + public void removeLineID(String lineID, String lineType) { + lineIDS.remove(lineID + ">>" + lineType); + } + + public String getLineID(String lineID, String lineType) { + for (Object temp : lineIDS) { + if (temp.toString().equals(lineID + ">>" + lineType)) { + return temp.toString(); + } + } + + return null; + } + + public List getLineIDS() { + return lineIDS; + } + + public void printLineIDS() { + Iterator iter = lineIDS.iterator(); + + while (iter.hasNext()) { + System.out.println(iter.next()); + } + } + + public List cloneLineIDS() { + List lineIDS = new ArrayList(); + + for (String lineID : this.lineIDS) { + lineIDS.add(lineID); + } + + return lineIDS; + } + + public void setLineIDS(List lineIDS) { + this.lineIDS = lineIDS; + } + + public void setNodeID(String nodeID) { + this.nodeID = nodeID; + } + + public String getNodeID() { + return nodeID; + } + + public void setNodeType(String nodeType) { + this.nodeType = nodeType; + } + + public String getNodeType() { + return nodeType; + } + + public void setState(int state) { + this.state = state; + } + + public int getState() { + return state; + } + + public void setMoveable(boolean moveable) { + this.moveable = moveable; + } + + public boolean isMoveable() { + return moveable; + } + + public void setDeleteable(boolean deleteable) { + this.deleteable = deleteable; + } + + public boolean isDeleteable() { + return deleteable; + } + + public String getAttribute(String key) { + String value = nodeAttributes.get(key); + return value; + } + + public void initializeAttributes(Map nodeAttributes) { + this.nodeAttributes.clear(); + Set keySet = nodeAttributes.keySet(); + Iterator iter = keySet.iterator(); + + while (iter.hasNext()) { + String key = iter.next(); + this.nodeAttributes.put(key, nodeAttributes.get(key)); + } + } + + public void initializeAttributes(String nodeAttributes) { + if (nodeAttributes == null) { + return; + } + + this.nodeAttributes.clear(); + StringTokenizer tokenizer = new StringTokenizer(nodeAttributes, "|"); + + while (tokenizer.hasMoreTokens()) { + String attribute = tokenizer.nextToken(); + StringTokenizer attributeTokenizer = new StringTokenizer(attribute, "="); + + if (attributeTokenizer.countTokens() == 2) { + String key = attributeTokenizer.nextToken(); + String value = attributeTokenizer.nextToken(); + this.nodeAttributes.put(key, value); + } + } + } + + public void setAttribute(String key, String value) { + nodeAttributes.put(key, value); + } + + public List getAttributeKeys() { + Set keySet = nodeAttributes.keySet(); + List keys = new ArrayList(keySet.size()); + Iterator iter = keySet.iterator(); + + while (iter.hasNext()) { + String key = iter.next(); + + if (key.indexOf("x_") != 0) { + keys.add(key); + } + } + + return keys; + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/MapUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/MapUtils.java new file mode 100644 index 00000000..277dac0f --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/MapUtils.java @@ -0,0 +1,88 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.utils; + +import java.io.ObjectOutputStream; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + + + +public class MapUtils { + public static final short PLATE_CARREE_PROJECTION = 0; + public static final short WEB_MERCATOR_PROJECTION = 1; + + + + private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new java.text.SimpleDateFormat("yyyy/MM"); + + + + public static String getModifiedMarketID(String marketID) { + String modifiedMarketID = marketID.replaceAll("/", "_"); + modifiedMarketID = modifiedMarketID.replaceAll(" ", "_"); + return modifiedMarketID; + } + + /** + * increment or decrement + * @param currentYearMonth + * @param value - positive value will increment, otherwise decrement + * @return null if not valid number (must be between 2008/01 to 2010/12) + */ + + +/* public static void saveColor(HttpServletRequest request, DomainService domainService, + String type, String colorValue) { +// String userID = Integer.toString(UserUtils.getUserId(request)); +// MapColorPK colorPK = new MapColorPK(); +// MapColorVO colorVO = new MapColorVO(); +// +// colorPK.setUserID(userID); +// colorPK.setPrefID(type); +// colorVO.setMapColorPK(colorPK); +// colorVO.setColorValue(colorValue); +// +// domainService.saveDomainObject(colorVO); + } */ +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/SwingWorker.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/SwingWorker.java new file mode 100644 index 00000000..eeac444c --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/SwingWorker.java @@ -0,0 +1,173 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the “License”); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.gmap.utils; + +import javax.swing.SwingUtilities; + +/** + * This is the 3rd version of SwingWorker (also known as + * SwingWorker 3), an abstract class that you subclass to + * perform GUI-related work in a dedicated thread. For + * instructions on using this class, see: + * + * http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html + * + * Note that the API changed slightly in the 3rd version: + * You must now invoke start() on the SwingWorker after + * creating it. + */ +public abstract class SwingWorker { + private Object value; // see getValue(), setValue() + private Thread thread; + + /** + * Class to maintain reference to current worker thread + * under separate synchronization control. + */ + private static class ThreadVar { + private Thread thread; + ThreadVar(Thread t) { thread = t; } + synchronized Thread get() { return thread; } + synchronized void clear() { thread = null; } + } + + private ThreadVar threadVar; + + /** + * Get the value produced by the worker thread, or null if it + * hasn't been constructed yet. + */ + protected synchronized Object getValue() { + return value; + } + + /** + * Set the value produced by worker thread + */ + private synchronized void setValue(Object x) { + value = x; + } + + /** + * Compute the value to be returned by the get method. + */ + public abstract Object construct(); + + /** + * Called on the event dispatching thread (not on the worker thread) + * after the construct method has returned. + */ + public void finished() { + } + + /** + * A new method that interrupts the worker thread. Call this method + * to force the worker to stop what it's doing. + */ + public void interrupt() { + Thread t = threadVar.get(); + if (t != null) { + t.interrupt(); + } + threadVar.clear(); + } + + /** + * Return the value created by the construct method. + * Returns null if either the constructing thread or the current + * thread was interrupted before a value was produced. + * + * @return the value created by the construct method + */ + public Object get() { + while (true) { + Thread t = threadVar.get(); + if (t == null) { + return getValue(); + } + try { + t.join(); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); // propagate + return null; + } + } + } + + + /** + * Start a thread that will call the construct method + * and then exit. + */ + public SwingWorker() { + final Runnable doFinished = new Runnable() { + public void run() { finished(); } + }; + + Runnable doConstruct = new Runnable() { + public void run() { + try { + setValue(construct()); + } + finally { + threadVar.clear(); + } + + SwingUtilities.invokeLater(doFinished); + } + }; + + Thread t = new Thread(doConstruct); + threadVar = new ThreadVar(t); + } + + /** + * Start the worker thread. + */ + public void start() { + Thread t = threadVar.get(); + if (t != null) { + t.start(); + } + } + + public Thread getThread() { + return threadVar.get(); + } +} -- cgit 1.2.3-korg