nl.dvberkel.tree.SvgLeaf Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tree.svg Show documentation
Show all versions of tree.svg Show documentation
Code to generate SVG from trees
The newest version!
package nl.dvberkel.tree;
import nl.dvberkel.box.BoundingBox;
import nl.dvberkel.box.Translation;
public class SvgLeaf implements SvgTree {
protected final Configuration configuration;
private BoundingBox boundingBox;
public SvgLeaf(Configuration configuration) {
this.configuration = configuration;
}
@Override
public BoundingBox boundingBox() {
if (boundingBox == null) {
this.boundingBox = defaultBoundingBox();
}
return boundingBox;
}
@Override
public void translateBy(Translation translation) {
boundingBox = boundingBox().translateBy(translation);
}
protected BoundingBox defaultBoundingBox() {
int size = 2 * (configuration.nodeRadius + configuration.padding);
return new BoundingBox(0, 0, size, size);
}
@Override
public int hashCode() {
return 31;
}
@Override
public boolean equals(Object obj) {
return obj != null && this.getClass().equals(obj.getClass());
}
}