Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Moving, Dragging, Resizing Images in Canvas  RSS feed

Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am having problem in giving the functionality for Dragging, Resizing of images in Canvas.
Actually , I have drawn an image in canvas & now I want that it should be able to be selected by user so that he can resize it , shear it, rotate it etc.
I am trying Graphics2D for it.
I have modified paint method of my canvas class as below :
public void paint(Graphics g) {
System.out.println("In paint of RefreshCanvas");
int w = 25;
int h = 20;
Graphics2D g2 = (Graphics2D)g;
AlphaComposite ac = AlphaComposite.getInstance (AlphaComposite.SRC_OVER,(float)0.8);

if(img==null || img.size()<1) { }
else {
System.out.println("Image found");
for(int i=0; i<img.size(); i++)
if (RText==null || RText.trim().length()<1) {
} else {
g2.setStroke(new BasicStroke(5.0f));
In above code img is the Vector containing Image objects & RText is the text message entered by user.
With the above code, I am able to display multiple overlapping images & also
some text over it.
But what I want that user should be able to select any of images & can resize, reshape and/or drag it. (A bit similar to as we can select image (Object) in MS PowerPoint and can replace & resize it).
Can anybody help/guide me in achieving this functionality.
Thanks & Waiting for some input.

Manoj Tyagi

Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Rocket Oven Kickstarter - from the trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!