本文整理汇总了Java中java.awt.BasicStroke.CAP_ROUND属性的典型用法代码示例。如果您正苦于以下问题:Java BasicStroke.CAP_ROUND属性的具体用法?Java BasicStroke.CAP_ROUND怎么用?Java BasicStroke.CAP_ROUND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.BasicStroke
的用法示例。
在下文中一共展示了BasicStroke.CAP_ROUND属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDashedBorder
/**
* Creates a dashed border of the specified {@code paint}, {@code thickness},
* line shape, relative {@code length}, and relative {@code spacing}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
*
* @param paint the {@link Paint} object used to generate a color
* @param thickness the width of a dash line
* @param length the relative length of a dash line
* @param spacing the relative spacing between dash lines
* @param rounded whether or not line ends should be round
* @return the {@code Border} object
*
* @throws IllegalArgumentException if the specified {@code thickness} is less than {@code 1}, or
* if the specified {@code length} is less than {@code 1}, or
* if the specified {@code spacing} is less than {@code 0}
* @since 1.7
*/
public static Border createDashedBorder(Paint paint, float thickness, float length, float spacing, boolean rounded) {
boolean shared = !rounded && (paint == null) && (thickness == 1.0f) && (length == 1.0f) && (spacing == 1.0f);
if (shared && (sharedDashedBorder != null)) {
return sharedDashedBorder;
}
if (thickness < 1.0f) {
throw new IllegalArgumentException("thickness is less than 1");
}
if (length < 1.0f) {
throw new IllegalArgumentException("length is less than 1");
}
if (spacing < 0.0f) {
throw new IllegalArgumentException("spacing is less than 0");
}
int cap = rounded ? BasicStroke.CAP_ROUND : BasicStroke.CAP_SQUARE;
int join = rounded ? BasicStroke.JOIN_ROUND : BasicStroke.JOIN_MITER;
float[] array = { thickness * (length - 1.0f), thickness * (spacing + 1.0f) };
Border border = createStrokeBorder(new BasicStroke(thickness, cap, join, thickness * 2.0f, array, 0.0f), paint);
if (shared) {
sharedDashedBorder = border;
}
return border;
}
示例2: DiscreteXYPainter
DiscreteXYPainter(float lineWidth, Color lineColor, Color fillColor,
int width, boolean fixedWidth, boolean topLineOnly,
boolean outlineOnly, double dataFactor, PointsComputer computer) {
super((int)Math.ceil(lineWidth), fillColor != null ||
(!topLineOnly && !outlineOnly), dataFactor);
if (lineColor == null && fillColor == null)
throw new IllegalArgumentException("lineColor or fillColor must not be null"); // NOI18N
this.lineWidth = (int)Math.ceil(lineWidth);
this.lineColor = Utils.checkedColor(lineColor);
this.fillColor = Utils.checkedColor(fillColor);
definingColor = lineColor != null ? lineColor : fillColor;
this.lineStroke = new BasicStroke(lineWidth, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND);
this.width = width;
this.fixedWidth = fixedWidth;
this.topLineOnly = topLineOnly;
this.outlineOnly = outlineOnly;
this.computer = computer;
}
示例3: drawFiltArea
/**
* 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);
}
示例4: drawDragArea
/**
* 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);
}
示例5: drawFiltArea
/**
* 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);
}
示例6: SynchronousXYItemMarker
public SynchronousXYItemMarker(int markRadius, float line1Width, Color line1Color,
float line2Width, Color line2Color, Color fillColor,
int type, int maxValueOffset) {
if (line1Color == null && line2Color == null && fillColor == null)
throw new IllegalArgumentException("No parameters defined"); // NOI18N
this.markRadius = markRadius;
this.line1Width = (int)Math.ceil(line1Width);
this.line1Color = Utils.checkedColor(line1Color);
this.line2Width = (int)Math.ceil(line2Width);
this.line2Color = Utils.checkedColor(line2Color);
this.fillColor = Utils.checkedColor(fillColor);
this.line1Stroke = line1Color == null ? null :
new BasicStroke(line1Width, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND);
this.line2Stroke = line2Color == null ? null :
new BasicStroke(line2Width, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND);
decorationRadius = markRadius + this.line1Width + this.line2Width;
this.type = type;
this.maxValueOffset = maxValueOffset;
}
示例7: initDefaultValues
private void initDefaultValues() {
sMarkPaint = new Color(120, 120, 120);
sOddPerfPaint = new Color(120, 120, 120);
sEvenPerfPaint = Color.WHITE;
hMarkPaint = new Color(80, 80, 80);
hOddPerfPaint = Color.BLACK;
hEvenPerfPaint = Color.WHITE;
markStroke = new BasicStroke(2.8f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
oddPerfStroke = new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 0, new float[] { 1.0f, 3.0f }, 0);
evenPerfStroke = new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 0, new float[] { 1.0f, 3.0f }, 2);
selectionExtent = 3;
}
示例8: paintWidget
@Override
public void paintWidget() {
ObjectState os = this.getState();
if(!os.isHovered() && !os.isSelected()) return; //all previewEdges visible and not hovering,
//no need to paint the switch
float hw = width/2;
Polygon pol = new Polygon();
pol.addPoint(0,(int) -height/2);
pol.addPoint((int)hw,(int) height/2);
pol.addPoint((int)-hw,(int) height/2);
Graphics2D gr = getGraphics();
gr.setColor(this.getForeground());
BasicStroke bs = new BasicStroke(2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
gr.setStroke(bs);
AffineTransform previousTransform;
previousTransform = gr.getTransform ();
if(output) {
if(os.isSelected() ){//hidden
gr.scale(1.0, -1.0);
}
} else { //input switch
if(os.isHovered() && !os.isSelected()){
gr.scale(1.0, -1.0);
}
}
gr.fillPolygon(pol);
gr.setTransform(previousTransform);
}
示例9: createNumericalChart
private JFreeChart createNumericalChart() {
JFreeChart chart;
XYDataset dataset = createNumericalDataSet();
// create the chart...
String domainName = dataTable == null ? MODEL_DOMAIN_AXIS_NAME : dataTable.getColumnName(plotColumn);
chart = ChartFactory.createXYLineChart(null, // chart title
domainName, // x axis label
RANGE_AXIS_NAME, // y axis label
dataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, // tooltips
false // urls
);
DeviationRenderer renderer = new DeviationRenderer(true, false);
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
if (dataset.getSeriesCount() == 1) {
renderer.setSeriesStroke(0, stroke);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesFillPaint(0, Color.RED);
} else {
for (int i = 0; i < dataset.getSeriesCount(); i++) {
renderer.setSeriesStroke(i, stroke);
Color color = getColorProvider().getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
renderer.setSeriesPaint(i, color);
renderer.setSeriesFillPaint(i, color);
}
}
renderer.setAlpha(0.12f);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(renderer);
return chart;
}
示例10: ContinuousXYPainter
ContinuousXYPainter(float lineWidth, Color lineColor, Color fillColor,
double dataFactor, PointsComputer computer) {
super((int)Math.ceil(lineWidth), fillColor != null, dataFactor);
if (lineColor == null && fillColor == null)
throw new IllegalArgumentException("lineColor or fillColor must not be null"); // NOI18N
this.lineWidth = (int)Math.ceil(lineWidth);
this.lineColor = Utils.checkedColor(lineColor);
this.fillColor = Utils.checkedColor(fillColor);
definingColor = lineColor != null ? lineColor : fillColor;
this.lineStroke = new BasicStroke(lineWidth, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND);
this.computer = computer;
}
示例11: createChart
private JFreeChart createChart(XYDataset dataset, boolean createLegend) {
// create the chart...
JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
null, // x axis label
null, // y axis label
dataset, // data
PlotOrientation.VERTICAL, createLegend, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.white);
// get a reference to the plot for further customization...
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
DeviationRenderer renderer = new DeviationRenderer(true, false);
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
if (dataset.getSeriesCount() == 1) {
renderer.setSeriesStroke(0, stroke);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesFillPaint(0, Color.RED);
} else {
for (int i = 0; i < dataset.getSeriesCount(); i++) {
renderer.setSeriesStroke(i, stroke);
Color color = getColorProvider().getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
renderer.setSeriesPaint(i, color);
renderer.setSeriesFillPaint(i, color);
}
}
renderer.setAlpha(0.12f);
plot.setRenderer(renderer);
ValueAxis valueAxis = plot.getRangeAxis();
valueAxis.setLabelFont(LABEL_FONT_BOLD);
valueAxis.setTickLabelFont(LABEL_FONT);
return chart;
}
示例12: getSolidStroke
static public BasicStroke getSolidStroke() {
return new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
}
示例13: createChart
private JFreeChart createChart(XYDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
null, // x axis label
null, // y axis label
dataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.white);
// get a reference to the plot for further customisation...
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
ValueAxis valueAxis = plot.getRangeAxis();
valueAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
valueAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);
ValueAxis domainAxis = plot.getDomainAxis();
domainAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
domainAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);
DeviationRenderer renderer = new DeviationRenderer(true, false);
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
if (dataset.getSeriesCount() == 1) {
renderer.setSeriesStroke(0, stroke);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesFillPaint(0, Color.RED);
} else if (dataset.getSeriesCount() == 2) {
renderer.setSeriesStroke(0, stroke);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesFillPaint(0, Color.RED);
renderer.setSeriesStroke(1, stroke);
renderer.setSeriesPaint(1, Color.BLUE);
renderer.setSeriesFillPaint(1, Color.BLUE);
} else {
for (int i = 0; i < dataset.getSeriesCount(); i++) {
renderer.setSeriesStroke(i, stroke);
Color color = colorProvider.getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
renderer.setSeriesPaint(i, color);
renderer.setSeriesFillPaint(i, color);
}
}
renderer.setAlpha(0.12f);
plot.setRenderer(renderer);
// legend settings
LegendTitle legend = chart.getLegend();
if (legend != null) {
legend.setPosition(RectangleEdge.TOP);
legend.setFrame(BlockBorder.NONE);
legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
legend.setItemFont(PlotterAdapter.LABEL_FONT);
}
return chart;
}
示例14: drawSelectLine
/**
* Draw the selected line of the convex hull and the information about it
*
* @param g
* Graphic object
* @param p1
* The first point of the line
* @param p2
* The second point of the line
* @param s3d
* Information aboute the classes
* @param classNames
* The name of the classes
*/
public void drawSelectLine(Graphics2D g, DPoint p1, DPoint p2) {
if ((p1 != null) && (p2 != null)) {
// Draw the selected line
Stroke oldStro = g.getStroke();
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND);
g.setStroke(stroke);
g.setColor(Color.BLACK);
g.drawLine(plane.getTrueX(p1.getX()), plane.getTrueY(p1.getY()),
plane.getTrueX(p2.getX()), plane.getTrueY(p2.getY()));
g.setStroke(oldStro);
// Set the middle point
int x = plane.getTrueX(p2.getX() + (p1.getX() - p2.getX()) / 2);
int y = plane.getTrueY(p2.getY() + (p1.getY() - p2.getY()) / 2);
Font label = new Font("Arial", Font.PLAIN, 7 + getPointSize());
g.setFont(label);
// Draw the label
for (int i = 0; i < data.getResults().getSaturationSectors().size(); i++) {
// Current sector
FinalSect2D sect = (FinalSect2D) data.getResults()
.getSaturationSectors().get(i);
String pb11 = FORMAT_3_DEC.format(sect.getBeta11() * 100);
String pb12 = FORMAT_3_DEC.format(sect.getBeta1() * 100);
String pb21 = FORMAT_3_DEC.format(sect.getBeta22() * 100);
String pb22 = FORMAT_3_DEC.format(sect.getBeta2() * 100);
if (sect.countStation() < 2) {
continue;
}
Station2D d1 = (sect.getstation()).get(0);
Station2D d2 = (sect.getstation()).get(1);
int d1x = (int) (d1.getVert()).getX();
int d1y = (int) (d1.getVert()).getY();
int d2x = (int) (d2.getVert()).getX();
int d2y = (int) (d2.getVert()).getY();
int p1x = (int) (p1.getX() * 100);
int p1y = (int) (p1.getY() * 100);
int p2x = (int) (p2.getX() * 100);
int p2y = (int) (p2.getY() * 100);
double t1 = ((p1.getY() - p2.getY()) / ((p2.getX() * p1.getY()) - (p1
.getX() * p2.getY())));
double t2 = ((p2.getX() - p1.getX()) / ((p2.getX() * p1.getY()) - (p1
.getX() * p2.getY())));
if (((d1x == p1x) && (d1y == p1y) && (d2x == p2x) && (d2y == p2y))
|| ((d1x == p2x) && (d1y == p2y) && (d2x == p1x) && (d2y == p1y))) {
g.drawString("X_" + data.getClassNames()[0] + "="
+ FORMAT_4_DEC.format(t1) + " job/sec", x, y
- (8 + getPointSize()));
g.drawString("X_" + data.getClassNames()[1] + "="
+ FORMAT_4_DEC.format(t2) + " job/sec", x, y);
g.drawString("Saturation sector X2 " + "= %[" + pb22
+ "," + pb21 + "]", x, y - 2 * (8 + getPointSize()));
g.drawString("Saturation sector X1 " + "= %[" + pb12
+ "," + pb11 + "]", x, y - 3 * (8 + getPointSize()));
break;
}
}
}
}
示例15: drawSelectLine
/**
* Draw the selected line of the convex hull
* and the information about it
* @param g Graphic object
* @param p1 The first point of the line
* @param p2 The second point of the line
* @param s3d Information aboute the classes
* @param classNames The name of the classes
*/
public void drawSelectLine(Graphics2D g, DPoint p1, DPoint p2, Vector<Object> s3d, String[] classNames) {
if ((p1 != null) && (p2 != null)) {
//Draw the selected line
Stroke oldStro = g.getStroke();
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
g.setStroke(stroke);
g.setColor(Color.BLACK);
g.drawLine((int) (p1.getX() * scale) + tran_x, tran_y - (int) (p1.getY() * scale), (int) (p2.getX() * scale) + tran_x, tran_y
- (int) (p2.getY() * scale));
g.setStroke(oldStro);
//Set the middle point
int x = (int) p2.getX() + (int) ((p1.getX() - p2.getX()) / 2);
int y = (int) p2.getY() + (int) ((p1.getY() - p2.getY()) / 2);
x = (int) (x * scale) + tran_x + (pointSize + 3);
y = tran_y - (int) (y * scale) - (pointSize + 1);
Font label = new Font("Arial", Font.PLAIN, 7 + pointSize);
g.setFont(label);
//Draw the label
for (int i = 0; i < s3d.size(); i++) {
// Current sector
FinalSect2D sect = (FinalSect2D) s3d.get(i);
String pb11 = format2Dec.format(sect.getBeta11() * 100);
String pb12 = format2Dec.format(sect.getBeta1() * 100);
String pb21 = format2Dec.format(sect.getBeta22() * 100);
String pb22 = format2Dec.format(sect.getBeta2() * 100);
if (sect.countStation() < 2) {
continue;
}
Station2D d1 = (sect.getstation()).get(0);
Station2D d2 = (sect.getstation()).get(1);
int d1x = (int) (d1.getVert()).getX();
int d1y = (int) (d1.getVert()).getY();
int d2x = (int) (d2.getVert()).getX();
int d2y = (int) (d2.getVert()).getY();
int p1x = (int) (p1.getX() * 100);
int p1y = (int) (p1.getY() * 100);
int p2x = (int) (p2.getX() * 100);
int p2y = (int) (p2.getY() * 100);
double t1 = ((p1.getY() - p2.getY()) / ((p2.getX() * p1.getY()) - (p1.getX() * p2.getY())));
double t2 = ((p2.getX() - p1.getX()) / ((p2.getX() * p1.getY()) - (p1.getX() * p2.getY())));
if (((d1x == p1x) && (d1y == p1y) && (d2x == p2x) && (d2y == p2y)) || ((d1x == p2x) && (d1y == p2y) && (d2x == p1x) && (d2y == p1y))) {
g.drawString(classNames[0] + "=" + format4Dec.format(t1) + " job/sec", x, y - (8 + pointSize));
g.drawString(classNames[1] + "=" + format4Dec.format(t2) + " job/sec", x, y);
g.drawString(classNames[1] + "% [" + pb22 + "," + pb12 + "]", x, y - 2 * (8 + pointSize));
g.drawString(classNames[0] + "% [" + pb21 + "," + pb11 + "]", x, y - 3 * (8 + pointSize));
break;
}
}
}
}