📄 intmatrix.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> Class IntMatrix</title></head><body><a name="_top_"></a><h1> Class IntMatrix</h1><pre>java.lang.Object | +----IntMatrix</pre><hr><dl> <dt> public class <b>IntMatrix</b> <dt> extends Object <dt> implements <a href="DrawingObj.html#_top_">DrawingObj</a></dl>An example implementation of the <code>DrawingObj</code> interface that can be added to the drawingPanel (an instance of <code>DrawingPanel</code>). Similar to <code>ComBox</code>, an instance of this object class is added to the drawing panel by using the <code>addDrawingObj</code> method from <code>DrawingPanel</code>. This drawing obj can be removed from the drawing panel by invoking the <code>removeObj</code> method. <p> As an example, an instance of IntMatrix class can be added to an instance of <code>DrawingPanel</code>, namely <code>drawingPanel</code> by using the following: <code><pre> IntMatrix matrix1 = new IntMatrix(4); drawingPanel.addDrawingObj(matrix1); matrix1.setColor(....); matrix1.move(x, y); .... </pre></code> It can then be removed from the drawing panel by: <code><pre> drawingPanel.removeObj(matrix1); </pre></code> <p> This class implements a matrix representation with all integer entries.<p><dl> <dt> <b>See Also:</b> <dd> <a href="ComBox.html#_top_">ComBox</a>, <a href="DrawingPanel.html#addDrawingObj">addDrawingObj</a>, <a href="DrawingPanel.html#removeObj">removeObj</a></dl><hr><a name="index"></a><h2> <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index"></h2><dl> <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o "> <a href="#IntMatrix(int)"><b>IntMatrix</b></a>(int) <dd> Construct a square matrix with number of rows = number of columns as specified by the single parameter of the constructor. <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o "> <a href="#IntMatrix(int, int)"><b>IntMatrix</b></a>(int, int) <dd> Construct a matrix with the number of rows and columns specified by the parameters of the constructor.</dl><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> This method has to be defined to fully implement the DrawingObj interface. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#drawBox(java.awt.Graphics, int, int, java.lang.String, java.awt.Color, java.awt.Color, java.awt.Font)"><b>drawBox</b></a>(Graphics, int, int, String, Color, Color, Font) <dd> This method is used to draw each element of the matrix. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#drawMatrix(java.awt.Graphics, int, int, java.awt.Color, java.awt.Color)"><b>drawMatrix</b></a>(Graphics, int, int, Color, Color) <dd> This method is only called from the <code>draw</code> method which in turn is called from the drawing panel to draw the matrix based on the position and color previously set. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#elem(int, int)"><b>elem</b></a>(int, int) <dd> Get a particular element of the matrix specified by the position given in the parameters of the method. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getX()"><b>getX</b></a>() <dd> Get the left most position of the matrix. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getY()"><b>getY</b></a>() <dd> Get the top most position of the matrix. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#incElem(int, int, int)"><b>incElem</b></a>(int, int, int) <dd> Increment the element specified by the first two parameters by the value specified by the third parameter. <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> Move the matrix to the position specified with reference to the top left corner. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#printMatrix()"><b>printMatrix</b></a>() <dd> Print out the contents of the matrix to the stdout. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#restoreAll()"><b>restoreAll</b></a>() <dd> Restore all previously highlighted element of the matrix (black and gray). <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#restoreHighlight(int, int)"><b>restoreHighlight</b></a>(int, int) <dd> Restore the element which was highlighted using Color.black. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#restoreHighlight2(int, int)"><b>restoreHighlight2</b></a>(int, int) <dd> Restore the element which was highlighted using Color.gray. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setColLabels(java.lang.String[])"><b>setColLabels</b></a>(String[]) <dd> Set a label to each column of the matrix based on the array of String passed in as the parameter. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setColor(java.awt.Color, java.awt.Color)"><b>setColor</b></a>(Color, Color) <dd> Set the foreground and background color for each element of the matrix. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setDiag(int[])"><b>setDiag</b></a>(int[]) <dd> Set the value for each element on the main diagonal based on the array passed in as the parameter. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setElem(int, int, int)"><b>setElem</b></a>(int, int, int) <dd> Assign a new value to the entry specified by the parameters. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setHighlight(int, int)"><b>setHighlight</b></a>(int, int) <dd> Highlight an element of the matrix, colouring it to black. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setHighlight2(int, int)"><b>setHighlight2</b></a>(int, int) <dd> Highlight an element of the matrix, colouring it to gray. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setLT(int)"><b>setLT</b></a>(int) <dd> Assign a value to all elements to the left hand side of the main diagonal (exclusive). <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setRowLabels(java.lang.String[])"><b>setRowLabels</b></a>(String[]) <dd> Set a label to each row of the matrix based on the array of String passed in as the parameter. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setTitle(java.lang.String)"><b>setTitle</b></a>(String) <dd> Set a title to the matrix.</dl><a name="constructors"></a><h2> <img src="images/constructors.gif" width=231 height=38 alt="Constructors"></h2><a name="IntMatrix"></a><a name="IntMatrix(int, int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a><b>IntMatrix</b><pre> public IntMatrix(int rows, int columns)</pre><dl> <dd> Construct a matrix with the number of rows and columns specified by the parameters of the constructor.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> rows - The number of rows of the new matrix. <dd> columns - The number of columns of the new matrix. </dl></dd></dl><a name="IntMatrix(int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a><b>IntMatrix</b><pre> public IntMatrix(int rows)</pre><dl> <dd> Construct a square matrix with number of rows = number of columns as specified by the single parameter of the constructor.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> rows - Number of rows/columns of the new matrix. </dl></dd></dl><a name="methods"></a><h2> <img src="images/methods.gif" width=151 height=38 alt="Methods"></h2><a name="elem(int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="elem"><b>elem</b></a><pre> public int elem(int i, int j)</pre><dl> <dd> Get a particular element of the matrix specified by the position given in the parameters of the method.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> i - The column number of the element of interest. <dd> j - The row number of the element to be extracted. <dt> <b>Returns:</b> <dd> The integer element at row and column specified by the two parameter. </dl></dd></dl><a name="setElem(int, int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setElem"><b>setElem</b></a><pre> public void setElem(int i, int j, int value)</pre><dl> <dd> Assign a new value to the entry specified by the parameters.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> i - The column number of the element that is being assigned a new value. <dd> j - The row number of the element that is being assigned a new value. <dd> value - The new value of the element. </dl></dd></dl><a name="incElem(int, int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="incElem"><b>incElem</b></a><pre> public void incElem(int i, int j, int value)</pre><dl> <dd> Increment the element specified by the first two parameters by the value specified by the third parameter.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> i - The column number of the element to be incremented. <dd> j - The row number of the element to be incremented. <dd> value - The amount of the element incrementation. </dl></dd></dl><a name="setDiag(int[])"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setDiag"><b>setDiag</b></a><pre> public void setDiag(int value[])</pre><dl> <dd> Set the value for each element on the main diagonal based on the array passed in as the parameter. The length of the array must be at least equal to the longest dimension of the matrix and the matrix must be a square matrix. Otherwise, an exception might be raised during execution.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> value - An array of value to be assigned to each of the element on the main diagonal of the matrix. </dl></dd></dl><a name="setLT(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setLT"><b>setLT</b></a><pre> public void setLT(int value)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -