50 likes | 296 Views
Recitation 4. In this recitation you will have an example on drawing graph on ObjectEditor. Basic tasks are try to change the values in the code and see the difference of graphs. The code can be found in the recitation page. Code Explanations.
E N D
Recitation 4 • In this recitation you will have an example on drawing graph on ObjectEditor. Basic tasks are try to change the values in the code and see the difference of graphs. • The code can be found in the recitation page.
Code Explanations • The ALine class and AShape class are two classes that implement the Line interface. Notice that the two classes are basically the same. The only difference is the Aline class contains annotations say that it follow line pattern.
Run the code and observe the windows of ObjectEditor, console and the values of variables in the tree view of ObjectEditor
What you can do with the code • Try to initialize the two instances with different initial values (in Driver line 7 and 8) • Try some new arguments of OEFrame.setSize (line 10). • For the calling of sleep method in the for loop, replace the argument with some small numbers like 10, and modify the argument of calling of moveShapes to (lineArray, 1). • If you know refactor, then use it to rename the AShape into ARectangleand AStringShape(notice the difference) • Try to comment out some methods in ALine and in its interface. Then try just comment out these methods in the interface.
If you have done all those jobs, try following stuff • Search in the lecture slides and sample code to find a way to display string and image(notice annotations and different properties) • Add a new method in AShape public Stroke getStroke(){return new BasicStroke(5.0f);} And the import statements import java.awt.BasicStroke; import java.awt.Stroke; -------------------Still in AShape----------------------------- public Color getColor() {return Color.GREEN;} Import statement import java.awt.Color; • Review the polar coordination representation of a point