Hi
i am loading image in browser using Swing components inside a JScrollPane. I have to draw up on this loaded image using real world coordinates.How can i do it?
What's a "real world coordinate"? Latitude and longitude? Translate between viewport coordinates.
vinod chemmi
Ranch Hand
Joined: Jun 15, 2009
Posts: 35
posted
0
David Newton wrote:What's a "real world coordinate"? Latitude and longitude? Translate between viewport coordinates.
Nope
I exact problem is locating components in image of electronics boards. I will get x,y cartesian coordinates and boards images.
I succeeded in loading the image in an applet and integrated in jsp page.i am using JScrollPane to load image and placed in a boarder lay out(Center portion).
David Newton wrote:So you're asking how to scale your viewport?
No david.
i have the cartesian cordinates of components in borad. i want to put small mark in loaded images. I tried it,but failed to point exact location.
vinod cmt wrote:I tried it,but failed to point exact location.
What exactly did you try and how have you failed? Maybe you could provide your implementation of paintComponent() method?
Censorship is the younger of two shameful sisters, the older one bears the name inquisition. -- Johann Nepomuk Nestroy
vinod chemmi
Ranch Hand
Joined: Jun 15, 2009
Posts: 35
posted
0
Peter Taucher wrote:
vinod cmt wrote:I tried it,but failed to point exact location.
What exactly did you try and how have you failed? Maybe you could provide your implementation of paintComponent() method?
Yes,
i am pasting code snippets with in paintComponent()
double imgwidth=image.getWidth(null);// image is image object loaded.
double imgheight=image.getHeight(null);
double scaleX=imgwidth/boardwidth; //boardwidth is the width of the original board we calculated in mm
double scaleY=imgheight/boardheight;//boardheight is height of original board.
double x,y;
x=Double.parseDouble("X");//X is cartesian x coordinate
y=Double.parseDouble("Y");//Y is cartesian y coordinate.
y=boardheight-y;
x=x*scaleX;y=y*scaleY;
x-=20;y-=20;
Rectangle r=new Rectangle2D.Double(x,y,10,10);
g2D.draw(r);
g2D.fill(r);
But it is not locating as i expected.where is the problem?
Peter Taucher
Ranch Hand
Joined: Nov 18, 2006
Posts: 174
posted
0
1) Use code tags
2) What do you expect, and how does the result differ from your expectations? -> TellTheDetails
vinod chemmi
Ranch Hand
Joined: Jun 15, 2009
Posts: 35
posted
0
Peter Taucher wrote:1) Use code tags
2) What do you expect, and how does the result differ from your expectations? -> TellTheDetails
Hi Taucher
Can you explain code tag? is t any Tag library?
I am putting small mark up on components with in image.But the rectangle which i drawn is little away from the components.
Can you suggest any other method ?
Thanks for reply.
Peter Taucher
Ranch Hand
Joined: Nov 18, 2006
Posts: 174
posted
0
I'm providing a small example (using code tags):
I think (because you didn't really explain it) your problem might be the scaling. You have to translate the coords and size of the rectangles the same way you scale your image.
Vinod, I asked you to read your private messages, but apparently you haven't yet. This is your second warning.
vinod chemmi
Ranch Hand
Joined: Jun 15, 2009
Posts: 35
posted
0
Peter Taucher wrote:I'm providing a small example (using code tags):
I think (because you didn't really explain it) your problem might be the scaling. You have to translate the coords and size of the rectangles the same way you scale your image.
Hi Taucher
I am getting the x,y coordinates from CAD (PCB design people) .They were giving it in mills and i will get width,height and image of the borad.
I want draw exactly on components locations on board images loaded in jsp page.
You still didn't provide a valid problem description. What exactly are you expecting and how does the behaviour differ from your expectations (in detail!). Simply saying 'it doesn't paint where I want it to' makes no sense to anyone but you. Providing an example that shows the misbehaviour (SSCCE) might give us all the possibility to comprehend...
You still didn't provide a valid problem description. What exactly are you expecting and how does the behaviour differ from your expectations (in detail!). Simply saying 'it doesn't paint where I want it to' makes no sense to anyone but you. Providing an example that shows the misbehaviour (SSCCE) might give us all the possibility to comprehend...
Hi Taucher
I am attaching a board image and i want to draw the following components below.
cktref (x,y)
C13 (205,1150)
R1 (343,325)
R4 (292,1192)
C12 (388,334)
CR1 (976,399)
L4 (1040,1129)
C30 (790,1370)
Here x,y are in cartesian coordinates.
i plotted these components in red mark in image attached.
How it draw it exactly by loading in jsp page?
What do you mean "draw it exactly by loading in the JSP page"? Most of the red marks seem to be located correctly, no?
vinod chemmi
Ranch Hand
Joined: Jun 15, 2009
Posts: 35
posted
0
David Newton wrote:What do you mean "draw it exactly by loading in the JSP page"? Most of the red marks seem to be located correctly, no?
Hi David
Sorry for misleading.That red marks i did it using some Image editors,not through jsp page.I did for identifying the specified components.
I have to make simillar marks on boards after loading in jsp.
Also components X ,Y are in mills.
Actual board width is 30 mm and height is 30.9 mm.
Why do you have to make the marks after loading in JSP? Why not before? I don't understand why the coordinate transformation is difficult; can you explain what's actually happening? Where are the marks ending up? Can you post *just* the coordinate transformation code?
vinod chemmi
Ranch Hand
Joined: Jun 15, 2009
Posts: 35
posted
0
David Newton wrote:Why do you have to make the marks after loading in JSP? Why not before? I don't understand why the coordinate transformation is difficult; can you explain what's actually happening? Where are the marks ending up? Can you post *just* the coordinate transformation code?
Okay, don't, but don't expect much help if you're not willing to explain what your code is doing--the code you posted is trying to parse two strings as doubles. If that isn't your real code, then how do I know the *rest* of it is real?
Why do you subtract 20? Why do you subtract y from the boardheight? Why are you doing more beyond getting the "scaled" x, y coordinates? You didn't even say where the origin is for the board measurements, nor show where the boxes *were* being drawn so we'd know if it was something simple like different origins.
Roll your eyes all you want--but if you can't or won't provide the information asked for, or the information that's necessary, or the actual code that isn't working, I'm not sure what you expect people to do.
vinod chemmi
Ranch Hand
Joined: Jun 15, 2009
Posts: 35
posted
0
Hi David
By parsing strings to double just i am taking x,y coordinate in cartesian coordinates. The origin of the board is always left side bottom only.
That is why i am subtract y from boardheight..subtracting 20 for the sake of drawing rectangle around the components,through calculation we are getting middle point of components.
Thanks for reply.
David Newton wrote:Okay, don't, but don't expect much help if you're not willing to explain what your code is doing--the code you posted is trying to parse two strings as doubles. If that isn't your real code, then how do I know the *rest* of it is real?
Why do you subtract 20? Why do you subtract y from the boardheight? Why are you doing more beyond getting the "scaled" x, y coordinates? You didn't even say where the origin is for the board measurements, nor show where the boxes *were* being drawn so we'd know if it was something simple like different origins.
Roll your eyes all you want--but if you can't or won't provide the information asked for, or the information that's necessary, or the actual code that isn't working, I'm not sure what you expect people to do.