//This file is part of SECONDO. //Copyright (C) 2004, University in Hagen, Department of Computer Science, //Database Systems for New Applications. //SECONDO is free software; you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation; either version 2 of the License, or //(at your option) any later version. //SECONDO is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. //You should have received a copy of the GNU General Public License //along with SECONDO; if not, write to the Free Software //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package viewer.hoese.algebras; import java.awt.geom.*; import java.awt.*; import sj.lang.ListExpr; import java.util.*; import viewer.*; import viewer.hoese.*; import tools.Reporter; /** * The displayclass of the points datatype. */ public class DsplprecPoints extends DisplayGraph { Point2D.Double[] points=null; Rectangle2D.Double bounds=null; protected boolean defined; /** * Scans the representation of the points datatype and * an array containing the points. * The representation is a list of points which are given just * by the two coordinates describing the position. * @param value: the list representing this points value */ public void ScanValue (ListExpr value) { err = true; defined = false; points = null; bounds = null; if(isUndefined(value)){ err=false; defined = false; return; } defined = true; if(value.listLength()!=2){ return; } if(value.first().atomType()!=ListExpr.INT_ATOM){ return; } int scale = value.first().intValue(); if(scale<=0){ return; } value = value.second(); Vector pointsV = new Vector(20, 20); while (!value.isEmpty()) { ListExpr v = value.first(); value = value.rest(); if(v.listLength()!=2){ return; } Double X = Dsplprecise.getDouble(v.first(),false); Double Y = Dsplprecise.getDouble(v.second(),false); if(X==null || Y==null){ if(X==null){ System.out.println("cannot extract coord from " + v.first()); } if(Y==null){ System.out.println("cannot extract coord from " + v.second()); } return; } double x = X.doubleValue()/scale; double y = Y.doubleValue()/scale; if(!ProjectionManager.project(x,y,aPoint)){ return; } pointsV.add(new Point2D.Double(aPoint.x, aPoint.y)); } err = false; computeBounds(pointsV); } protected void computeBounds(Vector pointsV){ bounds = null; if(!err){ // copy the vector into the array to avoid cast // during painting this object int size = pointsV.size(); points = new Point2D.Double[size]; for(int i=0;i