0
votes

I am building a document layout editor in NetBeans Visual Library API, and I am looking for a way to let the user rotate a widget about it's center with the mouse. How would I go about adding this functionality?

UPDATE

I think I need to clarify, this is what I want to accomplish:

  1. User clicks on a Widget in my NetBeans Visual Library API based document layout editor
  2. User drags the mouse. As the user drags the mouse the Widget rotates about it's center
  3. User release the mouse button. The Widget remains in the rotated position.

I am not using an NetBeans Platform or an IDE.

1
For starters, not by using NetBeans code generation when creating your Swing GUI. - Hovercraft Full Of Eels
I'm not. I'm only using the Visual Library API, not all of NetBeans; and I don't use an IDE anyway. - MaverickXero
You'll need some kind of user control, too. A JSpinner with domain-centric units is simple but effective. - trashgod
@trashgod I stated in my question that I'm looking to rotate via the mouse. Other then that I really don't know what you're comment is referring to. - MaverickXero
I am not using a UI element to specify the rotation. I want to click on the widget to be rotated and drag the mouse. As the mouse drags the widget rotates until it is in the desired position and I release the mouse button. I know how I can do this with swing objects that I am custom painting, but I am asking specifically in the context of the NetBeans Visual Library API. - MaverickXero

1 Answers

0
votes

Looking at the API doc for Widget, I don't see how it is possible.

There is another approach I can suggest.

extend Widget (the relevant widget you are interested in), add support for rotation. In paintWidget method, add a line

graphicsContext.rotate(angle)

The angle will have to come from your model or user interaction. How you build the user interaction is another exercise, but this approach should work.

If you need something which is already provided, then simply copy the source in your own class and add support for rotation.

If you have already come across a better way, I would be happy to learn about it.