use of java.awt.Stroke in project Activiti by Activiti.
the class DefaultProcessDiagramCanvas method drawInclusiveGateway.
public void drawInclusiveGateway(GraphicInfo graphicInfo, double scaleFactor) {
// rhombus
drawGateway(graphicInfo);
int x = (int) graphicInfo.getX();
int y = (int) graphicInfo.getY();
int width = (int) graphicInfo.getWidth();
int height = (int) graphicInfo.getHeight();
int diameter = width / 2;
if (scaleFactor == 1.0) {
// circle inside rhombus
Stroke orginalStroke = g.getStroke();
g.setStroke(GATEWAY_TYPE_STROKE);
Ellipse2D.Double circle = new Ellipse2D.Double(((width - diameter) / 2) + x, ((height - diameter) / 2) + y, diameter, diameter);
g.draw(circle);
g.setStroke(orginalStroke);
}
}
use of java.awt.Stroke in project Activiti by Activiti.
the class DefaultProcessDiagramCanvas method drawMultiInstanceMarker.
public void drawMultiInstanceMarker(boolean sequential, int x, int y, int width, int height) {
int rectangleWidth = MARKER_WIDTH;
int rectangleHeight = MARKER_WIDTH;
int lineX = x + (width - rectangleWidth) / 2;
int lineY = y + height - rectangleHeight - 3;
Stroke orginalStroke = g.getStroke();
g.setStroke(MULTI_INSTANCE_STROKE);
if (sequential) {
g.draw(new Line2D.Double(lineX, lineY, lineX + rectangleWidth, lineY));
g.draw(new Line2D.Double(lineX, lineY + rectangleHeight / 2, lineX + rectangleWidth, lineY + rectangleHeight / 2));
g.draw(new Line2D.Double(lineX, lineY + rectangleHeight, lineX + rectangleWidth, lineY + rectangleHeight));
} else {
g.draw(new Line2D.Double(lineX, lineY, lineX, lineY + rectangleHeight));
g.draw(new Line2D.Double(lineX + rectangleWidth / 2, lineY, lineX + rectangleWidth / 2, lineY + rectangleHeight));
g.draw(new Line2D.Double(lineX + rectangleWidth, lineY, lineX + rectangleWidth, lineY + rectangleHeight));
}
g.setStroke(orginalStroke);
}
use of java.awt.Stroke in project android_frameworks_base by ResurrectionRemix.
the class Paint_Delegate method nGetFillPath.
@LayoutlibDelegate
static /*package*/
boolean nGetFillPath(long native_object, long src, long dst) {
Paint_Delegate paint = sManager.getDelegate(native_object);
if (paint == null) {
return false;
}
Path_Delegate srcPath = Path_Delegate.getDelegate(src);
if (srcPath == null) {
return true;
}
Path_Delegate dstPath = Path_Delegate.getDelegate(dst);
if (dstPath == null) {
return true;
}
Stroke stroke = paint.getJavaStroke();
Shape strokeShape = stroke.createStrokedShape(srcPath.getJavaShape());
dstPath.setJavaShape(strokeShape);
// FIXME figure out the return value?
return true;
}
use of java.awt.Stroke in project ChatGameFontificator by GlitchCog.
the class ColorSwatch method paint.
@Override
public void paint(Graphics g) {
super.paint(g);
if (isSelected()) {
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint(Color.BLACK);
Stroke stroke = new BasicStroke(BORDER_THICKNESS, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] { 3, 3, 3, 3 }, dashTimer.getOffset());
g2d.setStroke(stroke);
final int halfThickness = Math.max(1, BORDER_THICKNESS / 2);
g2d.drawRect(halfThickness, halfThickness, getWidth() - BORDER_THICKNESS, getHeight() - BORDER_THICKNESS);
}
}
use of java.awt.Stroke in project jdk8u_jdk by JetBrains.
the class WPathGraphics method draw.
/**
* Strokes the outline of a Shape using the settings of the current
* graphics state. The rendering attributes applied include the
* clip, transform, paint or color, composite and stroke attributes.
* @param s The shape to be drawn.
* @see #setStroke
* @see #setPaint
* @see java.awt.Graphics#setColor
* @see #transform
* @see #setTransform
* @see #clip
* @see #setClip
* @see #setComposite
*/
@Override
public void draw(Shape s) {
Stroke stroke = getStroke();
/* If the line being drawn is thinner than can be
* rendered, then change the line width, stroke
* the shape, and then set the line width back.
* We can only do this for BasicStroke's.
*/
if (stroke instanceof BasicStroke) {
BasicStroke lineStroke;
BasicStroke minLineStroke = null;
float deviceLineWidth;
float lineWidth;
AffineTransform deviceTransform;
Point2D.Float penSize;
/* Get the requested line width in user space.
*/
lineStroke = (BasicStroke) stroke;
lineWidth = lineStroke.getLineWidth();
penSize = new Point2D.Float(lineWidth, lineWidth);
/* Compute the line width in device coordinates.
* Work on a point in case there is asymetric scaling
* between user and device space.
* Take the absolute value in case there is negative
* scaling in effect.
*/
deviceTransform = getTransform();
deviceTransform.deltaTransform(penSize, penSize);
deviceLineWidth = Math.min(Math.abs(penSize.x), Math.abs(penSize.y));
/* If the requested line is too thin then map our
* minimum line width back to user space and set
* a new BasicStroke.
*/
if (deviceLineWidth < MIN_DEVICE_LINEWIDTH) {
Point2D.Float minPenSize = new Point2D.Float(MIN_DEVICE_LINEWIDTH, MIN_DEVICE_LINEWIDTH);
try {
AffineTransform inverse;
float minLineWidth;
/* Convert the minimum line width from device
* space to user space.
*/
inverse = deviceTransform.createInverse();
inverse.deltaTransform(minPenSize, minPenSize);
minLineWidth = Math.max(Math.abs(minPenSize.x), Math.abs(minPenSize.y));
/* Use all of the parameters from the current
* stroke but change the line width to our
* calculated minimum.
*/
minLineStroke = new BasicStroke(minLineWidth, lineStroke.getEndCap(), lineStroke.getLineJoin(), lineStroke.getMiterLimit(), lineStroke.getDashArray(), lineStroke.getDashPhase());
setStroke(minLineStroke);
} catch (NoninvertibleTransformException e) {
/* If we can't invert the matrix there is something
* very wrong so don't worry about the minor matter
* of a minimum line width.
*/
}
}
super.draw(s);
/* If we changed the stroke, put back the old
* stroke in order to maintain a minimum line
* width.
*/
if (minLineStroke != null) {
setStroke(lineStroke);
}
/* The stroke in effect was not a BasicStroke so we
* will not try to enforce a minimum line width.
*/
} else {
super.draw(s);
}
}
Aggregations