当前位置: 首页>>代码示例>>Java>>正文


Java CycleMethod.NO_CYCLE属性代码示例

本文整理汇总了Java中java.awt.MultipleGradientPaint.CycleMethod.NO_CYCLE属性的典型用法代码示例。如果您正苦于以下问题:Java CycleMethod.NO_CYCLE属性的具体用法?Java CycleMethod.NO_CYCLE怎么用?Java CycleMethod.NO_CYCLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.MultipleGradientPaint.CycleMethod的用法示例。


在下文中一共展示了CycleMethod.NO_CYCLE属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPaint

/**
 * Creates paint for a vertex with given bounds and (inner) colour.
 */
static public Paint createPaint(Rectangle b, Color c) {
    // only bother with special paint if the vertex is not too small to notice
    if (!GRADIENT_PAINT || b.width < 10 && b.height < 10) {
        return c;
    } else {
        int cx = b.x + b.width / 2;
        int cy = b.y + b.height / 2;
        int fx = b.x + b.width / 3;
        int fy = b.y + 2 * b.height / 3;
        int rx = b.width - fx;
        int ry = b.height - fy;
        float r = (float) Math.sqrt(rx * rx + ry * ry);
        Paint newPaint = new RadialGradientPaint(cx, cy, r, fx, fy, new float[] {0f, 1f},
            getGradient(c), CycleMethod.NO_CYCLE);
        return newPaint;
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:20,代码来源:JAttr.java

示例2: renderAt

/**
 * The snowflakes are drawn as squares with a circular gradient in the middle.
 * That's why they look circular and fuzzy. This is also pretty cheap since it doesn't require blurring and drawing
 * squares is fast.
 *
 * @param x top right corner of snowflake x coordinate
 * @param y top right corner of snowflake y coordinate
 * @param diameter diameter of snowflake
 * @param alpha calculated transparency
 */
@Override
protected void renderAt(double x, double y, double diameter, double alpha) {
    Color snowflakeColor = new Color(1.0f, 1.0f, 1.0f, (float) alpha);
    if (diameter > 7) {
        // Center of snowflake is white with opacity according to the value provided in alpha
        float radius = (float) (diameter / 2.0);
        Point2D.Float center = new Point2D.Float((float) (x + radius), (float) (y + radius));
        Paint paint = new RadialGradientPaint(center, radius, center, GRADIENT_POSITIONS,
                new Color[]{snowflakeColor, snowflakeColor, TRANSPARENT_WHITE},
                CycleMethod.NO_CYCLE);
        g2d.setPaint(paint);
        g2d.fillRect((int) x, (int) y, (int) diameter, (int) diameter);
    } else if (diameter > 3) {
        // for small snowflakes an oval works just fine
        g2d.setColor(snowflakeColor);
        g2d.fillOval((int) x, (int) y, (int) diameter, (int) diameter);
    } else {
        // just a rectangle would work for these
        g2d.setColor(snowflakeColor);
        g2d.fillRect((int) x, (int) y, (int) diameter, (int) diameter);
    }
}
 
开发者ID:martinmarinov,项目名称:snowstorm,代码行数:32,代码来源:AwtSnowflakeRenderer.java

示例3: createPaint

private Paint createPaint(PaintType type, int startx, int starty,
                          int w, int h)
{
    // make sure that the blue color doesn't show up when filling a
    // w by h rect
    w++; h++;

    int endx = startx + w;
    int endy = starty + h;
    Rectangle2D.Float r = new Rectangle2D.Float(startx, starty, w, h);
    switch (type) {
        case COLOR: return Color.red;
        case GRADIENT: return
            new GradientPaint(startx, starty, Color.red,
                              endx, endy, Color.green);
        case LINEAR_GRADIENT: return
            new LinearGradientPaint(startx, starty, endx, endy,
                new float[] { 0.0f, 0.999f, 1.0f },
                new Color[] { Color.red, Color.green, Color.blue });
        case RADIAL_GRADIENT: return
            new RadialGradientPaint(startx, starty,
                (float)Math.sqrt(w * w + h * h),
                new float[] { 0.0f, 0.999f, 1.0f },
                new Color[] { Color.red, Color.green, Color.blue },
                CycleMethod.NO_CYCLE);
        case TEXTURE: {
            BufferedImage bi =
                new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g = (Graphics2D) bi.getGraphics();
            g.setPaint(createPaint(PaintType.LINEAR_GRADIENT, 0, 0, w, h));
            g.fillRect(0, 0, w, h);
            return new TexturePaint(bi, r);
        }
    }
    return Color.green;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:TransformedPaintTest.java

示例4: createImage

void createImage(Graphics2D g, int size){
    float r = size / 2.0f;
    
    float r2 = size * 0.9f;	// 直径
    float a0 = (size - r2) / 2.0f;
    
    AlphaComposite orig = (AlphaComposite) g.getComposite();
    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
    
    g.setComposite(alpha);
    
    float offset = a0;
    g.setPaint(new Color(0, 0, 0));
    g.fill(new Ellipse2D.Double(a0 + offset, a0 + offset, r2, r2));
    
    g.setComposite(orig);
    
    Color c0 = new Color(255, 255, 255);
    Color c1 = new Color(190, 190, 190);
    
    Point2D center = new Point2D.Double(r - (r2 * 0.1), r - (r2 * 0.1));
    float radius = r2 * 0.54f;
    Point2D focus = new Point2D.Double(r - (r2 * 0.1), r - (r2 * 0.1));
    float[] dist = {0.0f, 1.0f};
    Color[] colors = {c0, c1};
    RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE);
    
    
    g.setPaint(p);
    g.fill(new Ellipse2D.Double(a0, a0, r2, r2));
}
 
开发者ID:msanpopo,项目名称:mgoban,代码行数:31,代码来源:WhiteStone.java

示例5: createImage

void createImage(Graphics2D g, int size){
    float r = size / 2.0f;
    
    float r2 = size * 0.5f;	// 直径
    float a0 = (size - r2) / 2.0f;
    
    AlphaComposite orig = (AlphaComposite) g.getComposite();
    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
    
    g.setComposite(alpha);
    
    float offset = (size * 0.1f) / 2.0f;
    g.setPaint(new Color(0, 0, 0));
    g.fill(new Ellipse2D.Double(a0 + offset, a0 + offset, r2, r2));
    
    g.setComposite(orig);
    
    Color c0 = new Color(255, 255, 255);
    Color c1 = new Color(190, 190, 190);
    
    Point2D center = new Point2D.Double(r - (r2 * 0.1), r - (r2 * 0.1));
    float radius = r2 * 0.54f;
    Point2D focus = new Point2D.Double(r - (r2 * 0.1), r - (r2 * 0.1));
    float[] dist = {0.0f, 1.0f};
    Color[] colors = {c0, c1};
    RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE);
    
    
    g.setPaint(p);
    g.fill(new Ellipse2D.Double(a0, a0, r2, r2));
}
 
开发者ID:msanpopo,项目名称:mgoban,代码行数:31,代码来源:WhiteTerritory.java

示例6: createImage

void createImage(Graphics2D g, int size){
    float r = size / 2.0f;
    
    float r2 = size * 0.9f;	// 直径
    float a0 = (size - r2) / 2.0f;
    
    AlphaComposite orig = (AlphaComposite) g.getComposite();
    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
    
    g.setComposite(alpha);
    
    float offset = a0;
    g.setPaint(new Color(0, 0, 0));
    g.fill(new Ellipse2D.Double(a0 + offset, a0 + offset, r2, r2));
    
    g.setComposite(orig);
                        
    Color c0 = new Color(140, 140, 140);
    Color c1 = new Color(10, 10, 10);
            
    Point2D center = new Point2D.Double(r - (r2 * 0.1), r - (r2 * 0.1));
    float radius = r2 * 0.54f;
    Point2D focus = new Point2D.Double(r - (r2 * 0.1), r - (r2 * 0.1));
    float[] dist = {0.0f, 1.0f};
    Color[] colors = {c0, c1};
    RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE);

    g.setPaint(p);
    g.fill(new Ellipse2D.Double(a0, a0, r2, r2));
}
 
开发者ID:msanpopo,项目名称:mgoban,代码行数:30,代码来源:BlackStone.java

示例7: createImage

void createImage(Graphics2D g, int size){
    float r = size / 2.0f;
    
    float r2 = size * 0.5f;	// 直径
    float a0 = (size - r2) / 2.0f;
    
    AlphaComposite orig = (AlphaComposite) g.getComposite();
    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
    
    g.setComposite(alpha);
    
    float offset = (size * 0.1f) / 2.0f;
    g.setPaint(new Color(0, 0, 0));
    g.fill(new Ellipse2D.Double(a0 + offset, a0 + offset, r2, r2));
    
    g.setComposite(orig);
    
    Color c0 = new Color(140, 140, 140);
    Color c1 = new Color(10, 10, 10);
    
    Point2D center = new Point2D.Double(r - (r2 * 0.1), r - (r2 * 0.1));
    float radius = r2 * 0.54f;
    Point2D focus = new Point2D.Double(r - (r2 * 0.1), r - (r2 * 0.1));
    float[] dist = {0.0f, 1.0f};
    Color[] colors = {c0, c1};
    RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE);
    
    
    g.setPaint(p);
    g.fill(new Ellipse2D.Double(a0, a0, r2, r2));
}
 
开发者ID:msanpopo,项目名称:mgoban,代码行数:31,代码来源:BlackTerritory.java

示例8: createPlayerVisionImage

private BufferedImage createPlayerVisionImage(int circleRadius) {
	float circleDiameter = circleRadius * 2.0f;
	Shape circle = new Ellipse2D.Float(0, 0, circleDiameter, circleDiameter);
	BufferedImage image = new BufferedImage((int)circleDiameter, (int)circleDiameter, BufferedImage.TYPE_INT_ARGB);
	
	Graphics2D ga = (Graphics2D) image.createGraphics();
	
	Point2D center = new Point2D.Float(circleRadius, circleRadius);
    Point2D focus = new Point2D.Float(circleRadius, circleRadius);
    float[] dist = {0.0f, 0.70f, 0.95f};
    Color transparentBlack = new Color(0, 0, 0, 0);
	Color[] colors = {transparentBlack, transparentBlack, Color.BLACK};
    RadialGradientPaint p =
        new RadialGradientPaint(center, circleRadius, focus,
                                 dist, colors,
                                 CycleMethod.NO_CYCLE);
    
    ga.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    ga.setPaint(p);
	
	ga.fill(circle);
	ga.setStroke(new BasicStroke(2));
	ga.draw(circle);
	
	ga.dispose();
	
	return image;
}
 
开发者ID:WorldGrower,项目名称:WorldGrower,代码行数:29,代码来源:PlayerCharacterVisionPainter.java

示例9: paintBubble

private void paintBubble(Graphics2D g2, Ellipse2D shape, double evidence, boolean on) {
		g2 = (Graphics2D)g2.create(); // create 'copy' and manipulate on that

		int x = (int)shape.getCenterX();
		int y = (int)shape.getCenterY();
		int radius = (int)(shape.getWidth()/2);
		
		/*
		 * Color whether on or off
		 */
		if (on) {
			g2.setColor(SENSOR_ON);
			g2.setComposite(BlendComposite.Hue);
			g2.fillRect(x - 5, y - 5, 10, 10);
			g2.setComposite(AlphaComposite.SrcAtop); // reset
		}
		
		/*
		 * Fill gradient
		 */
		Point2D center = new Point2D.Float(x, y);
		Point2D focus = new Point2D.Float(x, y);
		Color[] colors;
		if (evidence == 0) { colors = zero_colors; }
		else if (evidence > 0) { colors = pos_colors; }
		else { colors = neg_colors; }
		
		if (radius <= 0) { // not sure why this happens
//			System.out.println("radius = " + radius); 
			radius = 1;
		}
		
		RadialGradientPaint paint = new RadialGradientPaint(
				center, radius, 
				focus,
				dist, colors,
				CycleMethod.NO_CYCLE);
		g2.setPaint(paint);
		g2.fill(shape);
	}
 
开发者ID:claudiotrindade,项目名称:contexttoolkit,代码行数:40,代码来源:FloorplanPanel.java

示例10: indexIntoGradientsArrays

/**
 * Helper function to index into the gradients array.  This is necessary
 * because each interval has an array of colors with uniform size 255.
 * However, the color intervals are not necessarily of uniform length, so
 * a conversion is required.
 *
 * @param position the unmanipulated position, which will be mapped
 *                 into the range 0 to 1
 * @returns integer color to display
 */
protected final int indexIntoGradientsArrays(float position) {
    // first, manipulate position value depending on the cycle method
    if (cycleMethod == CycleMethod.NO_CYCLE) {
        if (position > 1) {
            // upper bound is 1
            position = 1;
        } else if (position < 0) {
            // lower bound is 0
            position = 0;
        }
    } else if (cycleMethod == CycleMethod.REPEAT) {
        // get the fractional part
        // (modulo behavior discards integer component)
        position = position - (int)position;

        //position should now be between -1 and 1
        if (position < 0) {
            // force it to be in the range 0-1
            position = position + 1;
        }
    } else { // cycleMethod == CycleMethod.REFLECT
        if (position < 0) {
            // take absolute value
            position = -position;
        }

        // get the integer part
        int part = (int)position;

        // get the fractional part
        position = position - part;

        if ((part & 1) == 1) {
            // integer part is odd, get reflected color instead
            position = 1 - position;
        }
    }

    // now, get the color based on this 0-1 position...

    if (isSimpleLookup) {
        // easy to compute: just scale index by array size
        return gradient[(int)(position * fastGradientArraySize)];
    } else {
        // more complicated computation, to save space

        // for all the gradient interval arrays
        for (int i = 0; i < gradients.length; i++) {
            if (position < fractions[i+1]) {
                // this is the array we want
                float delta = position - fractions[i];

                // this is the interval we want
                int index = (int)((delta / normalizedIntervals[i])
                                  * (GRADIENT_SIZE_INDEX));

                return gradients[i][index];
            }
        }
    }

    return gradients[gradients.length - 1][GRADIENT_SIZE_INDEX];
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:73,代码来源:MultipleGradientPaintContext.java

示例11: makePaint

private Paint makePaint(PaintType paintType,
                        CycleMethod cycleMethod,
                        ColorSpaceType colorSpace,
                        XformType xformType, int numStops)
{
    int startX   = TESTW/6;
    int startY   = TESTH/6;
    int endX     = TESTW/2;
    int endY     = TESTH/2;
    int ctrX     = TESTW/2;
    int ctrY     = TESTH/2;
    int focusX   = ctrX + 20;
    int focusY   = ctrY + 20;
    float radius = 100.0f;
    Paint paint;
    AffineTransform transform;

    Color[] colors = Arrays.copyOf(COLORS, numStops);
    float[] fractions = new float[colors.length];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = ((float)i) / (fractions.length-1);
    }

    switch (xformType) {
    default:
    case IDENTITY:
        transform = new AffineTransform();
        break;
    case TRANSLATE:
        transform = AffineTransform.getTranslateInstance(2, 2);
        break;
    case SCALE:
        transform = AffineTransform.getScaleInstance(1.2, 1.4);
        break;
    case SHEAR:
        transform = AffineTransform.getShearInstance(0.1, 0.1);
        break;
    case ROTATE:
        transform = AffineTransform.getRotateInstance(Math.PI / 4,
                                                      getWidth()/2,
                                                      getHeight()/2);
        break;
    }

    switch (paintType) {
    case BASIC:
        boolean cyclic = (cycleMethod != CycleMethod.NO_CYCLE);
        paint =
            new GradientPaint(startX, startY, Color.RED,
                              endX, endY, Color.BLUE, cyclic);
        break;

    default:
    case LINEAR:
        paint =
            new LinearGradientPaint(new Point2D.Float(startX, startY),
                                    new Point2D.Float(endX, endY),
                                    fractions, colors,
                                    cycleMethod, colorSpace,
                                    transform);
        break;

    case RADIAL:
        paint =
            new RadialGradientPaint(new Point2D.Float(ctrX, ctrY),
                                    radius,
                                    new Point2D.Float(focusX, focusY),
                                    fractions, colors,
                                    cycleMethod, colorSpace,
                                    transform);
        break;
    }

    return paint;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:75,代码来源:GradientPaints.java

示例12: indexIntoGradientsArrays

/**
 * Helper function to index into the gradients array.  This is necessary
 * because each interval has an array of colors with uniform size 255.
 * However, the color intervals are not necessarily of uniform length, so
 * a conversion is required.
 *
 * @param position the unmanipulated position, which will be mapped
 *                 into the range 0 to 1
 * @return integer color to display
 */
protected final int indexIntoGradientsArrays(float position) {
    // first, manipulate position value depending on the cycle method
    if (cycleMethod == CycleMethod.NO_CYCLE) {
        if (position > 1) {
            // upper bound is 1
            position = 1;
        } else if (position < 0) {
            // lower bound is 0
            position = 0;
        }
    } else if (cycleMethod == CycleMethod.REPEAT) {
        // get the fractional part
        // (modulo behavior discards integer component)
        position = position - (int)position;

        //position should now be between -1 and 1
        if (position < 0) {
            // force it to be in the range 0-1
            position = position + 1;
        }
    } else { // cycleMethod == CycleMethod.REFLECT
        if (position < 0) {
            // take absolute value
            position = -position;
        }

        // get the integer part
        int part = (int)position;

        // get the fractional part
        position = position - part;

        if ((part & 1) == 1) {
            // integer part is odd, get reflected color instead
            position = 1 - position;
        }
    }

    // now, get the color based on this 0-1 position...

    if (isSimpleLookup) {
        // easy to compute: just scale index by array size
        return gradient[(int)(position * fastGradientArraySize)];
    } else {
        // more complicated computation, to save space

        // for all the gradient interval arrays
        for (int i = 0; i < gradients.length; i++) {
            if (position < fractions[i+1]) {
                // this is the array we want
                float delta = position - fractions[i];

                // this is the interval we want
                int index = (int)((delta / normalizedIntervals[i])
                                  * (GRADIENT_SIZE_INDEX));

                return gradients[i][index];
            }
        }
    }

    return gradients[gradients.length - 1][GRADIENT_SIZE_INDEX];
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:73,代码来源:MultipleGradientPaintContext.java

示例13: indexIntoGradientsArrays

/**
 * Helper function to index into the gradients array.  This is necessary
 * because each interval has an array of colors with uniform size 255.
 * However, the color intervals are not necessarily of uniform length, so
 * a conversion is required.
 *
 * @param position the unmanipulated position, which will be mapped
 *                 into the range 0 to 1
 * @returns integer color to display
 */
protected final int indexIntoGradientsArrays(float position) {       
    // first, manipulate position value depending on the cycle method
    if (cycleMethod == CycleMethod.NO_CYCLE) {
        if (position > 1) {
            // upper bound is 1
            position = 1;
        } else if (position < 0) {
            // lower bound is 0
            position = 0;
        }
    } else if (cycleMethod == CycleMethod.REPEAT) {
        // get the fractional part
        // (modulo behavior discards integer component)
        position = position - (int)position; 

        //position should now be between -1 and 1
        if (position < 0) {
            // force it to be in the range 0-1
            position = position + 1;
        }           
    } else { // cycleMethod == CycleMethod.REFLECT
        if (position < 0) {
            // take absolute value
            position = -position;
        }                      

        // get the integer part
        int part = (int)position;

        // get the fractional part
        position = position - part;

        if ((part & 1) == 1) {
            // integer part is odd, get reflected color instead
            position = 1 - position;
        }
    }
   
    // now, get the color based on this 0-1 position...

    if (isSimpleLookup) {
        // easy to compute: just scale index by array size
        return gradient[(int)(position * fastGradientArraySize)];
    } else {
        // more complicated computation, to save space
        
        // for all the gradient interval arrays
        for (int i = 0; i < gradients.length; i++) { 
            if (position < fractions[i+1]) {
                // this is the array we want
                float delta = position - fractions[i];        

                // this is the interval we want
                int index = (int)((delta / normalizedIntervals[i]) 
                                  * (GRADIENT_SIZE_INDEX));
                
                return gradients[i][index];
            }            
        }
    }
    
    return gradients[gradients.length - 1][GRADIENT_SIZE_INDEX];        
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:73,代码来源:MultipleGradientPaintContext.java


注:本文中的java.awt.MultipleGradientPaint.CycleMethod.NO_CYCLE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。