
be.quodlibet.boxable.ImageCell Maven / Gradle / Ivy
package be.quodlibet.boxable;
import org.apache.pdfbox.pdmodel.PDPage;
import be.quodlibet.boxable.image.Image;
public class ImageCell extends Cell {
private Image img;
private final HorizontalAlignment align;
private final VerticalAlignment valign;
ImageCell(Row row, float width, Image image, boolean isCalculated) {
super(row, width, null, isCalculated);
this.img = image;
if(image.getWidth() > getInnerWidth()){
scaleToFit();
}
this.align = HorizontalAlignment.LEFT;
this.valign = VerticalAlignment.TOP;
}
public void scaleToFit() {
img = img.scale(getInnerWidth());
}
ImageCell(Row row, float width, Image image, boolean isCalculated, HorizontalAlignment align,
VerticalAlignment valign) {
super(row, width, null, isCalculated, align, valign);
this.img = image;
if(image.getWidth() > getInnerWidth()){
scaleToFit();
}
this.align = align;
this.valign = valign;
}
@Override
public float getTextHeight() {
return img.getHeight();
}
@Override
public float getHorizontalFreeSpace() {
return getInnerWidth() - img.getWidth();
}
@Override
public float getVerticalFreeSpace() {
return getInnerHeight() - img.getHeight();
}
/**
*
* Method which retrieve {@link Image}
*
*
* @return {@link Image}
*/
public Image getImage() {
return img;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy