本文整理汇总了Java中org.eclipse.draw2d.Graphics.setLineDash方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.setLineDash方法的具体用法?Java Graphics.setLineDash怎么用?Java Graphics.setLineDash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.Graphics
的用法示例。
在下文中一共展示了Graphics.setLineDash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Override to render the circle without background and with dotted outline
*/
@Override
protected void paintFigure(Graphics graphics) {
Rectangle bounds = getBounds().getCopy();
Rectangle realBounds = bounds.getCopy();
int offset = (int)(HIDDEN_CHILDREN_INDICATOR_SIZE * 0.5);
bounds.setY(bounds.y + offset);
bounds.setHeight(bounds.width);
//Compensate for line width
int lineWidth = outlineWidth / 2;
bounds.expand(-lineWidth, -lineWidth);
DEGraphicalEditorTheme theme = DEGraphicalEditor.getTheme();
graphics.setLineStyle(SWT.LINE_CUSTOM);
graphics.setLineDash(new int[] {4});
graphics.setLineWidth(theme.getLineWidth());
graphics.setForegroundColor(theme.getLineColor());
Point topLeft = realBounds.getTopLeft();
Point bottomLeft = realBounds.getBottomLeft();
graphics.drawLine(new Point(topLeft.x+offset-theme.getLineWidth() / 2, topLeft.y),
new Point(bottomLeft.x+offset-theme.getLineWidth() / 2, bottomLeft.y-HIDDEN_CHILDREN_INDICATOR_SIZE));
DEDrawingUtil.outlineEllipsis(graphics, bounds, outlineColor);
}
示例2: draw
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void draw(LineAttribute lineAttr, Graphics graphics, ResourceManager resourceManager) {
Color stdFgColor = graphics.getForegroundColor();
int stdLineStyle = graphics.getLineStyle();
Color lineColor = getSwtColor(lineAttr.lineColor, resourceManager);
if (lineColor != null) {
graphics.setForegroundColor(lineColor);
}
try {
float lineWidth = (float) ((DoubleToken) lineAttr.lineWidth.getToken()).doubleValue();
graphics.setLineWidthFloat(lineWidth);
int x2_step = (int) ((DoubleToken) lineAttr.x.getToken()).doubleValue();
int y2_step = (int) ((DoubleToken) lineAttr.y.getToken()).doubleValue();
// TODO may need to move this upwards as other shape types may also have dashed lines in Ptolemy II
ArrayToken dashArrayToken = (ArrayToken) lineAttr.dashArray.getToken();
if (dashArrayToken != null && dashArrayToken.length() > 0) {
graphics.setLineStyle(SWT.LINE_DASH);
float[] dashPattern = new float[dashArrayToken.length()];
for (int i = 0; i < dashArrayToken.length(); i++) {
dashPattern[i] = (float) ((DoubleToken) dashArrayToken.getElement(i)).doubleValue();
}
graphics.setLineDash(dashPattern);
}
Point tlp = getTopLeftLocation(lineAttr);
graphics.drawLine(tlp, tlp.getTranslated(x2_step, y2_step));
} catch (IllegalActionException e) {
LOGGER.error("Error reading dimensions for " + lineAttr.getFullName(), e);
} finally {
graphics.setForegroundColor(stdFgColor);
graphics.setLineStyle(stdLineStyle);
}
}