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

📄 node.java

📁 这是一个演示分布式系统并行计算的GUI程序
💻 JAVA
字号:
package cn.ac.siat.dswatcher;

import java.awt.*;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Date;

public class Node {
    Color color;
    String text = "";
    String description = "";
    double x;
    double y;
    private ArrayList runningProcessList = new ArrayList();    //used for computers
    float processProportion;                                    //used for processes.
    Date start_time;                                              //used for processes.
    Date end_time;                                                //used for processes.
    boolean processFinished = false;

    public Node(String text,String description, Color color,float processProportion) {
        this.color = color;
        this.text = text;
        this.description = description;
        this.processProportion = processProportion;
    }

    public Date getStart_time() {
        return start_time;
    }

    public void setStart_time(Date start_time) {
        this.start_time = start_time;
    }

    public Date getEnd_time() {
        return end_time;
    }

    public void setEnd_time(Date end_time) {
        this.end_time = end_time;
    }

    public Node(String text, String description, double x, double y ,Color color) {
        this.text = text;
        this.description = description;
        this.color = color;
        this.x = x;
        this.y = y;
    }

    public Node() {
    }

    public boolean isProcessFinished() {
        return processFinished;
    }

    public void setProcessFinished(boolean processFinished) {
        this.processFinished = processFinished;
    }

    public float getProcessProportion() {
        return processProportion;
    }

    public void setProcessProportion(float processProportion) {
        this.processProportion = processProportion;
    }

    public ArrayList getRunningProcessList() {
        return runningProcessList;
    }

    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public void setX(double x) {
        this.x = x;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    /**
     * unit: millisecond
     * @return period time
     */
    public long runPeriodTime()
    {
        return(end_time.getTime() - start_time.getTime());
    }

    public boolean contains(Point2D p)
    {
        double x = p.getX();
        double y = p.getY();
        double x1 = this.x;
        double y1 = this.y;
        double rectWidth = (ProcessPanel.canvasWidth - 40)*processProportion;
        double rectHeight = 12;
        double x2 = x1 + rectWidth;
        double y2 = y1 + rectHeight;
   //     System.out.println("("+x+";"+y+";"+x1+";"+y1+";"+x2+";"+y2+")");
        if( x > x1 && x < x2 && y > y1 && y < y2)
            return true;
        else
            return false;
    }

}

⌨️ 快捷键说明

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