Java Swing moving java.awt.Shape -


we have application displays kind of map. swing application draw set of java.awt.shapes 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.shapes. 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 :

  1. find trick move java.awt.shape seems best solution can't figure how that.

  2. change app have self drawing shapes nice have compute myslef contains , other more complex methods.

but there no translate or move methods on java.awt.shapes.

see affinetransform.createtransformedshape(shape), which:

returns new shape object defined geometry of specified shape 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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -