View Javadoc
1 /* ------------------------------------------------------------------- 2 GeoVISTA Center (Penn State, Dept. of Geography) 3 Java source file for the class LayerPoint 4 Copyright (c), 2002, GeoVISTA Center 5 All Rights Reserved. 6 Original Author: Frank Hardisty 7 $Author: hardisty $ 8 $Id: LayerPoint.java,v 1.2 2003/04/25 17:23:47 hardisty Exp $ 9 $Date: 2003/04/25 17:23:47 $ 10 Reference: Document no: 11 ___ ___ 12 ------------------------------------------------------------------- * 13 */ 14 15 16 package edu.psu.geovista.app.map; 17 import java.awt.image.*; 18 import java.awt.*; 19 import java.awt.geom.*; 20 /*** 21 * put your documentation comment here 22 */ 23 public class LayerPoint extends LayerShape { 24 25 private Point2D[] originalPoints; 26 27 28 /* 29 * selectionX1 is expected to be less than selectionX2, same with Y1 and y2 30 */ 31 public void findSelection (int selectionX1, int selectionX2, int selectionY1, 32 int selectionY2) { 33 } 34 35 /* 36 * selectionX1 is expected to be less than selectionX2, same with Y1 and y2 37 */ 38 public void findSelectionShift (int selectionX1, int selectionX2, int selectionY1, 39 int selectionY2) { 40 } 41 42 public int findIndication(int x, int y) {return Integer.MIN_VALUE;} 43 /*** 44 * sets the points that the layer will use to draw from 45 * these are assumed to be in user space 46 * @param originalPoints 47 */ 48 public void setOriginalPoints (Point2D[] originalPoints) { 49 this.originalPoints = originalPoints; 50 } 51 /*** 52 * retrieves the points 53 * @param originalPoints 54 */ 55 public Point2D[] getOriginalPoints () { 56 return this.originalPoints; 57 } 58 59 public Point2D[] shapesToPoints(Shape[] shapes){ 60 Point2D[] points = new Point2D.Double[shapes.length]; 61 for (int i = 0; i < shapes.length; i++) { 62 Point2D pnt = new Point2D.Double(); 63 Shape shp = shapes[i]; 64 PathIterator path = shp.getPathIterator(null); 65 double[] seg = new double[6]; 66 int segType = path.currentSegment(seg); 67 if (segType != path.SEG_MOVETO) { 68 throw new IllegalArgumentException("LayerPoint.shapesToPoints expects only PathIterator.SEG_MOVETO segments"); 69 } 70 pnt.setLocation(seg[0],seg[1]); 71 points[i] = pnt; 72 } 73 74 return points; 75 } 76 77 public Shape[] pointsToShapes(Point2D[] points){ 78 Shape[] shapes = new Shape[points.length]; 79 for (int i = 0; i < shapes.length; i++) { 80 GeneralPath shp = new GeneralPath(); 81 Point2D pnt = points[i]; 82 shp.moveTo((float)pnt.getX(),(float)pnt.getY()); 83 shapes[i] = shp; 84 } 85 86 return shapes; 87 } 88 89 90 public Shape[] findShapesForPoints(Point2D[] points){ 91 Shape[] shapes = new Shape[points.length]; 92 float shapeSize = 2f; 93 float half = shapeSize / 2f; 94 for (int i = 0; i < shapes.length; i++) { 95 Point2D pt = points[i]; 96 97 Ellipse2D eli= new Ellipse2D.Float((float)pt.getX() - half,(float)pt.getY() - half,shapeSize,shapeSize); 98 99 shapes[i] = eli; 100 } 101 102 return shapes; 103 } 104 }

This page was automatically generated by Maven