WorldWind color at pick point
Asked Answered
F

2

9

I'm trying to figure out a way to programmatically get the visual color (not the picking color) of the point where a user clicks on a WorldWind AnalyticSurface.

Looking at AnalyticSurface and PickedObjectList I'm not sure of what API calls I need to string together to do this or if its even possible.

Failure answered 10/4, 2015 at 19:35 Comment(1)
your links are brokenFaefaeces
C
1

Here is a possible solution. Just try. When clicked, (i assume you have made some MouseListener object with a mouseClicked() method in it), just get the current mouse pointer location on the whole computer screen as co-rdinate.

import java.awt.MouseInfo;
import java.awt.PointerInfo;
import java.awt.Point;
PointerInfo pi=MouseInfo.getPointerInfo();
Point p=pi.getLocation();

Now we got the position of point clicked on screen.

Using Robot class you can get the pixel at the location.

import.java.awt.Robot;
import.java.awt.Color;
Robot robot=new Robot();
Color color=robot.getPixelColor(p.x,p.y) ;
// you got the color at the clicked point.

Hope this helps.

Carlstrom answered 17/10, 2016 at 16:47 Comment(0)
L
0

Looking a little bit at the API I don't think it is possible unless you use some workaround. OK let's start at the beginning:

1. How to get the click event?

There seems to be no easy way. Could you get the click event from the parent container? Or if you first click a button like "pick color" then this button could put an invisible frame in front, this grabs the next click (and then it is closed immediately returning the color at click position, so the rest works as before).

2. How to get get the color?

Unless you have some way of mathematically calculate the color at the clicked position you could try to use createScreenCapture(...) (class Robot) and then get the pixel color with getRGB(...). Or if you are going for the transparent overlay then you can get the color directly.

Lickspittle answered 19/4, 2015 at 8:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.