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

de.invation.code.toval.graphic.mvc.AbstractComponent Maven / Gradle / Ivy

Go to download

TOVAL comprises a set of java classes for common programming issues. It includes utils for arrays, lists, sets and collections for convenient handling and modification, but also support for mathematic definitions concerning logic (clauses + resolution) together with some algorithms for permutations, powersets and resolution. Additionally it contains a number of types for multisets, matrices with object keys and much more.

The newest version!
package de.invation.code.toval.graphic.mvc;

import java.awt.Dimension;
import java.awt.Point;
import java.beans.PropertyChangeListener;

import javax.swing.JComponent;

@SuppressWarnings("serial")
public abstract class AbstractComponent extends JComponent implements PropertyChangeListener{
	
    protected M model;
    protected Dimension size;
    protected Point center;

    public AbstractComponent(M model) {
        this.model = model;
        model.addPropertyChangeListener(this);
    }
    
    public M getModel() {
    	return model;
    }
    
    public void setBounds(){
		setBounds(getLocation().x, getLocation().y, size.width, size.height);
		center = new Point(getLocation().x+size.width/2, getLocation().y+size.height/2);
	}
    
    @Override
    public void setLocation(Point p) {
       	super.setLocation(p);
       	center = new Point(getLocation().x+size.width/2, getLocation().y+size.height/2);
    }
    
    public Point getCenter() {
		return center;
	}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy