By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,798 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,798 IT Pros & Developers. It's quick & easy.

User change of curve shapes

P: n/a
PA
Hi,
I want to implement the following in an applet:

^
|
| + + + + + +H
| +
| +
| H
| +
| +
| +
| H+++++++H
|
|
|-------------------------------------->

Given this chart the user can change the shape of the curve
by dragging the handles H up/down or left/right.

Have you seen this before?
And can you give me with some tips / hints or even API's
that can help me?

TIA,

-- pa
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
SPG
Have a look at the JHotDraw package.
Really powerful drawing api.

Good luck!

"PA" <Pa***@hotmail.com> wrote in message
news:Ne********************@newsb.telia.net...
Hi,
I want to implement the following in an applet:

^
|
| + + + + + +H
| +
| +
| H
| +
| +
| +
| H+++++++H
|
|
|-------------------------------------->

Given this chart the user can change the shape of the curve
by dragging the handles H up/down or left/right.

Have you seen this before?
And can you give me with some tips / hints or even API's
that can help me?

TIA,

-- pa

Jul 17 '05 #2

P: n/a
PA <Pa***@hotmail.com> wrote in message news:<Ne********************@newsb.telia.net>...
Hi,
I want to implement the following in an applet:

^
|
| + + + + + +H
| +
| +
| H
| +
| +
| +
| H+++++++H
|
|
|-------------------------------------->

Given this chart the user can change the shape of the curve
by dragging the handles H up/down or left/right.


Try java.awt.geom.Shape
Say you're drawing on p, an instance of some subclass of JComponent
that you're writing. Then p.getGraphics() returns g, a Graphics
object. But g is actually of class java.awt.Graphics2D, and you can
cast it to that class. Then override the paintComponent method in p's
class to use draw(Shape).

public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.draw(myShape1);
g2.draw(myShape2);
// etc.
}

One Shape that gives straight lines is java.awt.geom.Line2D.Float.

If the thing on the right is a parabolic or elliptical segment with an
H in the middle, then try java.awt.geom.Quad2D.Float. Quad2D has a
"control point" which is related to the midpoint of the arc, though it
hovers a certain distance away from that midpoint.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.