sk.upjs.jpaz2.inspector.OIRowSeparatorRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jpaz2 Show documentation
Show all versions of jpaz2 Show documentation
Educational framework for Java beginners.
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