net.sourceforge.plantuml.skin.AbstractComponent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.skin;
import net.sourceforge.plantuml.klimt.UTranslate;
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.geom.XDimension2D;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
public abstract class AbstractComponent implements Component {
public final Style[] getUsedStyles() {
throw new UnsupportedOperationException();
}
public StyleSignatureBasic getStyleSignature() {
throw new UnsupportedOperationException();
}
private final Style style;
public AbstractComponent(Style style) {
this.style = style;
}
protected final Style getStyle() {
return style;
}
abstract protected void drawInternalU(UGraphic ug, Area area);
protected void drawBackgroundInternalU(UGraphic ug, Area area) {
}
public final void drawU(UGraphic ug, Area area, Context2D context) {
ug = ug.apply(new UTranslate(getPaddingX(), getPaddingY()));
if (context.isBackground())
drawBackgroundInternalU(ug, area);
else
drawInternalU(ug, area);
}
public double getPaddingX() {
return 0;
}
public double getPaddingY() {
return 0;
}
public abstract double getPreferredWidth(StringBounder stringBounder);
public abstract double getPreferredHeight(StringBounder stringBounder);
public final XDimension2D getPreferredDimension(StringBounder stringBounder) {
final double w = getPreferredWidth(stringBounder);
final double h = getPreferredHeight(stringBounder);
return new XDimension2D(w, h);
}
}