Java Code Examples for java.awt.geom.GeneralPath#curveTo()

The following examples show how to use java.awt.geom.GeneralPath#curveTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SinglePath.java    From han3_ji7_tsoo1_kian3 with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 把線段加到路徑中。
 * 
 * @param generalPath
 *            目標路徑
 */
public void addTo(GeneralPath generalPath)
{
	switch (type)
	{
	case PathIterator.SEG_MOVETO:
		generalPath.moveTo(controlPoint[0], controlPoint[1]);
		break;
	case PathIterator.SEG_LINETO:
		generalPath.lineTo(controlPoint[0], controlPoint[1]);
		break;
	case PathIterator.SEG_QUADTO:
		generalPath.quadTo(controlPoint[0], controlPoint[1],
				controlPoint[2], controlPoint[3]);
		break;
	case PathIterator.SEG_CUBICTO:
		generalPath.curveTo(controlPoint[0], controlPoint[1],
				controlPoint[2], controlPoint[3], controlPoint[4],
				controlPoint[5]);
		break;
	case PathIterator.SEG_CLOSE:
		generalPath.closePath();
		break;
	}
}
 
Example 2
Source File: mxCloudShape.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
public Shape createShape(mxGraphics2DCanvas canvas, mxCellState state) {
  Rectangle temp = state.getRectangle();
  int x = temp.x;
  int y = temp.y;
  int w = temp.width;
  int h = temp.height;
  GeneralPath path = new GeneralPath();

  path.moveTo((float)(x + 0.25 * w), (float)(y + 0.25 * h));
  path.curveTo((float)(x + 0.05 * w), (float)(y + 0.25 * h), x, (float)(y + 0.5 * h), (float)(x + 0.16 * w), (float)(y + 0.55 * h));
  path.curveTo(x, (float)(y + 0.66 * h), (float)(x + 0.18 * w), (float)(y + 0.9 * h), (float)(x + 0.31 * w), (float)(y + 0.8 * h));
  path.curveTo((float)(x + 0.4 * w), (y + h), (float)(x + 0.7 * w), (y + h), (float)(x + 0.8 * w), (float)(y + 0.8 * h));
  path.curveTo((x + w), (float)(y + 0.8 * h), (x + w), (float)(y + 0.6 * h), (float)(x + 0.875 * w), (float)(y + 0.5 * h));
  path.curveTo((x + w), (float)(y + 0.3 * h), (float)(x + 0.8 * w), (float)(y + 0.1 * h), (float)(x + 0.625 * w), (float)(y + 0.2 * h));
  path.curveTo((float)(x + 0.5 * w), (float)(y + 0.05 * h), (float)(x + 0.3 * w), (float)(y + 0.05 * h), (float)(x + 0.25 * w),
               (float)(y + 0.25 * h));
  path.closePath();

  return path;
}
 
Example 3
Source File: TrafficLight.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public BufferedImage createRedOnImage(final int WIDTH, final int HEIGHT) {
    final GraphicsConfiguration GFX_CONF = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    if (WIDTH <= 0 || HEIGHT <= 0) {
        return GFX_CONF.createCompatibleImage(1, 1, java.awt.Transparency.TRANSLUCENT);
    }
    final BufferedImage IMAGE = GFX_CONF.createCompatibleImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT);
    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();
    final Ellipse2D LIGHT_ON = new Ellipse2D.Double(0.17346938775510204 * IMAGE_WIDTH, 0.07553956834532374 * IMAGE_HEIGHT, 0.6530612244897959 * IMAGE_WIDTH, 0.2302158273381295 * IMAGE_HEIGHT);
    G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.1906474820143885 * IMAGE_HEIGHT), (0.32653061224489793f * IMAGE_WIDTH), new float[]{0.0f, 1.0f}, new Color[]{new Color(1f, 0f, 0f, 1f), new Color(0.2549019608f, 0f, 0.0156862745f, 1f)}));
    G2.fill(LIGHT_ON);

    final GeneralPath GLOW = new GeneralPath();
    GLOW.setWindingRule(Path2D.WIND_EVEN_ODD);
    GLOW.moveTo(0.0 * IMAGE_WIDTH, 0.19424460431654678 * IMAGE_HEIGHT);
    GLOW.curveTo(0.0 * IMAGE_WIDTH, 0.29136690647482016 * IMAGE_HEIGHT, 0.22448979591836735 * IMAGE_WIDTH, 0.37050359712230213 * IMAGE_HEIGHT, 0.5 * IMAGE_WIDTH, 0.37050359712230213 * IMAGE_HEIGHT);
    GLOW.curveTo(0.7755102040816326 * IMAGE_WIDTH, 0.37050359712230213 * IMAGE_HEIGHT, 1.0 * IMAGE_WIDTH, 0.29136690647482016 * IMAGE_HEIGHT, 1.0 * IMAGE_WIDTH, 0.1906474820143885 * IMAGE_HEIGHT);
    GLOW.curveTo(0.9081632653061225 * IMAGE_WIDTH, 0.13309352517985612 * IMAGE_HEIGHT, 0.7040816326530612 * IMAGE_WIDTH, 0.0683453237410072 * IMAGE_HEIGHT, 0.5 * IMAGE_WIDTH, 0.0683453237410072 * IMAGE_HEIGHT);
    GLOW.curveTo(0.2857142857142857 * IMAGE_WIDTH, 0.0683453237410072 * IMAGE_HEIGHT, 0.08163265306122448 * IMAGE_WIDTH, 0.13309352517985612 * IMAGE_HEIGHT, 0.0 * IMAGE_WIDTH, 0.19424460431654678 * IMAGE_HEIGHT);
    GLOW.closePath();
    G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.1906474820143885 * IMAGE_HEIGHT), (0.5153061224489796f * IMAGE_WIDTH), new float[]{0.0f, 1.0f}, new Color[]{new Color(1f, 0f, 0f, 1f), new Color(0.4627450980f, 0.0196078431f, 0.0039215686f, 0f)}));
    G2.fill(GLOW);

    G2.dispose();
    return IMAGE;
}
 
Example 4
Source File: lineutility.java    From mil-sym-java with Apache License 2.0 5 votes vote down vote up
/**
 * same as createStrokedShape except it uses a Path2D
 *
 * @param shape
 * @return
 */
protected static Shape createStrokedShape2(Path2D shape) {
    GeneralPath newshape = new GeneralPath(); // Start with an empty shape
    try {
        // Iterate through the specified shape, perturb its coordinates, and
        // use them to build up the new shape.
        float[] coords = new float[6];
        for (PathIterator i = shape.getPathIterator(null); !i.isDone(); i.next()) {
            int type = i.currentSegment(coords);
            switch (type) {
                case PathIterator.SEG_MOVETO:
                    //perturb(coords, 2);
                    newshape.moveTo(coords[0], coords[1]);
                    break;
                case PathIterator.SEG_LINETO:
                    //perturb(coords, 2);
                    newshape.lineTo(coords[0], coords[1]);
                    break;
                case PathIterator.SEG_QUADTO:
                    //perturb(coords, 4);
                    newshape.quadTo(coords[0], coords[1], coords[2], coords[3]);
                    break;
                case PathIterator.SEG_CUBICTO:
                    //perturb(coords, 6);
                    newshape.curveTo(coords[0], coords[1], coords[2], coords[3],
                            coords[4], coords[5]);
                    break;
                case PathIterator.SEG_CLOSE:
                    newshape.closePath();
                    break;
            }

        }
    } catch (Exception exc) {
        ErrorLogger.LogException(_className, "createStrokedShape",
                new RendererException("Failed inside createStrokedShape", exc));
    }
    return newshape;
}
 
Example 5
Source File: RadialQuarterN.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected BufferedImage create_DISABLED_Image(final int WIDTH) {
    if (WIDTH <= 0) {
        return null;
    }

    final BufferedImage IMAGE = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);
    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();

    transformGraphics(IMAGE_WIDTH, IMAGE_HEIGHT, G2);

    final GeneralPath BACKGROUND = new GeneralPath();
    BACKGROUND.setWindingRule(Path2D.WIND_EVEN_ODD);
    BACKGROUND.moveTo(IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.9158878504672897);
    BACKGROUND.curveTo(IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.9158878504672897, IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.08411214953271028, IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.08411214953271028);
    BACKGROUND.curveTo(IMAGE_WIDTH * 0.6401869158878505, IMAGE_HEIGHT * 0.08411214953271028, IMAGE_WIDTH * 0.46261682242990654, IMAGE_HEIGHT * 0.1588785046728972, IMAGE_WIDTH * 0.29439252336448596, IMAGE_HEIGHT * 0.32242990654205606);
    BACKGROUND.curveTo(IMAGE_WIDTH * 0.17289719626168223, IMAGE_HEIGHT * 0.4439252336448598, IMAGE_WIDTH * 0.08411214953271028, IMAGE_HEIGHT * 0.6635514018691588, IMAGE_WIDTH * 0.08411214953271028, IMAGE_HEIGHT * 0.9158878504672897);
    BACKGROUND.curveTo(IMAGE_WIDTH * 0.08411214953271028, IMAGE_HEIGHT * 0.9158878504672897, IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.9158878504672897, IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.9158878504672897);
    BACKGROUND.closePath();

    G2.setColor(new Color(102, 102, 102, 178));
    G2.fill(BACKGROUND);

    G2.dispose();

    return IMAGE;
}
 
Example 6
Source File: Util.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates an image that consists of {@code text} on a background containing a curved shape. The
 * returned image is appropriate for display in the header of a dialog to give it a "wizard-like"
 * look.
 */
public static Image getBanner(final String text) {
  // code stolen from swingx
  // swingx is lgpl, so no problems with copyright
  final int w = 530;
  final int h = 60;
  final BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2 = img.createGraphics();
  final Font font = new Font("Arial Bold", Font.PLAIN, 36);
  g2.setFont(font);
  g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2.setRenderingHint(
      RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  g2.setRenderingHint(
      RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
  // draw a big square
  g2.setColor(Color.GRAY);
  g2.fillRect(0, 0, w, h);
  // create the curve shape
  final GeneralPath curveShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);
  curveShape.moveTo(0, h * .6f);
  curveShape.curveTo(w * .167f, h * 1.2f, w * .667f, h * -.5f, w, h * .75f);
  curveShape.lineTo(w, h);
  curveShape.lineTo(0, h);
  curveShape.lineTo(0, h * .8f);
  curveShape.closePath();
  // draw into the buffer a gradient (bottom to top), and the text "Login"
  final GradientPaint gp = new GradientPaint(0, h, Color.GRAY, 0, 0, Color.LIGHT_GRAY);
  g2.setPaint(gp);
  g2.fill(curveShape);
  // g2.setPaint(Color.white);
  g2.setColor(Color.WHITE);
  final float loginStringY = h * .75f;
  final float loginStringX = w * .05f;
  g2.drawString(text, loginStringX, loginStringY);
  return img;
}
 
Example 7
Source File: TrafficLight.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public BufferedImage createYellowOnImage(final int WIDTH, final int HEIGHT) {
    final GraphicsConfiguration GFX_CONF = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    if (WIDTH <= 0 || HEIGHT <= 0) {
        return GFX_CONF.createCompatibleImage(1, 1, java.awt.Transparency.TRANSLUCENT);
    }
    final BufferedImage IMAGE = GFX_CONF.createCompatibleImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT);
    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();
    final Ellipse2D LIGHT_ON = new Ellipse2D.Double(0.17346938775510204 * IMAGE_WIDTH, 0.38489208633093525 * IMAGE_HEIGHT, 0.6530612244897959 * IMAGE_WIDTH, 0.2302158273381295 * IMAGE_HEIGHT);
    G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.5 * IMAGE_HEIGHT), (0.32653061224489793f * IMAGE_WIDTH), new float[]{0.0f, 1.0f}, new Color[]{new Color(0.9960784314f, 0.8313725490f, 0.2039215686f, 1f), new Color(0.5098039216f, 0.2f, 0.0470588235f, 1f)}));
    G2.fill(LIGHT_ON);

    final GeneralPath GLOW = new GeneralPath();
    GLOW.setWindingRule(Path2D.WIND_EVEN_ODD);
    GLOW.moveTo(0.0 * IMAGE_WIDTH, 0.5035971223021583 * IMAGE_HEIGHT);
    GLOW.curveTo(0.0 * IMAGE_WIDTH, 0.6007194244604317 * IMAGE_HEIGHT, 0.22448979591836735 * IMAGE_WIDTH, 0.6798561151079137 * IMAGE_HEIGHT, 0.5 * IMAGE_WIDTH, 0.6798561151079137 * IMAGE_HEIGHT);
    GLOW.curveTo(0.7755102040816326 * IMAGE_WIDTH, 0.6798561151079137 * IMAGE_HEIGHT, 1.0 * IMAGE_WIDTH, 0.6007194244604317 * IMAGE_HEIGHT, 1.0 * IMAGE_WIDTH, 0.5 * IMAGE_HEIGHT);
    GLOW.curveTo(0.9081632653061225 * IMAGE_WIDTH, 0.44244604316546765 * IMAGE_HEIGHT, 0.7040816326530612 * IMAGE_WIDTH, 0.3776978417266187 * IMAGE_HEIGHT, 0.5 * IMAGE_WIDTH, 0.3776978417266187 * IMAGE_HEIGHT);
    GLOW.curveTo(0.2857142857142857 * IMAGE_WIDTH, 0.3776978417266187 * IMAGE_HEIGHT, 0.08163265306122448 * IMAGE_WIDTH, 0.44244604316546765 * IMAGE_HEIGHT, 0.0 * IMAGE_WIDTH, 0.5035971223021583 * IMAGE_HEIGHT);
    GLOW.closePath();
    G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.5 * IMAGE_HEIGHT), (0.5153061224489796f * IMAGE_WIDTH), new float[]{0.0f, 1.0f}, new Color[]{new Color(0.9960784314f, 0.8313725490f, 0.2039215686f, 1f), new Color(0.5098039216f, 0.2f, 0.0470588235f, 0f)}));
    G2.fill(GLOW);

    G2.dispose();
    return IMAGE;
}
 
Example 8
Source File: StopWatch.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private BufferedImage create_SMALL_POINTER_SHADOW_Image(final int WIDTH) {
    if (WIDTH <= 0) {
        return null;
    }

    final BufferedImage IMAGE = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);
    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();

    final GeneralPath STOPWATCHPOINTERSMALL = new GeneralPath();
    STOPWATCHPOINTERSMALL.setWindingRule(Path2D.WIND_EVEN_ODD);
    STOPWATCHPOINTERSMALL.moveTo(IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.3130841121495327);
    STOPWATCHPOINTERSMALL.curveTo(IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.32242990654205606, IMAGE_WIDTH * 0.48598130841121495, IMAGE_HEIGHT * 0.3317757009345794, IMAGE_WIDTH * 0.4953271028037383, IMAGE_HEIGHT * 0.3364485981308411);
    STOPWATCHPOINTERSMALL.curveTo(IMAGE_WIDTH * 0.4953271028037383, IMAGE_HEIGHT * 0.3364485981308411, IMAGE_WIDTH * 0.4953271028037383, IMAGE_HEIGHT * 0.35046728971962615, IMAGE_WIDTH * 0.4953271028037383, IMAGE_HEIGHT * 0.35046728971962615);
    STOPWATCHPOINTERSMALL.lineTo(IMAGE_WIDTH * 0.5046728971962616, IMAGE_HEIGHT * 0.35046728971962615);
    STOPWATCHPOINTERSMALL.curveTo(IMAGE_WIDTH * 0.5046728971962616, IMAGE_HEIGHT * 0.35046728971962615, IMAGE_WIDTH * 0.5046728971962616, IMAGE_HEIGHT * 0.3364485981308411, IMAGE_WIDTH * 0.5046728971962616, IMAGE_HEIGHT * 0.3364485981308411);
    STOPWATCHPOINTERSMALL.curveTo(IMAGE_WIDTH * 0.514018691588785, IMAGE_HEIGHT * 0.3317757009345794, IMAGE_WIDTH * 0.5233644859813084, IMAGE_HEIGHT * 0.32242990654205606, IMAGE_WIDTH * 0.5233644859813084, IMAGE_HEIGHT * 0.3130841121495327);
    STOPWATCHPOINTERSMALL.curveTo(IMAGE_WIDTH * 0.5233644859813084, IMAGE_HEIGHT * 0.3037383177570093, IMAGE_WIDTH * 0.514018691588785, IMAGE_HEIGHT * 0.29439252336448596, IMAGE_WIDTH * 0.5046728971962616, IMAGE_HEIGHT * 0.2897196261682243);
    STOPWATCHPOINTERSMALL.curveTo(IMAGE_WIDTH * 0.5046728971962616, IMAGE_HEIGHT * 0.2897196261682243, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.20093457943925233, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.20093457943925233);
    STOPWATCHPOINTERSMALL.curveTo(IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.20093457943925233, IMAGE_WIDTH * 0.4953271028037383, IMAGE_HEIGHT * 0.2897196261682243, IMAGE_WIDTH * 0.4953271028037383, IMAGE_HEIGHT * 0.2897196261682243);
    STOPWATCHPOINTERSMALL.curveTo(IMAGE_WIDTH * 0.48598130841121495, IMAGE_HEIGHT * 0.29439252336448596, IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.3037383177570093, IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.3130841121495327);
    STOPWATCHPOINTERSMALL.closePath();

    G2.setPaint(SHADOW_COLOR);
    G2.fill(STOPWATCHPOINTERSMALL);

    G2.dispose();

    return IMAGE;
}
 
Example 9
Source File: FunkyWipeTransition2D.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
private static GeneralPath createPathCyclic() {
    GeneralPath p = new GeneralPath();
    p.moveTo(99.936f, 51.019f);
    p.curveTo(99.936f, 51.019f, 78.316f, 86.931f, 51.019f, 89.745f);
    p.curveTo(23.721f, 92.559f, -2.012f, 75.843f, 11.082f, 61.21f);
    p.curveTo(4.178f, 46.576f, 34.931f, 39.565f, 62.229f, 36.751f);
    p.curveTo(89.526f, 33.937f, 99.936f, 51.019f, 99.936f, 51.019f);
    return p;
}
 
Example 10
Source File: Radial2Top.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
private BufferedImage create_GLOW_Image(final int WIDTH, final Color GLOW_COLOR, final boolean ON) {
    if (WIDTH <= 0) {
        return null;
    }

    final BufferedImage IMAGE = UTIL.createImage(WIDTH, (int) (0.641860465116279 * WIDTH), Transparency.TRANSLUCENT);

    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();

    final GeneralPath GLOWRING = new GeneralPath();
    GLOWRING.setWindingRule(Path2D.WIND_EVEN_ODD);
    GLOWRING.moveTo(IMAGE_WIDTH * 0.11214953271028037, IMAGE_HEIGHT * 0.7737226277372263);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.11214953271028037, IMAGE_HEIGHT * 0.4233576642335766, IMAGE_WIDTH * 0.29906542056074764, IMAGE_HEIGHT * 0.1678832116788321, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.1678832116788321);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.705607476635514, IMAGE_HEIGHT * 0.1678832116788321, IMAGE_WIDTH * 0.8878504672897196, IMAGE_HEIGHT * 0.41605839416058393, IMAGE_WIDTH * 0.8878504672897196, IMAGE_HEIGHT * 0.7737226277372263);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.8878504672897196, IMAGE_HEIGHT * 0.8175182481751825, IMAGE_WIDTH * 0.883177570093458, IMAGE_HEIGHT * 0.8613138686131386, IMAGE_WIDTH * 0.883177570093458, IMAGE_HEIGHT * 0.8613138686131386);
    GLOWRING.lineTo(IMAGE_WIDTH * 0.11682242990654206, IMAGE_HEIGHT * 0.8613138686131386);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.11682242990654206, IMAGE_HEIGHT * 0.8613138686131386, IMAGE_WIDTH * 0.11214953271028037, IMAGE_HEIGHT * 0.8175182481751825, IMAGE_WIDTH * 0.11214953271028037, IMAGE_HEIGHT * 0.7737226277372263);
    GLOWRING.closePath();
    GLOWRING.moveTo(IMAGE_WIDTH * 0.08411214953271028, IMAGE_HEIGHT * 0.7737226277372263);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.08411214953271028, IMAGE_HEIGHT * 0.8175182481751825, IMAGE_WIDTH * 0.08878504672897196, IMAGE_HEIGHT * 0.8686131386861314, IMAGE_WIDTH * 0.08878504672897196, IMAGE_HEIGHT * 0.8686131386861314);
    GLOWRING.lineTo(IMAGE_WIDTH * 0.9065420560747663, IMAGE_HEIGHT * 0.8686131386861314);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.9065420560747663, IMAGE_HEIGHT * 0.8686131386861314, IMAGE_WIDTH * 0.9112149532710281, IMAGE_HEIGHT * 0.8175182481751825, IMAGE_WIDTH * 0.9112149532710281, IMAGE_HEIGHT * 0.7737226277372263);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.9112149532710281, IMAGE_HEIGHT * 0.41605839416058393, IMAGE_WIDTH * 0.7242990654205608, IMAGE_HEIGHT * 0.13138686131386862, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.13138686131386862);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.27102803738317754, IMAGE_HEIGHT * 0.13138686131386862, IMAGE_WIDTH * 0.08411214953271028, IMAGE_HEIGHT * 0.41605839416058393, IMAGE_WIDTH * 0.08411214953271028, IMAGE_HEIGHT * 0.7737226277372263);
    GLOWRING.closePath();

    if (!ON) {
        final Point2D GLOWRING_OFF_START = new Point2D.Double(0, GLOWRING.getBounds2D().getMinY());
        final Point2D GLOWRING_OFF_STOP = new Point2D.Double(0, GLOWRING.getBounds2D().getMaxY());

        final float[] GLOWRING_OFF_FRACTIONS = {
            0.0f,
            0.19f,
            0.2f,
            0.39f,
            0.4f,
            0.64f,
            0.65f,
            0.82f,
            1.0f
        };
        final Color[] GLOWRING_OFF_COLORS = {
            new Color(204, 204, 204, 102),
            new Color(255, 255, 255, 102),
            new Color(250, 250, 250, 102),
            new Color(158, 158, 158, 102),
            new Color(153, 153, 153, 102),
            new Color(202, 202, 202, 102),
            new Color(204, 204, 204, 102),
            new Color(255, 255, 255, 102),
            new Color(153, 153, 153, 102)
        };
        final LinearGradientPaint GLOWRING_OFF_GRADIENT = new LinearGradientPaint(GLOWRING_OFF_START, GLOWRING_OFF_STOP, GLOWRING_OFF_FRACTIONS, GLOWRING_OFF_COLORS);
        G2.setPaint(GLOWRING_OFF_GRADIENT);
        G2.fill(GLOWRING);
    } else {
        G2.translate(-10, -10);
        G2.drawImage(Shadow.INSTANCE.createDropShadow(GLOWRING, UTIL.setAlpha(GLOW_COLOR, 0.8f), GLOW_COLOR, true, null, null, 0, 1.0f, 10, 315, GLOW_COLOR), GLOWRING.getBounds().x, GLOWRING.getBounds().y, null);
        G2.translate(10, 10);

        final Point2D GLOWRING_HL_START = new Point2D.Double(0, GLOWRING.getBounds2D().getMinY());
        final Point2D GLOWRING_HL_STOP = new Point2D.Double(0, GLOWRING.getBounds2D().getMaxY());
        final float[] GLOWRING_HL_FRACTIONS = {
            0.0f,
            0.26f,
            0.42f,
            0.42009997f,
            0.56f,
            0.5601f,
            0.96f,
            0.9601f,
            1.0f
        };
        final Color[] GLOWRING_HL_COLORS = {
            new Color(255, 255, 255, 0),
            new Color(255, 255, 255, 63),
            new Color(255, 255, 255, 102),
            new Color(255, 255, 255, 98),
            new Color(255, 255, 255, 3),
            new Color(255, 255, 255, 0),
            new Color(255, 255, 255, 0),
            new Color(255, 255, 255, 0),
            new Color(255, 255, 255, 102)
        };
        final LinearGradientPaint GLOWRING_HL_GRADIENT = new LinearGradientPaint(GLOWRING_HL_START, GLOWRING_HL_STOP, GLOWRING_HL_FRACTIONS, GLOWRING_HL_COLORS);
        G2.setPaint(GLOWRING_HL_GRADIENT);
        G2.fill(GLOWRING);
    }
    G2.dispose();

    // Memoize parameters


    return IMAGE;
}
 
Example 11
Source File: DigitalRadial.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
private BufferedImage create_100FT_POINTER_Image(final int WIDTH) {
    if (WIDTH <= 0) {
        return null;
    }

    final BufferedImage IMAGE = UTIL.createImage(WIDTH, (int) (1.0 * WIDTH), Transparency.TRANSLUCENT);
    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
    //G2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
    //G2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    //G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();

    final GeneralPath POINTER100FT = new GeneralPath();
    POINTER100FT.setWindingRule(Path2D.WIND_EVEN_ODD);
    POINTER100FT.moveTo(IMAGE_WIDTH * 0.5186915887850467, IMAGE_HEIGHT * 0.4719626168224299);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.514018691588785, IMAGE_HEIGHT * 0.4719626168224299, IMAGE_WIDTH * 0.5093457943925234, IMAGE_HEIGHT * 0.4672897196261682, IMAGE_WIDTH * 0.5093457943925234, IMAGE_HEIGHT * 0.4672897196261682);
    POINTER100FT.lineTo(IMAGE_WIDTH * 0.5093457943925234, IMAGE_HEIGHT * 0.20093457943925233);
    POINTER100FT.lineTo(IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.16822429906542055);
    POINTER100FT.lineTo(IMAGE_WIDTH * 0.49065420560747663, IMAGE_HEIGHT * 0.20093457943925233);
    POINTER100FT.lineTo(IMAGE_WIDTH * 0.49065420560747663, IMAGE_HEIGHT * 0.4672897196261682);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.49065420560747663, IMAGE_HEIGHT * 0.4672897196261682, IMAGE_WIDTH * 0.48130841121495327, IMAGE_HEIGHT * 0.4719626168224299, IMAGE_WIDTH * 0.48130841121495327, IMAGE_HEIGHT * 0.4719626168224299);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.4719626168224299, IMAGE_HEIGHT * 0.48130841121495327, IMAGE_WIDTH * 0.4672897196261682, IMAGE_HEIGHT * 0.49065420560747663, IMAGE_WIDTH * 0.4672897196261682, IMAGE_HEIGHT * 0.5);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.4672897196261682, IMAGE_HEIGHT * 0.514018691588785, IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.5280373831775701, IMAGE_WIDTH * 0.49065420560747663, IMAGE_HEIGHT * 0.5327102803738317);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.49065420560747663, IMAGE_HEIGHT * 0.5327102803738317, IMAGE_WIDTH * 0.49065420560747663, IMAGE_HEIGHT * 0.5794392523364486, IMAGE_WIDTH * 0.49065420560747663, IMAGE_HEIGHT * 0.5887850467289719);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.48598130841121495, IMAGE_HEIGHT * 0.5934579439252337, IMAGE_WIDTH * 0.48130841121495327, IMAGE_HEIGHT * 0.5981308411214953, IMAGE_WIDTH * 0.48130841121495327, IMAGE_HEIGHT * 0.6074766355140186);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.48130841121495327, IMAGE_HEIGHT * 0.616822429906542, IMAGE_WIDTH * 0.49065420560747663, IMAGE_HEIGHT * 0.6261682242990654, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.6261682242990654);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.5093457943925234, IMAGE_HEIGHT * 0.6261682242990654, IMAGE_WIDTH * 0.5186915887850467, IMAGE_HEIGHT * 0.616822429906542, IMAGE_WIDTH * 0.5186915887850467, IMAGE_HEIGHT * 0.6074766355140186);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.5186915887850467, IMAGE_HEIGHT * 0.5981308411214953, IMAGE_WIDTH * 0.514018691588785, IMAGE_HEIGHT * 0.5934579439252337, IMAGE_WIDTH * 0.5046728971962616, IMAGE_HEIGHT * 0.5887850467289719);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.5046728971962616, IMAGE_HEIGHT * 0.5794392523364486, IMAGE_WIDTH * 0.5046728971962616, IMAGE_HEIGHT * 0.5327102803738317, IMAGE_WIDTH * 0.5093457943925234, IMAGE_HEIGHT * 0.5327102803738317);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.5233644859813084, IMAGE_HEIGHT * 0.5280373831775701, IMAGE_WIDTH * 0.5327102803738317, IMAGE_HEIGHT * 0.514018691588785, IMAGE_WIDTH * 0.5327102803738317, IMAGE_HEIGHT * 0.5);
    POINTER100FT.curveTo(IMAGE_WIDTH * 0.5327102803738317, IMAGE_HEIGHT * 0.49065420560747663, IMAGE_WIDTH * 0.5280373831775701, IMAGE_HEIGHT * 0.48130841121495327, IMAGE_WIDTH * 0.5186915887850467, IMAGE_HEIGHT * 0.4719626168224299);
    POINTER100FT.closePath();
    final Point2D POINTER100FT_START = new Point2D.Double(0, POINTER100FT.getBounds2D().getMinY());
    final Point2D POINTER100FT_STOP = new Point2D.Double(0, POINTER100FT.getBounds2D().getMaxY());
    final float[] POINTER100FT_FRACTIONS = {
        0.0f,
        0.31f,
        0.3101f,
        0.32f,
        1.0f
    };
    final Color[] POINTER100FT_COLORS = {
        new Color(255, 255, 255, 255),
        new Color(255, 255, 255, 255),
        new Color(255, 255, 255, 255),
        new Color(32, 32, 32, 255),
        new Color(32, 32, 32, 255)
    };
    final LinearGradientPaint POINTER100FT_GRADIENT = new LinearGradientPaint(POINTER100FT_START, POINTER100FT_STOP, POINTER100FT_FRACTIONS, POINTER100FT_COLORS);
    G2.setPaint(POINTER100FT_GRADIENT);
    G2.fill(POINTER100FT);

    G2.dispose();

    return IMAGE;
}
 
