All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scudata.ide.spl.etl.FieldDefineRender Maven / Gradle / Ivy

Go to download

SPL(Structured Process Language) A programming language specially for structured data computing.

There is a newer version: 20241126
Show newest version
package com.scudata.ide.spl.etl;

import java.awt.*;
import java.util.ArrayList;

import javax.swing.*;
import javax.swing.table.*;

import com.scudata.ide.common.swing.*;
import com.scudata.ide.spl.etl.element.FImport;

/**
 * ?ֶζ???ĵ?Ԫ????Ⱦ??
 * 
 * @author Joancy
 *
 */
public class FieldDefineRender extends JLabel implements TableCellRenderer {
	private static final long serialVersionUID = -6260220752855995789L;
	private FieldDefineIcon icon = new FieldDefineIcon();

	/**
	 * ???캯??
	 */
	public FieldDefineRender() {
		setOpaque(true);
		setHorizontalAlignment(CENTER);
		setVerticalAlignment(CENTER);
	}

	/**
	 * ʵ?ָ???ij??󷽷?
	 */
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		setText(" ");
		if (isSelected) {
			setForeground(table.getSelectionForeground());
			setBackground(table.getSelectionBackground());
		} else {
			setForeground(table.getForeground());
			setBackground(table.getBackground());
		}
		
		icon.setFieldDefines((ArrayList)value);
		int w = ((JTableEx) table).getColumn(column).getWidth();
		int h = table.getRowHeight(row);
		this.setPreferredSize(new Dimension(w, h));
		icon.setSize(w, h);
		setIcon(icon);
		return this;
	}
}

class FieldDefineIcon implements Icon {
	private ArrayList fieldDefines = new ArrayList();
	private int width, height;
	
	public FieldDefineIcon() {
		this(null);
	}

	public FieldDefineIcon(ArrayList fields) {
		if (fields != null) {
			fieldDefines = fields;
		}
	}

	public void paintIcon(Component c, Graphics g, int x, int y) {
		g.setColor(Color.white);
		g.fillRect(0, 0, width, height);
		String text = FImport.getFieldDefineExp(fieldDefines);
		g.setColor(Color.black);
		g.drawString(text, 0, 15);
	}

	public int getIconWidth() {
		return width;
	}

	public int getIconHeight() {
		return height;
	}

	public void setSize(int w, int h) {
		this.width = w;
		this.height = h;
	}

	public void setFieldDefines(ArrayList fields) {
		this.fieldDefines = fields;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy