本文整理汇总了Java中java.awt.Graphics2D.getStroke方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics2D.getStroke方法的具体用法?Java Graphics2D.getStroke怎么用?Java Graphics2D.getStroke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Graphics2D
的用法示例。
在下文中一共展示了Graphics2D.getStroke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
*
*/
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
Stroke stroke = g2.getStroke();
g2.setStroke(getSelectionStroke());
g.setColor(getSelectionColor());
Point last = state.getAbsolutePoint(0).getPoint();
for (int i = 1; i < state.getAbsolutePointCount(); i++) {
Point current = state.getAbsolutePoint(i).getPoint();
Line2D line = new Line2D.Float(last.x, last.y, current.x, current.y);
Rectangle bounds = g2.getStroke().createStrokedShape(line).getBounds();
if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) {
g2.draw(line);
}
last = current;
}
g2.setStroke(stroke);
super.paint(g);
}
示例2: paintForeground
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* Paints the foreground. Foreground is dynamic and should never be made
* part of the triple buffer. It is painted on top of the buffer.
*/
protected void paintForeground(Graphics g)
{
if (graphComponent != null)
{
Graphics2D g2 = (Graphics2D) g;
Stroke stroke = g2.getStroke();
g.setColor(Color.BLUE);
g2.setStroke(new BasicStroke(3));
g.drawRect(finderBounds.x, finderBounds.y, finderBounds.width,
finderBounds.height);
if (zoomHandleVisible)
{
g2.setStroke(stroke);
g.setColor(DEFAULT_ZOOMHANDLE_FILL);
g.fillRect(finderBounds.x + finderBounds.width - 6, finderBounds.y
+ finderBounds.height - 6, 8, 8);
g.setColor(Color.BLACK);
g.drawRect(finderBounds.x + finderBounds.width - 6, finderBounds.y
+ finderBounds.height - 6, 8, 8);
}
}
}
示例3: paint
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paint(Graphics g, Point topLeft, Point bottomRight) {
// Prepare graphics
Color oldColor = g.getColor();
g.setColor(getColor());
Stroke oldStroke = null;
if (g instanceof Graphics2D) {
Graphics2D g2 = (Graphics2D) g;
oldStroke = g2.getStroke();
g2.setStroke(getStroke());
}
// Draw
g.drawRect(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
// Restore graphics
g.setColor(oldColor);
if (g instanceof Graphics2D) {
((Graphics2D) g).setStroke(oldStroke);
}
int width = bottomRight.x-topLeft.x;
int height = bottomRight.y-topLeft.y;
Point p = new Point(topLeft.x+(width/2), topLeft.y+(height/2));
if (getLayer() == null || getLayer().isVisibleTexts()) paintText(g, p);
}
示例4: draw
import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw(GamePiece p, Graphics g, int x, int y, Component obs, double zoom) {
final Graphics2D g2d = (Graphics2D) g;
if (accept(p)) {
if (useImage) {
final int x1 = x - (int) (imagePainter.getImageSize().width * zoom / 2);
final int y1 = y - (int) (imagePainter.getImageSize().height * zoom / 2);
imagePainter.draw(g, x1, y1, zoom, obs);
}
else {
if (color == null || thickness <= 0) {
return;
}
final Shape s = p.getShape();
final Stroke str = g2d.getStroke();
g2d.setStroke(new BasicStroke(Math.max(1, Math.round(zoom * thickness))));
g2d.setColor(color);
final AffineTransform t = AffineTransform.getScaleInstance(zoom, zoom);
t.translate(x / zoom, y / zoom);
g2d.draw(t.createTransformedShape(s));
g2d.setStroke(str);
}
}
}
示例5: drawUnderline
import java.awt.Graphics2D; //导入方法依赖的package包/类
void drawUnderline(Graphics2D g2d,
float thickness,
float x1,
float x2,
float y) {
Stroke saveStroke = g2d.getStroke();
g2d.setStroke(stroke);
Line2D.Float drawLine = new Line2D.Float(x1, y, x2, y);
g2d.draw(drawLine);
drawLine.y1 += DEFAULT_THICKNESS;
drawLine.y2 += DEFAULT_THICKNESS;
drawLine.x1 += DEFAULT_THICKNESS;
g2d.draw(drawLine);
g2d.setStroke(saveStroke);
}
示例6: paintWidget
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintWidget() {
super.paintWidget();
Graphics2D g = this.getGraphics();
Stroke old = g.getStroke();
g.setColor(Color.BLUE);
Rectangle r = new Rectangle(this.getPreferredBounds());
r.width--;
r.height--;
if (this.getBounds().width > 0 && this.getBounds().height > 0) {
g.setStroke(new BasicStroke(2));
g.drawRect(r.x, r.y, r.width, r.height);
}
Color titleColor = Color.BLACK;
g.setColor(titleColor);
g.setFont(titleFont);
String s = "B" + blockNode.getName();
Rectangle2D r1 = g.getFontMetrics().getStringBounds(s, g);
g.drawString(s, r.x + 5, r.y + (int) r1.getHeight());
g.setStroke(old);
}
示例7: drawDragArea
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* Draw a semi-trasparet area
* @param g The graphic object
* @param dragPoint The first point
* @param beginPoint The second point
* @param c The color of the area
*/
public void drawDragArea(Graphics2D g, Point dragPoint, Point beginPoint, Color c) {
g.setColor(c);
Polygon poly = new Polygon();
poly.addPoint((int) beginPoint.getX(), (int) beginPoint.getY());
poly.addPoint((int) beginPoint.getX(), (int) dragPoint.getY());
poly.addPoint((int) dragPoint.getX(), (int) dragPoint.getY());
poly.addPoint((int) dragPoint.getX(), (int) beginPoint.getY());
//Set the widths of the shape's outline
Stroke oldStro = g.getStroke();
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
g.setStroke(stroke);
g.drawPolygon(poly);
g.setStroke(oldStro);
//Set the trasparency of the iside of the rectangle
Composite oldComp = g.getComposite();
Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
g.setComposite(alphaComp);
g.fillPolygon(poly);
g.setComposite(oldComp);
}
示例8: drawFiltArea
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* Draw a semi-trasparent area that is the filtered area
* @param g The graphic object
* @param filteredArea The filtered area
*/
public void drawFiltArea(Graphics2D g, Area filtArea) {
AffineTransform t = new AffineTransform();
t.scale(scale / 100, scale / 100);
AffineTransform t2 = new AffineTransform();
t2.translate(tran_x, tran_y);
filtArea.transform(t);
filtArea.transform(t2);
Stroke oldStro = g.getStroke();
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
g.setStroke(stroke);
g.setColor(Color.GRAY);
Composite oldComp = g.getComposite();
Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
g.setComposite(alphaComp);
g.fill(filtArea);
g.setComposite(oldComp);
g.setStroke(oldStro);
}
示例9: DoPaint
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void DoPaint(Graphics2D g) {
super.DoPaint(g);
Stroke bkp = g.getStroke();
g.setPaint(getForeColor());
if (getPontosParaDesenho() != null) {
if (isDashed()) {
g.setStroke(new BasicStroke(getLargura(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{1, 2}, 0));
} else {
g.setStroke(new BasicStroke(
getLargura(),
BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND));
}
g.drawPolyline(pontosParaDesenhoX, pontosParaDesenhoY, pontosParaDesenhoX.length);
}
g.setStroke(bkp);
}
示例10: LineHighlightEffect
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
*
*/
public LineHighlightEffect(Shape shape, Graphics2D graphics,
int length, ViselPane viselPane, boolean continuous) {
this.shape = shape;
this.length = length;
this.graphics = graphics;
this.viselPane = viselPane;
this.continuous = continuous;
timer = new Timer(length/10, this);
duration = 0;
stroke = (BasicStroke) graphics.getStroke();
currentLineWidth =
initialLineWidth = stroke.getLineWidth();
}
示例11: paint
import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paint(Graphics g) {
Rectangle b = getVisibleRect();
g.clearRect(b.x, b.y, b.width, b.height);
myBoard.draw(g, 0, 0, 1.0, this);
final Rectangle bounds =
new Rectangle(new Point(),myBoard.bounds().getSize());
grid.forceDraw(g,bounds,bounds,1.0,false);
final Rectangle selection = config.getSelectionRect();
if (selection != null) {
final Graphics2D g2d = (Graphics2D) g;
final Stroke str = g2d.getStroke();
g2d.setStroke(new BasicStroke(2.0f));
g2d.setColor(Color.RED);
g2d.drawRect(selection.x, selection.y, selection.width, selection.height);
g2d.setStroke(str);
}
}
示例12: render
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void render(final Graphics2D g, final Point2D emitterOrigin) {
final Point2D renderLocation = this.getLocation(emitterOrigin);
final Stroke oldStroke = g.getStroke();
g.setColor(this.getColor());
g.setStroke(new BasicStroke(this.stroke));
g.draw(new Rectangle2D.Double(renderLocation.getX(), renderLocation.getY(), this.getWidth(), this.getHeight()));
g.setStroke(oldStroke);
}
示例13: DoPaintDoks
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void DoPaintDoks(Graphics2D g) {
super.DoPaintDoks(g);
Stroke bkp = g.getStroke();
g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{1, 2}, 0));
Shape t = new Ellipse2D.Float(getLeft(), getTop(), getWidth(), getHeight());
g.draw(t);
g.setStroke(bkp);
}
示例14: paint
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paint(final Graphics2D g) {
g.setColor(function.getBackground());
final Rectangle2D rect = movingArea.getBounds(getBounds());
g.fill(rect);
g.setFont(function.getFont());
// g.setColor(function.getForeground());
super.paint(g);
final Stroke tmp = g.getStroke();
g.draw(rect);
if (!function.isHaveChilds()) {
g.draw(new Line2D.Double(rect.getX()
+ Math.round(movingArea.getIDoubleOrdinate(4)),
rect.getY(), rect.getX(), rect.getY()
+ Math.round(movingArea.getIDoubleOrdinate(4))));
}
g.setStroke(new BasicStroke(2));
/*
* g.draw(new Line2D.Double(rect.getX() + rect.getWidth() - 1,
* rect.getY() + 1, rect.getX() + rect.getWidth() - 1, rect.getY() +
* rect.getHeight() - 1)); g.draw(new Line2D.Double(rect.getX() + 1,
* rect.getY() + rect.getHeight() - 1, rect.getX() + rect.getWidth() -
* 1, rect .getY() + rect.getHeight() - 1));
*/
final String string = getIDEF0Kod();
g.setFont(function.getFont());
double h = MovingArea.getWidth(0)
+ MovingArea.getWidth((int) function.getFont()
.getStringBounds(string, g.getFontRenderContext())
.getHeight());
h = h * 0.7;
movingArea.paintText(g, string,
new FRectangle(getBounds().getX(), getBounds().getBottom() - h
- 3, getBounds().getWidth() - 3, h),
com.ramussoft.pb.print.old.Line.RIGHT_ALIGN, 1, true);
g.setStroke(tmp);
paintTringle(g);
}
示例15: paintWidget
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void
paintWidget() {
int secondsPerTick = 10;
int secTickHeight = 6;
Graphics2D g = getGraphics();
g.setColor(getForeground());
int ticksNum = (int) (totalTime / (1000 * secondsPerTick));
Stroke formerStroke = g.getStroke();
g.setStroke(lineStroke);
// draw main line
g.drawLine(0, 0, (int) (totalTime / TLWidget.zoomFactor), 0);
// draw ticks
for (int tick = 0; tick <= ticksNum; tick++) {
int x = tick * secondsPerTick * 1000 / TLWidget.zoomFactor;
g.drawLine(x, 0, x, majorTickHeight);
// draw label
String time = ((tick * secondsPerTick) / 60) + ":" + ((tick * secondsPerTick) % 60);
//g.drawString(time, x, majorTickHeight);
Rectangle2D r = g.getFontMetrics().getStringBounds(time, g);
g.drawString(time, x - (float)r.getWidth() * 0.5f, majorTickHeight + (float)(r.getHeight()));
// draw minor ticks, per seconds
int lastSecTick = (int) (totalTime / 1000 < (tick + 1) * secondsPerTick - 1 ? totalTime / 1000 : (tick+1) * secondsPerTick - 1);
for (int secTick = tick * secondsPerTick + 1; secTick <= lastSecTick; secTick++) {
int secX = secTick * 1000/TLWidget.zoomFactor;
g.drawLine(secX, 0, secX, secTickHeight);
}
}
g.setStroke(formerStroke);
}