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

org.jclarion.clarion.print.text.Column Maven / Gradle / Ivy

The newest version!
package org.jclarion.clarion.print.text;

import java.awt.Rectangle;

import org.jclarion.clarion.print.PrintObject;
import org.jclarion.clarion.print.TextElement;

public class Column implements Comparable
{
	private int x1;
	private int x2;
	private String key;
	
	public Column(int x,int width)
	{
		if (width<0) {
			x2=x;
			x1=x+width;
		} else {
			x1=x;
			x2=x+width;
		}
	}
	
	public Column(int x1,int x2,String key)
	{
		this.x1=x1;
		this.x2=x2;
		this.key=key;
	}
	
	public Column(PrintObject po,TextElement te) {
		Rectangle r = te.getDimension();
		int x = po.getPositionedX()+r.x+po.getX();
		int width = r.width;
		if (width<0) {
			x2=x;
			x1=x+width;
		} else {
			x1=x;
			x2=x+width;
		}
		key = te.getText();
	}

	public int hashCode()
	{
		return x1*17+x2;		
	}
	
	public boolean equals(Object o) {
		Column co = (Column)o;
		if (co.x1!=x1) return false;
		if (co.x2!=x2) return false;
		return true;
	}

	public boolean overlaps(Column c)
	{
		int o_x1=c.x1>x1 ? c.x1 : x1;
		int o_x2=c.x2




© 2015 - 2025 Weber Informatics LLC | Privacy Policy