Tabnine Logo
Graphics2D.setPaint
Code IndexAdd Tabnine to your IDE (free)

How to use
setPaint
method
in
java.awt.Graphics2D

Best Java code snippets using java.awt.Graphics2D.setPaint (Showing top 20 results out of 3,726)

Refine searchRefine arrow

  • Graphics2D.fill
  • Graphics2D.setStroke
  • Graphics2D.draw
  • Rectangle2D.Double.<init>
  • GradientPaint.<init>
  • Color.<init>
  • Line2D.Double.<init>
  • ValueAxis.valueToJava2D
  • BasicStroke.<init>
origin: libgdx/libgdx

  protected void paintComponent (Graphics graphics) {
    Graphics2D g = (Graphics2D)graphics;
    int width = getWidth() - 1;
    int height = getHeight() - 1;
    for (int i = 0, n = paletteColors.length - 1; i < n; i++) {
      Color color1 = paletteColors[i];
      Color color2 = paletteColors[i + 1];
      float point1 = i / (float)n * width;
      float point2 = (i + 1) / (float)n * width;
      g.setPaint(new GradientPaint(point1, 0, color1, point2, 0, color2, false));
      g.fillRect((int)point1, 0, (int)Math.ceil(point2 - point1), height);
    }
    g.setPaint(null);
    g.setColor(Color.black);
    g.drawRect(0, 0, width, height);
  }
}
origin: runelite/runelite

private void redrawGradient()
{
  Color primaryRight = Color.getHSBColor(1f - this.selectedY / (float) (size - 1), 1, 1);
  Graphics2D g = image.createGraphics();
  GradientPaint primary = new GradientPaint(
    0f, 0f, Color.WHITE,
    size - 1, 0f, primaryRight);
  GradientPaint shade = new GradientPaint(
    0f, 0f, new Color(0, 0, 0, 0),
    0f, size - 1, Color.BLACK);
  g.setPaint(primary);
  g.fillRect(0, 0, size, size);
  g.setPaint(shade);
  g.fillRect(0, 0, size, size);
  g.dispose();
  forceRedraw = true;
}
origin: libgdx/libgdx

  int point1 = (int)(percent1 * gradientWidth);
  int point2 = (int)Math.ceil(percent2 * gradientWidth);
  g.setPaint(new GradientPaint(point1, 0, color1, point2, 0, color2, false));
  g.fillRect(point1, 0, point2 - point1, gradientHeight);
g.setPaint(null);
g.setColor(Color.black);
g.drawRect(0, 0, gradientWidth, gradientHeight);
origin: org.apache.poi/poi

graphics.setPaint(fillPaint);
Rectangle2D cellAnc = tc.getAnchor();
graphics.fill(cellAnc);
    continue;
  graphics.setStroke(getStroke(stroke));
  Paint linePaint = drawPaint.getPaint(graphics, stroke.getPaint());
  graphics.setPaint(linePaint);
    default:
    case bottom:
      line = new Line2D.Double(x-borderSize, y+h, x+w+borderSize, y+h);
      break;
    case left:
      line = new Line2D.Double(x, y, x, y+h+borderSize);
      break;
    case right:
      line = new Line2D.Double(x+w, y, x+w, y+h+borderSize);
      break;
    case top:
  graphics.draw(line);
origin: magefree/mage

public static void drawRoundedBox(Graphics2D g, int x, int y, int w, int h, int bevel, Paint border, Paint fill) {
  g.setColor(new Color(0, 0, 0, 150));
  g.drawOval(x - 1, y - 1, bevel * 2, h);
  g.setPaint(border);
  g.drawOval(x, y, bevel * 2 - 1, h - 1);
  g.drawOval(x + w - bevel * 2, y, bevel * 2 - 1, h - 1);
  g.drawOval(x + 1, y + 1, bevel * 2 - 3, h - 3);
  g.drawOval(x + 1 + w - bevel * 2, y + 1, bevel * 2 - 3, h - 3);
  g.drawRect(x + bevel, y, w - 2 * bevel, h - 1);
  g.drawRect(x + 1 + bevel, y + 1, w - 2 * bevel - 2, h - 3);
  g.setPaint(fill);
  g.fillOval(x + 2, y + 2, bevel * 2 - 4, h - 4);
  g.fillOval(x + 2 + w - bevel * 2, y + 2, bevel * 2 - 4, h - 4);
  g.fillRect(x + bevel, y + 2, w - 2 * bevel, h - 4);
  g.setPaint(fill);
  g.setColor(abitbrighter(g.getColor()));
  g.drawLine(x + 1 + bevel, y + 1, x + 1 + bevel + w - 2 * bevel - 2, y + 1);
  g.setPaint(fill);
  g.setColor(abitdarker(g.getColor()));
  g.drawLine(x + 1 + bevel, y + h - 2, x + 1 + bevel + w - 2 * bevel - 2, y + h - 2);
}
origin: khuxtable/seaglass

private void paintShapeNode_0_0_0_3(Graphics2D g) {
  Rectangle2D.Double shape3 = new Rectangle2D.Double(6.419553279876709, 2.905667304992676, 6.532177448272705, 4.279702663421631);
  g.setPaint(new Color(183, 206, 243, 255));
  g.fill(shape3);
}
origin: stackoverflow.com

  BufferedImage.TYPE_INT_RGB);
Graphics2D imageGraphics = image.createGraphics();
GradientPaint gp = new GradientPaint(
  20f,
  20f,
  280f,
  Color.orange);
imageGraphics.setPaint(gp);
imageGraphics.fillRect(0, 0, 400, 300);
  BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.createGraphics();
g.setColor(new Color(255, 255, 255, 128));
g.fillRoundRect(
  0,
origin: stackoverflow.com

private Color colorBright = new Color(220,220,220);
private Color colorDark = new Color(150,150,150);
private Color black  = new Color(0,0,0,100);
private Color white = new Color(255,255,255,100);
private Color light = new Color(220,220,220,100);
  int h = thumbBounds.height;
  g2.setPaint( new GradientPaint(x, (int)(y-0.1*h), colorDark , x, (int)(y+1.2*h), light) );
  g2.fillRect( x, y, w, h );
  g2.setPaint( new GradientPaint(x, (int)(y+.65*h), light , x, (int)(y+1.3*h), colorDark) );
  g2.fillRect( x, (int)(y+.65*h), w, (int)(h-.65*h) );
origin: stackoverflow.com

final Color color1 = new Color(230, 255, 255, 0);
final Color color2 = new Color(255, 230, 255, 64);
final Color alphaColor = new Color(200, 200, 230, 64);
final Color color3 = new Color(
  alphaColor.getRed(), alphaColor.getGreen(), alphaColor.getBlue(), 0);
super.paint(g, c);
Graphics2D g2D = (Graphics2D) g;
GradientPaint gradient1 = new GradientPaint(
  0.0F, (float) c.getHeight() / (float) 2, color1, 0.0F, 0.0F, color2);
Rectangle rec1 = new Rectangle(0, 0, c.getWidth(), c.getHeight() / 2);
g2D.setPaint(gradient1);
g2D.fill(rec1);
GradientPaint gradient2 = new GradientPaint(
  0.0F, (float) c.getHeight() / (float) 2, color3, 0.0F, c.getHeight(), color4);
Rectangle rec2 = new Rectangle(0, c.getHeight() / 2, c.getWidth(), c.getHeight());
g2D.setPaint(gradient2);
g2D.fill(rec2);
origin: vert-x3/vertx-examples

public Image(Vertx vertx, String name) {
 try {
  final BufferedImage raster = ImageIO.read(((VertxInternal) vertx).resolveFile(name));
  width = raster.getWidth();
  height = raster.getHeight();
  data = raster.getRGB(0, 0, width, height, null, 0, width);
  for (int pixel : data)
   if (!colorMap.containsKey(pixel)) {
    BufferedImage offlineImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = offlineImage.createGraphics();
    g2.setPaint(new Color(pixel, true));
    g2.fillRect(0, 0, 1, 1);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ImageIO.write(offlineImage, "PNG", out);
    colorMap.put(pixel, Buffer.buffer().appendBytes(out.toByteArray()));
    out.close();
    g2.dispose();
   }
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}
origin: stackoverflow.com

BasicStroke basicStroke = new BasicStroke(2.0f);
public CButton(String txt) {
  super(txt);
protected void paintComponent(Graphics g) {
  Graphics2D g2d = (Graphics2D) g.create();
  g2d.setColor(new Color(0xFFAA00));
  g2d.setStroke(basicStroke);
  Rectangle2D txRect = new Rectangle2D.Double(0, 0, textureImg.getWidth(), textureImg.getHeight());
  TexturePaint txPaint = new TexturePaint(textureImg, txRect);
  g2d.setPaint(txPaint);
                              new Color[] { new Color(0x002AFF),
                              new Color(0x0CAAF9),
                              new Color(0x0CAAF9),
                              new Color(0x002AFF) });
    g2d.setPaint(lgrPaint);
origin: stackoverflow.com

    screenSize.height - taskBarSize - dialog.getHeight());
lpg = new LinearGradientPaint(0, 0, 0, dialog.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)});
dialog.setContentPane(panel);
dialog.setVisible(true);
protected void paintComponent(final Graphics g) {
  final Graphics2D g2d = (Graphics2D) g;
  g2d.setPaint(lpg);
  g2d.fillRect(1, 1, getWidth() - 2, getHeight() - 2);
  g2d.setColor(Color.BLACK);
origin: plantuml/plantuml

final HtmlColor extended = fontConfiguration.getExtendedColor();
if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
  final Rectangle2D.Double area = new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5,
      dimBack.getWidth(), dimBack.getHeight());
  if (extended instanceof HtmlColorGradient) {
    final GradientPaint paint = DriverRectangleG2d.getPaintGradient(x, y, mapper, dimBack.getWidth(),
        dimBack.getHeight(), extended);
    g2d.setPaint(paint);
    g2d.fill(area);
  } else {
    final Color backColor = mapper.getMappedColor(extended);
      g2d.setColor(backColor);
      g2d.setBackground(backColor);
      g2d.fill(area);
  g2d.setStroke(new BasicStroke((float) 1));
  g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos);
  g2d.setStroke(new BasicStroke());
    g2d.setColor(mapper.getMappedColor(extended));
  g2d.setStroke(new BasicStroke((float) 1.5));
  g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos);
  g2d.setStroke(new BasicStroke());
origin: haraldk/TwelveMonkeys

protected static BufferedImage drawSomething(final BufferedImage image) {
  Graphics2D g = image.createGraphics();
  try {
    int width = image.getWidth();
    int height = image.getHeight();
    g.clearRect(0, 0, width, height);
    g.setPaint(new LinearGradientPaint(0, 0, width, 0, new float[] {0.2f, 1}, new Color[] {new Color(0x0, true), Color.BLUE}));
    g.fillRect(0, 0, width, height);
    g.setPaint(new LinearGradientPaint(0, 0, 0, height, new float[] {0.2f, 1}, new Color[] {new Color(0x0, true), Color.RED}));
    g.fillRect(0, 0, width, height);
    g.setPaint(new LinearGradientPaint(0, 0, 0, height, new float[] {0, 1}, new Color[] {new Color(0x00ffffff, true), Color.WHITE}));
    g.fill(new Polygon(new int[] {0, width, width}, new int[] {0, height, 0}, 3));
  }
  finally {
    g.dispose();
  }
  return image;
}

origin: geotools/geotools

      rangeAxis);
} else if (g instanceof LineString) {
  g2.draw(new TranslatedLiteShape(g, dataArea, plot, domainAxis, rangeAxis));
} else {
      Color c = (Color) p;
      p =
          new Color(
              c.getRed() / 255f,
              c.getGreen() / 255f,
              polygonFillOpacity);
    g2.setPaint(p);
    g2.fill(new TranslatedLiteShape(g, dataArea, plot, domainAxis, rangeAxis));
  g2.setPaint(getSeriesPaint(series));
  g2.draw(new TranslatedLiteShape(g, dataArea, plot, domainAxis, rangeAxis));
origin: stackoverflow.com

GradientPaint gp = new GradientPaint(0f, 0f, new Color(127 + random.nextInt(128), 127 + random.nextInt(128), 127 + random.nextInt(128)),
    (float) halfScreenSize.width, (float) halfScreenSize.width, new Color(random.nextInt(128), random.nextInt(128), random.nextInt(128)));
BufferedImage bi = new BufferedImage(halfScreenSize.width, halfScreenSize.height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bi.createGraphics();
g2d.setPaint(gp);
g2d.fillRect(0, 0, halfScreenSize.width, halfScreenSize.height);
g2d.setFont(bigFont);
origin: apache/pdfbox

imageTransform.translate(0, -1);
Paint awtPaint = new TexturePaint(image,
    new Rectangle2D.Double(imageTransform.getTranslateX(), imageTransform.getTranslateY(),
        imageTransform.getScaleX(), imageTransform.getScaleY()));
awtPaint = applySoftMaskToPaint(awtPaint, softMask);
graphics.setPaint(awtPaint);
Rectangle2D unitRect = new Rectangle2D.Float(0, 0, 1, 1);
if (isContentRendered())
  graphics.fill(at.createTransformedShape(unitRect));
origin: stackoverflow.com

g2d.fillRect(0, 0, w, h);
g2d.setComposite(AlphaComposite.Src);
g2d.setPaint(g2d.getBackground());
g2d.fillRect(0, 0, w, h);
renderTime(g2d);
timeG.fillRect(0, 0, w, h);
timeG.setComposite(AlphaComposite.Src);
timeG.setPaint(Color.green);
timeG.drawString(s, 0, fm.getAscent());
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setBackground(new Color(0f, 0f, 0f, 0.3f));
f.setUndecorated(true);
f.add(new Translucent());
origin: plantuml/plantuml

        lastY = y + coord[1];
      } else if (type == USegmentType.SEG_LINETO) {
        final Shape line = new Line2D.Double(lastX, lastY, x + coord[0], y + coord[1]);
        drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor);
        lastX = x + coord[0];
        (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2()));
  g2d.setPaint(paint);
  g2d.fill(p);
} else if (back != null) {
  g2d.setColor(mapper.getMappedColor(back));
  g2d.fill(p);
  g2d.draw(p);
origin: org.apache.poi/poi

@SuppressWarnings("rawtypes")
public void draw(Graphics2D graphics) {
  Dimension pg = shape.getSheet().getSlideShow().getPageSize();
  final Rectangle2D anchor = new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight());
  PlaceableShape<?,?> ps = new PlaceableShape(){
    public ShapeContainer<?,?> getParent() { return null; }
    public Rectangle2D getAnchor() { return anchor; }
    public void setAnchor(Rectangle2D newAnchor) {}
    public double getRotation() { return 0; }
    public void setRotation(double theta) {}
    public void setFlipHorizontal(boolean flip) {}
    public void setFlipVertical(boolean flip) {}
    public boolean getFlipHorizontal() { return false; }
    public boolean getFlipVertical() { return false; }
    public Sheet<?,?> getSheet() { return shape.getSheet(); }
  };
  
  DrawFactory drawFact = DrawFactory.getInstance(graphics);
  DrawPaint dp = drawFact.getPaint(ps);
  Paint fill = dp.getPaint(graphics, getShape().getFillStyle().getPaint());
  Rectangle2D anchor2 = getAnchor(graphics, anchor);
  
  if(fill != null) {
    graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, anchor);
    graphics.setPaint(fill);
    graphics.fill(anchor2);
  }
}

java.awtGraphics2DsetPaint

Popular methods of Graphics2D

  • setColor
  • dispose
  • drawImage
  • setRenderingHint
  • fillRect
  • drawString
  • setFont
  • setStroke
    Sets the Stroke for the Graphics2D context.
  • fill
  • drawLine
  • getFontMetrics
  • draw
  • getFontMetrics,
  • draw,
  • setComposite,
  • translate,
  • drawRect,
  • setTransform,
  • getFontRenderContext,
  • getTransform,
  • setClip

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSharedPreferences (Context)
  • onCreateOptionsMenu (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Notification (javax.management)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Table (org.hibernate.mapping)
    A relational table
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now