1 11 12 package org.eclipse.jdt.internal.ui.text.comment; 13 14 import org.eclipse.swt.graphics.GC; 15 import org.eclipse.swt.widgets.Control; 16 17 22 public class DefaultTextMeasurement implements ITextMeasurement { 23 24 25 private Control fControl; 26 27 32 public DefaultTextMeasurement(Control control) { 33 fControl= control; 34 } 35 36 39 public int computeWidth(String string) { 40 GC graphics= new GC(fControl); 41 graphics.setFont(fControl.getFont()); 42 int width= graphics.stringExtent(string).x; 43 graphics.dispose(); 44 return width; 45 } 46 } 47 | Popular Tags |