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

sk.upjs.jpaz2.inspector.OIRowSeparatorRenderer Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package sk.upjs.jpaz2.inspector;

import java.awt.*;

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

/**
 * Renderer for OIRowSeparatorValue.
 */
@SuppressWarnings("serial")
class OIRowSeparatorRenderer extends DefaultTableCellRenderer {
	
	/**
	 * Column index of the current cell
	 */
	private int column;
	
	/**
	 * Table for which the rendering is realized
	 */
	private JTable table;
	
	/**
	 * Value of the current cell
	 */
	private OIRowSeparatorValue value;
	
	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		
		// copy all current parameters 
		this.column = column;
		this.table = table;
		
		// set text that is shown
		this.value = (OIRowSeparatorValue)value;
		
		return this;
	}
	
	@Override
	public void paint(Graphics g) {
		Graphics2D g2 = (Graphics2D) g;

		// -- this code is written in order to solve the absence of colspan parameter for cells
		
		// compute shift according to information which cell is rendered
		TableColumnModel cm = table.getColumnModel();		
		int pixelShift = 0;
		int totalWidth = 0;
		int totalHeight = getHeight(); 
		
		for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy