Search in sources :

Example 1 with Stroke

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;
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke)

Example 2 with Stroke

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;
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Shape(java.awt.Shape) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 3 with Stroke

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()));
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) DependantColor(org.gephi.preview.types.DependantColor) Color(java.awt.Color) DependantColor(org.gephi.preview.types.DependantColor) Rectangle(java.awt.Rectangle) Graphics2D(java.awt.Graphics2D)

Example 4 with Stroke

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);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Point(java.awt.Point)

Example 5 with Stroke

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);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) FontMetrics(java.awt.FontMetrics)

Aggregations

Stroke (java.awt.Stroke)43 BasicStroke (java.awt.BasicStroke)41 Paint (java.awt.Paint)18 Point (java.awt.Point)11 Shape (java.awt.Shape)11 Color (java.awt.Color)7 Line2D (java.awt.geom.Line2D)7 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)6 Graphics2D (java.awt.Graphics2D)6 AffineTransform (java.awt.geom.AffineTransform)5 Ellipse2D (java.awt.geom.Ellipse2D)4 Point2D (java.awt.geom.Point2D)4 Font (java.awt.Font)3 GradientPaint (java.awt.GradientPaint)3 Rectangle (java.awt.Rectangle)3 RoundRectangle2D (java.awt.geom.RoundRectangle2D)3 Dimension (java.awt.Dimension)2 AxisChart (org.jCharts.axisChart.AxisChart)2 AxisChartDataSet (org.jCharts.chartData.AxisChartDataSet)2 DataSeries (org.jCharts.chartData.DataSeries)2