diff options
author | TATTAVARADA <statta@research.att.com> | 2017-04-27 07:53:18 -0400 |
---|---|---|
committer | st782s <statta@research.att.com> | 2017-04-27 08:31:27 -0400 |
commit | 6beb446925c967aca92f5513adf36c5db77c00d6 (patch) | |
tree | 9392057ed0739de2445c5b2a2a8bee6dcdacbcf7 /ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map | |
parent | 246b225194e3e8dc1926294de591a94fd9787fa7 (diff) |
[PORTAL-7] Rebase
This rebasing includes common libraries and common overlays projects
abstraction of components
Change-Id: Ia1efa4deacdc5701e6205104ac021a6c80ed60ba
Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map')
6 files changed, 0 insertions, 972 deletions
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/ColorProperties.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/ColorProperties.java deleted file mode 100644 index a87af423..00000000 --- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/ColorProperties.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file 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. - * ================================================================================ - */ -package org.openecomp.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<String, Object> colorProperties; - private ArrayList<String> nodeLegends; - private ArrayList<String> lineLegends; - - public ColorProperties(NovaMap map) { - this.map = map; - colorProperties = new HashMap<String, Object>(); - } - - 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/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/GMapProperties.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/GMapProperties.java deleted file mode 100644 index 7c66f4be..00000000 --- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/GMapProperties.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.analytics.gmap.map; - -import org.openecomp.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/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/GeoCoordinate.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/GeoCoordinate.java deleted file mode 100644 index ed3fe8bd..00000000 --- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/GeoCoordinate.java +++ /dev/null @@ -1,25 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.analytics.gmap.map; - -public class GeoCoordinate { - public double longitude; - public double latitude; -} diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/MapConstant.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/MapConstant.java deleted file mode 100644 index cef1f4ad..00000000 --- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/MapConstant.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file 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. - * ================================================================================ - */ -package org.openecomp.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/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/NovaMap.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/NovaMap.java deleted file mode 100644 index ba245064..00000000 --- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/NovaMap.java +++ /dev/null @@ -1,504 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file 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. - * ================================================================================ - */ -package org.openecomp.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.openecomp.portalsdk.analytics.gmap.line.Line; -import org.openecomp.portalsdk.analytics.gmap.line.LineInfo; -import org.openecomp.portalsdk.analytics.gmap.map.layer.SwingLayer; -import org.openecomp.portalsdk.analytics.gmap.node.Node; -import org.openecomp.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<String> showList; - private ArrayList<SwingLayer> 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<meter2pixel.length; ++i) - meter2pixel[i] = meter2pixel[i-1]/2; - } - - private static void initShapeWidth() { - // ZOOM_MAX+1 is added to below line because of ArrayIndexOutOfException. This is Suggested by Hendra Tuty. - Sundar - shapeWidth = new int[MapConstant.ZOOM_MAX]; - int width = 0; - for (int i = 0; i < shapeWidth.length; i++) { - if (i < 5) { - - } - else if (i == 5) { - width = 4; - } - else if (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<String>(); - swingLayers = new ArrayList<SwingLayer>(); - } - - - - 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<SwingLayer> 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<<zoomLevel), - ( 0.5 - Math.log((1.0+sinLatitude)/(1.0-sinLatitude)) - /(4.0*Math.PI) )*256.0*(1<<zoomLevel) - ); - } - - private boolean checkTransform(Rectangle2D geoArea) { - System.out.println("%%%%%%map.checkTransform start"); - if (!this.geoArea.equals(geoArea)) { - Point2D point1 = getPixelPos(geoArea.getMinY(), geoArea.getMinX()); - Point2D point2 = getPixelPos(geoArea.getMaxY(), geoArea.getMaxX()); - mapArea.setRect(point1.getX(), point2.getY(), - boundingBox.getWidth(), boundingBox.getHeight()); - this.geoArea.setRect(geoArea); - resetTransform(boundingBox, mapArea); - System.out.println("%%%%%%map.checkTransform end 1"); - return true; - } - - System.out.println("%%%%%%map.checkTransform end 2"); - return false; - } - - private void resetTransform(Rectangle boundingBox, Rectangle2D mapArea) { - System.out.println("%%%%%%map.resetTransform start"); - if (mapArea == null || boundingBox.getWidth() == 0 || boundingBox.getHeight() == 0 ) { - System.out.println("%%%%%%map.resetTransform end 1"); - return; - } - - transform = new AffineTransform(mapArea.getWidth() / boundingBox.getWidth(), - 0.0, 0.0, mapArea.getHeight() / boundingBox.getHeight(), - mapArea.getMinX(), mapArea.getMinY()); - System.out.println("%%%%%%map.resetTransform end 2"); - } - - protected AffineTransform getTransform() { - if (transform != null) { - return new AffineTransform(transform); - } - - return null; - } - - public Point2D getScreenPointFromPixel(double xPixel, double yPixel) { - try { - return getTransform().inverseTransform(new Point2D.Double(xPixel, yPixel), null); - } catch (NoninvertibleTransformException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return null; - } - - public Point2D getScreenPointFromLonLat(double longitude, double latitude) { - Point2D point = getPixelPos(latitude, longitude); - return getScreenPointFromPixel(point.getX(), point.getY()); - } - - public Point2D getLonLatFromPixel(int x1, int y1) { - double x = (double) x1 / 256; - double y = (double) y1 / 256; - double lon = -180; // x - double lonWidth = 360; // width 360 - - //double lat = -90; // y - //double latHeight = 180; // height 180 - double lat = -1; - double latHeight = 2; - - int tilesAtThisZoom = 1 << getZoomLevel(); - lonWidth = 360.0 / tilesAtThisZoom; - lon = -180 + (x * lonWidth); - latHeight = -2.0 / tilesAtThisZoom; - lat = 1 + (y * latHeight); - - // convert lat and latHeight to degrees in a transverse mercator projection - // note that in fact the coordinates go from about -85 to +85 not -90 to 90! - latHeight += lat; - latHeight = (2 * Math.atan(Math.exp(Math.PI * latHeight))) - (Math.PI / 2); - latHeight *= (180 / Math.PI); - - lat = (2 * Math.atan(Math.exp(Math.PI * lat))) - (Math.PI / 2); - lat *= (180 / Math.PI); - - latHeight -= lat; - - if (lonWidth < 0) { - lon = lon + lonWidth; - lonWidth = -lonWidth; - } - - if (latHeight < 0) { - lat = lat + latHeight; - latHeight = -latHeight; - } - - return new Point2D.Double(lon, lat + latHeight); - } - - public ArrayList getImage(final HttpServletRequest request, Rectangle2D geoArea) { - Object showListArr[] = ((HashSet)getShowList()).toArray(); - BufferedImage image = new BufferedImage(boundingBox.width, boundingBox.height, BufferedImage.TYPE_INT_ARGB); - final Graphics2D g2d = image.createGraphics(); - // LEGEND INFO - BufferedImage legendImage = null; - Graphics2D g2Legend = null; - if(showLegend) { - legendImage = new BufferedImage(boundingBox.width, (int)(20*showListArr.length) + 20, BufferedImage.TYPE_INT_ARGB); - g2Legend = legendImage.createGraphics(); - g2Legend.setBackground(Color.WHITE); - } - - checkTransform(geoArea); - - boolean shapefileLayerPainted = false; - boolean swingLayerPainted = false; - - Object object = request.getAttribute("server_process_interrupted"); - if (object != null && ((Boolean) object)) { - System.out.println("interrupted"); - g2d.dispose(); - return null; - } - - for (SwingLayer layer : swingLayers) { - swingLayerPainted = swingLayerPainted || layer.paintLayer(request, g2d, boundingBox, mapArea, g2Legend); - } - - ArrayList imageArr = new ArrayList(); - //if(showLegend) layer.paintLegend(g2Legend); - - g2d.dispose(); - if(showLegend) - g2Legend.dispose(); - object = request.getAttribute("server_process_interrupted"); - - if (object != null && ((Boolean) object)) { - System.out.println("interrupted"); - return imageArr; - } - else if (!shapefileLayerPainted && !swingLayerPainted) { - System.out.println("not painted"); - return imageArr; - } - - imageArr.add(image); - if(g2Legend!=null) { - imageArr.add(legendImage); - } - return imageArr; - } - - public Object singleLeftClick(double longitude, double latitude, Rectangle2D geoArea) { - System.out.println("%%%%%%map.singleLeftClick start"); - System.out.println("%%%%%%map.singleLeftClick check transform start"); - checkTransform(geoArea); - System.out.println("%%%%%%map.singleLeftClick check transform end"); - Point2D screenPoint = getScreenPointFromLonLat(longitude, latitude); - System.out.println("%%%%%%map.singleLeftClick getting nodeExist array "); - ArrayList<NodeInfo> existNodeInfo = node.nodeExist(screenPoint); - - if (existNodeInfo == null) { - ArrayList<LineInfo> 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/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/layer/SwingLayer.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/layer/SwingLayer.java deleted file mode 100644 index f5237ccf..00000000 --- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/gmap/map/layer/SwingLayer.java +++ /dev/null @@ -1,234 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.analytics.gmap.map.layer; - -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -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.openecomp.portalsdk.analytics.gmap.map.ColorProperties; -import org.openecomp.portalsdk.analytics.gmap.map.MapConstant; -import org.openecomp.portalsdk.analytics.gmap.map.NovaMap; -import org.openecomp.portalsdk.analytics.gmap.node.Node; -import org.openecomp.portalsdk.analytics.gmap.node.NodeInfo; -import org.openecomp.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<String,NodeInfo> hashMap = node.getNodeCollection().getNodeCollection(); - Set set = hashMap.entrySet(); - int width = map.getShapeWidth(); - ArrayList<String> visibleLabel = new ArrayList<String>(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; - } -} |