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

📄 defaultdataentry.java

📁 网络分析软件pajek的数据格式转换工具。
💻 JAVA
字号:
//Skye Bender-deMoll draft translation code 2/13/01
//skyebend@bennington.edu

package PajekConverter;

import java.text.*;
import java.util.*;

public class DefaultDataEntry extends Object
/*
	DefaultDataEntry is sort of a stand in for a spreadsheet, it contains a series of arrays
	which hold each kind of data, line by line as they are passed (and parsed) from the datachecker.
	DefaultDataEntry also keeps trak of which lines had errors, and can return data either by
	entry (line) or by catagory (array), size of arrays are determed when datachecker is
	instantiated.  Actual assignment of color, catagories, etc is made by net assembler
	during conversion to nodes
*/
{
	//globals
	private int numRows = 0;		//indicates length of arrays
	private int currentRow = 0;		//index of current location in arrays


	//data arrays (input colums)
	private String[] rawIds;
	private String[] rawLinkIds;
	private String[] rawLabels;
	private String[] rawShapes;
	private double[] rawSizes;
	private String[] rawColors;
	private double[] rawXs;
	private double[] rawYs;
	private double[] rawZs;
	private String[] rawArcColors;
	private double[] rawArcWidths;
	private double[] rawArcWeights;

	private boolean[] forOutput; 	//flag indicates whether this node is to be exported
	private boolean[] errors;  		//flag set if there was a parsing problem
	private String[] errorItems;	//holds error messages for this line

	public DefaultDataEntry(int rows)
	{
		numRows = rows;
		//set lengths of all arrays
		rawIds = new String[numRows];
		rawLinkIds = new String[numRows];
		rawLabels = new String[numRows];
		rawShapes = new String[numRows];
		rawSizes = new double[numRows];
		rawColors = new String[numRows];
		rawXs = new double[numRows];
		rawYs = new double[numRows];
		rawZs = new double[numRows];
		rawArcColors = new String[numRows];
		rawArcWidths = new double[numRows];
		rawArcWeights = new double[numRows];

		forOutput= new boolean[numRows];
		errors = new boolean[numRows];;
		errorItems = new String[numRows];
	}

//------Methods---------


	public void addEntry(String id, String linkId, String label, String shape, double size,
							String color, double x, double y, String arcColor, double arcWidth, double arcWeight, boolean output, boolean error,
							String errorItem)
	{
		//places info from row in appropriate arrays
		 rawIds[currentRow] = id;
		 rawLinkIds[currentRow] = linkId;
		 rawLabels[currentRow] = label;
		 rawShapes[currentRow] = shape;
		 rawSizes[currentRow] = size;
		 rawColors[currentRow] = color;
		 rawXs[currentRow] = x;
		 rawYs[currentRow] = y;
		 rawZs[currentRow] = 0.000;  //currently not used
		 rawArcColors[currentRow] = arcColor;
		 rawArcWidths[currentRow] = arcWidth;
		 rawArcWeights[currentRow] = arcWeight;
		 forOutput[currentRow] = output;
		 errors[currentRow] = error;
		 errorItems[currentRow] = errorItem;

		 //increment row adress
		 currentRow++;
	}

//-----------Accesors-------------------

//getNumRows
	public int getNumRows()
	{
		return numRows;
	}
//getId
	public String getId(int index)
	{
		return rawIds[index];
	}
//getLink
	public String getLink(int index)
	{
		return rawLinkIds[index];
	}
//getLabel
	public String getLabel(int index)
	{
		return rawLabels[index];
	}
//getShape
	public String getShape(int index)
	{
		return rawShapes[index];
	}
//getSize
 	public double getSize(int index)
 	{
		return rawSizes[index];
	}
//getColor
	public String getColor(int index)
	{
		return rawColors[index];
	}
//getX
	public double getX(int index)
	{
		return rawXs[index];
	}
//getY
	public double getY(int index)
	{
		return rawYs[index];
	}
//getZ
	public double getZ(int index)
	{
		return rawZs[index];  //currently not used
	}
//getarcColor
	public String getArcColor(int index)
	{
		return rawArcColors[index];
	}
//getarcWidth
	public double getArcWidth(int index)
	{
		return rawArcWidths[index];
	}
//getArcWeight
	public double getArcWeight(int index)
	{
		return rawArcWeights[index];
	}
//isForOutput?
	public boolean isForOutput(int index)
	{
		return forOutput[index];
	}
//isError?
	public boolean isError(int index)
	{
		return errors[index];
	}
//getErrors
	public String getErrors(int index)
	{
		return errorItems[index];
	}

//getColorClasses
	public Vector getColorClasses()
	{
		Vector colors = new Vector();
		//for each raw colors catagory entry..
		for (int i=0; i<numRows; i++)
		{
			//check that it is not already in the list
			if (!colors.contains(rawColors[i]))
			{
				//put it in the list
				colors.add(rawColors[i]);
			}
		}
		return colors;
	}

//getArcColorClasses
	public Vector getArcColorClasses()
	{

		Vector arcColors = new Vector();
		//for each raw colors catagory entry..
		for (int i=0; i<numRows; i++)
		{
			//check that it is not already in the list
			if (!arcColors.contains(rawArcColors[i]))
			{
				//put it in the list
				arcColors.add(rawArcColors[i]);
			}
		}
		return arcColors;
	}

//getMaxSize
	public double getMaxSize()
	{
		double maxSize = 0.0;
		for (int i=0; i<numRows; i++)
		{
			if (rawSizes[i] > maxSize)
			{
				maxSize = rawSizes[i];
			}
		}
		return maxSize;
	}

//getShapeClasses
	public Vector getShapeClasses()
	{
		Vector shapes = new Vector();
		//for each raw shapes catagory entry..
		for (int i=0; i<numRows; i++)
		{
			//check that it is not already in the list
			if (!shapes.contains(rawShapes[i]))
			{
				//put it in the list
				shapes.add(rawShapes[i]);
			}
		}
		return shapes;
	}

//getNumValidNodes

//EDGES

//getRow
	public String getRow(int index)
	//returns tab deliniated string with all values for that row
	{
		String str = rawIds[index]+"\t"+rawLabels[index]+"\t"+rawLinkIds[index]+"\t"+rawShapes[index]+
				"\t"+rawSizes[index]+"\t"+rawColors[index]+"\t"+rawXs[index]+"\t"+rawYs[index]+
				"\t"+rawArcColors[index]+"\t"+rawArcWidths[index]+"\t"+rawArcWeights[index]+
				"\t"+forOutput[index]+"\t"+errors[index]+"\t"+errorItems[index]+"\n";
		return str;
	}

}

⌨️ 快捷键说明

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