use of org.eclipse.draw2d.geometry.Dimension in project cogtool by cogtool.
the class GraphicalWidgetBase method updateType.
public synchronized void updateType() {
// Mark the caches as dirty so that no one will use them
synchronized (this.flagLock) {
this.cachedMidgroundDirty = true;
}
IWidget w = getModel();
try {
// Change the renderer to one that is appropriate for the type
this.renderer = getRendererForType(w.getWidgetType(), w.getFrame().getDesign().getSkin(), w.isRendered());
} catch (Exception e) {
System.err.println("Error creating widget renderer: " + e);
try {
this.renderer = getRendererForType(w.getWidgetType(), SkinType.None, w.isRendered());
} catch (Exception ex) {
System.err.println("Error creating unskinned widget renderer: " + e);
this.renderer = new LabelRenderer(this.attrOverride);
}
}
Dimension widgetExtent = getSize();
this.renderer.setSize(widgetExtent.width, widgetExtent.height);
this.renderer.setText(w.getTitle());
this.renderer.updateData();
setCursor(determineProperCursor(w, this.desiredRolloverCursor));
regenerateCaches();
}
use of org.eclipse.draw2d.geometry.Dimension in project cogtool by cogtool.
the class GraphicalDevice method paintFigure.
/**
* Override to perform drawing tasks common to all graphical sources
*/
@Override
protected void paintFigure(Graphics g) {
Dimension size = getSize();
// Workaround Draw2D's inability to draw 0-size images.
int width = size.width;
if (width == 0) {
width = 1;
}
int height = size.height;
if (height == 0) {
height = 1;
}
Image scaled = null;
try {
// Draw foreground sheen (not selected)
foreground.setAlpha(0, 0, displayAlpha.determineAlpha(false));
// TODO: Can this be cached more efficiently?
scaled = new Image(null, foreground.scaledTo(width, height));
Point location = getLocation();
g.drawImage(scaled, location.x, location.y);
} catch (SWTException ex) {
throw new RcvrImageException("Drawing device foreground image failed", ex);
} finally {
if (scaled != null) {
scaled.dispose();
}
}
super.paintFigure(g);
button.paintFigure(g);
}
use of org.eclipse.draw2d.geometry.Dimension in project cogtool by cogtool.
the class ScalableGraphicalFigure method getPreferredSize.
/**
* @see Figure#getPreferredSize(int, int)
*/
@Override
public Dimension getPreferredSize(int wHint, int hHint) {
Dimension d = super.getPreferredSize(wHint, hHint);
int w = getInsets().getWidth();
int h = getInsets().getHeight();
return d.getExpanded(-w, -h).scale(scale).expand(w, h);
}
use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.
the class GraphPlanStyleProvider method wrapText.
/**
* wrap the too long text
*
* @param width
* @param str
* @return
*/
private String wrapText(int width, String str) {
Dimension dim1 = TextUtilities.INSTANCE.getStringExtents(str, GraphPlanTooltipFigure.normalFont);
// the width is big enough to display the String
if (dim1.width < width) {
return str;
}
// Calculate how many character to display per line
int pixPerChar = dim1.width / str.length();
int charPerLine = (MIN_CHAR_PER_LINE > width / pixPerChar) ? MIN_CHAR_PER_LINE : width / pixPerChar;
StringBuilder sb = new StringBuilder();
int startpos = 0;
int endpos = charPerLine;
while (startpos < str.length()) {
if (endpos >= str.length()) {
endpos = str.length();
}
sb.append(str.substring(startpos, endpos)).append("\n");
startpos += charPerLine;
endpos += charPerLine;
}
return sb.toString();
}
use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.
the class ERTableNode method getMaxSizeNode.
public static ERTableNode getMaxSizeNode(Collection<ERTableNode> allNodes, boolean horizon) {
int max = 0;
ERTableNode result = null;
for (ERTableNode node : allNodes) {
Dimension d = node.getDefaultPreferredSize();
if (horizon && d.width > max) {
result = node;
max = d.width;
} else if (!horizon && d.height > max) {
result = node;
max = d.height;
}
}
return result;
}
Aggregations