Java 类java.awt.GradientPaint 实例源码

项目:VISNode    文件:JNodeConnection.java   
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.translate(-getX(), -getY());
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setColor(Color.BLUE);
    int[] xs = new int[points.length];
    int[] ys = new int[points.length];
    for (int i = 0; i < points.length; i++) {
        xs[i] = points[i].x;
        ys[i] = points[i].y;
    }
    g2d.setColor(UIHelper.getColor("NodeConnection.border"));
    g2d.setStroke(new BasicStroke(3));
    g2d.drawPolyline(xs, ys, points.length);
    g2d.setPaint(new GradientPaint(points[0], UIHelper.getColor("NodeConnection.color1"), points[points.length - 1], UIHelper.getColor("NodeConnection.color2")));
    g2d.setStroke(new BasicStroke(1.5f));
    g2d.drawPolyline(xs, ys, points.length);
    g2d.dispose();
}
项目:incubator-netbeans    文件:BalloonManager.java   
@Override
protected void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g;

    g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );

    Composite oldC = g2d.getComposite();
    Shape s = getMask( getWidth(), getHeight() );

    g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.25f*currentAlpha ) );
    g2d.setColor( Color.black );
    g2d.fill( getShadowMask(s) );

    g2d.setColor( UIManager.getColor( "ToolTip.background" ) ); //NOI18N
    g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, currentAlpha ) );
    Point2D p1 = s.getBounds().getLocation();
    Point2D p2 = new Point2D.Double(p1.getX(), p1.getY()+s.getBounds().getHeight());
    if( isMouseOverEffect )
        g2d.setPaint( new GradientPaint( p2, getMouseOverGradientStartColor(), p1, getMouseOverGradientFinishColor() ) );
    else
        g2d.setPaint( new GradientPaint( p2, getDefaultGradientStartColor(), p1, getDefaultGradientFinishColor() ) );
    g2d.fill(s);
    g2d.setColor( Color.black );
    g2d.draw(s);
    g2d.setComposite( oldC );
}
项目:incubator-netbeans    文件:ContentHeader.java   
@Override
protected void paintComponent( Graphics g ) {
    Graphics2D g2d = ( Graphics2D ) g;
    int width = getWidth();
    int height = getHeight();

    g2d.setColor( Utils.getBorderColor() );
    g2d.drawRect( 0, 0, width, 12 );

    if( UIManager.getBoolean( "nb.startpage.defaultbackground" ) ) { //NOI18N
        g2d.setColor( UIManager.getColor("Tree.background") ); //NOI18N
    } else {
        g2d.setPaint( new GradientPaint( 0, 0, COL_GRADIENT_START, 0, 12, COL_GRADIENT_END ) );
    }
    g2d.fillRect( 1, 0, width-2, 12 );

    int imgWidth = IMG_BANNER.getWidth( this );
    int imgX = (width - imgWidth)/2;
    g2d.drawImage( IMG_BANNER, imgX, 13, imgWidth, height-13, this );
    if( imgX > 0 ) {
        g2d.setPaint( COL_BANNER_LEFT );
        g2d.fillRect( 0, 13, imgX, height-13 );
        g2d.setPaint( COL_BANNER_RIGHT );
        g2d.fillRect( width-imgX-1, 13, imgX+1, height-13 );
    }
}
项目:incubator-netbeans    文件:BalloonManager.java   
@Override
protected void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g;

    g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );

    Composite oldC = g2d.getComposite();
    Shape s = getMask( getWidth(), getHeight() );

    g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.25f*currentAlpha ) );
    g2d.setColor( Color.black );
    g2d.fill( getShadowMask(s) );

    g2d.setColor( UIManager.getColor( "ToolTip.background" ) ); //NOI18N
    g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, currentAlpha ) );
    Point2D p1 = s.getBounds().getLocation();
    Point2D p2 = new Point2D.Double(p1.getX(), p1.getY()+s.getBounds().getHeight());
    if( isMouseOverEffect )
        g2d.setPaint( new GradientPaint( p2, getMouseOverGradientStartColor(), p1, getMouseOverGradientFinishColor() ) );
    else
        g2d.setPaint( new GradientPaint( p2, getDefaultGradientStartColor(), p1, getDefaultGradientFinishColor() ) );
    g2d.fill(s);
    g2d.setColor( Color.black );
    g2d.draw(s);
    g2d.setComposite( oldC );
}
项目:incubator-netbeans    文件:HeapView.java   
/**
 * Paints the grid on top of the ticks.
 */
private void paintGridOverlay(Graphics2D g, int w, int h) {
    int numCells = GRID_COLORS.length / 2;
    int cellSize = (h - numCells - 1) / numCells;
    int c1 = 0xD0CCBC;
    int c2 = 0xEAE7D7;
    g.setPaint(new GradientPaint(
            0, 0, new Color((c1 >> 16) & 0xFF, (c1 >> 8) & 0xFF, c1 & 0xFF, 0x30),
            0, h, new Color((c2 >> 16) & 0xFF, (c2 >> 8) & 0xFF, c2 & 0xFF, 0x40)));
    for (int x = 0; x < w; x += cellSize + 1) {
        g.fillRect(x, 0, 1, h);
    }
    for (int y = h - cellSize - 1; y >= 0; y -= (cellSize + 1)) {
        g.fillRect(0, y, w, 1);
    }
}
项目:incubator-netbeans    文件:HeapView.java   
private void paintBackgroundTiles(Graphics2D g, int w, int h) {
    g.translate(1, 2);
    w -= BORDER_W;
    h -= BORDER_H;
    int numCells = GRID_COLORS.length / 2;
    int cellSize = (h - numCells - 1) / numCells;
    for (int i = 0; i < numCells; i++) {
        int colorIndex = i;
        int y = h - cellSize * (i + 1) - i;
        int x = 1;
        g.setPaint(new GradientPaint(0, y, GRID_COLORS[colorIndex * 2],
                0, y + cellSize - 1, GRID_COLORS[colorIndex * 2 + 1]));
        while (x < w) {
            int endX = Math.min(w, x + cellSize);
            g.fillRect(x, y, endX - x, cellSize);
            x = endX + 1;
        }
        y += cellSize + 1;
    }
    g.translate(-1, -2);
}
项目:rapidminer    文件:TableHeaderUI.java   
@Override
public void paint(Graphics g) {
    int h = this.getHeight();
    int w = this.getWidth();

    Graphics2D g2 = (Graphics2D) g;
    if (this.isPressed) {
        g2.setColor(Colors.TABLE_HEADER_BACKGROUND_PRESSED);
    } else {
        if (this.rollOver) {
            g2.setColor(Colors.TABLE_HEADER_BACKGROUND_FOCUS);
        } else {
            Paint gp = new GradientPaint(0, 0, Colors.TABLE_HEADER_BACKGROUND_GRADIENT_START, 0, h,
                    Colors.TABLE_HEADER_BACKGROUND_GRADIENT_END);
            g2.setPaint(gp);
        }
    }

    g2.fill(createHeaderShape(0, 0, w, h, isLeftmost, isRightmost));
    g2.setColor(Colors.TABLE_HEADER_BORDER);
    g2.draw(createHeaderShape(0, 0, w, h, isLeftmost, isRightmost));

    super.paint(g);
}
项目:brModelo    文件:baseDrawerFromForma.java   
protected void PaintGradiente(Graphics2D g) { //, boolean round) {
    int dist = 0;
    DimensioneParaPintura();
    W -= dist;
    H -= dist;
    boolean dv = getGDirecao() == VERTICAL;

    int type = AlphaComposite.SRC_OVER;

    g.setComposite(AlphaComposite.getInstance(type, alfa));

    GradientPaint GP = new GradientPaint(L, T, getGradienteStartColor(), dv ? L : L + W, dv ? T + H : T, getGradienteEndColor(), true);
    g.setPaint(GP);

    if (roundrect > 0 && isPintarBorda()) {
        g.fillRoundRect(L + 1, T + 1, W, H, roundrect, roundrect);
    } else {
        g.fillRect(L + 1, T + 1, W, H);
    }
}
项目:parabuild-ci    文件:WaterfallBarRenderer.java   
/**
 * Constructs a new renderer with default values for the bar colors.
 */
