package gve.calc.formula;

import java.awt.*;

When the cursor is not on the View, displays a symbol; else acts as a normal CursorPosLabel.
public abstract class TextSymbolView extends CursorPosLabel {
When the symbol is shown as text (i.e. if the cursor is on this View), add this amount of pixels to the left and right of white space Default is half a space. To modify defaults, just call setInsetTextX().
private int insetTextX = -1;
Idem for symbolic view (i.e. when the cursor is not on us) Default is zero.
private int insetSymbolX = 0; public TextSymbolView(String str) { super(str); } public TextSymbolView(String str,int pos) { super(str); } public void setInsetTextX(int inset) { insetTextX = inset; invalidate(); } public void setInsetSymbolX(int inset) { insetSymbolX = inset; invalidate(); } public Dimension getPreferredSize() { if (getCursorPos() < 0) { Dimension dim = getSymbolSize(); dim.width += insetSymbolX*2; return dim; } if (insetTextX < 0) insetTextX = getFontMetrics(getFont()).charWidth(' ')/2; Dimension dim = super.getPreferredSize(); return new Dimension(dim.width + insetTextX*2,dim.height); } public void paint(Graphics g) { if (getCursorPos() < 0) { g.translate(insetSymbolX,0); paintSymbol(g); return; } g.translate(insetTextX,0); if (insetTextX < 0) insetTextX = getFontMetrics(getFont()).charWidth(' ')/2; super.paint(g); } abstract public Dimension getSymbolSize(); abstract public void paintSymbol(Graphics g); }