You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Answer4e.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package answers;
  13. import figures.FigureElement;
  14. import figures.Group;
  15. import figures.Point;
  16. import java.awt.Rectangle;
  17. aspect Answer4e {
  18. private Rectangle Group.cache = null;
  19. private Group FigureElement.enclosingGroup = null;
  20. before(FigureElement p, Group g):
  21. execution(void add(FigureElement)) && args(p) && target(g) {
  22. p.enclosingGroup = g;
  23. }
  24. Rectangle around(Group g):
  25. execution(Rectangle Group.getBounds()) && this(g) {
  26. if (g.cache == null) {
  27. g.cache = proceed(g);
  28. }
  29. return g.cache;
  30. }
  31. before(Point p): set(* Point.*) && target(p) {
  32. FigureElement fe = p;
  33. while (fe.enclosingGroup != null) {
  34. fe.enclosingGroup.cache = null;
  35. fe = fe.enclosingGroup;
  36. }
  37. }
  38. }