Search in sources :

Example 6 with TextMetrics

use of com.ait.lienzo.client.core.types.TextMetrics in project drools-wb by kiegroup.

the class NodeLabel method setLabel.

public void setLabel(final String label) {
    final Layer scratchLayer = new Layer();
    final LienzoPanel scratchPanel = new LienzoPanel(100, 100);
    scratchPanel.add(scratchLayer);
    text.setText(label);
    final TextMetrics tm = text.measure(scratchLayer.getContext());
    final double cw = tm.getWidth() + 10;
    final double ch = tm.getHeight() + 10;
    container.setWidth(cw);
    container.setHeight(ch);
    container.setLocation(new Point2D(-cw / 2, -ch / 2));
}
Also used : LienzoPanel(com.ait.lienzo.client.widget.LienzoPanel) Point2D(com.ait.lienzo.client.core.types.Point2D) TextMetrics(com.ait.lienzo.client.core.types.TextMetrics) Layer(com.ait.lienzo.client.core.shape.Layer)

Example 7 with TextMetrics

use of com.ait.lienzo.client.core.types.TextMetrics in project drools-wb by kiegroup.

the class BaseGuidedDecisionTreeNodeFactory method getDragProxyWidth.

private double getDragProxyWidth(final Text nodeLabel) {
    final LienzoPanel panel = new LienzoPanel(100, 100);
    final Layer layer = new Layer();
    panel.add(layer);
    final TextMetrics tm = nodeLabel.measure(layer.getContext());
    return Math.max(getWidth(), tm.getWidth());
}
Also used : LienzoPanel(com.ait.lienzo.client.widget.LienzoPanel) TextMetrics(com.ait.lienzo.client.core.types.TextMetrics) Layer(com.ait.lienzo.client.core.shape.Layer)

Aggregations

TextMetrics (com.ait.lienzo.client.core.types.TextMetrics)7 Layer (com.ait.lienzo.client.core.shape.Layer)3 LienzoPanel (com.ait.lienzo.client.widget.LienzoPanel)3 Context2D (com.ait.lienzo.client.core.Context2D)1 FillGradient (com.ait.lienzo.client.core.types.FillGradient)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1