lib/browser/GraphBrowser/Vertex.java
changeset 11872 4f24fd4dbcf5
parent 11798 fbab70de9b0d
child 13968 689868b99bde
equal deleted inserted replaced
11871:0493188cff42 11872:4f24fd4dbcf5
     1 /***************************************************************************
     1 /***************************************************************************
     2   Title:      GraphBrowser/Vertex.java
     2   Title:      GraphBrowser/Vertex.java
     3   ID:         $Id$
     3   ID:         $Id$
     4   Author:     Stefan Berghofer, TU Muenchen
     4   Author:     Stefan Berghofer, TU Muenchen
     5   Copyright   1997  TU Muenchen
     5   License:    GPL (GNU GENERAL PUBLIC LICENSE)
     6 
     6 
     7   This class contains attributes and methods common to all kinds of
     7   This class contains attributes and methods common to all kinds of
     8   vertices (e.g. coordinates, successors, predecessors).
     8   vertices (e.g. coordinates, successors, predecessors).
     9 ***************************************************************************/
     9 ***************************************************************************/
    10 
    10 
    13 import java.util.*;
    13 import java.util.*;
    14 import java.awt.*;
    14 import java.awt.*;
    15 import java.io.*;
    15 import java.io.*;
    16 
    16 
    17 abstract class Vertex {
    17 abstract class Vertex {
    18 	protected static final Font font=new Font("Helvetica",Font.PLAIN,12);
       
    19 
       
    20 	Vector children=new Vector(10,10);
    18 	Vector children=new Vector(10,10);
    21 	Vector parents=new Vector(10,10);
    19 	Vector parents=new Vector(10,10);
    22 	int degree=0;
    20 	int degree=0;
    23 	int number=-1;
    21 	int number=-1;
    24 	double weight=0;
    22 	double weight=0;
    68 
    66 
    69 	public void setID(String s) {}
    67 	public void setID(String s) {}
    70 
    68 
    71 	public Dimension getLabelSize(Graphics g) {
    69 	public Dimension getLabelSize(Graphics g) {
    72 		FontMetrics fm = g == null ? 
    70 		FontMetrics fm = g == null ? 
    73 		    new DefaultFontMetrics(font) : g.getFontMetrics(font);
    71 		    new DefaultFontMetrics(12) : g.getFontMetrics(g.getFont());
    74 		
    72 		
    75 		return new Dimension(
    73 		return new Dimension(
    76 		        Math.max(fm.stringWidth("[. . . .]"),fm.stringWidth(getLabel())),
    74 		        Math.max(fm.stringWidth("[. . . .]"),fm.stringWidth(getLabel())),
    77 			fm.getAscent()+fm.getDescent());
    75 			fm.getAscent()+fm.getDescent());
    78 	}
    76 	}