Java Swing moving java.awt.Shape -
we have application displays kind of map. swing application draw set of java.awt.shape
s java.awt.graphics2d#draw(shape)
, fine.
and now, have extend app allow our users editing (moving shapes on) map. there no translate
or move
methods on java.awt.shape
s. can't change position (java.awt.point
) of shape.
i have tried override java.awt.shape#getpathiterator
in order apply translation matches shape position. it's tricky because method accept transformation have merge , because correct pathiterator
should start @ (0, 0)
because relative shape position.
and anyway, won't work because seems graphics2d
don't use method draw java.awt.shape
.
so now, i'm feeling bit lost. solution let shapes drawn themselves, have rewrite part of application. that's not problem have know best solution :
find trick move
java.awt.shape
seems best solution can't figure how that.change app have self drawing shapes nice have compute myslef
contains
, other more complex methods.
but there no
translate
ormove
methods onjava.awt.shape
s.
see affinetransform.createtransformedshape(shape)
, which:
returns new
shape
object defined geometry of specifiedshape
after has been transformed transform.
of course, there graphics2d.translate(x,y)
..
translates origin of
graphics2d
context point (x, y) in current coordinate system. ..
Comments
Post a Comment