@Override
public double measureStringWidth(String text) {
CanvasRenderingContext2D context = (CanvasRenderingContext2D) canvas.getContext("2d");
context.setFont(calculator.getFont());
TextMetrics metrics = context.measureText(text);
return metrics.getWidth();
}