progresslistener.html

来自「Geotools是一个开源的Java GIS工具包,可利用它来开发符合标准的地理」· HTML 代码 · 共 500 行 · 第 1/2 页

HTML
500
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.4.2_13) on Tue Jun 05 11:36:17 GMT-05:00 2007 --><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><TITLE>ProgressListener (Geotools 2.3.x 2.3.2 API)</TITLE><META NAME="keywords" CONTENT="org.geotools.util.ProgressListener interface"><META NAME="keywords" CONTENT="getDescription()"><META NAME="keywords" CONTENT="setDescription()"><META NAME="keywords" CONTENT="started()"><META NAME="keywords" CONTENT="progress()"><META NAME="keywords" CONTENT="complete()"><META NAME="keywords" CONTENT="dispose()"><META NAME="keywords" CONTENT="isCanceled()"><META NAME="keywords" CONTENT="setCanceled()"><META NAME="keywords" CONTENT="warningOccurred()"><META NAME="keywords" CONTENT="exceptionOccurred()"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="ProgressListener (Geotools 2.3.x 2.3.2 API)";}</SCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/ProgressListener.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;PREV CLASS&nbsp;&nbsp;NEXT CLASS</FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../index.html" target="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="ProgressListener.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">org.geotools.util</FONT><BR>Interface ProgressListener</H2><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../org/geotools/util/NullProgressListener.html" title="class in org.geotools.util">NullProgressListener</A>, <A HREF="../../../org/geotools/gui/headless/ProgressMailer.html" title="class in org.geotools.gui.headless">ProgressMailer</A>, <A HREF="../../../org/geotools/gui/headless/ProgressPrinter.html" title="class in org.geotools.gui.headless">ProgressPrinter</A>, <A HREF="../../../org/geotools/gui/swing/ProgressWindow.html" title="class in org.geotools.gui.swing">ProgressWindow</A></DD></DL><HR><DL><DT>public interface <B>ProgressListener</B></DL><P>Monitor the progress of some lengthly operation. This interface makes no assumption about the output device. It may be the standard output stream (see <A HREF="../../../org/geotools/gui/headless/ProgressPrinter.html" title="class in org.geotools.gui.headless"><CODE>ProgressPrinter</CODE></A> implementation), a window (<A HREF="../../../org/geotools/gui/swing/ProgressWindow.html" title="class in org.geotools.gui.swing"><CODE>ProgressWindow</CODE></A>) or mails automatically sent to some address (<A HREF="../../../org/geotools/gui/headless/ProgressMailer.html" title="class in org.geotools.gui.headless"><CODE>ProgressMailer</CODE></A>). Additionnaly, this interface provides support for non-fatal warning and exception reports. <p> All  implementations are multi-thread safe,  even the <cite>Swing</cite> implemention.  can be invoked from any thread, which never need to be the <cite>Swing</cite>'s thread. This is usefull for performing lenghtly operation in a background thread. Example: <blockquote><pre> &nbsp;ProgressListener p = new <A HREF="../../../org/geotools/gui/headless/ProgressPrinter.html" title="class in org.geotools.gui.headless"><CODE>ProgressPrinter</CODE></A>(); &nbsp;p.setDecription("Loading data"); &nbsp;p.start(); &nbsp;for (int j=0; j&lt;1000; j++) { &nbsp;    // ... some process... &nbsp;    if ((j &amp; 255) == 0) &nbsp;        p.progress(j/10f); &nbsp;} &nbsp;p.complete(); </pre></blockquote> <strong>Note:</strong> The line <code>if ((j&nbsp;&amp;&nbsp;255)&nbsp;==&nbsp;0)</code> is used for reducing the amount of calls to <A HREF="../../../org/geotools/util/ProgressListener.html#progress(float)"><CODE>progress(float)</CODE></A> (only once every 256 steps). This is not mandatory, but may speed up the process. <p> Here is another example showing how to cancel: <pre><code>      Iterator iterator = null;      try{          float size = size();          float position = 0;          progress.started();          for( iterator = iterator(); !progress.isCanceled() && iterator.hasNext(); progress.progress( (position++)/size )){              try {                  Feature feature = (Feature) iterator.next();                  visitor.visit(feature);              }              catch( Exception erp ){                  progress.exceptionOccurred( erp );              }          }          progress.complete();      }      finally {          close( iterator );      } </code></pre> Note the use of try and catch to report exceptions.<P><P><DL><DT><B>Since:</B></DT>  <DD>2.0</DD><DT><B>Author:</B></DT>  <DD>Martin Desruisseaux</DD><DT><B>See Also:</B><DD><A HREF="../../../org/geotools/gui/headless/ProgressPrinter.html" title="class in org.geotools.gui.headless"><CODE>ProgressPrinter</CODE></A>, <A HREF="../../../org/geotools/gui/headless/ProgressMailer.html" title="class in org.geotools.gui.headless"><CODE>ProgressMailer</CODE></A>, <A HREF="../../../org/geotools/gui/swing/ProgressWindow.html" title="class in org.geotools.gui.swing"><CODE>ProgressWindow</CODE></A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/javax/swing/ProgressMonitor.html" title="class or interface in javax.swing"><CODE>ProgressMonitor</CODE></A><DT><B>Module:</B></DT><DD><CODE><B>module/api</B></CODE> &nbsp; (<A HREF="http://maven.geotools.fr/repository/org/geotools/gt2-api/"><CODE>gt2-api.jar</CODE></A>) (<A HREF="http://maven.geotools.fr/reports/api/index.html">Maven report</A>) (<A HREF="http://svn.geotools.org/geotools/tags/2.3.2/module/api/src/org/geotools/util/ProgressListener.java">SVN head</A>)</DD></DL><HR><P><!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/util/ProgressListener.html#complete()">complete</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Notifies this listener that the operation has finished. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/util/ProgressListener.html#dispose()">dispose</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Release any resources used by this listener. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/util/ProgressListener.html#exceptionOccurred(java.lang.Throwable)">exceptionOccurred</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Throwable.html" title="class or interface in java.lang">Throwable</A>&nbsp;exception)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reports an exception. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/util/ProgressListener.html#getDescription()">getDescription</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the description for the lengthly operation to be reported, or  if none.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/util/ProgressListener.html#isCanceled()">isCanceled</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is this job canceled?</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/util/ProgressListener.html#progress(float)">progress</A></B>(float&nbsp;percent)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Notifies this listener of progress in the lengthly operation. </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/util/ProgressListener.html#setCanceled(boolean)">setCanceled</A></B>(boolean&nbsp;cancel)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Indicate that progress should is canceled.</TD></TR>

⌨️ 快捷键说明

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