📄 drawingobj.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><!--NewPage--><html><head><!-- Generated by javadoc on Tue Nov 03 15:31:36 EST 1998 --><title> Interface DrawingObj</title></head><body><a name="_top_"></a><h1> Interface DrawingObj</h1><dl> <dt> public interface <b>DrawingObj</b></dl>Interface for the drawing object to be drawn in the drawing panel. <p> Any graphical objects to be displayed on the <code>DrawingPanel</code> should implement this interface. All the abstract methods of the interface must be defined in the object class defining the graphical object. <p> For example, if <code>Box</code> is a class which implements <code>DrawingObj</code>, i.e. the class declaration of <code>Box</code> starts with the following line: <code><pre> class Box implements DrawingObj { ... </pre></code> Then any instance of class <code>Box</code> can be added to the drawing canvas as follows: <code><pre> Box box = new Box(...); drawingPanel.addDrawingObj(box); box.move(x, y); drawingPanel.redraw(); </pre></code> The first line declares an instance of class <code>Box</code> called <code>box</code>. The next line uses the method <code>addDrawingObj</code> to add <code>box</code> into the canvas <code>drawingPanel</code>, which is an instance of the object class <code>DrawingPanel</code>. <p> The <code>move</code> method of the drawing object (which must be specified) is then called to move the corresponding object to position <code>(x, y)</code>. Finally, the <code>redraw()</code> method of <code>DrawingPanel</code> class is called to refresh the panel and delay for the object to be visible.<p><dl> <dt> <b>See Also:</b> <dd> <a href="DrawingPanel.html#_top_">DrawingPanel</a>, <a href="DrawingPanel.html#addDrawingObj">addDrawingObj</a>, <a href="DrawingPanel.html#redraw">redraw</a></dl><hr><a name="index"></a><h2> <img src="images/method-index.gif" width=207 height=38 alt="Method Index"></h2><dl> <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#draw(java.awt.Graphics)"><b>draw</b></a>(Graphics) <dd> Paint method of the drawing object. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getX()"><b>getX</b></a>() <dd> Returns the x coordinate of the drawing object's reference point. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getY()"><b>getY</b></a>() <dd> Returns the y coordinate of the drawing object's reference point. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#move(int, int)"><b>move</b></a>(int, int) <dd> This method repositions the drawing object to the new location specified by the paramters.</dl><a name="methods"></a><h2> <img src="images/methods.gif" width=151 height=38 alt="Methods"></h2><a name="draw(java.awt.Graphics)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="draw"><b>draw</b></a><pre> public abstract void draw(Graphics g)</pre><dl> <dd> Paint method of the drawing object.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> g - A reference to the graphical context. </dl></dd></dl><a name="move(int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="move"><b>move</b></a><pre> public abstract void move(int x, int y)</pre><dl> <dd> This method repositions the drawing object to the new location specified by the paramters.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> x - The x coordinate of the drawing object's new position. <dd> y - The y coordinate of the drawing object's new position. </dl></dd></dl><a name="getX()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getX"><b>getX</b></a><pre> public abstract int getX()</pre><dl> <dd> Returns the x coordinate of the drawing object's reference point.<p> <dd><dl> <dt> <b>Returns:</b> <dd> The x coordinate of the drawing object's reference point. </dl></dd></dl><a name="getY()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getY"><b>getY</b></a><pre> public abstract int getY()</pre><dl> <dd> Returns the y coordinate of the drawing object's reference point.<p> <dd><dl> <dt> <b>Returns:</b> <dd> The y coordinate of the drawing object's reference point. </dl></dd></dl></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -