class DelegatingShape { protected final Location loc = new Location(0, 0); protected final Dimension dim = new Dimension(0, 0); public double getX() { return loc.getX(); } public double getY() { return loc.getY(); } public double getWidth() { return dim.getWidth(); } public double getHeight() { return dim.getHeight(); } public void adjustLocation() { loc.adjust(); } public void adjustDimensions() { dim.adjust(); } } class Location { protected double x; protected double y; public Location(double initX, double initY) { x = initX; y = initY; } public synchronized double getX() { return x;} public synchronized double gety() { return y; } public synchronized void adjust() { x = longCalculation1(); y = longCalculation2(); } protected double longCalculation1() { /* ... */ } protected double longCalculation2() { /* ... */ } } class Dimension { protected double width; protected double height; public Dimension(double initW, double initH) { width = initW; height = initH; } public synchronized double getWidth() { return width;} public synchronized double getHeight() { return height; } public synchronized void adjust() { width = longCalculation3(); height = longCalculation4(); } protected double longCalculation3() { /* ... */ } protected double longCalculation4() { /* ... */ } }