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 Dsplcmpoint extends DisplayTimeGraph implements LabelAttribute, RenderAttribute { Point2D.Double point; Vector PointMaps; Rectangle2D.Double bounds; double minValue = Integer.MAX_VALUE; double maxValue = Integer.MIN_VALUE; boolean defined; double radius = 0.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); return "("+format.format(e)+"("+format.format(x)+", "+ format.format(y)+"))"; } /** * 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(Intervals==null || PointMaps==null){ return null; } if(RefLayer==null){ return null; } double t = RefLayer.getActualTime(); int index = IntervalSearch.getTimeIndex(t,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 = (t-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); point = new Point2D.Double(x, y); double ps = Cat.getPointSize(renderAttribute,CurrentState.ActualTime); // The higth and width of the circle is related to the radius-value. // But pix / pixy denote the complete width / higth // of the point-object, they are set to 2*radius. double pixy = 0; double pix = 0; if( e == 0.0 ) { pixy = 4; pix = 4; } else { pixy = Math.abs(2*e); pix = Math.abs(2*e); } Shape shp; if (Cat.getPointasRect()) shp = new Rectangle2D.Double(point.getX()- pix/2, point.getY() - pixy/2, pix, pixy); else { shp = new Ellipse2D.Double(point.getX()- pix/2, point.getY() - pixy/2, pix, pixy); } 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 ("(epsilon[x1,y1 | x2,y2]) = ("+e+"["+x1+","+y1+" <> "+x2+","+y2+"])"); } } }