net.sourceforge.plantuml.math.TeXIconBuilder 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.math;
import java.awt.Color;
import java.awt.Insets;
import java.lang.reflect.InvocationTargetException;
import javax.swing.Icon;
public class TeXIconBuilder {
private Icon icon;
public TeXIconBuilder(String tex, Color foregroundColor)
throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
// TeXFormula formula = new TeXFormula(latex);
final Class> clTeXFormula = Class.forName("org.scilab.forge.jlatexmath.TeXFormula");
final Object formula = clTeXFormula.getConstructor(String.class).newInstance(tex);
// TeXIcon icon = formula.new
// TeXIconBuilder().setStyle(TeXConstants.STYLE_DISPLAY).setSize(20).build();
final Class> clTeXIconBuilder = clTeXFormula.getClasses()[0];
final Object builder = clTeXIconBuilder.getConstructors()[0].newInstance(formula);
clTeXIconBuilder.getMethod("setStyle", int.class).invoke(builder, 0);
clTeXIconBuilder.getMethod("setSize", float.class).invoke(builder, (float) 20);
icon = (Icon) clTeXIconBuilder.getMethod("build").invoke(builder);
final int margin = 1;
final Insets insets = new Insets(margin, margin, margin, margin);
icon.getClass().getMethod("setInsets", insets.getClass()).invoke(icon, insets);
icon.getClass().getMethod("setForeground", foregroundColor.getClass()).invoke(icon, foregroundColor);
}
public Icon getIcon() {
return icon;
}
}