0

I need to apply different Affine Transform to different graphic objects(eg lines), is it suitable to use multiple Graphics2D objects to perform this task? Code:

   Graphics2D g2seconds = (Graphics2D) g; // g - Graphics class
   Graphics2D g2minutes = (Graphics2D) g;

   AffineTransform atseconds =  
           AffineTransform.getRotateInstance(Math.PI/30*s, 0, 0);//s = Time in seconds
   AffineTransform atminutes =  
           AffineTransform.getRotateInstance(Math.PI/30*m, 0, 0);//m = Time in minutes

   g2seconds.setTransform(atseconds);
   g2seconds.drawLine(0, 0, 10, 10);

   g2minutes .setTransform(atminutes);
   g2minutes .drawLine(0, 0, 10, 10);
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
hunterra
  • 95
  • 1
  • 6

1 Answers1

1

No, because those aren't two distinct objects at all, they are two references to the same object.

user207421
  • 305,947
  • 44
  • 307
  • 483