本文整理汇总了Java中java.awt.Stroke类的典型用法代码示例。如果您正苦于以下问题:Java Stroke类的具体用法?Java Stroke怎么用?Java Stroke使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Stroke类属于java.awt包,在下文中一共展示了Stroke类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEquals
import java.awt.Stroke; //导入依赖的package包/类
/**
* 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));
}
示例2: drawDomainCrosshair
import java.awt.Stroke; //导入依赖的package包/类
/**
* Draws a domain crosshair.
*
* @param g2 the graphics target.
* @param dataArea the data area.
* @param orientation the plot orientation.
* @param value the crosshair value.
* @param axis the axis against which the value is measured.
* @param stroke the stroke used to draw the crosshair line.
* @param paint the paint used to draw the crosshair line.
*
* @since 1.0.4
*/
protected void drawDomainCrosshair(Graphics2D g2, Rectangle2D dataArea,
PlotOrientation orientation, double value, ValueAxis axis,
Stroke stroke, Paint paint) {
if (axis.getRange().contains(value)) {
Line2D line = null;
if (orientation == PlotOrientation.VERTICAL) {
double xx = axis.valueToJava2D(value, dataArea,
RectangleEdge.BOTTOM);
line = new Line2D.Double(xx, dataArea.getMinY(), xx,
dataArea.getMaxY());
}
else {
double yy = axis.valueToJava2D(value, dataArea,
RectangleEdge.LEFT);
line = new Line2D.Double(dataArea.getMinX(), yy,
dataArea.getMaxX(), yy);
}
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(line);
}
}
示例3: createStroke
import java.awt.Stroke; //导入依赖的package包/类
/**
*
*/
public Stroke createStroke(Map<String, Object> style)
{
double width = mxUtils
.getFloat(style, mxConstants.STYLE_STROKEWIDTH, 1) * scale;
boolean dashed = mxUtils.isTrue(style, mxConstants.STYLE_DASHED);
if (dashed)
{
float[] dashPattern = mxUtils.getFloatArray(style,
mxConstants.STYLE_DASH_PATTERN,
mxConstants.DEFAULT_DASHED_PATTERN, " ");
float[] scaledDashPattern = new float[dashPattern.length];
for (int i = 0; i < dashPattern.length; i++)
{
scaledDashPattern[i] = (float) (dashPattern[i] * scale * width);
}
return new BasicStroke((float) width, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER, 10.0f, scaledDashPattern, 0.0f);
}
else
{
return new BasicStroke((float) width);
}
}
示例4: setOutlineStroke
import java.awt.Stroke; //导入依赖的package包/类
/**
* Sets the stroke used to outline the plot area and sends a {@link PlotChangeEvent} to all
* registered listeners. If you set this attribute to <code>null<.code>, no outline will be
* drawn.
*
* @param stroke the stroke (<code>null</code> permitted).
*/
public void setOutlineStroke(Stroke stroke) {
if (stroke == null) {
if (this.outlineStroke != null) {
this.outlineStroke = null;
notifyListeners(new PlotChangeEvent(this));
}
}
else {
if (this.outlineStroke != null) {
if (this.outlineStroke.equals(stroke)) {
return; // nothing to do
}
}
this.outlineStroke = stroke;
notifyListeners(new PlotChangeEvent(this));
}
}
示例5: ClipPath
import java.awt.Stroke; //导入依赖的package包/类
/**
* Constructor for ClipPath.
*
* @param xValue x coordinates of curved to be created
* @param yValue y coordinates of curved to be created
* @param fillPath whether the path is to filled
* @param drawPath whether the path is to drawn as an outline
* @param fillPaint the fill paint
* @param drawPaint the outline stroke color
* @param drawStroke the stroke style
* @param composite the composite rule
*/
public ClipPath(double[] xValue, double[] yValue, boolean fillPath, boolean drawPath,
Paint fillPaint, Paint drawPaint, Stroke drawStroke, Composite composite) {
this.xValue = xValue;
this.yValue = yValue;
this.fillPath = fillPath;
this.drawPath = drawPath;
this.fillPaint = fillPaint;
this.drawPaint = drawPaint;
this.drawStroke = drawStroke;
this.composite = composite;
}
示例6: drawRangeLine
import java.awt.Stroke; //导入依赖的package包/类
/**
* Utility method for drawing a line perpendicular to the range axis (used for crosshairs).
*
* @param g2 the graphics device.
* @param dataArea the area defined by the axes.
* @param value the data value.
* @param stroke the line stroke.
* @param paint the line paint.
*/
protected void drawRangeLine(Graphics2D g2,
Rectangle2D dataArea,
double value, Stroke stroke, Paint paint) {
double java2D = getRangeAxis().valueToJava2D(value, dataArea, getRangeAxisEdge());
Line2D line = null;
if (this.orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(java2D, dataArea.getMinY(), java2D, dataArea.getMaxY());
}
else if (this.orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(dataArea.getMinX(), java2D, dataArea.getMaxX(), java2D);
}
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(line);
}
示例7: XYLineAnnotation
import java.awt.Stroke; //导入依赖的package包/类
/**
* Creates a new annotation that draws a line from (x1, y1) to (x2, y2)
* where the coordinates are measured in data space (that is, against the
* plot's axes).
*
* @param x1 the x-coordinate for the start of the line.
* @param y1 the y-coordinate for the start of the line.
* @param x2 the x-coordinate for the end of the line.
* @param y2 the y-coordinate for the end of the line.
* @param stroke the line stroke (<code>null</code> not permitted).
* @param paint the line color (<code>null</code> not permitted).
*/
public XYLineAnnotation(double x1, double y1, double x2, double y2,
Stroke stroke, Paint paint) {
if (stroke == null) {
throw new IllegalArgumentException("Null 'stroke' argument.");
}
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.stroke = stroke;
this.paint = paint;
}
示例8: XYPolygonAnnotation
import java.awt.Stroke; //导入依赖的package包/类
/**
* Creates a new annotation. The array of polygon coordinates must
* contain an even number of coordinates (each pair is an (x, y) location
* on the plot) and the last point is automatically joined back to the
* first point.
*
* @param polygon the coordinates of the polygon's vertices
* (<code>null</code> not permitted).
* @param stroke the shape stroke (<code>null</code> permitted).
* @param outlinePaint the shape color (<code>null</code> permitted).
* @param fillPaint the paint used to fill the shape (<code>null</code>
* permitted).
*/
public XYPolygonAnnotation(double[] polygon,
Stroke stroke,
Paint outlinePaint, Paint fillPaint) {
if (polygon == null) {
throw new IllegalArgumentException("Null 'polygon' argument.");
}
if (polygon.length % 2 != 0) {
throw new IllegalArgumentException("The 'polygon' array must "
+ "contain an even number of items.");
}
this.polygon = (double[]) polygon.clone();
this.stroke = stroke;
this.outlinePaint = outlinePaint;
this.fillPaint = fillPaint;
}
示例9: draw
import java.awt.Stroke; //导入依赖的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);
}
}
}
示例10: drawFiltArea
import java.awt.Stroke; //导入依赖的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);
}
示例11: drawRangeGridlines
import java.awt.Stroke; //导入依赖的package包/类
/**
* Draws the gridlines for the plot.
*
* @param g2 the graphics device.
* @param dataArea the area inside the axes.
* @param ticks the ticks.
*/
protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) {
// draw the range grid lines, if any...
if (isRangeGridlinesVisible()) {
Stroke gridStroke = getRangeGridlineStroke();
Paint gridPaint = getRangeGridlinePaint();
if ((gridStroke != null) && (gridPaint != null)) {
ValueAxis axis = getRangeAxis();
if (axis != null) {
Iterator iterator = ticks.iterator();
while (iterator.hasNext()) {
ValueTick tick = (ValueTick) iterator.next();
CategoryItemRenderer renderer1 = getRenderer();
if (renderer1 != null) {
renderer1.drawRangeGridline(
g2, this, getRangeAxis(), dataArea, tick.getValue()
);
}
}
}
}
}
}
示例12: draw
import java.awt.Stroke; //导入依赖的package包/类
public void draw(Graphics2D g) {
if(!plot)return;
Stroke stroke = g.getStroke();
g.setStroke( new BasicStroke( 1f/(float)map.getZoom() ));
if(enabled) {
g.setColor(Color.black);
} else {
g.setColor(new Color(120, 90, 60));
}
for( int k=0 ; k<cruises.size() ; k++) {
Vector t = ((MBCruise)cruises.get(k)).tracks;
for( int i=0 ; i<t.size() ; i++) {
((MBTrack)t.get(i)).draw(g);
}
}
if(enabled) {
drawSelectedCruise(g, Color.white);
drawSelectedTrack(g, cruiseColor);
}
g.setStroke(stroke);
}
示例13: render
import java.awt.Stroke; //导入依赖的package包/类
@Override
public void render(final Graphics2D g, final Point2D emitterOrigin) {
final Point2D renderLocation = this.getLocation(emitterOrigin);
g.setColor(this.getColor());
Stroke oldStroke = g.getStroke();
g.setStroke(this.getStroke());
g.draw(new Ellipse2D.Double(renderLocation.getX(), renderLocation.getY(), this.getWidth(), this.getHeight()));
g.setStroke(oldStroke);
}
示例14: getStroke
import java.awt.Stroke; //导入依赖的package包/类
public static Stroke getStroke(String name, Stroke defaultStroke) {
String val = getString(name);
if (val == null)
return defaultStroke;
ByteArrayInputStream is = new ByteArrayInputStream(
DatatypeConverter.parseHexBinary(val));
try {
return DataLoader.readStroke(is, new DataLoader.MemoryData());
} catch (IOException e) {// shell never happen
e.printStackTrace();
return null;
}
}
示例15: setAdvanceLineStroke
import java.awt.Stroke; //导入依赖的package包/类
/**
* The advance line is the line drawn at the limit of the current cycle,
* when erasing the previous cycle.
*
* @param stroke the stroke (<code>null</code> not permitted).
*/
public void setAdvanceLineStroke(Stroke stroke) {
if (stroke == null) {
throw new IllegalArgumentException("Null 'stroke' argument.");
}
this.advanceLineStroke = stroke;
}