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

📄 nodemem.java

📁 java编程的一些Applets例子。值得深入研究一下。
💻 JAVA
字号:
/* Attempt at hierarchy representation with expand/contract display
 * The NodeMem objects hold the data for individual entries
*/

/*  Public Notice
 *  Hier.java, HierCanvas.java and NodeMem.java are copyright (c) 1996
 *  by William B. Brogden - wbrogden@bga.com
 *  130 Woodland Trail, Leander, TX  78641
 *  These classes can be used for private or commercial applications
 *  without restriction, but I would appreciate it if you let me know
 *  what you are using them for & if you make improvements.
 */

import java.awt.Rectangle ;
import java.io.StreamTokenizer;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Vector ;

// to represent a member of the hierarchy
public class NodeMem {
  public boolean visible ;  // in current display - calc by canvas
  public boolean exposed ;  // due to hierarchy selections
  public Rectangle sRect ;  // set when displayed
  public int level  ;  // 1 - n where 1 is base - derive from tag count
  int parent ;  // if not level 1
  int child  ;  // n of first child, or 0 if none
  int nxsib, prevsib ;    // n of next or previous sib or 0 if none
  public String tags[] ;  // names appearing in hierarchy
  public String desc   ;  // long text description

  public void dump() {
    int i ;
    for( i = 0 ; i < level ; i++ ) {
      System.out.print(  tags[i] + " " );
    }
    System.out.println( "level " + level );    
  }

  // Note that setting the way the StreamTokenizer recognizes chars
  // is extremely important - see the Hier.run() routine
  // number of tags, StreamTokenizer reading input file
  NodeMem( int Ntag,  StreamTokenizer st )  throws IOException {
    int tagct  = 0 ;
    tags = new String[ Ntag ] ;
    sRect = new Rectangle() ;
    exposed = false ;
    nxsib = prevsib = -1 ; parent = -1 ;
    desc = null ; 
    boolean inline = true ;
  while( inline ) {
     switch( st.nextToken() ) {
       case StreamTokenizer.TT_EOL :
        // System.out.println("End of line"); 
        inline = false ; break ;
       case StreamTokenizer.TT_EOF :
        // System.out.println("End of file"); 
        inline = false ; break ;
       case StreamTokenizer.TT_WORD :
        // System.out.println("Word: " + st.sval ); 
        tags[ tagct++ ] = st.sval ; break ;
       case StreamTokenizer.TT_NUMBER :
        System.out.println("Number: " + st.nval ) ; break ;
       case 34 :  // parsed string in quotes
        // System.out.println("String: " + st.sval ) ;
        desc = st.sval ;  break ;
       default :
        System.out.println("Unknown token" + st.ttype );
      } // end switch
    } // end while loop
    if( tagct == 1 ) exposed = true ;
    level = tagct ;  // 1 to ?
    while( tagct < Ntag ) { tags[ tagct++ ] = "" ; }
    if( desc == null ) desc = "" ;
  } // end constructor
}

⌨️ 快捷键说明

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