Example 12
Source File: RapidBorder.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {

	width--;
	height--;

	Graphics2D g2 = (Graphics2D) g.create();
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	GeneralPath border = new GeneralPath();
	// top left
	border.moveTo(x + cornerSize, y);
	border.lineTo(x + width - cornerSize, y);
	// top right
	border.curveTo(x + width - cornerSize, y, x + width, y, x + width, y + cornerSize);
	border.lineTo(x + width, y + height - cornerSize);
	// bottom right
	border.curveTo(x + width, y + height, x + width, y + height, x + width - cornerSize, y + height);
	border.lineTo(x + cornerSize, y + height);
	// bottom left
	border.curveTo(x, y + height, x, y + height, x, y + height - cornerSize);
	border.lineTo(x, y + cornerSize);
	// top left again
	border.curveTo(x, y, x, y, x + cornerSize, y);

	if (headerHeight > 0) {
		if (height <= headerHeight + cornerSize) {
			g2.setColor(color);
			g2.fill(border);
		} else {
			g2.setColor(c.getBackground());
			g2.fill(border);

			GeneralPath header = new GeneralPath();
			// top left
			header.moveTo(x + cornerSize, y);
			header.lineTo(x + width - cornerSize, y);
			// top right
			header.curveTo(x + width - cornerSize, y, x + width, y, x + width, y + cornerSize);
			header.lineTo(x + width, y + headerHeight);
			header.lineTo(x, y + headerHeight);
			header.lineTo(x, y + cornerSize);
			// top left again
			header.curveTo(x, y, x, y, x + cornerSize, y);
			g2.setColor(color);
			g2.fill(header);
		}
	}

	g2.setColor(color);
	g2.draw(border);

	g2.dispose();
}
 
Example 13
Source File: Level.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
private BufferedImage create_STEPPOINTER_Image(final int WIDTH) {
    if (WIDTH <= 0) {
        return null;
    }

    final BufferedImage IMAGE = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);
    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
    G2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();

    final GeneralPath POINTER_SMALL_LEFT = new GeneralPath();
    POINTER_SMALL_LEFT.setWindingRule(Path2D.WIND_EVEN_ODD);
    POINTER_SMALL_LEFT.moveTo(IMAGE_WIDTH * 0.2850467289719626, IMAGE_HEIGHT * 0.514018691588785);
    POINTER_SMALL_LEFT.lineTo(IMAGE_WIDTH * 0.2102803738317757, IMAGE_HEIGHT * 0.5);
    POINTER_SMALL_LEFT.lineTo(IMAGE_WIDTH * 0.2850467289719626, IMAGE_HEIGHT * 0.48130841121495327);
    POINTER_SMALL_LEFT.curveTo(IMAGE_WIDTH * 0.2850467289719626, IMAGE_HEIGHT * 0.48130841121495327, IMAGE_WIDTH * 0.2803738317757009, IMAGE_HEIGHT * 0.49065420560747663, IMAGE_WIDTH * 0.2803738317757009, IMAGE_HEIGHT * 0.4953271028037383);
    POINTER_SMALL_LEFT.curveTo(IMAGE_WIDTH * 0.2803738317757009, IMAGE_HEIGHT * 0.5046728971962616, IMAGE_WIDTH * 0.2850467289719626, IMAGE_HEIGHT * 0.514018691588785, IMAGE_WIDTH * 0.2850467289719626, IMAGE_HEIGHT * 0.514018691588785);
    POINTER_SMALL_LEFT.closePath();
    final Point2D POINTER_SMALL_LEFT_START = new Point2D.Double(POINTER_SMALL_LEFT.getBounds2D().getMinX(), 0);
    final Point2D POINTER_SMALL_LEFT_STOP = new Point2D.Double(POINTER_SMALL_LEFT.getBounds2D().getMaxX(), 0);
    final float[] POINTER_SMALL_FRACTIONS = {
        0.0f,
        0.3f,
        0.59f,
        1.0f
    };
    final Color[] POINTER_SMALL_COLORS = {
        UTIL.setAlpha(getPointerColor().DARK, 180),
        UTIL.setAlpha(getPointerColor().LIGHT, 180),
        UTIL.setAlpha(getPointerColor().LIGHT, 180),
        UTIL.setAlpha(getPointerColor().DARK, 180)
    };
    final LinearGradientPaint POINTER_SMALL_LEFT_GRADIENT = new LinearGradientPaint(POINTER_SMALL_LEFT_START, POINTER_SMALL_LEFT_STOP, POINTER_SMALL_FRACTIONS, POINTER_SMALL_COLORS);
    G2.setPaint(POINTER_SMALL_LEFT_GRADIENT);
    G2.fill(POINTER_SMALL_LEFT);
    final Color STROKE_COLOR_POINTER_SMALL = UTIL.setAlpha(getPointerColor().LIGHT, 128);
    G2.setColor(STROKE_COLOR_POINTER_SMALL);
    G2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
    G2.draw(POINTER_SMALL_LEFT);

    final GeneralPath POINTER_SMALL_RIGHT = new GeneralPath();
    POINTER_SMALL_RIGHT.setWindingRule(Path2D.WIND_EVEN_ODD);
    POINTER_SMALL_RIGHT.moveTo(IMAGE_WIDTH * 0.7149532710280374, IMAGE_HEIGHT * 0.514018691588785);
    POINTER_SMALL_RIGHT.lineTo(IMAGE_WIDTH * 0.7897196261682243, IMAGE_HEIGHT * 0.5);
    POINTER_SMALL_RIGHT.lineTo(IMAGE_WIDTH * 0.7149532710280374, IMAGE_HEIGHT * 0.48130841121495327);
    POINTER_SMALL_RIGHT.curveTo(IMAGE_WIDTH * 0.7149532710280374, IMAGE_HEIGHT * 0.48130841121495327, IMAGE_WIDTH * 0.719626168224299, IMAGE_HEIGHT * 0.49065420560747663, IMAGE_WIDTH * 0.719626168224299, IMAGE_HEIGHT * 0.4953271028037383);
    POINTER_SMALL_RIGHT.curveTo(IMAGE_WIDTH * 0.719626168224299, IMAGE_HEIGHT * 0.5046728971962616, IMAGE_WIDTH * 0.7149532710280374, IMAGE_HEIGHT * 0.514018691588785, IMAGE_WIDTH * 0.7149532710280374, IMAGE_HEIGHT * 0.514018691588785);
    POINTER_SMALL_RIGHT.closePath();
    final Point2D POINTER_SMALL_RIGHT_START = new Point2D.Double(POINTER_SMALL_RIGHT.getBounds2D().getMaxX(), 0);
    final Point2D POINTER_SMALL_RIGHT_STOP = new Point2D.Double(POINTER_SMALL_RIGHT.getBounds2D().getMinX(), 0);

    final LinearGradientPaint POINTER_SMALL_RIGHT_GRADIENT = new LinearGradientPaint(POINTER_SMALL_RIGHT_START, POINTER_SMALL_RIGHT_STOP, POINTER_SMALL_FRACTIONS, POINTER_SMALL_COLORS);
    G2.setPaint(POINTER_SMALL_RIGHT_GRADIENT);
    G2.fill(POINTER_SMALL_RIGHT);
    G2.setColor(STROKE_COLOR_POINTER_SMALL);
    G2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
    G2.draw(POINTER_SMALL_RIGHT);

    G2.dispose();

    return IMAGE;
}
 
Example 14
Source File: Clock.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
private BufferedImage create_KNOB_Image(final int WIDTH) {
    if (WIDTH <= 0) {
        return null;
    }

    final BufferedImage IMAGE = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);
    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
    G2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();

    final GeneralPath KNOBSHADOW = new GeneralPath();
    KNOBSHADOW.setWindingRule(Path2D.WIND_EVEN_ODD);
    KNOBSHADOW.moveTo(IMAGE_WIDTH * 0.4532710280373832, IMAGE_HEIGHT * 0.5046728971962616);
    KNOBSHADOW.curveTo(IMAGE_WIDTH * 0.4532710280373832, IMAGE_HEIGHT * 0.48130841121495327, IMAGE_WIDTH * 0.4719626168224299, IMAGE_HEIGHT * 0.45794392523364486, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.45794392523364486);
    KNOBSHADOW.curveTo(IMAGE_WIDTH * 0.5280373831775701, IMAGE_HEIGHT * 0.45794392523364486, IMAGE_WIDTH * 0.5467289719626168, IMAGE_HEIGHT * 0.48130841121495327, IMAGE_WIDTH * 0.5467289719626168, IMAGE_HEIGHT * 0.5046728971962616);
    KNOBSHADOW.curveTo(IMAGE_WIDTH * 0.5467289719626168, IMAGE_HEIGHT * 0.5327102803738317, IMAGE_WIDTH * 0.5280373831775701, IMAGE_HEIGHT * 0.5560747663551402, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.5560747663551402);
    KNOBSHADOW.curveTo(IMAGE_WIDTH * 0.4719626168224299, IMAGE_HEIGHT * 0.5560747663551402, IMAGE_WIDTH * 0.4532710280373832, IMAGE_HEIGHT * 0.5327102803738317, IMAGE_WIDTH * 0.4532710280373832, IMAGE_HEIGHT * 0.5046728971962616);
    KNOBSHADOW.closePath();
    final Point2D KNOBSHADOW_START = new Point2D.Double(0, KNOBSHADOW.getBounds2D().getMinY());
    final Point2D KNOBSHADOW_STOP = new Point2D.Double(0, KNOBSHADOW.getBounds2D().getMaxY());
    final float[] KNOBSHADOW_FRACTIONS = {
        0.0f,
        1.0f
    };
    final Color[] KNOBSHADOW_COLORS = {
        new Color(40, 40, 41, 255),
        new Color(13, 13, 13, 255)
    };
    final LinearGradientPaint KNOBSHADOW_GRADIENT = new LinearGradientPaint(KNOBSHADOW_START, KNOBSHADOW_STOP, KNOBSHADOW_FRACTIONS, KNOBSHADOW_COLORS);
    G2.setPaint(KNOBSHADOW_GRADIENT);
    G2.fill(KNOBSHADOW);

    final GeneralPath KNOB = new GeneralPath();
    KNOB.setWindingRule(Path2D.WIND_EVEN_ODD);
    KNOB.moveTo(IMAGE_WIDTH * 0.45794392523364486, IMAGE_HEIGHT * 0.5);
    KNOB.curveTo(IMAGE_WIDTH * 0.45794392523364486, IMAGE_HEIGHT * 0.4766355140186916, IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.45794392523364486, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.45794392523364486);
    KNOB.curveTo(IMAGE_WIDTH * 0.5233644859813084, IMAGE_HEIGHT * 0.45794392523364486, IMAGE_WIDTH * 0.5420560747663551, IMAGE_HEIGHT * 0.4766355140186916, IMAGE_WIDTH * 0.5420560747663551, IMAGE_HEIGHT * 0.5);
    KNOB.curveTo(IMAGE_WIDTH * 0.5420560747663551, IMAGE_HEIGHT * 0.5233644859813084, IMAGE_WIDTH * 0.5233644859813084, IMAGE_HEIGHT * 0.5420560747663551, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.5420560747663551);
    KNOB.curveTo(IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.5420560747663551, IMAGE_WIDTH * 0.45794392523364486, IMAGE_HEIGHT * 0.5233644859813084, IMAGE_WIDTH * 0.45794392523364486, IMAGE_HEIGHT * 0.5);
    KNOB.closePath();
    final Point2D KNOB_START = new Point2D.Double(0, KNOB.getBounds2D().getMinY());
    final Point2D KNOB_STOP = new Point2D.Double(0, KNOB.getBounds2D().getMaxY());
    final float[] KNOB_FRACTIONS = {
        0.0f,
        1.0f
    };
    final Color[] KNOB_COLORS = {
        new Color(238, 240, 242, 255),
        new Color(101, 105, 109, 255)
    };
    final LinearGradientPaint KNOB_GRADIENT = new LinearGradientPaint(KNOB_START, KNOB_STOP, KNOB_FRACTIONS, KNOB_COLORS);
    G2.setPaint(KNOB_GRADIENT);
    G2.fill(KNOB);

    G2.dispose();

    return IMAGE;
}
 
Example 15
Source File: Clock.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
private BufferedImage create_TOP_KNOB_Image(final int WIDTH) {
    if (WIDTH <= 0) {
        return null;
    }

    final BufferedImage IMAGE = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);
    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();

    switch (getPointerType()) {
        case TYPE2:
            final double CENTER_KNOB_DIAMETER = WIDTH * 0.0887850467;
            final Ellipse2D CENTER_KNOB = new Ellipse2D.Double(CENTER.getX() - CENTER_KNOB_DIAMETER / 2, CENTER.getY() - CENTER_KNOB_DIAMETER / 2, CENTER_KNOB_DIAMETER, CENTER_KNOB_DIAMETER);
            G2.setPaint(getPointerColor().MEDIUM);
            G2.fill(CENTER_KNOB);
            break;

        case TYPE1:

        default:
            final GeneralPath TOPKNOBSHADOW = new GeneralPath();
            TOPKNOBSHADOW.setWindingRule(Path2D.WIND_EVEN_ODD);
            TOPKNOBSHADOW.moveTo(IMAGE_WIDTH * 0.4719626168224299, IMAGE_HEIGHT * 0.5);
            TOPKNOBSHADOW.curveTo(IMAGE_WIDTH * 0.4719626168224299, IMAGE_HEIGHT * 0.48598130841121495, IMAGE_WIDTH * 0.48598130841121495, IMAGE_HEIGHT * 0.4719626168224299, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.4719626168224299);
            TOPKNOBSHADOW.curveTo(IMAGE_WIDTH * 0.514018691588785, IMAGE_HEIGHT * 0.4719626168224299, IMAGE_WIDTH * 0.5280373831775701, IMAGE_HEIGHT * 0.48598130841121495, IMAGE_WIDTH * 0.5280373831775701, IMAGE_HEIGHT * 0.5);
            TOPKNOBSHADOW.curveTo(IMAGE_WIDTH * 0.5280373831775701, IMAGE_HEIGHT * 0.514018691588785, IMAGE_WIDTH * 0.514018691588785, IMAGE_HEIGHT * 0.5280373831775701, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.5280373831775701);
            TOPKNOBSHADOW.curveTo(IMAGE_WIDTH * 0.48598130841121495, IMAGE_HEIGHT * 0.5280373831775701, IMAGE_WIDTH * 0.4719626168224299, IMAGE_HEIGHT * 0.514018691588785, IMAGE_WIDTH * 0.4719626168224299, IMAGE_HEIGHT * 0.5);
            TOPKNOBSHADOW.closePath();
            final Point2D TOPKNOBSHADOW_START = new Point2D.Double(0, TOPKNOBSHADOW.getBounds2D().getMinY());
            final Point2D TOPKNOBSHADOW_STOP = new Point2D.Double(0, TOPKNOBSHADOW.getBounds2D().getMaxY());
            final float[] TOPKNOBSHADOW_FRACTIONS = {
                0.0f,
                1.0f
            };
            final Color[] TOPKNOBSHADOW_COLORS = {
                new Color(221, 223, 223, 255),
                new Color(38, 40, 41, 255)
            };
            final LinearGradientPaint TOPKNOBSHADOW_GRADIENT = new LinearGradientPaint(TOPKNOBSHADOW_START, TOPKNOBSHADOW_STOP, TOPKNOBSHADOW_FRACTIONS, TOPKNOBSHADOW_COLORS);
            G2.setPaint(TOPKNOBSHADOW_GRADIENT);
            G2.fill(TOPKNOBSHADOW);

            final GeneralPath TOPKNOB = new GeneralPath();
            TOPKNOB.setWindingRule(Path2D.WIND_EVEN_ODD);
            TOPKNOB.moveTo(IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.5);
            TOPKNOB.curveTo(IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.48598130841121495, IMAGE_WIDTH * 0.48598130841121495, IMAGE_HEIGHT * 0.4766355140186916, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.4766355140186916);
            TOPKNOB.curveTo(IMAGE_WIDTH * 0.514018691588785, IMAGE_HEIGHT * 0.4766355140186916, IMAGE_WIDTH * 0.5233644859813084, IMAGE_HEIGHT * 0.48598130841121495, IMAGE_WIDTH * 0.5233644859813084, IMAGE_HEIGHT * 0.5);
            TOPKNOB.curveTo(IMAGE_WIDTH * 0.5233644859813084, IMAGE_HEIGHT * 0.514018691588785, IMAGE_WIDTH * 0.514018691588785, IMAGE_HEIGHT * 0.5233644859813084, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.5233644859813084);
            TOPKNOB.curveTo(IMAGE_WIDTH * 0.48598130841121495, IMAGE_HEIGHT * 0.5233644859813084, IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.514018691588785, IMAGE_WIDTH * 0.4766355140186916, IMAGE_HEIGHT * 0.5);
            TOPKNOB.closePath();
            final Point2D TOPKNOB_START = new Point2D.Double(0, TOPKNOB.getBounds2D().getMinY());
            final Point2D TOPKNOB_STOP = new Point2D.Double(0, TOPKNOB.getBounds2D().getMaxY());
            final float[] TOPKNOB_FRACTIONS = {
                0.0f,
                0.11f,
                0.12f,
                0.2f,
                0.2001f,
                1.0f
            };
            final Color[] TOPKNOB_COLORS = {
                new Color(234, 235, 238, 255),
                new Color(234, 236, 238, 255),
                new Color(232, 234, 236, 255),
                new Color(192, 197, 203, 255),
                new Color(190, 195, 201, 255),
                new Color(169, 174, 181, 255)
            };
            final LinearGradientPaint TOPKNOB_GRADIENT = new LinearGradientPaint(TOPKNOB_START, TOPKNOB_STOP, TOPKNOB_FRACTIONS, TOPKNOB_COLORS);
            G2.setPaint(TOPKNOB_GRADIENT);
            G2.fill(TOPKNOB);
            break;
    }

    G2.dispose();

    return IMAGE;
}
 
