/* Copyright 2001 Michael R. Wick */ package Strategies; import java.awt.Canvas; import java.awt.Dimension; import java.awt.Point; import java.awt.Color; import java.awt.Graphics; import Shapes.*; import java.util.*; public class ExplodeShapeMutationStrategy extends ShapeMutationStrategy { public ExplodeShapeMutationStrategy(int w) { super(w); } public void mutate( Shape s ) { // USE MOD??? Point ctr; int d1, d2; ctr = s.getCenter(); d1 = r.nextInt(0, Math.abs( (origin.x - ctr.x) / 4) ); d2 = r.nextInt(0, Math.abs( (origin.y - ctr.y)/ 4) ); s.translateTo( new Point((ctr.x - d1)%origin.x, (ctr.y - d2)%origin.y) ); } }