public WaterfallBarRenderer() {
    this(
        new GradientPaint(
            0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 
            0.0f, 0.0f, new Color(0x66, 0x66, 0xFF)
        ), 
        new GradientPaint(
            0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 
            0.0f, 0.0f, new Color(0x66, 0xFF, 0x66)
        ), 
        new GradientPaint(
            0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 
            0.0f, 0.0f, new Color(0xFF, 0x66, 0x66)
        ),
        new GradientPaint(
            0.0f, 0.0f, new Color(0xFF, 0xFF, 0x22), 
            0.0f, 0.0f, new Color(0xFF, 0xFF, 0x66)
        )
    );
}
项目:JavaPPTX    文件:PPWindowImage.java   
private void drawTitleBar(Graphics2D g) {
   Graphics2D g2 = (Graphics2D) g.create();
   RoundRectangle2D titleBar = createTitleBarShape();
   double h = SF * (TITLE_BAR_HEIGHT + CORNER_RADIUS) + 1;
   g2.setPaint(new GradientPaint(0, 0, grayColor(GRAY_TOP),
                                 0, (float) h, grayColor(GRAY_BOTTOM)));
   g2.fill(titleBar);
   g2.setColor(Color.DARK_GRAY);
   g2.draw(titleBar);
   g2.setColor(Color.BLACK);
   int scaledSize = (int) Math.round(SF * TITLE_FONT_SIZE);
   g2.setFont(Font.decode(TITLE_FONT_FAMILY + "-" + scaledSize));
   FontMetrics fm = g2.getFontMetrics();
   int x = (int) Math.round((sw - fm.stringWidth(title)) / 2);
   int y = (int) Math.round(SF * (TITLE_BAR_HEIGHT / 2 + TITLE_DY));
   g2.drawString(title, x, y);
   drawBall(g2, RED_BALL, 0);
   drawBall(g2, AMBER_BALL, 1);
   drawBall(g2, GREEN_BALL, 2);
   g2.dispose();
}
项目:dead-code-detector    文件:DeadCodeDetectorUI.java   
/** {@inheritDoc} */
@Override
protected void paintComponent(Graphics graphics) {
    // Surchargée pour dessiner le fond avec gradient
    final LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
    final String lafName = lookAndFeel != null ? lookAndFeel.getName() : null;
    if ("Substance".equals(lafName)) {
        super.paintComponent(graphics); // le gradient fonctionne mal en substance ?
    }

    final Color startColor = getBackground();
    final Color endColor = GRADIENT_COLOR;
    final int w = getWidth();
    final int h = getHeight();

    // l'image du gradient pourrait être mise en cache, mais ce n'est pas grave
    final Paint paint = new GradientPaint(0, h / 2f, startColor, 1, h, endColor, false);
    final Graphics2D graphix = (Graphics2D) graphics.create();
    graphix.setPaint(paint);
    graphix.fillRect(0, 0, w, h);
    graphix.dispose();
}
项目:Tarski    文件:mxLabelShape.java   
/**
 * Draws the glass effect
 */
public static void drawGlassEffect(mxGraphics2DCanvas canvas, mxCellState state) {
  double size = 0.4;
  canvas.getGraphics()
      .setPaint(new GradientPaint((float) state.getX(), (float) state.getY(),
          new Color(1, 1, 1, 0.9f), (float) (state.getX()),
          (float) (state.getY() + state.getHeight() * size), new Color(1, 1, 1, 0.3f)));

  float sw = (float) (mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1)
      * canvas.getScale() / 2);

  GeneralPath path = new GeneralPath();
  path.moveTo((float) state.getX() - sw, (float) state.getY() - sw);
  path.lineTo((float) state.getX() - sw, (float) (state.getY() + state.getHeight() * size));
  path.quadTo((float) (state.getX() + state.getWidth() * 0.5),
      (float) (state.getY() + state.getHeight() * 0.7),
      (float) (state.getX() + state.getWidth() + sw),
      (float) (state.getY() + state.getHeight() * size));
  path.lineTo((float) (state.getX() + state.getWidth() + sw), (float) state.getY() - sw);
  path.closePath();

  canvas.getGraphics().fill(path);
}
项目:QN-ACTR-Release    文件:QueueDrawer.java   
private void drawUtilizationMulti(double U, Color startC, Color border, boolean gradientFill, Graphics2D g2d, int cpu) {

        double x = getProcessorXY().x, y = getProcessorXY().y;
        try {
            occupiedRect = new Rectangle2D.Double(x + PROC_RAD / 2 + ELEMS_GAP / 2, y + cpu * (PROC_RAD - ELEMS_GAP) + ELEMS_GAP * cpu * 3
                    - ELEMS_GAP / 2, PROC_RAD - ELEMS_GAP, (PROC_RAD - ELEMS_GAP) * (1 - U / nCpu));
        } catch (Exception e) {
            occupiedRect = new Rectangle2D.Double(x + PROC_RAD / 2 + ELEMS_GAP / 2, y + cpu * (PROC_RAD - ELEMS_GAP) + ELEMS_GAP * cpu * 3
                    - ELEMS_GAP / 2, PROC_RAD - ELEMS_GAP, 0);
        }
        occupiedEll = new Ellipse2D.Double(x + PROC_RAD / 2 + ELEMS_GAP / 2, y + cpu * (PROC_RAD - ELEMS_GAP) + ELEMS_GAP * cpu * 3 - ELEMS_GAP / 2,
                PROC_RAD - ELEMS_GAP, PROC_RAD - ELEMS_GAP);
        if (gradientFill) {
            GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + 2 * PROC_RAD), startC.darker(),
                    false);
            g2d.setPaint(gp);
        } else {
            g2d.setPaint(startC);
        }
        occupiedArea = new Area(occupiedEll);
        occupiedArea.subtract(new Area(occupiedRect));
        g2d.fill(occupiedArea);
        g2d.setPaint(Color.BLACK);
        g2d.draw(occupiedArea);

    }
项目:batmapper    文件:ExitPaintTransformer.java   
public Paint transform( Exit exit ) {
    Layout<Room, Exit> layout = vv.getGraphLayout();
    Pair<Room> pair = layout.getGraph().getEndpoints( exit );
    Room begin = pair.getFirst();
    Room end = pair.getSecond();
    Point2D beginPoint = transformer.transform( layout.transform( begin ) );
    Point2D endPoint = transformer.transform( layout.transform( end ) );
    float xFirst = (float) beginPoint.getX();
    float yFirst = (float) beginPoint.getY();
    float xEnd = (float) endPoint.getX();
    float yEnd = (float) endPoint.getY();

    if (selfLoop.evaluate( Context.<Graph<Room, Exit>, Exit>getInstance( layout.getGraph(), exit ) )) {
        xEnd += 50;
        yEnd += 50;
    }

    return new GradientPaint( xFirst, yFirst, getColorFor( begin ), xEnd, yEnd, getColorFor( end ), true );
}
项目:DicomViewer    文件:SliderComponent.java   
@Override
protected void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    int cursorX = valueToPosition(value);

    GradientPaint gradient = new GradientPaint(0, 0, colorLimitMin, sliderWidth(), 0, colorLimitMax, true);

    // slider
    g2.setPaint(gradient);
    fillSlider(g2);
    g2.setColor(Color.black);
    drawSlider(g2);

    // cursor
    Color fillColor = ColorTools.gradiant(colorLimitMin, colorLimitMax, valueAsCoef(value));
    drawCursor(g2, fillColor, Color.black, cursorX);

    if (drawValue) {
       // final String valueAsString = getValueAsString(); //Float.toString(Math.round(value * 10) / 10f);
        printStringOnCursor(g2, getValueAsString(), cursorX, true);
    }
}
项目:parabuild-ci    文件:WaterfallBarRenderer.java   
/**
 * Constructs a new renderer with default values for the bar colors.
 */
public WaterfallBarRenderer() {
    this(
        new GradientPaint(
            0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x66, 0x66, 0xFF)
        ), 
        new GradientPaint(
            0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x66, 0xFF, 0x66)
        ), 
        new GradientPaint(
            0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x66, 0x66)
        ),
        new GradientPaint(
            0.0f, 0.0f, new Color(0xFF, 0xFF, 0x22), 0.0f, 0.0f, new Color(0xFF, 0xFF, 0x66)
        )
    );
}
项目:openjdk-jdk10    文件:TSFrame.java   
private static void render(Graphics g, int w, int h, boolean useNonOpaque) {
    if (useNonOpaque) {
        Graphics2D g2d = (Graphics2D)g;
        GradientPaint p =
            new GradientPaint(0.0f, 0.0f,
                              new Color(rnd.nextInt(0xffffff)),
                              w, h,
                              new Color(rnd.nextInt(0xff),
                                        rnd.nextInt(0xff),
                                        rnd.nextInt(0xff), 0),
                              true);
        g2d.setPaint(p);
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.fillOval(0, 0, w, h);
    } else {
        g.setColor(new Color(rnd.nextInt(0xffffff)));
        g.fillRect(0, 0, w, h);
    }
}
项目:cuttlefish    文件:PluggableRendererDemo.java   
public Paint getFillPaint(Vertex v)
{
    float alpha = transparency.getNumber(v).floatValue();
    if (pi.isPicked(v))
    {
        return new Color(1f, 1f, 0, alpha); 
    }
    else
    {
        if (seed_coloring && v.containsUserDatumKey(BarabasiAlbertGenerator.SEED))
        {
            Color dark = new Color(0, 0, dark_value, alpha);
            Color light = new Color(0, 0, light_value, alpha);
            return new GradientPaint( 0, 0, dark, 10, 0, light, true);
        }
        else
            return new Color(1f, 0, 0, alpha);
    }

}
项目:parabuild-ci    文件:StackedXYAreaRendererTests.java   
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    StackedXYAreaRenderer r1 = new StackedXYAreaRenderer();
    StackedXYAreaRenderer r2 = new StackedXYAreaRenderer();
    assertEquals(r1, r2);
    assertEquals(r2, r1);

    r1.setShapePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 
            3.0f, 4.0f, Color.green));
    assertFalse(r1.equals(r2));
    r2.setShapePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 
            3.0f, 4.0f, Color.green));
    assertTrue(r1.equals(r2));

    Stroke s = new BasicStroke(1.23f);
    r1.setShapeStroke(s);
    assertFalse(r1.equals(r2));
    r2.setShapeStroke(s);
    assertTrue(r1.equals(r2)); 
}
项目:parabuild-ci    文件:BoxAndWhiskerRendererTests.java   
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer();
    BoxAndWhiskerRenderer r2 = new BoxAndWhiskerRenderer();
    assertEquals(r1, r2);

    r1.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 
            3.0f, 4.0f, Color.blue));
    assertFalse(r1.equals(r2));
    r2.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 
            3.0f, 4.0f, Color.blue));
    assertEquals(r1, r2);

    r1.setFillBox(!r1.getFillBox());
    assertFalse(r1.equals(r2));
    r2.setFillBox(!r2.getFillBox());
    assertEquals(r1, r2);

    r1.setItemMargin(0.11);
    assertFalse(r1.equals(r2));
    r2.setItemMargin(0.11);
    assertEquals(r1, r2);

}
项目:parabuild-ci    文件:LineRenderer3DTests.java   
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    LineRenderer3D r1 = new LineRenderer3D();
    LineRenderer3D r2 = new LineRenderer3D();
    assertEquals(r1, r2);

    r1.setXOffset(99.9);
    assertFalse(r1.equals(r2));
    r2.setXOffset(99.9);
    assertTrue(r1.equals(r2));

    r1.setYOffset(111.1);
    assertFalse(r1.equals(r2));
    r2.setYOffset(111.1);
    assertTrue(r1.equals(r2));

    r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, 
            Color.blue));
    assertFalse(r1.equals(r2));
    r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, 
            Color.blue));
    assertTrue(r1.equals(r2));
}
项目:trashjam2017    文件:GradientEffect.java   
/**
 * @see org.newdawn.slick.font.effects.Effect#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, org.newdawn.slick.UnicodeFont, org.newdawn.slick.font.Glyph)
 */
public void draw(BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) {
    int ascent = unicodeFont.getAscent();
    float height = (ascent) * scale;
    float top = -glyph.getYOffset() + unicodeFont.getDescent() + offset + ascent / 2 - height / 2;
    g.setPaint(new GradientPaint(0, top, topColor, 0, top + height, bottomColor, cyclic));
    g.fill(glyph.getShape());
}
项目:litiengine    文件:Appearance.java   
public Paint getBackgroundPaint(double width, double height) {
  if (this.isTransparentBackground()) {
    return null;
  }

  if (this.backgroundColor2 == null) {
    return this.backgroundColor1;
  }

  if (this.horizontalBackgroundGradient) {
    return new GradientPaint(0, 0, this.backgroundColor1, (float) (width / 2.0), 0, this.backgroundColor2);
  } else {
    return new GradientPaint(0, 0, this.backgroundColor1, 0, (float) (height / 2.0), this.backgroundColor2);
  }
}
项目:incubator-netbeans    文件:RendererPanel.java   
@Override
public void paintComponent(Graphics g) {
    if (isRoot && colorManager.isAqua() && node.isExpandable() && node.isRenderedWithGradient()) {
        Graphics2D g2d = (Graphics2D) g;
        Paint oldPaint = g2d.getPaint();
        g2d.setPaint(new GradientPaint(0, 0, Color.white, 0, getHeight() / 2, getBackground()));
        g2d.fillRect(0, 0, getWidth(), getHeight());
        g2d.setPaint(oldPaint);
    } else {
        super.paintComponent(g);
    }
}
项目:jdk8u-jdk    文件:TransformedPaintTest.java   
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;
}
项目:brModelo    文件:LivreTriangulo.java   
@Override
protected void PinteRegiao(Graphics2D g) {
    Composite originalComposite = g.getComposite();
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alfa));
    g.setPaint(this.getForeColor());

    if (isGradiente()) {
        int dist = 0;
        int w = getWidth() - dist;
        int h = getHeight() - dist;
        int L = getLeft();
        int T = getTop();
        boolean dv = getGDirecao() == VERTICAL;

        GradientPaint GP = new GradientPaint(L, T, getGradienteStartColor(), dv ? L : L + w, dv ? T + h : T, getGradienteEndColor(), true);
        g.setPaint(GP);
    }

    Stroke bkp = g.getStroke();
    if (isDashed()) {
        g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{1, 2}, 0));
    }
    if (isGradiente()) {
        g.fill(getRegiao());
    }
    g.draw(getRegiao()); //Pinta as eventuais linhas internas do dezenho. Ex. LivreVariosDocumemtos 

    g.setStroke(bkp);
    g.setComposite(originalComposite);
}
项目:incubator-netbeans    文件:XYBackground.java   
public void paint(Graphics2D g, Rectangle dirtyArea, ChartContext context) {
    if (Utils.forceSpeed()) g.setPaint(GRADIENT_BOTTOM);
    else g.setPaint(new GradientPaint(
                    new Point(0, Utils.checkedInt(context.getViewportOffsetY())),
                    GRADIENT_TOP,
                    new Point(0, context.getViewportHeight()),
                    GRADIENT_BOTTOM));
    g.fill(dirtyArea);
}
项目:jdk8u-jdk    文件:SunGraphics2D.java   
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
项目:sbc-qsystem    文件:QPanel.java   
private void DrawRectangleGradient(Graphics2D g2, int w, int h) {
    /* RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g2.setRenderingHints(qualityHints); */
    GradientPaint gradient = new GradientPaint(startPoint.x, startPoint.y, startColor,
        endPoint.x,
        endPoint.y, endColor, cycleFillGradient);
    g2.setPaint(gradient);
    g2.fillRect(0, 0, w, h);

    //  RoundGradientPaint rgp = new RoundGradientPaint(w/2, h/2, startColor, new Point2D.Double(w, h),endColor);
    //  g2.setPaint(rgp);
    //  g2.fillRect(0,0,w,h);
}
项目:rapidminer    文件:TabbedPaneUI.java   
private static void paintSelectedRight(Graphics g, int x, int y, int w, int h) {
    g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[2]);
    g.drawLine(x, y + 1, x + w - 11, y + 1);

    g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[3]);
    g.drawLine(x, y, x + w - 15, y);

    ColorUIResource c1 = RapidLookTools.getColors().getTabbedPaneColors()[4];
    g.setColor(c1);

    g.drawLine(w + x - 10, y + 1, w + x - 10, y + 2);
    g.drawLine(w + x - 9, y + 2, w + x - 9, y + 2);
    g.drawLine(w + x - 8, y + 2, w + x - 8, y + 3);
    g.drawLine(w + x - 7, y + 3, w + x - 7, y + 4);
    g.drawLine(w + x - 6, y + 4, w + x - 6, y + 5);

    g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[5]);

    g.drawLine(x, y + 2, x + w - 11, y + 2);
    g.drawLine(x, y + 3, x + w - 9, y + 3);
    g.drawLine(x, y + 4, x + w - 8, y + 4);
    g.drawLine(x, y + 5, x + w - 7, y + 5);

    Graphics2D g2 = (Graphics2D) g;
    g2.setPaint(new GradientPaint(1, y + 6, RapidLookTools.getColors().getTabbedPaneColors()[6], 1, y + h,
            RapidLookTools.getColors().getTabbedPaneColors()[7]));

    int[] xArr = new int[] { x + 4, w + x - 5, w + x - 5, x + 4 };
    int[] yArr = new int[] { y + 6, y + 6, y + h, y + h };
    Polygon p1 = new Polygon(xArr, yArr, 4);

    g2.fillPolygon(p1);

    g.setColor(c1);
    g.drawLine(w + x - 5, y + 6, x + w - 5, y + h - 1);

    g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[1]);
    g.drawLine(x + w - 14, y, x + w - 12, y);
    g.drawLine(w + x - 6, y + 6, x + w - 6, y + 6);
}
项目:rapidminer    文件:MenuBarBackgroundPainter.java   
@Override
protected void paintToImage(Component c, Graphics g, int w, int h, Object[] args) {
    g.setColor(new ColorUIResource(252, 252, 252));
    g.fillRect(0, 0, w, 3);

    Graphics2D g2 = (Graphics2D) g;
    g2.setPaint(new GradientPaint(0, 3, new ColorUIResource(252, 252, 252), 0, h - 3, new ColorUIResource(232, 232, 232)));
    g2.fillRect(0, 3, w, h - 3);
}
项目:rapidminer    文件:ProcessDrawUtils.java   
/**
 * Draws a shadow around the given rectangle.
 *
 * @param rect
 *            the rectangle which should get a shadow
 * @param g2
 *            the graphics context to draw the shadow on
 */
