Search in sources :

Example 6 with GeneralPath

use of java.awt.geom.GeneralPath in project openblocks by mikaelhg.

the class CIconButton method getIconShape.

/**
     * This methods maps an icon Enum to an icon Shape
     *
     * @param icon - icon enum
     *
     * @requires none
     * @return the cooresponding icon shape (to match the icon enum)
     * 		   or null if the icon enum does not match any known ones.
     */
private Shape getIconShape(Icon icon) {
    int width = this.getWidth() - 2 * ICON_INSET;
    if (icon == Icon.PLAY) {
        GeneralPath shape = new GeneralPath();
        shape.moveTo(ICON_INSET, ICON_INSET);
        shape.lineTo(ICON_INSET + width, ICON_INSET + width / 2);
        shape.lineTo(ICON_INSET, ICON_INSET + width);
        shape.lineTo(ICON_INSET, ICON_INSET);
        shape.closePath();
        return shape;
    } else if (icon == Icon.PAUSE) {
        Rectangle2D.Float rect1 = new Rectangle2D.Float(ICON_INSET, ICON_INSET, width / 3, width);
        Rectangle2D.Float rect2 = new Rectangle2D.Float(ICON_INSET + width * 2 / 3, ICON_INSET, width / 3, width);
        Area shape1 = new Area(rect1);
        Area shape2 = new Area(rect2);
        shape1.add(shape2);
        return shape1;
    } else if (icon == Icon.STEP) {
        Rectangle2D.Float rect = new Rectangle2D.Float(ICON_INSET, ICON_INSET, width / 5, width);
        GeneralPath triangle = new GeneralPath();
        triangle.moveTo(ICON_INSET + width * 2 / 5, ICON_INSET);
        triangle.lineTo(ICON_INSET + width, ICON_INSET + width / 2);
        triangle.lineTo(ICON_INSET + width * 2 / 5, ICON_INSET + width);
        triangle.closePath();
        Area area1 = new Area(rect);
        Area area2 = new Area(triangle);
        area1.add(area2);
        return area1;
    } else if (icon == Icon.STOP) {
        Rectangle2D.Float rect1 = new Rectangle2D.Float(ICON_INSET, ICON_INSET, width, width);
        Area shape1 = new Area(rect1);
        return shape1;
    }
    return null;
}
Also used : Area(java.awt.geom.Area) GeneralPath(java.awt.geom.GeneralPath) Rectangle2D(java.awt.geom.Rectangle2D) GradientPaint(java.awt.GradientPaint)

Example 7 with GeneralPath

use of java.awt.geom.GeneralPath in project openblocks by mikaelhg.

the class SliderBlueprint method reformTrailingTrack.

/**
     * creates the shape of the track on the right side of the thumb
     * @param blueprint
     * @return general path shape of the track on the right side of the thumb
     */
public Shape reformTrailingTrack(SliderBlueprint blueprint) {
    GeneralPath shape = new GeneralPath();
    shape.moveTo(blueprint.thumbCenter, blueprint.trackTop);
    shape.lineTo(blueprint.closeTrackEdgeRight, blueprint.trackTop);
    shape.curveTo(blueprint.farTrackEdgeRight, blueprint.trackTop, blueprint.farTrackEdgeRight, blueprint.trackBottom, blueprint.closeTrackEdgeRight, blueprint.trackBottom);
    shape.lineTo(blueprint.thumbCenter, blueprint.trackBottom);
    shape.lineTo(blueprint.thumbCenter, blueprint.trackTop);
    shape.closePath();
    return shape;
}
Also used : GeneralPath(java.awt.geom.GeneralPath)

Example 8 with GeneralPath

use of java.awt.geom.GeneralPath in project openblocks by mikaelhg.

the class CTextField method getXCross.

private Shape getXCross(int w, int h) {
    GeneralPath shape = new GeneralPath();
    shape.moveTo(w - h * 2 / 3, h / 3);
    shape.lineTo(w - h / 3, h * 2 / 3);
    shape.moveTo(w - h / 3, h / 3);
    shape.lineTo(w - h * 2 / 3, h * 2 / 3);
    return shape;
}
Also used : GeneralPath(java.awt.geom.GeneralPath)

Example 9 with GeneralPath

use of java.awt.geom.GeneralPath in project openblocks by mikaelhg.

the class Comment method reformComment.

/**
     * Recalculate the shape of this comment 
     */
public void reformComment() {
    int w = textArea.isEditable() ? (int) (this.width * zoom) : (int) (Comment.MINIMUM_WIDTH * zoom);
    int h = textArea.isEditable() ? (int) (this.height * zoom) : (int) (Comment.MINIMUM_HEIGHT * zoom);
    int m = (int) (this.margin * zoom);
    GeneralPath path2 = new GeneralPath();
    path2.moveTo(m - 1, m - 1);
    path2.lineTo(w - m, m - 1);
    path2.lineTo(w - m, h - m);
    path2.lineTo(m - 1, h - m);
    path2.closePath();
    textarea = path2;
    body = new RoundRectangle2D.Double(0, 0, w - 1, h - 1, 3 * m, 3 * m);
    GeneralPath path3 = new GeneralPath();
    path3.moveTo(w - 3 * m, h);
    path3.lineTo(w, h - 3 * m);
    path3.curveTo(w, h, w, h, w - 3 * m, h);
    resize = path3;
    scrollPane.setBounds(m, m, w - 2 * m, h - 2 * m);
    scrollPane.setThumbWidth(textArea.isEditable() ? 2 * m : 0);
    this.setBounds(this.getX(), this.getY(), w, h);
    this.revalidate();
    this.repaint();
    if (arrow != null) {
        arrow.updateArrow();
    }
}
Also used : GeneralPath(java.awt.geom.GeneralPath) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Point(java.awt.Point)

Example 10 with GeneralPath

use of java.awt.geom.GeneralPath in project processing by processing.

the class PdeTextAreaPainter method drawRightArrow.

private static void drawRightArrow(Graphics g, float x, float y, float w, float h) {
    Graphics2D g2 = (Graphics2D) g;
    GeneralPath path = new GeneralPath();
    path.moveTo(x, y);
    path.lineTo(x + w, y + h / 2);
    path.lineTo(x, y + h);
    path.closePath();
    g2.fill(path);
}
Also used : GeneralPath(java.awt.geom.GeneralPath) Graphics2D(java.awt.Graphics2D)

Aggregations

GeneralPath (java.awt.geom.GeneralPath)84 AffineTransform (java.awt.geom.AffineTransform)14 PathIterator (java.awt.geom.PathIterator)14 Rectangle2D (java.awt.geom.Rectangle2D)8 Graphics2D (java.awt.Graphics2D)6 Point (java.awt.Point)6 Paint (java.awt.Paint)5 Color (java.awt.Color)4 Area (java.awt.geom.Area)4 Shape (java.awt.Shape)3 Point2D (java.awt.geom.Point2D)3 LayoutPathImpl (sun.font.LayoutPathImpl)3 BasicStroke (java.awt.BasicStroke)2 GradientPaint (java.awt.GradientPaint)2 RoundRectangle2D (java.awt.geom.RoundRectangle2D)2 JBColor (com.intellij.ui.JBColor)1 PdfContentByte (com.itextpdf.text.pdf.PdfContentByte)1 PdfGState (com.itextpdf.text.pdf.PdfGState)1 AlphaComposite (java.awt.AlphaComposite)1 Composite (java.awt.Composite)1