use of java.awt.Stroke in project scriptographer by scriptographer.
the class DocumentGraphics2D method draw.
public void draw(Shape shape) {
// Only BasicStroke can be converted.
Stroke stroke = gc.getStroke();
if (stroke instanceof BasicStroke) {
BasicStroke basicStroke = (BasicStroke) stroke;
PathItem item = createPathItem(shape);
java.awt.Color color = gc.getColor();
item.setStrokeColor(color);
item.setDashArray(basicStroke.getDashArray());
item.setDashOffset(basicStroke.getDashPhase());
item.setStrokeCap(IntegerEnumUtils.get(StrokeCap.class, basicStroke.getEndCap()));
item.setStrokeJoin(IntegerEnumUtils.get(StrokeJoin.class, basicStroke.getLineJoin()));
item.setStrokeWidth(basicStroke.getLineWidth());
item.setMiterLimit(basicStroke.getMiterLimit());
item.setFillColor(Color.NONE);
}
firstShape = false;
}
use of java.awt.Stroke in project platform_frameworks_base by android.
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 gephi-plugins-bootcamp by gephi.
the class SquareNodes method renderSquaresJava2D.
public void renderSquaresJava2D(Item item, G2DTarget target, PreviewProperties properties) {
//Params
Float x = item.getData(NodeItem.X);
Float y = item.getData(NodeItem.Y);
Float size = item.getData(NodeItem.SIZE);
Color color = item.getData(NodeItem.COLOR);
Color borderColor = ((DependantColor) properties.getValue(PreviewProperty.NODE_BORDER_COLOR)).getColor(color);
float borderSize = properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH);
int alpha = (int) ((properties.getFloatValue(PreviewProperty.NODE_OPACITY) / 100f) * 255f);
if (alpha > 255) {
alpha = 255;
}
//Graphics
Graphics2D graphics = target.getGraphics();
if (borderSize > 0) {
Stroke stroke = new BasicStroke(borderSize);
graphics.setStroke(stroke);
graphics.setColor(new Color(borderColor.getRed(), borderColor.getGreen(), borderColor.getBlue(), alpha));
graphics.draw(new Rectangle(x.intValue(), y.intValue(), size.intValue(), size.intValue()));
}
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha));
graphics.fill(new Rectangle(x.intValue(), y.intValue(), size.intValue(), size.intValue()));
}
use of java.awt.Stroke in project gephi by gephi.
the class EquationDisplay method drawVerticalGrid.
private void drawVerticalGrid(Graphics2D g2) {
double minorSpacing = majorX / minorX;
double axisH = yPositionToPixel(originY);
Stroke gridStroke = new BasicStroke(STROKE_GRID);
Stroke axisStroke = new BasicStroke(STROKE_AXIS);
for (double x = originX + majorX; x < maxX + majorX; x += majorX) {
g2.setStroke(gridStroke);
g2.setColor(COLOR_MINOR_GRID);
for (int i = 0; i < minorX; i++) {
int position = (int) xPositionToPixel(x - i * minorSpacing);
g2.drawLine(position, 0, position, getHeight());
}
int position = (int) xPositionToPixel(x);
g2.setColor(COLOR_MAJOR_GRID);
g2.drawLine(position, 0, position, getHeight());
g2.setStroke(axisStroke);
g2.setColor(COLOR_AXIS);
g2.drawLine(position, (int) axisH - 3, position, (int) axisH + 3);
}
for (double x = originX - majorX; x > minX - majorX; x -= majorX) {
g2.setStroke(gridStroke);
g2.setColor(COLOR_MINOR_GRID);
for (int i = 0; i < minorX; i++) {
int position = (int) xPositionToPixel(x + i * minorSpacing);
g2.drawLine(position, 0, position, getHeight());
}
int position = (int) xPositionToPixel(x);
g2.setColor(COLOR_MAJOR_GRID);
g2.drawLine(position, 0, position, getHeight());
g2.setStroke(axisStroke);
g2.setColor(COLOR_AXIS);
g2.drawLine(position, (int) axisH - 3, position, (int) axisH + 3);
}
}
use of java.awt.Stroke in project gephi by gephi.
the class EquationDisplay method drawAxis.
private void drawAxis(Graphics2D g2) {
double axisH = yPositionToPixel(originY);
double axisV = xPositionToPixel(originX);
g2.setColor(COLOR_AXIS);
Stroke stroke = g2.getStroke();
g2.setStroke(new BasicStroke(STROKE_AXIS));
g2.drawLine(0, (int) axisH, getWidth(), (int) axisH);
g2.drawLine((int) axisV, 0, (int) axisV, getHeight());
FontMetrics metrics = g2.getFontMetrics();
g2.drawString(formatter.format(0.0), (int) axisV + 5, (int) axisH + metrics.getHeight());
g2.setStroke(stroke);
}
Aggregations