當前位置: 首頁>>代碼示例>>Java>>正文


Java LinearGradientPaint類代碼示例

本文整理匯總了Java中java.awt.LinearGradientPaint的典型用法代碼示例。如果您正苦於以下問題:Java LinearGradientPaint類的具體用法?Java LinearGradientPaint怎麽用?Java LinearGradientPaint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LinearGradientPaint類屬於java.awt包,在下文中一共展示了LinearGradientPaint類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createCustomLcdBackgroundPaint

import java.awt.LinearGradientPaint; //導入依賴的package包/類
@Override
public Paint createCustomLcdBackgroundPaint(final Color[] LCD_COLORS) {
    final Point2D FOREGROUND_START = new Point2D.Double(0.0, LCD.getMinY() + 1.0);
    final Point2D FOREGROUND_STOP = new Point2D.Double(0.0, LCD.getMaxY() - 1);
    if (FOREGROUND_START.equals(FOREGROUND_STOP)) {
        FOREGROUND_STOP.setLocation(0.0, FOREGROUND_START.getY() + 1);
    }

    final float[] FOREGROUND_FRACTIONS = {
        0.0f,
        0.03f,
        0.49f,
        0.5f,
        1.0f
    };

    final Color[] FOREGROUND_COLORS = {
        LCD_COLORS[0],
        LCD_COLORS[1],
        LCD_COLORS[2],
        LCD_COLORS[3],
        LCD_COLORS[4]
    };

    return new LinearGradientPaint(FOREGROUND_START, FOREGROUND_STOP, FOREGROUND_FRACTIONS, FOREGROUND_COLORS);
}
 
開發者ID:mars-sim,項目名稱:mars-sim,代碼行數:27,代碼來源:DigitalRadial.java

示例2: Push

import java.awt.LinearGradientPaint; //導入依賴的package包/類
public Push() {
  setUndecorated(true);
  setSize(300, 100);
  this.setAlwaysOnTop(true);

  // size of the screen
  final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

  // height of the task bar
  final Insets scnMax = Toolkit.getDefaultToolkit().getScreenInsets(
      getGraphicsConfiguration());
  final int taskBarSize = scnMax.bottom;

  setLocation(screenSize.width - getWidth(), screenSize.height - taskBarSize
      - getHeight());

  // background paint
  lpg = new LinearGradientPaint(0, 0, 0, getHeight() / 2, new float[] { 0f,
      0.3f, 1f }, new Color[] { new Color(0.8f, 0.8f, 1f),
      new Color(0.7f, 0.7f, 1f), new Color(0.6f, 0.6f, 1f) });

  // blue background panel
  setContentPane(new BackgroundPanel());
}
 
開發者ID:CoffeeCodeSwitzerland,項目名稱:Lernkartei_2017,代碼行數:25,代碼來源:Push.java

示例3: paint

import java.awt.LinearGradientPaint; //導入依賴的package包/類
public void paint(Graphics2D g, Rectangle dirtyArea, ChartContext context) {
    if (gradient || selection) {
        int rowsCount = chart.getRowsCount();
        for (int i = 0; i < rowsCount; i++) {
            TimelineChart.Row row = chart.getRow(i);
            ChartContext rowContext = row.getContext();

            int y = Utils.checkedInt(rowContext.getViewportOffsetY());
            int h = Utils.checkedInt(rowContext.getViewportHeight() - 1);

            if (gradient) {
                g.setPaint(new LinearGradientPaint(0, y, 0, y + h, FRACTIONS, COLORS));
                g.fillRect(0, y, chart.getWidth(), h);
            }

            if (selection && chart.isRowSelected(row)) {
                g.setColor(SELECTED_FILTER);
                g.fillRect(0, y, chart.getWidth(), h);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:RowForegroundDecorator.java

示例4: drawIcon

import java.awt.LinearGradientPaint; //導入依賴的package包/類
@Override
public void drawIcon(Graphics2D g2, int width, int height, int percentage) {
	// prepare background
	g2.setColor(Color.WHITE);
	g2.fillRect(0, 0, width, height);

	// 0-50 % is the same color, only the last 50% fade into red
	Color startColor = new Color(0f, .5f, 0, 0.7f);
	g2.setColor(startColor);
	g2.setPaint(new LinearGradientPaint(width / 2, 0f, width, 0f, new float[] { 0f, 0.5f, 1f }, new Color[] {
			new Color(0f, .5f, 0, 0.7f), new Color(1f, 1f, 0f, 0.7f), new Color(1f, 0, 0, 0.7f) }));
	g2.fillRect(0, 0, (int) (percentage / 100d * width), height);

	// draw border
	g2.setColor(Color.GRAY);
	g2.drawRect(0, 0, width - 1, height - 1);
	g2.dispose();
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:19,代碼來源:DynamicIconUrlStreamHandler.java

示例5: isPaintValid

import java.awt.LinearGradientPaint; //導入依賴的package包/類
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
        D3DGraphicsDevice gd = (D3DGraphicsDevice)
            dstData.getDeviceConfiguration().getDevice();
        if (gd.isCapPresent(CAPS_LCD_SHADER)) {
            // we can delegate to the optimized two-color gradient
            // codepath, which should be faster
            return true;
        }
    }

    return super.isPaintValid(sg2d);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:D3DPaints.java

示例6: createCustomLcdBackgroundPaint

import java.awt.LinearGradientPaint; //導入依賴的package包/類
@Override
public Paint createCustomLcdBackgroundPaint(final Color[] LCD_COLORS) {
    final Point2D FOREGROUND_START = new Point2D.Double(0.0, 1.0);
    final Point2D FOREGROUND_STOP = new Point2D.Double(0.0, getHeight() - 1);
    if (FOREGROUND_START.equals(FOREGROUND_STOP)) {
        FOREGROUND_STOP.setLocation(0.0, FOREGROUND_START.getY() + 1);
    }

    final float[] FOREGROUND_FRACTIONS = {
        0.0f,
        0.03f,
        0.49f,
        0.5f,
        1.0f
    };

    final Color[] FOREGROUND_COLORS = {
        LCD_COLORS[0],
        LCD_COLORS[1],
        LCD_COLORS[2],
        LCD_COLORS[3],
        LCD_COLORS[4]
    };

    return new LinearGradientPaint(FOREGROUND_START, FOREGROUND_STOP, FOREGROUND_FRACTIONS, FOREGROUND_COLORS);
}
 
開發者ID:mars-sim,項目名稱:mars-sim,代碼行數:27,代碼來源:DisplayMulti.java

示例7: createCustomLcdBackgroundPaint

import java.awt.LinearGradientPaint; //導入依賴的package包/類
@Override
public java.awt.Paint createCustomLcdBackgroundPaint(final Color[] LCD_COLORS) {
    final Point2D FOREGROUND_START = new Point2D.Double(0.0, LCD.getMinY() + 1.0);
    final Point2D FOREGROUND_STOP = new Point2D.Double(0.0, LCD.getMaxY() - 1);
    if (FOREGROUND_START.equals(FOREGROUND_STOP)) {
        FOREGROUND_STOP.setLocation(0.0, FOREGROUND_START.getY() + 1);
    }

    final float[] FOREGROUND_FRACTIONS = {
        0.0f,
        0.03f,
        0.49f,
        0.5f,
        1.0f
    };

    final Color[] FOREGROUND_COLORS = {
        LCD_COLORS[0],
        LCD_COLORS[1],
        LCD_COLORS[2],
        LCD_COLORS[3],
        LCD_COLORS[4]
    };

    return new LinearGradientPaint(FOREGROUND_START, FOREGROUND_STOP, FOREGROUND_FRACTIONS, FOREGROUND_COLORS);
}
 
開發者ID:mars-sim,項目名稱:mars-sim,代碼行數:27,代碼來源:RadialBargraph.java

示例8: WoodTexture

import java.awt.LinearGradientPaint; //導入依賴的package包/類
private WoodTexture() {
    Color c0 = new Color(231, 190, 106);
    Color c1 = new Color(232, 185, 96);
    Color c2 = new Color(216, 168, 82);
    
    Point2D start = new Point2D.Float(0, 0);
    Point2D end = new Point2D.Float(100, 10);
    float[] dist = {0.0f, 0.6f, 1.0f};
    Color[] colors = {c0, c1, c2};
    LinearGradientPaint p = new LinearGradientPaint(start, end, dist, colors);
    
    texture = new BufferedImage(100, 10, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = texture.createGraphics();
    
    g.setPaint(p);
    g.fill(new Rectangle2D.Double(0, 0, 100, 10));
    
}
 
開發者ID:msanpopo,項目名稱:mgoban,代碼行數:19,代碼來源:WoodTexture.java

示例9: getFlatGradient

import java.awt.LinearGradientPaint; //導入依賴的package包/類
/**
 * Creates a flat version of the current gradient. This is a linear gradient
 * from 0.0 to length,0. This gradient is suitable for drawing previews of
 * the real gradient.
 *
 * @param length
 * @return a gradient Paint with values between 0.0 and length
 */
private MultipleGradientPaint getFlatGradient(JXGradientChooser chooser, double length) {
    MultipleGradientPaint gp = chooser.getGradient();

    // set up the data for the gradient
    float[] fractions = gp.getFractions();
    Color[] colors = gp.getColors();

    // fill in the gradient
    Point2D start = new Point2D.Float(0, 0);
    Point2D end = new Point2D.Float((float) length, 0);
    MultipleGradientPaint paint = new LinearGradientPaint(
            (float) start.getX(),
            (float) start.getY(),
            (float) end.getX(),
            (float) end.getY(),
            fractions, colors);
    return paint;
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:27,代碼來源:PaintPicker.java

示例10: createGradientImage

import java.awt.LinearGradientPaint; //導入依賴的package包/類
private BufferedImage createGradientImage(Color... colors)
{
    final float[] fractions = new float[colors.length];

    final float step = 1.0F / colors.length;

    for (int i = 0; i < colors.length; i++)
    {
        fractions[i] = i * step;
    }

    final LinearGradientPaint gradient = new LinearGradientPaint(0, 0, 256, 1, fractions, colors, MultipleGradientPaint.CycleMethod.REPEAT);
    final BufferedImage bi = new BufferedImage(256, 1, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D g = bi.createGraphics();
    try
    {
        g.setPaint(gradient);
        g.fillRect(0, 0, 256, 1);
    }
    finally
    {
        g.dispose();
    }
    return bi;
}
 
開發者ID:mraad,項目名稱:ExportImageSOI,代碼行數:26,代碼來源:ColorMapper.java

示例11: paintComponent

import java.awt.LinearGradientPaint; //導入依賴的package包/類
@Override
protected void paintComponent(Graphics graphics) {
	super.paintComponent(graphics);
	Graphics2D g2d = (Graphics2D) graphics;
	g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	Point2D start = new Point2D.Float(0, 0);
	Point2D end = new Point2D.Float(0, getHeight());
	float[] dist = { 0.0f, 0.8f, .95f, 1f };
	Color bg = getBackground();
	Color bgd = getBackground().darker();
	Color[] colors = { bgd, bg, bgd, bgd.darker() };
	LinearGradientPaint gp1 = new LinearGradientPaint(start, end, dist, colors);
	g2d.setPaint(gp1);
	g2d.fillRect(0, 0, getWidth(), getHeight());
}
 
開發者ID:onyxbits,項目名稱:raccoon4,代碼行數:17,代碼來源:TitleStrip.java

示例12: getGradient

import java.awt.LinearGradientPaint; //導入依賴的package包/類
/**
 * Gets the gradient.
 * 
 * @param colors the colors
 * @param steps the steps
 * @return the gradient
 */
private int[] getGradient(Color[] colors, int steps) {

    // Draw the gradient to a buffered image
    Point2D start = new Point2D.Float(0, 0);
    Point2D end = new Point2D.Float(1, steps);
    float[] dist = new float[colors.length];
    for (int i = 0; i < dist.length; i++) {
        dist[i] = (1.0f / dist.length) * i;
    }
    LinearGradientPaint p = new LinearGradientPaint(start, end, dist, colors);
    BufferedImage legend = new BufferedImage(1, steps, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = (Graphics2D) legend.getGraphics();
    g2d.setPaint(p);
    g2d.drawRect(0, 0, 1, steps);
    g2d.dispose();

    // Convert to color array
    int[] result = new int[steps];
    for (int y = 0; y < steps; y++) {
        result[y] = legend.getRGB(0, y);
    }

    // Return
    return result;
}
 
開發者ID:prasser,項目名稱:jhc,代碼行數:33,代碼來源:JHCGradient.java

示例13: getGui

import java.awt.LinearGradientPaint; //導入依賴的package包/類
public Gui getGui() {
return new Gui() {

    @Override
    public void render(Graphics2D g2d, int width, int height) {
	LinearGradientPaint gradient = new LinearGradientPaint(0, 0, 0, 100, new float[]{0,1}, new Color[]{new Color(0x666666),new Color(0x444444)});
	g2d.setPaint(gradient);
	g2d.fillRect(0, 0, width, 100);
	g2d.setColor(new Color(0x666666));
	g2d.fillRect(0, 100, width, height - 100);
	g2d.setColor(Color.WHITE);
	g2d.setFont(Client.instance.translation.font.deriveFont(Font.BOLD, 35F));
	g2d.drawString(name, 50, 50);
	g2d.setFont(Client.instance.translation.font.deriveFont(Font.BOLD, 18F));
	g2d.setColor(Color.GRAY);
	g2d.drawString(ip, 50, 75);
	if(ping >= 0) {
	    if(ping == 0)
		g2d.setColor(Color.RED.darker());
	    g2d.drawString(ping == 0 ? Client.instance.translation.translate("protocol.timeout") : ping + "ms", 50, 95);
	}
    }
    
};
   }
 
開發者ID:GymDon-P-Q11Info-13-15,項目名稱:game-client,代碼行數:26,代碼來源:ServerListEntry.java

示例14: doPaintBackground

import java.awt.LinearGradientPaint; //導入依賴的package包/類
private void doPaintBackground(Graphics2D graphics2D, int x, int y, int width, int height) {
	Color color = Colors.darker(Color.decode("#006699"), 64, 64, 64);
	
	graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	
	Paint paint = graphics2D.getPaint();
	
	float startX = x;
	float startY = y;
	float endX = x;
	float endY = y + height - 1;
	
	Color[] colors = new Color[4];
	
	colors[0] = Colors.brighter(color, 32, 32, 32);
	colors[1] = Colors.darker(color, 16, 16, 16);
	colors[2] = Colors.darker(color, 16, 16, 16);
	colors[3] = Colors.darker(color, 16, 16, 16);
	
	graphics2D.setPaint(new LinearGradientPaint(startX, startY, endX, endY, fractions, colors));
	graphics2D.fillRoundRect(x, y, width - 1, height - 1, 2, 2);
	graphics2D.setColor(Colors.brighter(color, 32, 32, 32));
	graphics2D.setStroke(stroke);
	graphics2D.drawRoundRect(x, y, width - 1, height - 1, 2, 2);
	graphics2D.setPaint(paint);
}
 
開發者ID:WavePropagation,項目名稱:org.dayflower,代碼行數:27,代碼來源:ProgressUpdateFutureImpl.java

示例15: getAsText

import java.awt.LinearGradientPaint; //導入依賴的package包/類
public String getAsText() {
    if (null == getValue()) return null;
    LinearGradientPaint p = (LinearGradientPaint) getValue();
    return new StringBuilder()
        .append(p.getStartPoint().getX())
        .append(", ")
        .append(p.getStartPoint().getY())
        .append(", ")
        .append(p.getEndPoint().getX())
        .append(", ")
        .append(p.getEndPoint().getY())
        .append(", ")
        .append(formatFractions(p.getFractions()))
        .append(", ")
        .append(formatColors(p.getColors()))
        .append(", ")
        .append(p.getCycleMethod().name())
        .toString();
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:20,代碼來源:LinearGradientPaintPropertyEditor.java


注:本文中的java.awt.LinearGradientPaint類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。