use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.
the class RectangleFigureDelegate method drawFigure.
@Override
public void drawFigure(Graphics graphics) {
graphics.pushState();
Rectangle bounds = getBounds();
bounds.width--;
bounds.height--;
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, 1, bounds);
graphics.setAlpha(getAlpha());
if (!isEnabled()) {
setDisabledState(graphics);
}
// Fill
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
graphics.fillRectangle(bounds);
disposeGradientPattern(graphics, gradient);
// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawRectangle(bounds);
// Icon
// getOwner().drawIconImage(graphics, bounds);
getOwner().drawIconImage(graphics, bounds, 0, 0, 0, 0);
graphics.popState();
}
use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.
the class RoundedRectangleFigureDelegate method drawFigure.
@Override
public void drawFigure(Graphics graphics) {
graphics.pushState();
Rectangle bounds = getBounds();
bounds.width--;
bounds.height--;
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, 1, bounds);
graphics.setAlpha(getAlpha());
if (!isEnabled()) {
setDisabledState(graphics);
}
// Fill
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
graphics.fillRoundRectangle(bounds, fArc.width, fArc.height);
disposeGradientPattern(graphics, gradient);
// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawRoundRectangle(bounds, fArc.width, fArc.height);
// Image Icon
Rectangle imageArea = new Rectangle(bounds.x + 2, bounds.y + 2, bounds.width - 4, bounds.height - 4);
getOwner().drawIconImage(graphics, bounds, imageArea, 0, 0, 0, 0);
graphics.popState();
}
use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.
the class AbstractDiagramModelObjectFigure method applyGradientPattern.
/**
* Apply a gradient pattern to the given Graphics instance and bounds using the current fill color, alpha and gradient setting
* If a gradient is applied the alpha of graphics will be set to 255 so callers should set it back if needed after
* calling {@link #disposeGradientPattern(Graphics, Pattern)}
* @return the Pattern if a gradient should be applied or null if not
*/
protected Pattern applyGradientPattern(Graphics graphics, Rectangle bounds) {
Pattern gradient = null;
// Apply gradient
if (getGradient() != IDiagramModelObject.GRADIENT_NONE) {
// Ensure graphics#alpha is 255
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=575778
graphics.setAlpha(255);
gradient = FigureUtils.createGradient(graphics, bounds, getFillColor(), getAlpha(), Direction.get(getGradient()));
graphics.setBackgroundPattern(gradient);
}
return gradient;
}
use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.
the class StickyFigure method drawFigure.
@Override
protected void drawFigure(Graphics graphics) {
graphics.pushState();
graphics.setAlpha(getAlpha());
Rectangle bounds = getBounds().getCopy();
bounds.width--;
bounds.height--;
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, 1, bounds);
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
graphics.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
disposeGradientPattern(graphics, gradient);
// Icon
drawIconImage(graphics, bounds);
// Outline
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
graphics.popState();
}
use of org.eclipse.swt.graphics.Pattern in project archi by archimatetool.
the class ValueStreamFigure method drawFigure.
@Override
protected void drawFigure(Graphics graphics) {
if (getFigureDelegate() != null) {
getFigureDelegate().drawFigure(graphics);
drawIcon(graphics);
return;
}
graphics.pushState();
Rectangle bounds = getBounds().getCopy();
bounds.width--;
bounds.height--;
// Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill
setLineWidth(graphics, 1, bounds);
int indent = Math.min(bounds.height / 2, bounds.width / 2);
int centre_y = bounds.y + bounds.height / 2;
int point_startx = bounds.x + bounds.width - indent;
graphics.setAlpha(getAlpha());
if (!isEnabled()) {
setDisabledState(graphics);
}
// Shape
Path path = new Path(null);
path.moveTo(bounds.x, bounds.y);
path.lineTo(bounds.x + indent, centre_y);
path.lineTo(bounds.x, bounds.y + bounds.height);
path.lineTo(point_startx, bounds.y + bounds.height);
path.lineTo(bounds.x + bounds.width, centre_y);
path.lineTo(point_startx, bounds.y);
path.lineTo(bounds.x, bounds.y);
path.lineTo(bounds.x + indent, centre_y);
// Fill
graphics.setBackgroundColor(getFillColor());
Pattern gradient = applyGradientPattern(graphics, bounds);
graphics.fillPath(path);
disposeGradientPattern(graphics, gradient);
// Outline
graphics.setForegroundColor(getLineColor());
graphics.drawPath(path);
path.dispose();
// Icon
// drawIconImage(graphics, bounds);
int top = 0, right = 0, left = 0, bottom = 0;
switch(((IIconic) getDiagramModelObject()).getImagePosition()) {
case IIconic.ICON_POSITION_TOP_LEFT:
case IIconic.ICON_POSITION_BOTTOM_LEFT:
left = 10;
break;
case IIconic.ICON_POSITION_TOP_RIGHT:
case IIconic.ICON_POSITION_BOTTOM_RIGHT:
right = -indent;
break;
case IIconic.ICON_POSITION_MIDDLE_LEFT:
left = indent;
break;
case IIconic.ICON_POSITION_MIDDLE_RIGHT:
right = -10;
break;
}
drawIconImage(graphics, bounds, top, right, bottom, left);
graphics.popState();
}
Aggregations