Results 1 to 2 of 2
- 03-15-2011, 04:16 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 12
- Rep Power
- 0
how to provide X & Y values for creating polygon? plz refer below
hi to all
Here i have been trying to do a paint application something like there are
2 buttons such as RECTANGLE , ELLIPSE by following those buttons you have some
EMPTY SPACE which enables you to draw these shapes mentioned Above
based on your need you can select a shape either one of these before you draw
so that selected image will be drawn in the EMPTY SPACE but the image appears only after your mouse pointer drawn on the empty space, but not image appeared automatically when the button is selected
So to implement this RECTANGLE ,ELLIPSE i just want these two methods
drawRect(x,y,w,h)
Ellipse2D.Float(x,y,w,h)
for EXAMPLE Consider about RECTANGLE in this methods to find height & width of RECTANGLE i just create 2 variable and by subtracting end point of cursor with the Starting point found height and width of rectangle
this is inside a public void paint method
int width = end.x - start.x; // declaring variables
int height = end.y - start.y; // declaring variables
g.drawRect(start.x, start.y, width, height); // declaring variables to draw RECTANGLE
but now i want to implement POLYGON and the method of this something like
this X & Y points with the N Points
int xpoints[] = {25, 145, 25, 145, 25};
int ypoints[] = {25, 25, 145, 145, 25};
int npoints = 5;
g.drawPolygon(xpoints, ypoints, npoints);
so in this case i exactly don't know How to provide X & Y values based on where the polygon drawn in empty space
and i'm not allowed to draw polygon just by providing X & Y Values(NUMBERS)
Instead of that i need something like getting X & Y values from a EMPTY SPACE and apply those X & Y values instead of numbers
DO I need to use something like X1.y1.x2,y2,x3,y3........x5,y5
i tried for this but not working any help would be much appreciated
Thanks in advance
Mano
- 03-15-2011, 07:03 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
Similar Threads
-
How to provide x & y values for polygon ? Plz refer below
By Manojx in forum New To JavaReplies: 3Last Post: 03-15-2011, 06:49 PM -
Refer to an object from an array/for loop
By Chro in forum New To JavaReplies: 2Last Post: 11-09-2010, 06:12 PM -
Please provide some help
By saurabh_87 in forum New To JavaReplies: 3Last Post: 04-23-2009, 08:38 AM -
[SOLVED] Creating List of Values Using ClipBoard Object
By Judoon_Platoon in forum Java AppletsReplies: 2Last Post: 05-21-2008, 08:07 AM -
Refer a good Java compiler
By trill in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:31 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks