Search in sources :

Example 61 with GeneralPath

use of java.awt.geom.GeneralPath in project android_frameworks_base by DirtyUnicorns.

the class Path_Delegate method transform.

/**
     * Transform the points in this path by matrix, and write the answer
     * into dst. If dst is null, then the the original path is modified.
     *
     * @param matrix The matrix to apply to the path
     * @param dst    The transformed path is written here. If dst is null,
     *               then the the original path is modified
     */
public void transform(Matrix_Delegate matrix, Path_Delegate dst) {
    if (matrix.hasPerspective()) {
        assert false;
        Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_AFFINE, "android.graphics.Path#transform() only " + "supports affine transformations.", null, null);
    }
    GeneralPath newPath = new GeneralPath();
    PathIterator iterator = mPath.getPathIterator(matrix.getAffineTransform());
    newPath.append(iterator, false);
    if (dst != null) {
        dst.mPath = newPath;
    } else {
        mPath = newPath;
    }
}
Also used : GeneralPath(java.awt.geom.GeneralPath) PathIterator(java.awt.geom.PathIterator)

Example 62 with GeneralPath

use of java.awt.geom.GeneralPath in project intellij-community by JetBrains.

the class MacUIUtil method paintComboboxFocusRing.

public static void paintComboboxFocusRing(@NotNull final Graphics2D g2d, @NotNull final Rectangle bounds) {
    final Color color = getFocusRingColor();
    final Color[] colors = new Color[] { ColorUtil.toAlpha(color, 180), ColorUtil.toAlpha(color, 130), ColorUtil.toAlpha(color, 80), ColorUtil.toAlpha(color, 80) };
    final Object oldAntialiasingValue = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    final Object oldStrokeControlValue = g2d.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
    int _y = MAC_COMBO_BORDER_V_OFFSET;
    final GeneralPath path1 = new GeneralPath();
    path1.moveTo(2, _y + 4);
    path1.quadTo(2, +_y + 2, 4, _y + 2);
    path1.lineTo(bounds.width - 7, _y + 2);
    path1.quadTo(bounds.width - 5, _y + 3, bounds.width - 4, _y + 5);
    path1.lineTo(bounds.width - 4, bounds.height - 7 + _y);
    path1.quadTo(bounds.width - 5, bounds.height - 5 + _y, bounds.width - 7, bounds.height - 4 + _y);
    path1.lineTo(4, bounds.height - 4 + _y);
    path1.quadTo(2, bounds.height - 4 + _y, 2, bounds.height - 6 + _y);
    path1.closePath();
    g2d.setColor(colors[0]);
    g2d.draw(path1);
    final GeneralPath path2 = new GeneralPath();
    path2.moveTo(1, 5 + _y);
    path2.quadTo(1, 1 + _y, 5, 1 + _y);
    path2.lineTo(bounds.width - 8, 1 + _y);
    path2.quadTo(bounds.width - 4, 2 + _y, bounds.width - 3, 6 + _y);
    path2.lineTo(bounds.width - 3, bounds.height - 7 + _y);
    path2.quadTo(bounds.width - 4, bounds.height - 4 + _y, bounds.width - 8, bounds.height - 3 + _y);
    path2.lineTo(4, bounds.height - 3 + _y);
    path2.quadTo(1, bounds.height - 3 + _y, 1, bounds.height - 6 + _y);
    path2.closePath();
    g2d.setColor(colors[1]);
    g2d.draw(path2);
    final GeneralPath path3 = new GeneralPath();
    path3.moveTo(0, 4 + _y);
    path3.quadTo(0, _y, 7, _y);
    path3.lineTo(bounds.width - 9, _y);
    path3.quadTo(bounds.width - 2, 1 + _y, bounds.width - 2, 7 + _y);
    path3.lineTo(bounds.width - 2, bounds.height - 8 + _y);
    path3.quadTo(bounds.width - 3, bounds.height - 1 + _y, bounds.width - 12, bounds.height - 2 + _y);
    path3.lineTo(7, bounds.height - 2 + _y);
    path3.quadTo(0, bounds.height - 1 + _y, 0, bounds.height - 7 + _y);
    path3.closePath();
    g2d.setColor(colors[2]);
    g2d.draw(path3);
    // restore rendering hints
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue);
    g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue);
}
Also used : GeneralPath(java.awt.geom.GeneralPath)

