當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。