public static void drawShadow(final Rectangle2D rect, final Graphics2D g2) {
    Graphics2D g2S = (Graphics2D) g2.create();

    Rectangle2D shadow = new Rectangle2D.Double(rect.getX() + 5, rect.getY() + ProcessDrawer.HEADER_HEIGHT + 5,
            rect.getWidth(), rect.getHeight() - ProcessDrawer.HEADER_HEIGHT);
    GeneralPath bottom = new GeneralPath();
    bottom.moveTo(shadow.getX(), rect.getMaxY());
    bottom.lineTo(rect.getMaxX(), rect.getMaxY());
    bottom.lineTo(shadow.getMaxX(), shadow.getMaxY());
    bottom.lineTo(shadow.getMinX(), shadow.getMaxY());
    bottom.closePath();
    g2S.setPaint(new GradientPaint((float) rect.getX(), (float) rect.getMaxY(), Color.gray, (float) rect.getX(),
            (float) shadow.getMaxY(), TRANSPARENT_GRAY));
    g2S.fill(bottom);

    GeneralPath right = new GeneralPath();
    right.moveTo(rect.getMaxX(), shadow.getMinY());
    right.lineTo(shadow.getMaxX(), shadow.getMinY());
    right.lineTo(shadow.getMaxX(), shadow.getMaxY());
    right.lineTo(rect.getMaxX(), rect.getMaxY());
    right.closePath();
    g2S.setPaint(new GradientPaint((float) rect.getMaxX(), (float) shadow.getY(), Color.gray, (float) shadow.getMaxX(),
            (float) shadow.getY(), TRANSPARENT_GRAY));
    g2S.fill(right);

    g2S.dispose();
}
项目:rapidminer    文件:AnnotationDrawer.java   
/**
 * Draws indicator in case the annotation text overflows on the y axis.
 *
 * @param anno
 *            the annotation
 * @param g
 *            the graphics context to draw upon
 * @param loc
 *            the location of the annotation
 * @param printing
 *            if we are currently printing
 */
private void drawOverflowIndicator(final WorkflowAnnotation anno, final Graphics2D g, final Rectangle2D loc,
        final boolean printing) {
    if (printing) {
        // never draw them for printing
        return;
    }
    Graphics2D g2 = (Graphics2D) g.create();

    int size = 20;
    int xOffset = 10;
    int yOffset = 10;
    int stepSize = size / 4;
    int dotSize = 3;
    int x = (int) loc.getMaxX() - size - xOffset;
    int y = (int) loc.getMaxY() - size - yOffset;
    GradientPaint gp = new GradientPaint(x, y, Color.WHITE, x, y + size * 1.5f, Color.LIGHT_GRAY);
    g2.setPaint(gp);
    g2.fillRect(x, y, size, size);

    g2.setColor(Color.BLACK);
    g2.drawRect(x, y, size, size);

    g2.fillOval(x + stepSize, y + stepSize * 2, dotSize, dotSize);
    g2.fillOval(x + stepSize * 2, y + stepSize * 2, dotSize, dotSize);
    g2.fillOval(x + stepSize * 3, y + stepSize * 2, dotSize, dotSize);

    g2.dispose();
}
项目:jmt    文件:QueueDrawer.java   
private void drawProcessor(Color startC, Color border, boolean gradientFill, Graphics2D g2d) {
    double x = getProcessorXY().x, y = getProcessorXY().y;
    processor.setFrame(x, y, 2 * PROC_RAD, 2 * PROC_RAD);
    if (gradientFill) {
        GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + PROC_RAD * 2), startC.darker(),
                false);
        g2d.setPaint(gp);
    } else {
        g2d.setPaint(startC);
    }
    g2d.fill(processor);
    g2d.setPaint(border);
    g2d.draw(processor);
}
项目:jmt    文件:QueueDrawer.java   
private void drawProcessor2(Color startC, Color border, boolean gradientFill, Graphics2D g2d, int cpu) {
    double x = getProcessorXY().x, y = getProcessorXY().y;
    processor.setFrame(x + PROC_RAD / 2, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2, PROC_RAD, PROC_RAD);
    if (gradientFill) {
        GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + PROC_RAD * 2), startC.darker(),
                false);
        g2d.setPaint(gp);
    } else {
        g2d.setPaint(startC);
    }
    g2d.fill(processor);
    g2d.setPaint(border);
    g2d.draw(processor);
}
项目:jmt    文件:QueueDrawer.java   
private void drawProcessorMulti(Color startC, Color border, boolean gradientFill, Graphics2D g2d, int cpu) {
    double x = getProcessorXY().x, y = getProcessorXY().y;
    processor.setFrame(x + PROC_RAD / 2 + ELEMS_GAP / 2, y + cpu * (PROC_RAD - ELEMS_GAP) + ELEMS_GAP * cpu * 3 - ELEMS_GAP / 2, PROC_RAD
            - ELEMS_GAP, PROC_RAD - ELEMS_GAP);
    if (gradientFill) {
        GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + PROC_RAD * 2), startC.darker(),
                false);
        g2d.setPaint(gp);
    } else {
        g2d.setPaint(startC);
    }
    g2d.fill(processor);
    g2d.setPaint(border);
    g2d.draw(processor);
}
项目:jmt    文件:QueueDrawer.java   
private void drawPoint(Color startC, Color border, boolean gradientFill, Graphics2D g2d, int point) {
    double x = getProcessorXY().x, y = getProcessorXY().y;
    processor.setFrame(x + PROC_RAD, y + PROC_RAD - ELEMS_GAP / 2 + ELEMS_GAP * point, 0.5, 0.5);
    if (gradientFill) {
        GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + PROC_RAD * 2), startC.darker(),
                false);
        g2d.setPaint(gp);
    } else {
        g2d.setPaint(startC);
    }
    g2d.fill(processor);
    g2d.setPaint(border);
    g2d.draw(processor);
}
项目:jmt    文件:QueueDrawer.java   
private void drawUtilization(double U, Color startC, Color border, boolean gradientFill, Graphics2D g2d) {

        double x = getProcessorXY().x, y = getProcessorXY().y;
        try {
            occupiedRect = new Rectangle2D.Double(x, y, 2 * PROC_RAD, 2 * PROC_RAD * (1 - U));
        } catch (Exception e) {
            occupiedRect = new Rectangle2D.Double(x, y, 2 * PROC_RAD, 0.0);
        }
        occupiedEll = new Ellipse2D.Double(x, y, 2 * PROC_RAD, 2 * PROC_RAD);
        if (gradientFill) {
            GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + 2 * PROC_RAD), startC.darker(),
                    false);
            g2d.setPaint(gp);
        } else {
            g2d.setPaint(startC);
        }
        occupiedArea = new Area(occupiedEll);
        occupiedArea.subtract(new Area(occupiedRect));
        g2d.fill(occupiedArea);
        g2d.setPaint(Color.BLACK);
        g2d.draw(occupiedArea);

        // //draw informations about processes
        // txtBounds = drawCenteredText("job n.:" + donejobs, Color.BLACK, x +
        // PROC_RAD,y + PROC_RAD * 2 + 4 * ELEMS_GAP,g2d, false);
        // //draw orizontal line parallel to occupation
        //          
        // //draw box around text
        // txtBounds.setFrame(
        // x + PROC_RAD - txtBounds.getWidth() / 2,
        // y + 2 * PROC_RAD + 4 * ELEMS_GAP - txtBounds.getHeight() / 2,
        // txtBounds.getWidth(),
        // txtBounds.getHeight());
        //          
        // g2d.draw(txtBounds);
    }
