?? vertex.java
字號:
// file: Vertex.java//// import java libraries//import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import java.util.*;import java.io.*;import java.lang.*;import javax.swing.border.*;public class Vertex extends JButton implements Serializable, Constants { // --------------------------------------------------- // // declare class member data // // --------------------------------------------------- // the relevant information about the vertex // public String vertexName = null; public String iconName = null; public int vertexType = NONE; public int vertexImpl = NONE; public ImageIcon vertexIcon = null; public Point vertexLocation = null; // the parents and children of the vertex // public Vector vertexParents = null; public Vector vertexChildren = null; // the dimensions of the vertex // public int vertexWidth = -1; public int vertexHeight = -1; // container related data types // public Vector vertexContainer = null; // parameters used by the algorithm vertex // public Vector values =new Vector(5,5); public Vector names = new Vector(5,5); public Vector types = new Vector(5,5); public String association = null; public Vector subclass =new Vector(5,5); public int max_subclass = 0; public Vector subparam =new Vector(5,5); public int max_subparam = 0; public Vector identify = new Vector(5,5); public boolean actionAdded = false; public static boolean isAdd = false; // --------------------------------------------------- // // class constructors // // --------------------------------------------------- // method: Vertex // // arguments: none // returns: none // public Vertex() { // invoke the parent constructor // super(); // set the font of the vertex // setFont(newFont); // disable the focus from being painted // setFocusPainted(false); // disable the content area from being painted // setContentAreaFilled(false); // set the horizontal text position // setHorizontalTextPosition(SwingConstants.CENTER); // initialize class vector data types // vertexParents = new Vector(10, 10); vertexChildren = new Vector(10, 10); // set the default dimensions of the vertex // setBackground(Color.white); setSize(VERTEX_WIDTH, VERTEX_HEIGHT); setPreferredSize(new Dimension(VERTEX_WIDTH, VERTEX_HEIGHT)); setMinimumSize(new Dimension(VERTEX_WIDTH, VERTEX_HEIGHT)); setVertexWidth(VERTEX_WIDTH); setVertexHeight(VERTEX_HEIGHT); } // method: Vertex // // arguments: // String name: (input) vertex name // int type: (input) vertex type // returns: none // public Vertex(String name) { // invoke the parent constructor // super(name); //setBorder(LineBorder.createGrayLineBorder()); //setBorder(new EtchedBorder()); //setBorderPainted(true); // set the font of the vertex // //setFont(newFont); // disable the focus from being painted // //setFocusPainted(true); // disable the content area from being painted // //setContentAreaFilled(true); // set the horizontal text position // //setHorizontalTextPosition(SwingConstants.CENTER); } // method: Vertex // // arguments: // String name: (input) vertex name // int type: (input) vertex type // returns: none // public Vertex(String name, int type, int impl) { // invoke the parent constructor // super(name); // set the format and name of the vertex // vertexName = name; vertexType = type; vertexImpl = impl; // set the name of the vertex // if (name.length() > 5) { setText(name.substring(0, 5)); } else { setText(name); } // set the font of the vertex // setFont(newFont); // disable the focus from being painted // setFocusPainted(false); // disable the content area from being painted // setContentAreaFilled(false); // set the horizontal text position // setHorizontalTextPosition(SwingConstants.CENTER); // initialize class vector data types // switch (vertexType) { case CONTAINER: vertexParents = new Vector(10, 10); vertexChildren = new Vector(10, 10); vertexContainer = new Vector(50, 10); break; default: vertexParents = new Vector(10, 10); vertexChildren = new Vector(10, 10); break; } // set the default dimensions of the vertex // switch (vertexType) { case ALGORITHM: setBackground(Color.white); setSize(ALGORITHM_WIDTH, ALGORITHM_HEIGHT); setPreferredSize(new Dimension(ALGORITHM_WIDTH, ALGORITHM_HEIGHT)); setMinimumSize(new Dimension(ALGORITHM_WIDTH, ALGORITHM_HEIGHT)); setVertexWidth(ALGORITHM_WIDTH); setVertexHeight(ALGORITHM_HEIGHT); break; case CONTAINER: setBackground(Color.white); setSize(CONT_WIDTH, CONT_HEIGHT); setPreferredSize(new Dimension(CONT_WIDTH, CONT_HEIGHT)); setMinimumSize(new Dimension(CONT_WIDTH, CONT_HEIGHT)); setVertexWidth(CONT_WIDTH); setVertexHeight(CONT_HEIGHT); break; default: setBackground(Color.cyan); setSize(VERTEX_WIDTH, VERTEX_HEIGHT); setPreferredSize(new Dimension(VERTEX_WIDTH, VERTEX_HEIGHT)); setMinimumSize(new Dimension(VERTEX_WIDTH, VERTEX_HEIGHT)); setVertexWidth(VERTEX_WIDTH); setVertexHeight(VERTEX_HEIGHT); break; } } // method: Vertex // // arguments: // int type: (input) vertex type // ImageIcon icon: (input) vertex icon // returns: none // public Vertex(ImageIcon icon, int type) { // invoke the parent constructor // super(icon); // set the format for the vertex // vertexName = new String("Algorithm"); vertexIcon = icon; vertexType = type; vertexImpl = NONE; // set the font of the vertex // setFont(newFont); // disable the focus from being painted // setFocusPainted(false); // disable the content area from being painted // setContentAreaFilled(false); // set the horizontal text position // setHorizontalTextPosition(SwingConstants.CENTER); // initialize class vector data types // switch (vertexType) { case CONTAINER: vertexParents = new Vector(10, 10); vertexChildren = new Vector(10, 10); vertexContainer = new Vector(50, 10); break; default: vertexParents = new Vector(10, 10); vertexChildren = new Vector(10, 10); break; } // set the default dimensions of the vertex // switch (vertexType) { case ALGORITHM: setBackground(Color.white); setSize(ALGORITHM_WIDTH, ALGORITHM_HEIGHT); setPreferredSize(new Dimension(ALGORITHM_WIDTH, ALGORITHM_HEIGHT)); setMinimumSize(new Dimension(ALGORITHM_WIDTH, ALGORITHM_HEIGHT)); setVertexWidth(ALGORITHM_WIDTH); setVertexHeight(ALGORITHM_HEIGHT); break; case CONTAINER: setBackground(Color.white); setSize(CONT_WIDTH, CONT_HEIGHT); setPreferredSize(new Dimension(CONT_WIDTH, CONT_HEIGHT)); setMinimumSize(new Dimension(CONT_WIDTH, CONT_HEIGHT)); setVertexWidth(CONT_WIDTH); setVertexHeight(CONT_HEIGHT); break; default: setBackground(Color.cyan); setSize(VERTEX_WIDTH, VERTEX_HEIGHT); setPreferredSize(new Dimension(VERTEX_WIDTH, VERTEX_HEIGHT)); setMinimumSize(new Dimension(VERTEX_WIDTH, VERTEX_HEIGHT)); setVertexWidth(VERTEX_WIDTH); setVertexHeight(VERTEX_HEIGHT); break; } } // method: Vertex // // arguments: // ImageIcon icon: (input) vertex icon // String name: (input) vertex name // int type: (input) vertex type // int impl: (input) vertex implementation // returns: none // public Vertex(ImageIcon icon, String name, int type, int impl) { // invoke the parent constructor // super(icon); // set the format for the vertex // vertexName = name; vertexIcon = icon; vertexType = type; vertexImpl = impl; // set the vertex text // if (name.length() > 5) { setText(name.substring(0, 5)); } else { setText(name); } // set the font of the vertex // setFont(newFont); // disable the focus from being painted // setFocusPainted(false); // disable the content area from being painted // setContentAreaFilled(false); // set the horizontal text position // setHorizontalTextPosition(SwingConstants.CENTER); // initialize class vector data types // switch (vertexType) { case CONTAINER: vertexParents = new Vector(10, 10); vertexChildren = new Vector(10, 10); vertexContainer = new Vector(50, 10); break; default: vertexParents = new Vector(10, 10); vertexChildren = new Vector(10, 10); break; } // set the default dimensions of the vertex // switch (vertexType) { case ALGORITHM: setBackground(Color.white); setSize(ALGORITHM_WIDTH, ALGORITHM_HEIGHT); setPreferredSize(new Dimension(ALGORITHM_WIDTH, ALGORITHM_HEIGHT)); setMinimumSize(new Dimension(ALGORITHM_WIDTH, ALGORITHM_HEIGHT)); setVertexWidth(ALGORITHM_WIDTH); setVertexHeight(ALGORITHM_HEIGHT); break; case CONTAINER: setBackground(Color.white); setSize(CONT_WIDTH, CONT_HEIGHT); setPreferredSize(new Dimension(CONT_WIDTH, CONT_HEIGHT)); setMinimumSize(new Dimension(CONT_WIDTH, CONT_HEIGHT)); setVertexWidth(CONT_WIDTH); setVertexHeight(CONT_HEIGHT); break; default: setBackground(Color.white); setSize(VERTEX_WIDTH, VERTEX_HEIGHT); setPreferredSize(new Dimension(VERTEX_WIDTH, VERTEX_HEIGHT)); setMinimumSize(new Dimension(VERTEX_WIDTH, VERTEX_HEIGHT)); setVertexWidth(VERTEX_WIDTH); setVertexHeight(VERTEX_HEIGHT); break; } } // method: Vertex // // arguments: none // returns: none // public Vertex(Vertex copy) { super(); // set the vertex parameters // vertexType = copy.vertexType; vertexImpl = copy.vertexImpl; if (copy.vertexName != null) { vertexName = new String(copy.vertexName); if (vertexName.length() > 4) { setText(vertexName.substring(0, 4)); } else { setText(vertexName); } setVertexName(vertexName); if(copy.iconName != null) { iconName = new String(copy.iconName); setText(iconName); } } if ((copy.vertexIcon != null)&&(copy.vertexIcon.getImage() != null)) { vertexIcon = new ImageIcon(copy.vertexIcon.getImage()); setIcon(vertexIcon); } // set the vertex arcs parameters // if (copy.vertexLocation != null) { vertexLocation = new Point(copy.vertexLocation); } // set the vertex parents, children and container elements // if (copy.vertexParents != null) { vertexParents = new Vector(copy.vertexParents); } if (copy.vertexChildren != null) { vertexChildren = new Vector(copy.vertexChildren); } if (copy.vertexContainer != null) { vertexContainer = new Vector(copy.vertexContainer); } // set the vertex vertex dimensions // vertexWidth = copy.vertexWidth; vertexHeight = copy.vertexHeight; // set the algorithm related parameters // if (copy.values != null) { values = new Vector(copy.values); } if (copy.names != null) { names = new Vector(copy.names); } if (copy.types != null) { types = new Vector(copy.types); } if ( copy.association != null) { association = new String(copy.association); } if (copy.subclass != null) { subclass = new Vector(copy.subclass); } max_subclass = copy.max_subclass; if (copy.subparam != null) { subparam = new Vector(copy.subparam); } max_subparam = copy.max_subparam; actionAdded = copy.actionAdded; // set the font of the vertex // setFont(newFont); // disable the focus from being painted // setFocusPainted(false); // disable the content area from being painted // setContentAreaFilled(false); // set the horizontal text position // setHorizontalTextPosition(SwingConstants.CENTER); // set the default dimensions of the vertex //
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -