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


Java RadialGradientPaint类代码示例

本文整理汇总了Java中java.awt.RadialGradientPaint的典型用法代码示例。如果您正苦于以下问题:Java RadialGradientPaint类的具体用法?Java RadialGradientPaint怎么用?Java RadialGradientPaint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createTestImage

import java.awt.RadialGradientPaint; //导入依赖的package包/类
private static BufferedImage createTestImage() {
    int w = 1024;
    int h = 768;

    BufferedImage img = new
        BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = img.createGraphics();
    Color[] colors = { Color.red, Color.green, Color.blue };
    float[] dist = {0.0f, 0.5f, 1.0f };
    Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);

    RadialGradientPaint p =
        new RadialGradientPaint(center, 0.5f * w, dist, colors);
    g.setPaint(p);
    g.fillRect(0, 0, w, h);
    g.dispose();

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

示例2: createSrcImage

import java.awt.RadialGradientPaint; //导入依赖的package包/类
private static BufferedImage createSrcImage() {
    BufferedImage img = createImage();

    Graphics2D g = img.createGraphics();
    Color[] colors = { Color.red, Color.green, Color.blue };
    float[] dist = {0.0f, 0.5f, 1.0f };
    Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);

    RadialGradientPaint p =
            new RadialGradientPaint(center, 0.5f * w, dist, colors);
    g.setPaint(p);
    g.fillRect(0, 0, w, h);
    g.dispose();

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

示例3: createPaint

import java.awt.RadialGradientPaint; //导入依赖的package包/类
/**
 * 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,代码行数:21,代码来源:JAttr.java

示例4: RadialLight

import java.awt.RadialGradientPaint; //导入依赖的package包/类
public RadialLight(final float x, final float y, final float radius, final float intensity) {
	super(x, y, intensity);
	this.radius = radius;

	/******** DRAW THE LIGHT IMAGE **********************************************************/
	final Color[] color = { new Color(0, 0, 0, intensity), new Color(0, 0, 0, 0) };
	lightImage = new BufferedImage((int)(radius*2), (int)(radius*2), BufferedImage.TYPE_INT_ARGB);
	final Graphics2D g2d = (Graphics2D) lightImage.getGraphics();
	final float[] distance = { 0f, 1f };
	g2d.setPaint(new RadialGradientPaint(new Point((int)radius, (int)radius), radius, distance, color));
	g2d.fillOval(0, 0, (int)(radius*2), (int)(radius*2));
	g2d.dispose();
	/***************************************************************************************/

	Handler.lights.add(this);
}
 
开发者ID:MitchWeaver,项目名称:sjgs,代码行数:17,代码来源:RadialLight.java

示例5: paintButton

import java.awt.RadialGradientPaint; //导入依赖的package包/类
private void paintButton(Graphics g, Color[] colors) {
	
	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	int width = this.getWidth();
	int height = this.getHeight();

	Point2D center = new Point2D.Float(width / 2, height / 2);
	float radius = width / 2;
	float[] dist = { 0.0f, 0.8f };
	RadialGradientPaint paint = new RadialGradientPaint(center, radius, dist, colors);
	g2.setPaint(paint);
	shape = new RoundRectangle2D.Double(0, 0, width, height, height, height);
	g2.fill(shape);

	Font defaultFont = getFont();
	g2.setFont(defaultFont);
	g2.setColor(Color.BLACK);
	Rectangle2D rect = defaultFont.getStringBounds(text, g2.getFontRenderContext());
	LineMetrics lineMetrics = defaultFont.getLineMetrics(text, g2.getFontRenderContext());
	g2.drawString(text, (float) (width / 2 - rect.getWidth() / 2), (float) ((height / 2)
			+ ((lineMetrics.getAscent() + lineMetrics.getDescent()) / 2 - lineMetrics.getDescent())));

}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:25,代码来源:MyButton.java

示例6: paintButton

import java.awt.RadialGradientPaint; //导入依赖的package包/类
private void paintButton(Graphics g, Color[] colors)
{
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int width = this.getWidth();
    int height = this.getHeight();

    Point2D center = new Point2D.Float(width / 2, height / 2);
    float radius = width / 2;
    float[] dist = {0.0f, 0.8f};
    RadialGradientPaint paint = new RadialGradientPaint(center, radius, dist, colors);
    g2.setPaint(paint);
    shape = new RoundRectangle2D.Double(0, 0, width, height, height, height);
    g2.fill(shape);

    Font defaultFont = getFont();
    g2.setFont(defaultFont);
    g2.setColor(Color.BLACK);
    Rectangle2D rect = defaultFont.getStringBounds(text, g2.getFontRenderContext());
    LineMetrics lineMetrics = defaultFont.getLineMetrics(text, g2.getFontRenderContext());
    g2.drawString(text,
        (float)(width / 2 - rect.getWidth() / 2),
        (float)((height / 2) + ((lineMetrics.getAscent() + lineMetrics.getDescent()) / 2 - lineMetrics.getDescent())));

}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:26,代码来源:CTDFrame.java

示例7: createArea3DEffectGradient

import java.awt.RadialGradientPaint; //导入依赖的package包/类
/**
 * Returns a radial gradient paint that will be used as overlay for the track or area image
 * to achieve some kind of a 3d effect.
 * @param WIDTH
 * @param RADIUS_FACTOR
 * @return a radial gradient paint that will be used as overlay for the track or area image
 */
protected RadialGradientPaint createArea3DEffectGradient(final int WIDTH, final float RADIUS_FACTOR) {
    final float[] FRACTIONS;
    final Color[] COLORS;

    FRACTIONS = new float[]{
        0.0f,
        0.6f,
        1.0f
    };
    COLORS = new Color[]{
        new Color(1.0f, 1.0f, 1.0f, 0.75f),
        new Color(1.0f, 1.0f, 1.0f, 0.0f),
        new Color(0.0f, 0.0f, 0.0f, 0.3f)
    };
    final Point2D GRADIENT_CENTER = new Point2D.Double(WIDTH / 2.0, WIDTH / 2.0);

    return new RadialGradientPaint(GRADIENT_CENTER, WIDTH * RADIUS_FACTOR, FRACTIONS, COLORS);
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:26,代码来源:AbstractRadial.java

示例8: RadialBargraph

import java.awt.RadialGradientPaint; //导入依赖的package包/类
public RadialBargraph() {
    super();
    barGraphColor = ColorDef.RED;
    CENTER = new Point2D.Double();
    LED_CENTER = new Point2D.Double();
    LED_FRACTIONS = new float[]{
        0.0f,
        1.0f
    };
    sectionGradients = new java.util.HashMap<Section, RadialGradientPaint>(4);
    sectionAngles = new java.util.HashMap<Section, Point2D>(4);

    ledTrackStartAngle = getGaugeType().ORIGIN_CORRECTION - (0 * (getGaugeType().APEX_ANGLE / (getMaxValue() - getMinValue())));
    ledTrackAngleExtend = -(getMaxValue() - getMinValue()) * (getGaugeType().APEX_ANGLE / (getMaxValue() - getMinValue()));
    calcBargraphTrack();
    prepareBargraph(getInnerBounds().width);
    setLcdVisible(true);
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:19,代码来源:RadialBargraph.java

示例9: HighlightedButton

import java.awt.RadialGradientPaint; //导入依赖的package包/类
/**
 * Creates a new instance of HighlightedButton
 */
public HighlightedButton(String label) {
    super(label);
    
    // Get the Graphics for the image
    Graphics2D g2d = highlight.createGraphics();
    
    // Erase the image with a transparent background
    g2d.setComposite(AlphaComposite.Clear);
    g2d.fillRect(0, 0, HIGHLIGHT_SIZE, HIGHLIGHT_SIZE);
    g2d.setComposite(AlphaComposite.SrcOver);
    
    // Draw the highlight
    Point2D center = new Point2D.Float((float)HIGHLIGHT_SIZE / 2.0f,
            (float)HIGHLIGHT_SIZE / 2.0f);
    float radius = (float)HIGHLIGHT_SIZE / 2.0f;
    float[] dist = {0.0f, .85f};
    Color[] colors = {Color.white, new Color(255, 255, 255, 0)};
    RadialGradientPaint paint = new RadialGradientPaint(center, radius,
            dist, colors);
    g2d.setPaint(paint);
    g2d.fillOval(0, 0, HIGHLIGHT_SIZE, HIGHLIGHT_SIZE);
    g2d.dispose();
}
 
开发者ID:romainguy,项目名称:filthy-rich-clients,代码行数:27,代码来源:HighlightedButton.java


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