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

How to use
draw
method
in
java.awt.Graphics2D

Best Java code snippets using java.awt.Graphics2D.draw (Showing top 20 results out of 6,435)

Refine searchRefine arrow

  • Graphics2D.setStroke
  • Graphics2D.fill
  • Graphics2D.setPaint
  • BasicStroke.<init>
  • Graphics2D.setColor
  • Line2D.Double.<init>
  • Rectangle2D.Double.<init>
origin: plantuml/plantuml

public void drawDebug(Graphics2D g2d) {
  for (Line2D r : linesForInters) {
    g2d.setColor(color);
    g2d.draw(r);
  }
  g2d.setColor(Color.BLACK);
  // g2d.draw(curve);
}
origin: runelite/runelite

  private void renderPoly(Graphics2D graphics, Color color, Polygon polygon)
  {
    if (polygon != null)
    {
      graphics.setColor(color);
      graphics.setStroke(new BasicStroke(2));
      graphics.draw(polygon);
      graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
      graphics.fill(polygon);
    }
  }
}
origin: plantuml/plantuml

public void draw(Graphics2D g2d) {
  g2d.setStroke(new BasicStroke((float) 1.5));
  g2d.draw(curve);
  g2d.setStroke(new BasicStroke());
}
origin: plantuml/plantuml

g2.setColor(Color.white);
g2.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND));
 new BasicStroke(
  strokeWeight,
 new BasicStroke(
  strokeWeight,
  BasicStroke.CAP_BUTT,
g2.setStroke(normalStroke);
shapesIt = storageShapes.iterator();
while(shapesIt.hasNext()){
      g2.setColor(shape.getFillColor());
    g2.fill(path);
    g2.setStroke(dashStroke);
  g2.draw(path);
    g2.fill(path);
    g2.draw(path);
  g2.draw(path);
origin: runelite/runelite

private Ellipse2D drawEllipse(Graphics2D graphics, int x, int y)
{
  graphics.setColor(config.progressOrbBackgroundColor());
  Ellipse2D ellipse = new Ellipse2D.Double(x, y, config.xpOrbSize(), config.xpOrbSize());
  graphics.fill(ellipse);
  graphics.draw(ellipse);
  return ellipse;
}
origin: runelite/runelite

for (BufferedImage icon : icons)
  graphics.setStroke(new BasicStroke(2));
  graphics.setColor(COLOR_ICON_BACKGROUND);
  graphics.fillOval(
    point.getX() - totalWidth / 2 + currentPosX - bgPadding,
    icon.getHeight() + bgPadding * 2);
  graphics.setColor(COLOR_ICON_BORDER);
  graphics.drawOval(
    point.getX() - totalWidth / 2 + currentPosX - bgPadding,
    null);
  graphics.setColor(COLOR_ICON_BORDER_FILL);
  Arc2D.Double arc = new Arc2D.Double(
    point.getX() - totalWidth / 2 + currentPosX - bgPadding,
      gorilla.getAttacksUntilSwitch()) / DemonicGorilla.ATTACKS_PER_SWITCH,
    Arc2D.OPEN);
  graphics.draw(arc);
origin: libgdx/libgdx

public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) {
  g = (Graphics2D)g.create();
  if (stroke != null)
    g.setStroke(stroke);
  else
    g.setStroke(getStroke());
  g.setColor(color);
  g.draw(glyph.getShape());
  g.dispose();
}
origin: plantuml/plantuml

final boolean isLine = shape instanceof Line2D.Double;
if (isLine) {
  gg.setColor(colorLine);
  gg.draw(shape);
} else {
  gg.setColor(color);
  gg.fill(shape);
origin: geotools/geotools

pointerLength = Math.max(pointerLength, radius);
imageGraphic = image.createGraphics();
imageGraphic.setColor(circleColor);
imageGraphic.fillOval(
    circleCenterX - radius, circleCenterY - radius, radius * 2, radius * 2);
imageGraphic.setColor(wedgeColor);
imageGraphic.fillArc(
    circleCenterX - radius,
    calculateWedgeAngle(pointerDirection, wedgeWidth),
    wedgeWidth * 2);
imageGraphic.setColor(barUncColor);
imageGraphic.fillRect(
    circleCenterX - barUncWidth,
    calculateEndOfPointer(
        circleCenterX, circleCenterY, pointerLength, pointerDirection);
imageGraphic.setStroke(new java.awt.BasicStroke(3));
imageGraphic.setColor(pointerColor);
imageGraphic.draw(
    new java.awt.geom.Line2D.Double(
        circleCenterX, circleCenterY, endPoint[0], endPoint[1]));
imageGraphic.setStroke(new java.awt.BasicStroke(3));
imageGraphic.setColor(barColor);
imageGraphic.draw(
    new java.awt.geom.Line2D.Double(
        circleCenterX, circleCenterY, circleCenterX, circleCenterY - barHeight));
origin: stanfordnlp/CoreNLP

g2.setColor(paintColor);
g2.drawString(nodeStr, (float) (nodeTab + start.getX()), (float) (start.getY() + nodeAscent));
g2.setColor(curColor);
double layerMultiplier = (1.0 + belowLineSkip + aboveLineSkip + parentSkip);
double layerHeight = nodeHeight * layerMultiplier;
 g2.draw(new Line2D.Double(lineStartX, lineStartY, lineEndX, lineEndY));
 childStartX += cWidth;
 if (i < t.children().length - 1) {
origin: org.apache.poi/poi

protected void drawDecoration(Graphics2D graphics, Paint line, BasicStroke stroke) {
  if(line == null) {
    return;
  }
  graphics.setPaint(line);
  List<Outline> lst = new ArrayList<>();
  LineDecoration deco = getShape().getLineDecoration();
  Outline head = getHeadDecoration(graphics, deco, stroke);
  if (head != null) {
    lst.add(head);
  }
  Outline tail = getTailDecoration(graphics, deco, stroke);
  if (tail != null) {
    lst.add(tail);
  }
  for(Outline o : lst){
    java.awt.Shape s = o.getOutline();
    Path p = o.getPath();
    graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
    if(p.isFilled()) {
      graphics.fill(s);
    }
    if(p.isStroked()) {
      graphics.draw(s);
    }
  }
}
origin: magefree/mage

g2.setColor(CardRendererUtils.abitdarker(boxColor));
g2.setPaint(paint);
g2.draw(curve);
g2.setColor(Color.black);
g2.draw(innercurve);
origin: graphhopper/graphhopper

public void plotDirectedEdge(Graphics2D g2, double lat, double lon, double lat2, double lon2, float width) {
  g2.setStroke(new BasicStroke(width));
  int startLon = (int) getX(lon);
  int startLat = (int) getY(lat);
  int destLon = (int) getX(lon2);
  int destLat = (int) getY(lat2);
  g2.drawLine(startLon, startLat, destLon, destLat);
  // only for deep zoom show direction
  if (scaleX < 0.0001) {
    g2.setStroke(new BasicStroke(3));
    Path2D.Float path = new Path2D.Float();
    path.moveTo(destLon, destLat);
    path.lineTo(destLon + 6, destLat - 2);
    path.lineTo(destLon + 6, destLat + 2);
    path.lineTo(destLon, destLat);
    AffineTransform at = new AffineTransform();
    double angle = Math.atan2(lat2 - lat, lon2 - lon);
    at.rotate(-angle + Math.PI, destLon, destLat);
    path.transform(at);
    g2.draw(path);
  }
}
origin: plantuml/plantuml

public static void drawBorder(UParam param, HtmlColor color, ColorMapper mapper, UShapeSized sized, Shape shape,
    Graphics2D g2d, double x, double y) {
  if (color == null) {
    return;
  }
  if (color instanceof HtmlColorGradient) {
    final GradientPaint paint = getPaintGradient(x, y, mapper, sized.getWidth(), sized.getHeight(), color);
    g2d.setPaint(paint);
  } else {
    g2d.setColor(mapper.getMappedColor(color));
  }
  DriverLineG2d.manageStroke(param, g2d);
  g2d.draw(shape);
}
origin: kiegroup/optaplanner

public void drawRoute(Graphics2D g, double lon1, double lat1, double lon2, double lat2, boolean straight, boolean dashed) {
  int x1 = translateLongitudeToX(lon1);
  int y1 = translateLatitudeToY(lat1);
  int x2 = translateLongitudeToX(lon2);
  int y2 = translateLatitudeToY(lat2);
  if (dashed) {
    g.setStroke(TangoColorFactory.FAT_DASHED_STROKE);
  }
  if (straight) {
    g.drawLine(x1, y1, x2, y2);
  } else {
    double xDistPart = (x2 - x1) / 3.0;
    double yDistPart = (y2 - y1) / 3.0;
    double ctrlx1 = x1 + xDistPart + yDistPart;
    double ctrly1 = y1 - xDistPart + yDistPart;
    double ctrlx2 = x2 - xDistPart - yDistPart;
    double ctrly2 = y2 + xDistPart - yDistPart;
    g.draw(new CubicCurve2D.Double(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2));
  }
  if (dashed) {
    g.setStroke(TangoColorFactory.NORMAL_STROKE);
  }
}
origin: apache/pdfbox

@Override
public void strokePath() throws IOException
{
  graphics.setComposite(getGraphicsState().getStrokingJavaComposite());
  graphics.setPaint(getStrokingPaint());
  graphics.setStroke(getStroke());
  setClip();
  //TODO bbox of shading pattern should be used here? (see fillPath)
  if (isContentRendered())
  {
    graphics.draw(linePath);
  }
  linePath.reset();
}
origin: stackoverflow.com

int y2 = getHeight();
Line2D line = new Line2D.Double(x1, y1, x2, y2);
Rectangle2D rect = new Rectangle2D.Double(x, y, width, height);
g2d.draw(rect);
g2d.draw(line);
for (Point2D p : ps) {
  if (p != null) {
    g2d.fill(new Ellipse2D.Double(p.getX() - 4, p.getY() - 4, 8, 8));
        new Line2D.Double(
        rectangle.getX(),
        rectangle.getY(),
        new Line2D.Double(
        rectangle.getX(),
        rectangle.getY() + rectangle.getHeight(),
origin: runelite/runelite

  private void renderTargetOverlay(Graphics2D graphics, NPC actor, Color color)
  {
    Polygon objectClickbox = actor.getConvexHull();
    if (objectClickbox != null)
    {
      graphics.setColor(color);
      graphics.setStroke(new BasicStroke(2));
      graphics.draw(objectClickbox);
      graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
      graphics.fill(objectClickbox);
    }
  }
}
origin: runelite/runelite

public static void renderHoverableArea(Graphics2D graphics, Area area, net.runelite.api.Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor)
{
  if (area != null)
  {
    if (area.contains(mousePosition.getX(), mousePosition.getY()))
    {
      graphics.setColor(borderHoverColor);
    }
    else
    {
      graphics.setColor(borderColor);
    }
    graphics.draw(area);
    graphics.setColor(fillColor);
    graphics.fill(area);
  }
}
origin: libgdx/libgdx

public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) {
  g = (Graphics2D)g.create();
  if (stroke != null)
    g.setStroke(stroke);
  else
    g.setStroke(getStroke());
  g.setColor(color);
  g.draw(glyph.getShape());
  g.dispose();
}
java.awtGraphics2Ddraw

Javadoc

Draws the text given by the specified string, using this graphics context's current font and color. The baseline of the leftmost character is at position (x, y) in this graphics context's coordinate system.

Popular methods of Graphics2D

  • setColor
  • dispose
  • drawImage
  • setRenderingHint
  • fillRect
  • drawString
  • setFont
  • setStroke
    Sets the Stroke for the Graphics2D context.
  • fill
  • setPaint
  • drawLine
  • getFontMetrics
  • drawLine,
  • getFontMetrics,
  • 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