Display mouse coordinates near mouse as hints on mouse move

JFreeChart has quite flexible support for crosshairs. To do what you described I would use an Overlay on the ChartPanel, and update the crosshairs from your ChartMouseListener. Here is a self-contained example (which I’ll add to the collection of demos that we ship with the JFreeChart Developer Guide): package org.jfree.chart.demo; import java.awt.BasicStroke; import java.awt.Color; import … Read more

Inline labels in Matplotlib

Update: User cphyc has kindly created a Github repository for the code in this answer (see here), and bundled the code into a package which may be installed using pip install matplotlib-label-lines. Pretty Picture: In matplotlib it’s pretty easy to label contour plots (either automatically or by manually placing labels with mouse clicks). There does … Read more

Getting Latitude and longitude in 30 seconds

Please check how i’m using in my app and its working perfect.I’m using fused api for update location please follow few steps.Currently you using very old approach.So, there is no need now and pass here your time in milliseconds what you want UPDATE_INTERVAL_IN_MILLISECONDS Step 1. Make this class GoogleLocationService.java public class GoogleLocationService { private GoogleServicesCallbacks … Read more

Converting 3D position to 2d screen position [r69!]

I’ve written for my project the following function; it receives an THREE.Object3D instance and a camera as a parameters and returns the position on the screen. function toScreenPosition(obj, camera) { var vector = new THREE.Vector3(); var widthHalf = 0.5*renderer.context.canvas.width; var heightHalf = 0.5*renderer.context.canvas.height; obj.updateMatrixWorld(); vector.setFromMatrixPosition(obj.matrixWorld); vector.project(camera); vector.x = ( vector.x * widthHalf ) + widthHalf; … Read more

Calculate area of polygon given (x,y) coordinates

Implementation of Shoelace formula could be done in Numpy. Assuming these vertices: import numpy as np x = np.arange(0,1,0.001) y = np.sqrt(1-x**2) We can redefine the function in numpy to find the area: def PolyArea(x,y): return 0.5*np.abs(np.dot(x,np.roll(y,1))-np.dot(y,np.roll(x,1))) And getting results: print PolyArea(x,y) # 0.26353377782163534 Avoiding for loop makes this function ~50X faster than PolygonArea: %timeit … Read more

Getting View’s coordinates relative to the root layout

The Android API already provides a method to achieve that. Try this: Rect offsetViewBounds = new Rect(); //returns the visible bounds childView.getDrawingRect(offsetViewBounds); // calculates the relative coordinates to the parent parentViewGroup.offsetDescendantRectToMyCoords(childView, offsetViewBounds); int relativeTop = offsetViewBounds.top; int relativeLeft = offsetViewBounds.left; Here is the doc