Example 16
Source File: GeneralPathObjectDescription.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Creates an object based on this description.
 *
 * @return The object.
 */
public Object createObject() {
  final int wRule = parseWindingRule();
  if ( wRule == -1 ) {
    return null;
  }

  final PathIteratorSegment[] segments =
      (PathIteratorSegment[]) getParameter( GeneralPathObjectDescription.SEGMENTS_NAME );
  if ( segments == null ) {
    return null;
  }

  final GeneralPath path = new GeneralPath();
  path.setWindingRule( wRule );
  for ( int i = 0; i < segments.length; i++ ) {
    final int segmentType = segments[i].getSegmentType();
    switch ( segmentType ) {
      case PathIterator.SEG_CLOSE: {
        path.closePath();
        break;
      }
      case PathIterator.SEG_CUBICTO: {
        path.curveTo( segments[i].getX1(), segments[i].getY1(), segments[i].getX2(), segments[i].getY2(), segments[i]
            .getX3(), segments[i].getY3() );
        break;
      }
      case PathIterator.SEG_LINETO: {
        path.lineTo( segments[i].getX1(), segments[i].getY1() );
        break;
      }
      case PathIterator.SEG_MOVETO: {
        path.moveTo( segments[i].getX1(), segments[i].getY1() );
        break;
      }
      case PathIterator.SEG_QUADTO: {
        path.quadTo( segments[i].getX1(), segments[i].getY1(), segments[i].getX2(), segments[i].getY2() );
        break;
      }
      default:
        throw new IllegalStateException( "Unexpected result from path iterator." );
    }
  }
  return path;
}
 
Example 17
Source File: WritingStroke.java    From pumpernickel with MIT License 4 votes vote down vote up
/**
 * Create a new WritingStroke based on output from a previous call to
 * toString()
 * 
 * @param s
 *            previous output from <code>WritingStroke.toString()</code>
 */
public WritingStroke(String s) {
	StringTokenizer tokenizer = new StringTokenizer(s);
	String token = (!tokenizer.hasMoreElements()) ? null : tokenizer
			.nextToken();
	GeneralPath path = new GeneralPath();
	boolean empty = true;
	while (token != null) {
		if (token.equals("w")) {
			pauseBeats = Float.parseFloat(tokenizer.nextToken());
		} else if (token.equals("m")) {
			empty = false;
			path.moveTo(Float.parseFloat(tokenizer.nextToken()),
					Float.parseFloat(tokenizer.nextToken()));
		} else if (token.equals("l")) {
			path.lineTo(Float.parseFloat(tokenizer.nextToken()),
					Float.parseFloat(tokenizer.nextToken()));
		} else if (token.equals("q")) {
			path.quadTo(Float.parseFloat(tokenizer.nextToken()),
					Float.parseFloat(tokenizer.nextToken()),
					Float.parseFloat(tokenizer.nextToken()),
					Float.parseFloat(tokenizer.nextToken()));
		} else if (token.equals("c")) {
			path.curveTo(Float.parseFloat(tokenizer.nextToken()),
					Float.parseFloat(tokenizer.nextToken()),
					Float.parseFloat(tokenizer.nextToken()),
					Float.parseFloat(tokenizer.nextToken()),
					Float.parseFloat(tokenizer.nextToken()),
					Float.parseFloat(tokenizer.nextToken()));
		} else if (token.equals("z")) {
			path.closePath();
		}
		token = (!tokenizer.hasMoreElements()) ? null : tokenizer
				.nextToken();
	}
	if (!empty) {
		shape = path;
		this.measuredShape = new MeasuredShape(shape);
	} else {
		shape = null;
	}
}
 
Example 18
Source File: RadialQuarterN.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
private BufferedImage create_GLOW_Image(final int WIDTH, final Color GLOW_COLOR, final boolean ON) {
    if (WIDTH <= 0) {
        return null;
    }

    final BufferedImage IMAGE = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);

    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();

    final GeneralPath GLOWRING = new GeneralPath();
    GLOWRING.setWindingRule(Path2D.WIND_EVEN_ODD);
    GLOWRING.moveTo(IMAGE_WIDTH * 0.8925233644859814, IMAGE_HEIGHT * 0.8925233644859814);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.8925233644859814, IMAGE_HEIGHT * 0.8925233644859814, IMAGE_WIDTH * 0.10747663551401869, IMAGE_HEIGHT * 0.8925233644859814, IMAGE_WIDTH * 0.10747663551401869, IMAGE_HEIGHT * 0.8925233644859814);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.10747663551401869, IMAGE_HEIGHT * 0.6588785046728972, IMAGE_WIDTH * 0.19626168224299065, IMAGE_HEIGHT * 0.4532710280373832, IMAGE_WIDTH * 0.308411214953271, IMAGE_HEIGHT * 0.3411214953271028);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.4672897196261682, IMAGE_HEIGHT * 0.17757009345794392, IMAGE_WIDTH * 0.6308411214953271, IMAGE_HEIGHT * 0.10747663551401869, IMAGE_WIDTH * 0.8925233644859814, IMAGE_HEIGHT * 0.10747663551401869);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.8925233644859814, IMAGE_HEIGHT * 0.10747663551401869, IMAGE_WIDTH * 0.8925233644859814, IMAGE_HEIGHT * 0.8925233644859814, IMAGE_WIDTH * 0.8925233644859814, IMAGE_HEIGHT * 0.8925233644859814);
    GLOWRING.closePath();
    GLOWRING.moveTo(IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.9158878504672897);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.9158878504672897, IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.08411214953271028, IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.08411214953271028);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.6401869158878505, IMAGE_HEIGHT * 0.08411214953271028, IMAGE_WIDTH * 0.46261682242990654, IMAGE_HEIGHT * 0.1588785046728972, IMAGE_WIDTH * 0.29439252336448596, IMAGE_HEIGHT * 0.32242990654205606);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.17289719626168223, IMAGE_HEIGHT * 0.4439252336448598, IMAGE_WIDTH * 0.08411214953271028, IMAGE_HEIGHT * 0.6635514018691588, IMAGE_WIDTH * 0.08411214953271028, IMAGE_HEIGHT * 0.9158878504672897);
    GLOWRING.curveTo(IMAGE_WIDTH * 0.08411214953271028, IMAGE_HEIGHT * 0.9158878504672897, IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.9158878504672897, IMAGE_WIDTH * 0.9158878504672897, IMAGE_HEIGHT * 0.9158878504672897);
    GLOWRING.closePath();

    if (!ON) {
        final Point2D GLOWRING_OFF_START = new Point2D.Double( (0.3037383177570093 * IMAGE_WIDTH), (0.3037383177570093 * IMAGE_HEIGHT) );
        final Point2D GLOWRING_OFF_STOP = new Point2D.Double( ((0.3037383177570093 + 0.5980669504428276) * IMAGE_WIDTH), ((0.3037383177570093 + 0.5980669504428275) * IMAGE_HEIGHT) );

        final float[] GLOWRING_OFF_FRACTIONS = {
            0.0f,
            0.19f,
            0.2f,
            0.39f,
            0.4f,
            0.64f,
            0.65f,
            0.82f,
            1.0f
        };
        final Color[] GLOWRING_OFF_COLORS = {
            new Color(204, 204, 204, 102),
            new Color(255, 255, 255, 102),
            new Color(250, 250, 250, 102),
            new Color(158, 158, 158, 102),
            new Color(153, 153, 153, 102),
            new Color(202, 202, 202, 102),
            new Color(204, 204, 204, 102),
            new Color(255, 255, 255, 102),
            new Color(153, 153, 153, 102)
        };
        final LinearGradientPaint GLOWRING_OFF_GRADIENT = new LinearGradientPaint(GLOWRING_OFF_START, GLOWRING_OFF_STOP, GLOWRING_OFF_FRACTIONS, GLOWRING_OFF_COLORS);
        G2.setPaint(GLOWRING_OFF_GRADIENT);
        G2.fill(GLOWRING);
    } else {
        G2.translate(-10, -10);
        G2.drawImage(Shadow.INSTANCE.createDropShadow(GLOWRING, GLOW_COLOR, GLOW_COLOR, true, null, null, 0, 1.0f, 10, 315, GLOW_COLOR), GLOWRING.getBounds().x, GLOWRING.getBounds().y, null);
        G2.translate(10, 10);

        final Point2D GLOWRING_HL_START = new Point2D.Double( (0.3037383177570093 * IMAGE_WIDTH), (0.3037383177570093 * IMAGE_HEIGHT) );
        final Point2D GLOWRING_HL_STOP = new Point2D.Double( ((0.3037383177570093 + 0.5980669504428276) * IMAGE_WIDTH), ((0.3037383177570093 + 0.5980669504428275) * IMAGE_HEIGHT) );
        final float[] GLOWRING_HL_FRACTIONS = {
            0.0f,
            0.26f,
            0.42f,
            0.42009997f,
            0.56f,
            0.5601f,
            0.96f,
            0.9601f,
            1.0f
        };
        final Color[] GLOWRING_HL_COLORS = {
            new Color(255, 255, 255, 0),
            new Color(255, 255, 255, 63),
            new Color(255, 255, 255, 102),
            new Color(255, 255, 255, 98),
            new Color(255, 255, 255, 3),
            new Color(255, 255, 255, 0),
            new Color(255, 255, 255, 0),
            new Color(255, 255, 255, 0),
            new Color(255, 255, 255, 102)
        };
        final LinearGradientPaint GLOWRING_HL_GRADIENT = new LinearGradientPaint(GLOWRING_HL_START, GLOWRING_HL_STOP, GLOWRING_HL_FRACTIONS, GLOWRING_HL_COLORS);
        G2.setPaint(GLOWRING_HL_GRADIENT);
        G2.fill(GLOWRING);
    }
    G2.dispose();

    return IMAGE;
}
 
Example 19
Source File: MultiThumbSliderUI.java    From PyramidShader with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Shape getShape(float width,float height,boolean leftEdge,boolean rightEdge,boolean sharpEdgesHint) {
	float k = width/2;
	GeneralPath p = new GeneralPath();
	float r = 5;
	
	if( (leftEdge) && (!rightEdge) ) {
		k = k*2;
		p.moveTo(0, height/2);
		p.lineTo(-k, height/2-k);
		p.lineTo(-k, -height/2+r);
		p.curveTo(-k, -height/2, -k, -height/2, -k+r, -height/2);
		p.lineTo(0, -height/2);
		p.closePath();
	} else if( (rightEdge) && (!leftEdge) ) {
		k = k*2;
		p.moveTo(0, -height/2);
		p.lineTo(k-r, -height/2);
		p.curveTo(k, -height/2, k, -height/2, k, -height/2+r);
		p.lineTo(k, height/2-k);
		p.lineTo(0, height/2);
		p.closePath();
	} else {
		if(sharpEdgesHint) {
			p.moveTo(0, height/2);
			p.lineTo(-k, height/2-k);
			p.lineTo(-k, -height/2+1);
			p.lineTo(-k+1, -height/2);
			p.lineTo(k-1, -height/2);
			p.lineTo(k, -height/2+1);
			p.lineTo(k, height/2-k);
			p.closePath();
		} else {
			p.moveTo(0, height/2);
			p.lineTo(-k, height/2-k);
			p.lineTo(-k, -height/2+r);
			p.curveTo(-k, -height/2, -k, -height/2, -k+r, -height/2);
			p.lineTo(k-r, -height/2);
			p.curveTo(k, -height/2, k, -height/2, k, -height/2+r);
			p.lineTo(k, height/2-k);
			p.closePath();
		}
	}
	return p;
}
 
Example 20
Source File: CurvesPanel.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License votes vote down vote up
protected void drawCurve(Graphics2D g2,
            float y1, float y1_offset,
            float y2, float y2_offset,
            float cx1, float cx1_offset,
            float cy1, float cy1_offset,
            float cx2, float cx2_offset,
            float cy2, float cy2_offset,
            float thickness,
            float speed,
            boolean invert) {
        float width = getWidth();
       
        float offset = (float) Math.sin(counter / (speed * Math.PI));
        
        float start_x = 0.0f;
        float start_y = offset * y1_offset + y1;
        float end_x = width;
        float end_y = offset * y2_offset + y2;
        
        float ctrl1_x = offset * cx1_offset + cx1;
        float ctrl1_y = offset * cy1_offset + cy1;
        float ctrl2_x = offset * cx2_offset + cx2;
        float ctrl2_y = offset * cy2_offset + cy2;
       
        GeneralPath thickCurve = new GeneralPath();
        thickCurve.moveTo(start_x, start_y);
        thickCurve.curveTo(ctrl1_x, ctrl1_y,
                ctrl2_x, ctrl2_y,
                end_x, end_y);
        thickCurve.lineTo(end_x, end_y + thickness);
        thickCurve.curveTo(ctrl2_x, ctrl2_y + thickness,
                ctrl1_x, ctrl1_y + thickness,
                start_x, start_y + thickness);
        thickCurve.lineTo(start_x, start_y);
       
        Rectangle bounds = thickCurve.getBounds();
        if (!bounds.intersects(g2.getClipBounds())) {
            return;
        }
      
        GradientPaint painter = new GradientPaint(0, bounds.y,
                invert ? end : start,
                0, bounds.y + bounds.height,
                invert ? start : end);

        Paint oldPainter = g2.getPaint();
        g2.setPaint(painter);
        g2.fill(thickCurve);
       
        g2.setPaint(oldPainter);
    }