public int getZoomLevel(Circle circle) { if (circle != null){ double radius = circle.getRadius(); double scale = radius / 500; zoomLevel =(int) (16 - Math.log(scale) / Math.log(2)); } return zoomLevel; }
final Circle circle = MAP.addCircle(new CircleOptions().center(EGYPT) .strokeColor(Color.CYAN).radius(100)); ValueAnimator vAnimator = new ValueAnimator(); vAnimator.setRepeatCount(ValueAnimator.INFINITE); vAnimator.setRepeatMode(ValueAnimator.RESTART); /* PULSE */ vAnimator.setIntValues(0, 100); vAnimator.setDuration(1000); vAnimator.setEvaluator(new IntEvaluator()); vAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); vAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedFraction = valueAnimator.getAnimatedFraction(); // Log.e("", "" + animatedFraction); circle.setRadius(animatedFraction * 100); } }); vAnimator.start();
public Circle(double x, double y, double r) { setCentre(new Coordinate(x, y)); setRadius(r); }
@Test public void test() { Coordinate p0 = new Coordinate(34.2d,34.4d); Coordinate p1 = new Coordinate(31.2d,32.4d); Coordinate p2 = new Coordinate(36.2d,35.4d); Triangle triangle = new Triangle(p0, p1, p2); Assert.assertNotNull(triangle.inCentre()); Assert.assertNotNull(triangle.centroid(p0, p1, p2)); triangle = new Triangle(2d, 4d, 15d, 23d, 23d, 32d); Assert.assertNotNull(triangle); }
public List<Person> findNear(double x, double y, double maxDistance, SurfaceType surfaceType) { Point point = new Point(x, y); point.setSurfaceType(surfaceType); Query q = em .createQuery("Select p from Person p where p.currentLocation > :point AND p.currentLocation < :maxDistance"); q.setParameter("point", point); q.setParameter("maxDistance", maxDistance); List<Person> persons = q.getResultList(); return persons; }
@Override public Object getInstance(Class<?> clazz) { return new Point(0.0, 0.0); }
public Triangle(double x1, double y1, double x2, double y2, double x3, double y3) { super(new Coordinate(x1, y1), new Coordinate(x2, y2), new Coordinate(x3, y3)); }
public List<Person> findWithinTriangle(double x1, double y1, double x2, double y2, double x3, double y3) { Triangle triangle = new Triangle(x1, y1, x2, y2, x3, y3); Query q = em.createQuery("Select p from Person p where p.currentLocation IN :triangle"); q.setParameter("triangle", triangle); List<Person> persons = q.getResultList(); return persons; }
function Shape(x, y) { var that= this; this.x= x; this.y= y; this.toString= function() { return 'Shape at '+that.x+', '+that.y; }; } function Circle(x, y, r) { var that= this; Shape.call(this, x, y); this.r= r; var _baseToString= this.toString; this.toString= function() { return 'Circular '+_baseToString(that)+' with radius '+that.r; }; }; var mycircle= new Circle();
@Override public Coordinate[] getCoordinates() { com.vividsolutions.jts.geom.Coordinate[] coordinates = super.getCoordinates(); Coordinate[] cs = new Coordinate[coordinates.length]; int count = 0; for (com.vividsolutions.jts.geom.Coordinate c : coordinates) { cs[count++] = new Coordinate(c); } return cs; } }
var obj = new Circle(); if (obj instanceof Shape) { // do something with a shape object }
node> require('circle_object') {} node> Circle { [Function] PI: 3.14 } node> var c = new Circle(3) { radius: 3 } node> c.area()
Base<? extends Shape> bs = someInterface.getBaseOfSomeKindOfShape(); bs.setX(new Circle());
Base<? extends Shape> bs = new Base<Square>(); // Really a Base<Square> bs.setX(new Circle());
public class MovingCircle extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new Circle()); } }
public Figure createInstance(int numSides) { Figure figure = null; switch(numSides) { case 0: figure = new Circle(); break; case 3: // etc... // Make a case for each valid number of sides // Don't forget to put a "break;" after each case! default: // Not a valid shape; print your error message } return figure; }