package viewer.hoese.algebras; import java.awt.geom.*; import java.awt.*; import viewer.*; import viewer.hoese.*; import sj.lang.ListExpr; import java.util.*; import gui.Environment; import tools.Reporter; /** * A displayclass for the cmpoint for TemporalAlgebra */ public class Dsplcmpointregion extends DisplayTimeGraph implements LabelAttribute, RenderAttribute { Point2D.Double point; Area area; private Path2D.Double rect; private Shape shp; Vector PointMaps; Rectangle2D.Double bounds; double minValue = Integer.MAX_VALUE; double maxValue = Integer.MIN_VALUE; boolean defined; double radius = 0.0, dir=0; static java.text.DecimalFormat format = new java.text.DecimalFormat("#.#####"); public int numberOfShapes(){ return 1; } /** Returns a short text usable as label **/ public String getLabel(double time){ if(Intervals==null || PointMaps==null){ return null; } int index = IntervalSearch.getTimeIndex(time,Intervals); if(index<0){ return null; } CPointMap pm = (CPointMap) PointMaps.get(index); Interval in = (Interval)Intervals.get(index); double t1 = in.getStart(); double t2 = in.getEnd(); double Delta = (time-t1)/(t2-t1); double e = pm.e; double x = pm.x1+Delta*(pm.x2-pm.x1); double y = pm.y1+Delta*(pm.y2-pm.y1); int hSign = pm.x1 < pm.x2 ? 1 :-1; int vSign = pm.y1 < pm.y2 ? 1 :-1; dir = Math.atan2(pm.y2 - pm.y1, pm.x2 - pm.x1) * Math.PI / 180 ; double tmpx = pm.x1 - hSign * Math.abs(Math.sin(dir)) * pm.e; // em.x1+delta*(em.x2-em.x1); double tmpy = pm.y1 - vSign * Math.abs(Math.cos(dir)) * pm.e; // return "(("+format.format(x)+", "+ format.format(y)+")"+format.format(e)+")"; // return "("+format.format(e)+"("+format.format(tmpx)+", "+ format.format(tmpy)+"))"+ " DIR " + dir + " Math.sin(dir) " + Math.sin(dir) + " Math.cos(dir) "+ Math.cos(dir) ;// + "Index" + index + " t1" + format.format(t1) + " t2 "+ format.format(t2) + " Delta " + format.format(Delta) + " time " + format.format(time) + " CMPoint "+ pm + " PointMap " + PointMaps.size(); } /** * Gets the shape of this instance at the ActualTime * @param at The actual transformation, used to calculate the correct size. * @return Rectangle or Circle Shape if ActualTime is defined otherwise null. */ public Shape getRenderObject(int num,AffineTransform at) { if(num!=0){ return null; } if(!defined){ return null; } return shp; } /** * Reads the coefficients out of ListExpr for the point and radius * @param le ListExpr of four reals. * @return The CPointMap that was read. */ private CPointMap readCPointMap(double e, ListExpr le) { Double value[] = { null, null, null, null }; if (le.listLength() != 4) return null; for (int i = 0; i < 4; i++) { value[i] = LEUtils.readNumeric(le.first()); if (value[i] == null) return null; le = le.rest(); } double x1, y1; double v0 = value[0].doubleValue(); double v1 = value[1].doubleValue(); double v2 = value[2].doubleValue(); double v3 = value[3].doubleValue(); if(minValue>v0) minValue=v0; if(maxValuev2) minValue=v2; if(maxValue=0; } class CPointMap{ double e, x1,x2,y1,y2; public CPointMap(double e, double x1, double y1, double x2, double y2) { this.e = e; this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; } public String toString(){ return ("([x1,y1 | x2,y2]epsilon) = (["+x1+","+y1+" <> "+x2+","+y2+"] "+e+")"); } } }