Example 63 with GeneralPath

use of java.awt.geom.GeneralPath in project android_frameworks_base by AOSPA.

the class Path_Delegate method offset.

/**
     * Offset the path by (dx,dy), returning true on success
     *
     * @param dx  The amount in the X direction to offset the entire path
     * @param dy  The amount in the Y direction to offset the entire path
     */
public void offset(float dx, float dy) {
    GeneralPath newPath = new GeneralPath();
    PathIterator iterator = mPath.getPathIterator(new AffineTransform(0, 0, dx, 0, 0, dy));
    newPath.append(iterator, false);
    mPath = newPath;
}
Also used : GeneralPath(java.awt.geom.GeneralPath) PathIterator(java.awt.geom.PathIterator) AffineTransform(java.awt.geom.AffineTransform)

Example 64 with GeneralPath

use of java.awt.geom.GeneralPath in project antlrworks by antlr.

the class DBInputProcessorToken method drawToken.

public void drawToken(DBInputTextTokenInfo info, Graphics2D g, Color c, boolean fill) {
    g.setColor(c);
    try {
        Rectangle r1 = textPane.modelToView(info.start);
        Rectangle r2 = textPane.modelToView(info.end);
        if (r2.y > r1.y) {
            // token spans more than one line
            GeneralPath gp = new GeneralPath();
            Area area = new Area();
            for (int index = info.start; index < info.end; index++) {
                Rectangle r = textPane.modelToView(index);
                // compute the width of the index
                r.width = Math.max(0, textPane.modelToView(index + 1).x - r.x);
                area.add(new Area(r));
            }
            gp.append(area, true);
            if (fill)
                g.fill(gp);
            else
                g.draw(gp);
        } else {
            if (fill)
                g.fillRect(r1.x, r1.y, r2.x - r1.x, r1.height);
            else
                g.drawRect(r1.x, r1.y, r2.x - r1.x, r1.height);
        }
    } catch (BadLocationException e) {
    // Ignore exception
    }
}
Also used : Area(java.awt.geom.Area) GeneralPath(java.awt.geom.GeneralPath) BadLocationException(javax.swing.text.BadLocationException)

Example 65 with GeneralPath

use of java.awt.geom.GeneralPath in project android_frameworks_base by ResurrectionRemix.

the class Path_Delegate method transform.

/**
     * Transform the points in this path by matrix, and write the answer
     * into dst. If dst is null, then the the original path is modified.
     *
     * @param matrix The matrix to apply to the path
     * @param dst    The transformed path is written here. If dst is null,
     *               then the the original path is modified
     */
public void transform(Matrix_Delegate matrix, Path_Delegate dst) {
    if (matrix.hasPerspective()) {
        assert false;
        Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_AFFINE, "android.graphics.Path#transform() only " + "supports affine transformations.", null, null);
    }
    GeneralPath newPath = new GeneralPath();
    PathIterator iterator = mPath.getPathIterator(matrix.getAffineTransform());
    newPath.append(iterator, false);
    if (dst != null) {
        dst.mPath = newPath;
    } else {
        mPath = newPath;
    }
}
Also used : GeneralPath(java.awt.geom.GeneralPath) PathIterator(java.awt.geom.PathIterator)

Aggregations

GeneralPath (java.awt.geom.GeneralPath)96 Point (java.awt.Point)14 AffineTransform (java.awt.geom.AffineTransform)14 PathIterator (java.awt.geom.PathIterator)14 Graphics2D (java.awt.Graphics2D)8 Rectangle2D (java.awt.geom.Rectangle2D)8 Color (java.awt.Color)7 Paint (java.awt.Paint)7 BasicStroke (java.awt.BasicStroke)6 Point2D (java.awt.geom.Point2D)6 Stroke (java.awt.Stroke)5 Area (java.awt.geom.Area)4 Shape (java.awt.Shape)3 CubicCurve2D (java.awt.geom.CubicCurve2D)3 LayoutPathImpl (sun.font.LayoutPathImpl)3 GradientPaint (java.awt.GradientPaint)2 Rectangle (java.awt.Rectangle)2 Line2D (java.awt.geom.Line2D)2 RoundRectangle2D (java.awt.geom.RoundRectangle2D)2 JBColor (com.intellij.ui.JBColor)1