Search in sources :

Example 51 with GeneralPath

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

the class AutoCompletePanel method paint.

@Override
public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    int w = this.getWidth();
    int h = this.getHeight();
    g.setColor(BACKGROUND);
    g.fillRoundRect(0, 0, w - 1, h - 1, MARGIN * 2, MARGIN * 2);
    GeneralPath resize = new GeneralPath();
    resize.moveTo(w - 2 * MARGIN, h);
    resize.lineTo(w, h - 2 * MARGIN);
    resize.curveTo(w - 1, h - 1, w - 1, h - 1, w - 2 * MARGIN, h);
    g.setColor(Color.gray);
    g2.fill(resize);
    g.setColor(Color.gray);
    g.drawRoundRect(0, 0, w - 1, h - 1, MARGIN * 2, MARGIN * 2);
    super.paint(g);
}
Also used : GeneralPath(java.awt.geom.GeneralPath) Graphics2D(java.awt.Graphics2D)

Example 52 with GeneralPath

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

the class BlockShape method reformArea.

/**
     * Reform the BlockShape area.  This is the major procedure that makes all of the sides
     * combines them in their correct directions, and connects them so they are all one direction.
     * @return reformed Area of the BlockShape
     */
public Area reformArea() {
    //hopefully reseting is less costly than creating new ones
    gpTop.reset();
    gpRight.reset();
    gpBottom.reset();
    gpLeft.reset();
    setupDimensions();
    //make all of the sides
    makeTopSide();
    makeRightSide();
    makeBottomSide();
    makeLeftSide();
    //corrected (clockwise) left and bottom
    gpBottomClockwise = new GeneralPath();
    gpLeftClockwise = new GeneralPath();
    gpBottomClockwise.moveTo((float) gpBottom.getCurrentPoint().getX(), (float) gpBottom.getCurrentPoint().getY());
    gpLeftClockwise.moveTo((float) gpLeft.getCurrentPoint().getX(), (float) gpLeft.getCurrentPoint().getY());
    BlockShapeUtil.appendPath(gpBottomClockwise, gpBottom, true);
    BlockShapeUtil.appendPath(gpLeftClockwise, gpLeft, true);
    //create direction specific paths
    GeneralPath gpClockwise = new GeneralPath();
    GeneralPath gpCounterClockwise = new GeneralPath();
    //add to the direction specific paths
    gpCounterClockwise.append(gpLeft, true);
    gpCounterClockwise.append(gpBottom, true);
    gpClockwise.append(gpTop, true);
    gpClockwise.append(gpRight, true);
    //connect so gpCounterClockwise is the full path
    //it must be counter-clockwise for the bevel to be able to use it
    BlockShapeUtil.appendPath(gpCounterClockwise, gpClockwise, true);
    //convert it to an area
    blockArea = new Area(gpCounterClockwise);
    return blockArea;
}
Also used : Area(java.awt.geom.Area) GeneralPath(java.awt.geom.GeneralPath)

Example 53 with GeneralPath

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

the class SliderBlueprint method reformLeadingTrack.

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

Example 54 with GeneralPath

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

the class SliderBlueprint method reformTicks.

/**
     * creates the shape of the ticks
     * @param blueprint
     * @return general path of the ticks
     */
public Shape reformTicks(SliderBlueprint blueprint) {
    GeneralPath ticks = new GeneralPath();
    int count = 0;
    float position = blueprint.closeTrackEdgeLeft;
    float interval = (float) (blueprint.closeTrackEdgeRight - blueprint.closeTrackEdgeLeft) / this.tickNumber;
    while (count < (tickNumber + 1)) {
        ticks.moveTo((int) position, blueprint.trackTop);
        ticks.lineTo((int) position, blueprint.trackBottom);
        position += interval;
        count += 1;
    }
    ticks.closePath();
    return ticks;
}
Also used : GeneralPath(java.awt.geom.GeneralPath) GradientPaint(java.awt.GradientPaint)

Example 55 with GeneralPath

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

the class CQueryField 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)

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