public static final native TextMetrics make(int w, int h) /*-{ return { width : w, height : h }; }-*/;
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() ); }
private double getDragProxyHeight( 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( getHeight(), tm.getHeight() ); }
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() ); }
private double getDragProxyHeight( 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( getHeight(), tm.getHeight() ); }
public static final NFastDoubleArrayJSO getTextOffsets(final String font, final TextBaseLine baseline) { FORBOUNDS.getContext().setTextFont(font); FORBOUNDS.getContext().setTextAlign(TextAlign.LEFT); FORBOUNDS.getContext().setTextBaseline(TextBaseLine.ALPHABETIC); final int m = (int) FORBOUNDS.getContext().measureText("M").getWidth(); final int w = (int) FORBOUNDS.getContext().measureText("Mg").getWidth(); final int h = (m * 4); final ScratchPad temp = new ScratchPad(w, h); final Context2D ctxt = temp.getContext(); ctxt.setFillColor(ColorName.BLACK); ctxt.fillRect(0, 0, w, h); ctxt.setTextFont(font); ctxt.setTextAlign(TextAlign.LEFT); ctxt.setTextBaseline(baseline); ctxt.setFillColor(ColorName.WHITE); ctxt.fillText("Mg", 0, m * 2); return getTextOffsets(ctxt.getImageData(0, 0, w, h).getData(), w, h, m * 2); }
public static final native TextMetrics make(int w, int h) /*-{ return { width : w, height : h }; }-*/;
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 ) ); }
private static final NFastDoubleArrayJSO getTextOffsets(final String font, final TextBaseLine baseline) { FORBOUNDS.getContext().setTextFont(font); FORBOUNDS.getContext().setTextAlign(TextAlign.LEFT); FORBOUNDS.getContext().setTextBaseline(TextBaseLine.ALPHABETIC); final int m = (int) FORBOUNDS.getContext().measureText("M").getWidth(); final int w = (int) FORBOUNDS.getContext().measureText("Mg").getWidth(); final int h = (m * 4); final ScratchCanvas temp = new ScratchCanvas(w, h); final Context2D ctxt = temp.getContext(); ctxt.setFillColor(ColorName.BLACK); ctxt.fillRect(0, 0, w, h); ctxt.setTextFont(font); ctxt.setTextAlign(TextAlign.LEFT); ctxt.setTextBaseline(baseline); ctxt.setFillColor(ColorName.WHITE); ctxt.fillText("Mg", 0, m * 2); return getTextOffsets(ctxt.getImageData(0, 0, w, h).getData(), w, h, m * 2); }
public static final native TextMetrics make(int w, int h) /*-{ return { width : w, height : h }; }-*/;
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 ) ); }
public static final NFastDoubleArrayJSO getTextOffsets(final String font, final TextBaseLine baseline) { FORBOUNDS.getContext().setTextFont(font); FORBOUNDS.getContext().setTextAlign(TextAlign.LEFT); FORBOUNDS.getContext().setTextBaseline(TextBaseLine.ALPHABETIC); final int m = (int) FORBOUNDS.getContext().measureText("M").getWidth(); final int w = (int) FORBOUNDS.getContext().measureText("Mg").getWidth(); final int h = (m * 4); final ScratchPad temp = new ScratchPad(w, h); final Context2D ctxt = temp.getContext(); ctxt.setFillColor(ColorName.BLACK); ctxt.fillRect(0, 0, w, h); ctxt.setTextFont(font); ctxt.setTextAlign(TextAlign.LEFT); ctxt.setTextBaseline(baseline); ctxt.setFillColor(ColorName.WHITE); ctxt.fillText("Mg", 0, m * 2); return getTextOffsets(ctxt.getImageData(0, 0, w, h).getData(), w, h, m * 2); }
public static final native TextMetrics make(int w, int h) /*-{ return {width: w, height: h}; }-*/;