Java 类java.awt.LinearGradientPaint 实例源码

项目:Lernkartei_2017    文件:Push.java   
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());
}
项目:incubator-netbeans    文件:RowForegroundDecorator.java   
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);
            }
        }
    }
}
项目:rapidminer    文件:DynamicIconUrlStreamHandler.java   
@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();
}
项目:OpenJSharp    文件:D3DPaints.java   
@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);
}
项目:jdk8u-jdk    文件:D3DPaints.java   
@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);
}
项目:openjdk-jdk10    文件:D3DPaints.java   
@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);
}
项目:openjdk9    文件:D3DPaints.java   
@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);
}
项目:Lernkartei    文件:Push.java   
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());
}
项目:jdk8u_jdk    文件:D3DPaints.java   
@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);
}
项目:lookaside_java-1.8.0-openjdk    文件:D3DPaints.java   
@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);
}
项目:rapidminer-studio    文件:DynamicIconUrlStreamHandler.java   
@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();
}
项目:mars-sim    文件:DigitalRadial.java   
@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);
}
项目:mars-sim    文件:WindDirection.java   
@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);
}
项目:mars-sim    文件:DigitalRadial.java   
@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);
}
项目:mars-sim    文件:DisplayMulti.java   
@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);
}
项目:mars-sim    文件:RadialBargraph.java   
@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);
}
项目:mars-sim    文件:DisplaySingle.java   
@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);
}
项目:mars-sim    文件:Radial.java   
@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);
}
项目:mars-sim    文件:RadialCounter.java   
@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);
}
项目:mars-sim    文件:LinearBargraph.java   
@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);
}
项目:mars-sim    文件:DigitialRadial.java   
@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);
}
项目:mars-sim    文件:DisplayCircular.java   
@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);
}
项目:mgoban    文件:WoodTexture.java   
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));

}
项目:swingx    文件:PaintPicker.java   
/**
 * 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;
}
项目:ExportImageSOI    文件:ColorMapper.java   
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;
}
项目:infobip-open-jdk-8    文件:D3DPaints.java   
@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);
}
项目:jdk8u-dev-jdk    文件:D3DPaints.java   
@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);
}
项目:raccoon4    文件:TitleStrip.java   
@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());
}
项目:jhc    文件:JHCGradient.java   
/**
 * 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;
}
项目:jdk7-jdk    文件:D3DPaints.java   
@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);
}
项目:openjdk-source-code-learn    文件:D3DPaints.java   
@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);
}
项目:OLD-OpenJDK8    文件:D3DPaints.java   
@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);
}
项目:game-client    文件:ServerListEntry.java   
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);
    }
    }

};
   }
项目:openjdk-jdk7u-jdk    文件:D3DPaints.java   
@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);
}
项目:org.dayflower    文件:ProgressUpdateFutureImpl.java   
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);
}
项目:org.dayflower    文件:Java2DGame.java   
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);
}
项目:openjdk-icedtea7    文件:D3DPaints.java   
@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);
}
项目:griffon2    文件:LinearGradientPaintPropertyEditor.java   
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();
}
项目:griffon2    文件:LinearGradientPaintPropertyEditor.java   
private void handleAsMap(Map<?, ?> map) {
    if(map.isEmpty()) {
        super.setValueInternal(null);
        return;
    }

    float x1 = (Float) getMapValue(map, "x1", 0f);
    float y1 = (Float) getMapValue(map, "y1", 0f);
    float x2 = (Float) getMapValue(map, "x2", 0f);
    float y2 = (Float) getMapValue(map, "y2", 0f);
    MultipleGradientPaint.CycleMethod cyclicMethod = MultipleGradientPaint.CycleMethod.NO_CYCLE;

    float[] fractions = parseFractions(map, map.get("fractions"));
    Color[] colors = parseColors(map, map.get("colors"));
    if (fractions.length != colors.length) {
        throw illegalValue(map, LinearGradientPaint.class);
    }
    Object cyclicValue = map.get("cycle");
    if (null != cyclicValue) {
        cyclicMethod = parseCyclicMethod(map, String.valueOf(cyclicValue));
    }

    super.setValueInternal(new LinearGradientPaint(x1, y1, x2, y2, fractions, colors, cyclicMethod));
}
项目:griffon2    文件:LinearGradientPaintPropertyEditor.java   
private Color[] parseColors(Object source, String str) {
    if (!str.startsWith("[") || !str.endsWith("]")) {
        throw illegalValue(source, LinearGradientPaint.class);
    }

    String[] strs = str.substring(1, str.length() - 1).split(":");
    Color[] colors = new Color[strs.length];
    ColorPropertyEditor colorEditor = new ColorPropertyEditor();
    for (int i = 0; i < strs.length; i++) {
        try {
            colorEditor.setValueInternal(strs[i]);
            colors[i] = (Color) colorEditor.getValue();
        } catch (Exception e) {
            throw illegalValue(strs[i], LinearGradientPaint.class);
        }
    }

    return colors;
}