use of edu.cmu.cs.hcii.cogtool.view.ScalableInteractiveRectangle in project cogtool by cogtool.
the class SWTTextEditor method repaintTextEditor.
public void repaintTextEditor(double scale) {
if (getVisible()) {
IFigure f = (IFigure) getData();
Rectangle bounds = f.getBounds();
if (f instanceof ScalableInteractiveRectangle) {
bounds = PrecisionUtilities.getDraw2DRectangle(bounds.x / scale, bounds.y / scale, bounds.width / scale, bounds.height / scale);
}
ensureLayout();
int offset = OSUtils.MACOSX ? -2 : 1;
// jcorn - The above conditional flag may not be necessary since
// our switch to SWT 3.2
// TODO: Look into whether or not this conditional is required
//offset = 1;
int x = computeX(bounds, scale, offset);
int y = computeY(bounds, scale, offset);
setLocation(x, y);
int width = computeWidth(bounds, scale, offset);
int height = computeHeight(bounds, scale, offset);
setSize(width, height);
// TODO figure out whether getFontToUse() can reasonably
// return null; it has done so in some non-reproducible
// cases, but I don't yet know whether that is a bug, or if
// the bug was that were assuming that it was non-null. Given
// this code already appears to say "only set the font if there
// is non-zero length font data," it would appear that the
// right thing to do is skip the code if there isn't any font
// or font data, but with my limited knowledge of what's
// going on here I'm a little worried....
// Was: FontData[] fontData = getFontToUse().getFontData();
Font font = getFontToUse();
if (font == null) {
return;
}
FontData[] fontData = font.getFontData();
if (fontData == null) {
return;
}
if (fontData.length > 0) {
String fontName = fontData[0].getName();
int fontStyle = fontData[0].getStyle();
FontData newFontData = new FontData(fontName, computeFontHeight(height, scale, offset), fontStyle);
setFont(new Font(WindowUtil.GLOBAL_DISPLAY, newFontData));
}
}
}
Aggregations