Hi all,

I'm developing a drawing tool using Java. This will support drawing diagrams ( basically electrical components in a network ). As the drawing panel ,i have uesd a JPanel within JScrollPane so that user can scroll their diagram. The origin of my drawing panel is the top-left corner of that JPanel.(as default)

This will support rotating and many more facilities. I have got an issue with this rotating. For an example if user draw a one-line diagram (branch ) with few components connected in vertical direction and rotate it to be in horizontal direction ( if this diagram is much closer to left side of the JPanel ) then some of the components in the left side of that drawing will be hidden and i cannot scroll the panel into that negative direction.

If anyone has an idea on how to archive a solution for this, it will be a great help.
(Hope u guys understand the issue i explained above. if not, i can attach a screen shot of this )

Thanks a lot.

Rgds,
Darshana

There may be a better solution out there, but what about if you did a transpose whenever the user rotates their image to make sure the origin is kept above and to the left of the top-most and left-most areas of the drawing?

Yea. this is good solution and i had an idea of doing something same, but when user do a rotation for set of connected components, i would like to do that respect to one of the components( for an example, if user rotate set of components connected as a vertical branch, i would like to do it respect to top-most component, so that user see some actual rotation, other wise he will suddenly see a jump of top-most component to one side ( which is not generally present in real drawing tools :) )

Anyway solution u suggested is seems to be the best-available at the moment :) , so i will try that way.

Thanks a lot

Rgds,
Darshana

You might want to consider translating your origin to a point in the middle of the selected component of your drawing before you render it and positioning the viewport over that new origin. You would also need to ensure that the JPanel gets sized such that all of the drawing would be visible.

This article has been dead for over six months. Start a new discussion instead.