本文整理了Java中java.awt.Graphics2D.draw()
方法的一些代码示例,展示了Graphics2D.draw()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics2D.draw()
方法的具体详情如下:
包路径:java.awt.Graphics2D
类名称:Graphics2D
方法名:draw
[英]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.
[中]使用此图形上下文的当前字体和颜色绘制指定字符串给定的文本。最左侧字符的基线位于该图形上下文坐标系中的位置(x,y)
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!