AOP Programming Assignment Part B The java classes "figure.java" and "figs.java" contain two classes that implements the drawing of stickfigures (main is in figs.java). You need to first study how these programs work. Here's a summary. ///// class figure: A stick figure consists of the following set of Points which define the relative locations of each part of the anatomy: chest, neck, stomach, larm, rrarm, lleg, rleg, head, leye, reye, lmouth, rmouth, and lip. Each Point object has an x and y coordinate (e.g. chest.x, chest.y). The most important point is chest, from which the coordinates of all the other points are calculated. Each figure also has the following properties: int scale : size of figure (radius of head) Color color : color of figure int armfactor : controls arm position: down, straight, up (-1, 0, 1) int mouthfactor : controls shape of mouth (v for smile, ^ for frown). int angle : angle (counterclockwise) of rotation, 0-360. boolean autodraw : controls auto-drawing of figure (see below) The following public methods can be called to change the state of a figure: beHappy(), beSad(), armsUp(), armsDown(), armsStraight(), grow(), shrink(), setColor(Color newcolor), rotate(int angle), move(int dx, int dy). Each of these methods changes some appropriate parameter. For example, beHappy() will change the mouthfactor variable. Then, each of these methods will call the calcPoints procedure, which recalculates all the points starting with the chest coordinate. It's important that you study the structure of this procedure carefully. It calculates the coordinates of each point relative to the center/chest point, then calls the rotate() procedure to re-orient the points based on the angle of rotation (default 0). The drawing of a figure is done by the draw() method, which draws lines and circles to form a figure, based on the point coordinates. Note that this procedure actually draws to an off-screen animation buffer, unless the autodraw variable is set to true. This is to allow what's called "double buffering" - a standard technique in computer animation. An entire frame of drawings is composed and then shown to the user at once. No actual graphic appears unless the figs.nextframe(int) procedure is invoked. ///// class figs The figs class (in figs.java) controls the animation. The most important method of this class is animate() and nextframe(int). The animate procedure creates figure objects and animates them. For example: fig1 = new figure(400,300,this); // create figure at x=400, y=300 fig2 = new figure(50,100,this); figure.autodraw = false; // control animation manually fig1.beSad(); fig2.beHappy(); // set properties fig1.draw(); fig2.draw(); nextframe(100); // update display frame To draw the figures, call draw() on each figure then call nextframe(ms) where ms is the number of milliseconds to delay before the next animation frame. //////////// That's just a brief summary. compile and run the program (java figs) to see how it works, then study the code closely so you're comfortable with its structure. ----------------------------- Your assignment is to extend the program by drawing ears, or some other additional feature for each figure. Write a privileged aspect ears { ... So that ovals for ears are drawn for the figure. You need to add "inter-type" declarations to create two additional points for the center of two circles, lear and rear, represening the center of the left and right ears. The coordinates for these points relative to the chest point should be int x = chest.x; int y = chest.y; lear = new Point(x-scale/2,y-((3*scale)/2)); rear = new Point(x+scale/2,y-((3*scale)/2)); You should also add a new Color variable called earcolor so that the color of the ears can be changed independently of the rest of the figure. Given lear, rear and earcolor, the following (ordinary) procedure can render the ears in the correct position: public void drawEars(figure f) { Color oldcolor = f.color; f.brush.setColor(f.earcolor); int scale = f.scale; f.brush.fillOval(f.lear.x-(scale/4),f.lear.y-(scale/4), scale/2,scale/2); f.brush.fillOval(f.rear.x-(scale/4),f.rear.y-(scale/4), scale/2,scale/2); f.brush.setColor(oldcolor); } You can change the relative positioning of the ears if you'd like. You need to then write advice so that the ear points are also taken into account at all the relevant join points of the program (at the very least, consider calcPoints, orient and draw). To summarize: your aspect should add the following functionality: figure.lear, figure.rear, figure.earcolor variables. figure.setearcolor(Color newcolor) : sets the earcolor. -------------------------- Write another aspect: privileged aspect myanimiation { ... That replaces (with an around advice) the exiting figs.animate function of figs.java with your own animation program. You must create at least two figures and illustrate each capability. Especially important is that you must demonstrate how rotating the figure does not adversely affect the positioning of the ears. --------------- One final point: you must NOT CHANGE THE ORIGINAL JAVA PRORAMS IN ANY WAY. You can make your aspects "privileged" so they will have access to private elements of classes.