⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 histogram.html

📁 Java算法大全(近100种算法打包),內容詳實,很好的學習資料.
💻 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 Histogram</title></head><body><a name="_top_"></a><h1>  Class Histogram</h1><pre>java.lang.Object   |   +----java.awt.Component           |           +----java.awt.Container                   |                   +----java.awt.Panel                           |                           +----Histogram</pre><hr><dl>  <dt> public class <b>Histogram</b>  <dt> extends Panel  <dt> implements <a href="DrawingObj.html#_top_">DrawingObj</a></dl>This is one example of the drawing object inheriting <code>java.awt.Panel</code> which can be added to the drawing panel (<code>DrawingPanel</code>).  <p> Since <code>DrawingPanel</code> is also an extension of panel, this <code>Histogram</code> panel has to be added to the drawing panel by using the following statement (otherwise, the layout manager of this class might interprete its dimension as null during the panel initialization and nothing will show up): <code><pre>	Histogram histogram = new Histogram();	drawingPanel.setLayout(null);	drawingPanel.add(histogram); 	...	histogram.setTitle("title");	histogram.setXLabel("x-axis label");	histogram.setYLabel("y-axis label");	histogram.setYMax(maxY);	histogram.setXMax(maxX); 	histogram.setYStep(10);	histogram.setXStep(5);	histogram.reshape(x, y, width, height); </pre></code> <code>drawingPanel</code> is an instance of the class object <code>DrawingPanel</code>, which can be typically obtained from the instance of <code>AlgAnimFrame</code>, by calling the <code>getDrawingPanel()</code> method of the class. e.g. in <code>AlgThread</code>, the instance of <code>AlgAnimFrame</code> is passed in as <code>frame</code>. Therefore, <code><pre> 	drawingPanel = frame.getDrawingPanel(); </pre></code> The <code>reshape</code> method is inherited from a parent class. It is called to move the histogram to position <code>(x, y)</code> and set the dimension of the histogram to <code>width x height</code>.<p><dl>    <dt> <b>See Also:</b>    <dd> <a href="DrawingPanel.html#_top_">DrawingPanel</a>, <a href="AlgAnimFrame.html#_top_">AlgAnimFrame</a>, Panel</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="#Histogram()"><b>Histogram</b></a>()  <dd>  A constructor to this class which set the background of the panel to white, font to size 12 PLAIN courier, and initializes the title, x-axis label, y-axis label, etc.</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>  Same as <code>paint()</code>.  <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 panel.  <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 panel.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#incValueX(int)"><b>incValueX</b></a>(int)  <dd>  Increment the Y value of vertical bar specified by the parameter.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#init()"><b>init</b></a>()  <dd>  Initialize the histogram, removing all bars from the graph.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#paint(java.awt.Graphics)"><b>paint</b></a>(Graphics)  <dd>  Method to draw objects on the histogram panel.  <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 for the histogram.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setValueXY(int, int)"><b>setValueXY</b></a>(int, int)  <dd>  Set the Y value for the vertical bar at the specified X position.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setXLabel(java.lang.String)"><b>setXLabel</b></a>(String)  <dd>  Set a title for the x-axis.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setXMax(int)"><b>setXMax</b></a>(int)  <dd>  Set the maximum value for the x-axis of the histogram.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setXMin(int)"><b>setXMin</b></a>(int)  <dd>  Set the minimum value for the x-axis of the histogram.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setXStep(int)"><b>setXStep</b></a>(int)  <dd>  Set the incremental step for the x-axis of the histogram.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setYLabel(java.lang.String)"><b>setYLabel</b></a>(String)  <dd>  Set a title for the y-axis of the histogram.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setYMax(int)"><b>setYMax</b></a>(int)  <dd>  Set the maximum value for the y-axis of the histogram.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setYMin(int)"><b>setYMin</b></a>(int)  <dd>  Set the minimum value for the y-axis of the histogram.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setYStep(int)"><b>setYStep</b></a>(int)  <dd>  Set the incremental step for the y-axis.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#update(java.awt.Graphics)"><b>update</b></a>(Graphics)  <dd>  This method is invoked when the <code>repaint()</code> method is called.</dl><a name="constructors"></a><h2>  <img src="images/constructors.gif" width=231 height=38 alt="Constructors"></h2><a name="Histogram"></a><a name="Histogram()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a><b>Histogram</b><pre> public Histogram()</pre><dl>  <dd> A constructor to this class which set the background of the panel to white, font to size 12 PLAIN courier, and initializes the title, x-axis label, y-axis label, etc. Note that although the initial background color is set to white, it can be changed at any time after this contructor is called by using the <code>setBackground</code> method inherited. e.g. <code><pre>	Histogram histogram = new Histogram();	histogram.setBackground(Color.lightGray); </pre></code> For detail of what color can be set, refer to  <code>java.awt.Color</code>.<p></dl><a name="methods"></a><h2>  <img src="images/methods.gif" width=151 height=38 alt="Methods"></h2><a name="init()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="init"><b>init</b></a><pre> public void init()</pre><dl>  <dd> Initialize the histogram, removing all bars from the graph.<p></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 int getX()</pre><dl>  <dd> Get the left most position of the panel.<p>  <dd><dl>    <dt> <b>Returns:</b>    <dd> The x-coordinate of the top-left position of the histogram.  </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 int getY()</pre><dl>  <dd> Get the top most position of the panel.<p>  <dd><dl>    <dt> <b>Returns:</b>    <dd> The y-coordinate of the top-left position of the histogram.  </dl></dd></dl><a name="setTitle(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setTitle"><b>setTitle</b></a><pre> public void setTitle(String title)</pre><dl>  <dd> Set a title for the histogram.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> title - The new title of the histogram.  </dl></dd></dl><a name="setXLabel(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setXLabel"><b>setXLabel</b></a><pre> public void setXLabel(String xLabel)</pre><dl>  <dd> Set a title for the x-axis.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> xLabel - new title for the x-axis of the histogram.  </dl></dd></dl><a name="setYLabel(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setYLabel"><b>setYLabel</b></a><pre> public void setYLabel(String yLabel)</pre><dl>  <dd> Set a title for the y-axis of the histogram.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> yLabel - new title for the y-axis of the histogram.  </dl></dd></dl><a name="setYMax(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setYMax"><b>setYMax</b></a><pre> public void setYMax(int yMax)</pre><dl>  <dd> Set the maximum value for the y-axis of the histogram.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> yMax - The maximum value for the y-axis of the histogram.  </dl></dd></dl><a name="setYStep(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setYStep"><b>setYStep</b></a><pre> public void setYStep(int step)</pre><dl>  <dd> Set the incremental step for the y-axis. For example, if the minimum value of the y-axis is 0, and this incremental step is set to 5, then the value 0, 5, 10, 15, 20, ... will be displayed on the y-axis of the histogram.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> step - The incremental step for the y-axis of the histogram.  </dl></dd></dl><a name="setYMin(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setYMin"><b>setYMin</b></a><pre> public void setYMin(int yMin)</pre><dl>  <dd> Set the minimum value for the y-axis of the histogram.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> yMin - The new minimum value for the y-axis of the histogram.  </dl></dd></dl><a name="setXMax(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setXMax"><b>setXMax</b></a><pre> public void setXMax(int xMax)</pre><dl>  <dd> Set the maximum value for the x-axis of the histogram.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> xMax - The maximum value for the x-axis of the histogram.  </dl></dd></dl><a name="setXStep(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setXStep"><b>setXStep</b></a><pre> public void setXStep(int step)</pre><dl>  <dd> Set the incremental step for the x-axis of the histogram.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> step - The new incremental step for the x-axis of the histogram.    <dt> <b>See Also:</b>    <dd> <a href="#setYStep">setYStep</a>  </dl></dd></dl><a name="setXMin(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setXMin"><b>setXMin</b></a><pre> public void setXMin(int xMin)</pre><dl>  <dd> Set the minimum value for the x-axis of the histogram.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> xMin - The new minimum value for the x-axis of the histogram.  </dl></dd></dl><a name="setValueXY(int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setValueXY"><b>setValueXY</b></a><pre> public void setValueXY(int x,                        int y)</pre><dl>  <dd> Set the Y value for the vertical bar at the specified X position. If the x or y value specified in the parameter is larger than the maximum x or y value, the maximum value will be set to the specified value + 1.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> x - The vertical bar at X = x <p>    <dd> y - The value of the vertical bar specified by the first parameter.  </dl></dd></dl><a name="incValueX(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="incValueX"><b>incValueX</b></a><pre> public void incValueX(int x)</pre><dl>  <dd> Increment the Y value of vertical bar specified by the parameter. Initially, all x values are set to zero. If the x-value does not exist in the hashtable governing the histogram, it will be added.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> x - Specifies the vertical bar at X = x.  </dl></dd></dl><a name="update(java.awt.Graphics)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="update"><b>update</b></a><pre> public void update(Graphics g)</pre><dl>  <dd> This method is invoked when the <code>repaint()</code> method is called. The <code>update method is override here to eleminate flashing during the updating of the histogram panel.<p>  <dd><dl>    <dt> <b>Overrides:</b>    <dd> <a href="java.awt.Container.html#update(java.awt.Graphics)">update</a> in class Container  </dl></dd></dl><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 void draw(Graphics g)</pre><dl>  <dd> Same as <code>paint()</code>. This method just calls the paint() method. It must be defined here to implement the DrawingObj interface.<p>  <dd><dl>    <dt> <b>See Also:</b>    <dd> <a href="#paint">paint</a>  </dl></dd></dl><a name="paint(java.awt.Graphics)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="paint"><b>paint</b></a><pre> public void paint(Graphics g)</pre><dl>  <dd> Method to draw objects on the histogram panel.<p>  <dd><dl>    <dt> <b>Overrides:</b>    <dd> <a href="java.awt.Container.html#paint(java.awt.Graphics)">paint</a> in class Container  </dl></dd></dl></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -