*
* @param mousePosition
* the position on the map in pixels
*/
public static void findNearestStar(Point mousePosition) {
SkyMap sm = (SkyMap) userInterface.getSkyMap();
if (!sm.mapBounds.contains(mousePosition))
return;
if (mousePosition == null)
return;
Star nearestStar = Helper.getNearestStarFromPosition(mousePosition);
// may be null when no stars are loaded or visible
if (nearestStar != null) {
// get point and text
Point ttPos = nearestStar.getPoint();
String line1 = nearestStar.getName();
String line2 = nearestStar.getCoodinates().toString();
String line3 = "Magnitude : " + nearestStar.getMagnitude();
String line4 = "Type spectral : " + nearestStar.getSpectralType();
sm.drawToolTip(ttPos,
PanelsFactory.createToolTip("<html>" + line1 + "<br/>" + line2 + "<br/>" + line3 + "<br/>" + line4 + "<br/></html>",
nearestStar.getColor().brighter().brighter()));
}
}