use of org.graphstream.ui.graphicGraph.stylesheet.Value in project gs-ui-javafx by graphstream.
the class FxTextBox method apply.
// public abstract double getAscentDescent();
/**
* Factory companion object for text boxes.
*/
// static FontRenderContext defaultFontRenderContext = new FontRenderContext(new AffineTransform(), true, true);
public static TextBox apply(DefaultCamera2D camera, Style style) {
String fontName = style.getTextFont();
TextStyle fontStyle = style.getTextStyle();
Value fontSize = style.getTextSize();
Color textColor = ColorManager.getTextColor(style, 0);
Color bgColor = null;
boolean rounded = false;
switch(style.getTextBackgroundMode()) {
case NONE:
break;
case PLAIN:
rounded = false;
bgColor = ColorManager.getTextBackgroundColor(style, 0);
break;
case ROUNDEDBOX:
rounded = true;
bgColor = ColorManager.getTextBackgroundColor(style, 0);
break;
default:
break;
}
Values padding = style.getTextPadding();
double padx = camera.getMetrics().lengthToPx(padding, 0);
double pady = padx;
if (padding.size() > 1)
camera.getMetrics().lengthToPx(padding, 1);
return TextBox.apply(fontName, fontStyle, (int) fontSize.value, textColor, bgColor, rounded, padx, pady);
}