项目:Mujeed-Arabic-Prolog    文件:AquaBarTabbedPaneUI.java   
protected void paintTabBackground(Graphics g, int tabPlacement,
        int tabIndex, int x, int y, int w, int h, boolean isSelected) {
    Graphics2D g2d = (Graphics2D) g;
    ColorSet colorSet;

    Rectangle rect = rects[tabIndex];

    if (isSelected) {
        colorSet = selectedColorSet;
    } else if (getRolloverTab() == tabIndex) {
        colorSet = hoverColorSet;
    } else {
        colorSet = defaultColorSet;
    }

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);

    int width = rect.width;
    int xpos = rect.x;
    if (tabIndex > 0) {
        width--;
        xpos++;
    }

    g2d.setPaint(new GradientPaint(xpos, 0, colorSet.topGradColor1, xpos,
            10, colorSet.topGradColor2));
    g2d.fillRect(xpos, 0, width, 10);

    g2d.setPaint(new GradientPaint(0, 10, colorSet.bottomGradColor1, 0, 21,
            colorSet.bottomGradColor2));
    g2d.fillRect(xpos, 10, width, 11);

    if (contentTopBorderDrawn) {
        g2d.setColor(lineColor);
        g2d.drawLine(rect.x, 20, rect.x + rect.width - 1, 20);
    }
}
项目:jmt    文件:QueueDrawer.java   
private void drawOccupiedPercentage2(Color startC, Color border, boolean gradientFill, Graphics2D g2d, int cpu) {
    //processor.setFrame(x+PROC_RAD/2 , y + cpu*PROC_RAD, 2 * PROC_RAD /2, 2 * PROC_RAD /2);

    //      if (remainingTime[cpu] != 0) {
    double x = getProcessorXY().x, y = getProcessorXY().y;
    occupiedRect = new Rectangle2D.Double(x + PROC_RAD / 2, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2, 2 * PROC_RAD / 2, 2 * PROC_RAD
            * (1 - (double) remainingTime[cpu] / (double) totTime[cpu]) / 2);
    occupiedEll = new Ellipse2D.Double(x + PROC_RAD / 2, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2, 2 * PROC_RAD / 2, 2 * PROC_RAD / 2);
    if (gradientFill) {
        GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + 2 * PROC_RAD), startC.darker(),
                false);
        g2d.setPaint(gp);
    } else {
        g2d.setPaint(startC);
    }
    occupiedArea = new Area(occupiedEll);
    occupiedArea.subtract(new Area(occupiedRect));
    g2d.fill(occupiedArea);
    g2d.setPaint(Color.BLACK);
    g2d.draw(occupiedArea);

    // draw orizontal line parallel to occupation
    Line2D.Double l = new Line2D.Double(x + PROC_RAD * 2 + ELEMS_GAP, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2 + 2 * PROC_RAD
            * (1 - (double) remainingTime[cpu] / (double) totTime[cpu]) / 2,//y + PROC_RAD * 2 * (1 - (double) remainingTime / (double) totTime) /2 + ELEMS_GAP * cpu -  ELEMS_GAP /2  , 
            x + PROC_RAD * 2 + 2 * ELEMS_GAP, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2 + 2 * PROC_RAD
                    * (1 - (double) remainingTime[cpu] / (double) totTime[cpu]) / 2);//y + PROC_RAD * 2 * (1 - (double) remainingTime / (double) totTime) /2 + ELEMS_GAP * cpu -  ELEMS_GAP /2 );
    g2d.draw(l);

    // draw vertical line
    l = new Line2D.Double(x + PROC_RAD * 2 + 2 * ELEMS_GAP, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2 + 2 * PROC_RAD
            * (1 - (double) remainingTime[cpu] / (double) totTime[cpu]) / 2, x + PROC_RAD * 2 + 2 * ELEMS_GAP, y + PROC_RAD * 2 / 2 + cpu
            * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2);
    g2d.draw(l);

    //      }
}