本文整理汇总了Java中java.awt.BasicStroke.CAP_SQUARE属性的典型用法代码示例。如果您正苦于以下问题:Java BasicStroke.CAP_SQUARE属性的具体用法?Java BasicStroke.CAP_SQUARE怎么用?Java BasicStroke.CAP_SQUARE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.BasicStroke
的用法示例。
在下文中一共展示了BasicStroke.CAP_SQUARE属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: paint
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
RenderingHints renderHints
= new RenderingHints(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
renderHints.put(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
g2d.addRenderingHints(renderHints);
g2d.setPaint(Color.BLACK);
Stroke stroke = new BasicStroke(2.f,
BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
g2d.setStroke(stroke);
PintarTextos(g2d);
}
示例3: paintComponent
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g); //paint background
if (diagramaAtual == null) {
return;
}
RenderingHints renderHints
= new RenderingHints(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
renderHints.put(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
Graphics2D Canvas = (Graphics2D) g;
Canvas.addRenderingHints(renderHints);
Canvas.setPaint(Color.BLACK);
Stroke stroke = new BasicStroke(2.f,
BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
Canvas.setStroke(stroke);
Canvas.drawRect(box.getLocation().x, box.getLocation().y, box.getWidth(), box.getHeight());
Canvas.setPaint(Color.GRAY);
Canvas.drawRect(box.getLocation().x + 1, box.getLocation().y + 1, box.getWidth(), box.getHeight());
//Canvas.setPaint(Color.BLACK);
}
示例4: getStroke
/**
* Get the stroke being used to draw the outline
*
* @return The stroke being used to draw the outline
*/
public Stroke getStroke() {
if (stroke == null) {
return new BasicStroke(width, BasicStroke.CAP_SQUARE, join);
}
return stroke;
}
示例5: 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;
}
示例6: initDefaultValues
private void initDefaultValues() {
markPaint = new Color(80, 80, 80);
oddPerfPaint = Color.BLACK;
evenPerfPaint = 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;
}
示例7: createSelectionStroke
private Stroke createSelectionStroke() {
float[] f = new float[4];
f[0] = 10;
f[1] = 3;
f[2] = 10;
f[3] = 3;
return new BasicStroke(2f, BasicStroke.CAP_SQUARE,
BasicStroke.JOIN_MITER, 1, f, 0);
}
示例8: createSelectionStroke
private Stroke createSelectionStroke() {
float[] f = new float[4];
f[0] = 3;
f[1] = 3;
f[2] = 3;
f[3] = 3;
return new BasicStroke(0.5f, BasicStroke.CAP_SQUARE,
BasicStroke.JOIN_MITER, 1, f, 0);
}
示例9: selectStylePen
protected boolean selectStylePen(int cap, int join, float width,
Color color) {
long endCap;
long lineJoin;
float[] rgb = color.getRGBColorComponents(null);
switch(cap) {
case BasicStroke.CAP_BUTT: endCap = PS_ENDCAP_FLAT; break;
case BasicStroke.CAP_ROUND: endCap = PS_ENDCAP_ROUND; break;
default:
case BasicStroke.CAP_SQUARE: endCap = PS_ENDCAP_SQUARE; break;
}
switch(join) {
case BasicStroke.JOIN_BEVEL:lineJoin = PS_JOIN_BEVEL; break;
default:
case BasicStroke.JOIN_MITER:lineJoin = PS_JOIN_MITER; break;
case BasicStroke.JOIN_ROUND:lineJoin = PS_JOIN_ROUND; break;
}
return (selectStylePen(getPrintDC(), endCap, lineJoin, width,
(int) (rgb[0] * MAX_WCOLOR),
(int) (rgb[1] * MAX_WCOLOR),
(int) (rgb[2] * MAX_WCOLOR)));
}
示例10: setStroke
public void setStroke(Stroke stroke) {
if (stroke instanceof BasicStroke) {
BasicStroke bs = (BasicStroke) stroke;
// linewidth
gc.setLineWidth((int) bs.getLineWidth());
// line join
switch (bs.getLineJoin()) {
case BasicStroke.JOIN_BEVEL :
gc.setLineJoin(SWT.JOIN_BEVEL);
break;
case BasicStroke.JOIN_MITER :
gc.setLineJoin(SWT.JOIN_MITER);
break;
case BasicStroke.JOIN_ROUND :
gc.setLineJoin(SWT.JOIN_ROUND);
break;
}
// line cap
switch (bs.getEndCap()) {
case BasicStroke.CAP_BUTT :
gc.setLineCap(SWT.CAP_FLAT);
break;
case BasicStroke.CAP_ROUND :
gc.setLineCap(SWT.CAP_ROUND);
break;
case BasicStroke.CAP_SQUARE :
gc.setLineCap(SWT.CAP_SQUARE);
break;
}
// set the line style to solid by default
gc.setLineStyle(SWT.LINE_SOLID);
// apply dash style if any
float[] dashes = bs.getDashArray();
if (dashes != null) {
int[] swtDashes = new int[dashes.length];
for (int i = 0; i < swtDashes.length; i++) {
swtDashes[i] = (int) dashes[i];
}
gc.setLineDash(swtDashes);
}
}
else {
throw new RuntimeException(
"Can only handle 'Basic Stroke' at present.");
}
}
示例11: paintComponent
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g); //paint background
RenderingHints renderHints
= new RenderingHints(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
renderHints.put(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
Graphics2D Canvas = (Graphics2D) g;
Canvas.addRenderingHints(renderHints);
// Canvas.setPaint(Color.BLACK);
// Canvas.draw3DRect(0, 0, getWidth() - 4, getHeight() - 4, true);
Canvas.setPaint(Color.BLACK);
Stroke stroke = new BasicStroke(1.f,
BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
Canvas.setStroke(stroke);
Canvas.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
Canvas.setPaint(Color.GRAY);
Canvas.drawRect(0, 0, getWidth() - 2, getHeight() - 2);
if (pgatual == 0) {
return;
}
float[] dash4 = {2f, 2f, 2f};
BasicStroke bs4 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash4,
2f);
Canvas.setStroke(bs4);
Canvas.drawLine(l - 1, 1, l - 1, getHeight() - 1);
Canvas.drawLine(l + w + 1, 1, l + w + 1, getHeight() - 1);
Canvas.drawLine(1, t - 1, getWidth() - 1, t - 1);
Canvas.drawLine(1, t + h + 1, getWidth() - 1, t + h + 1);
Canvas.setStroke(new BasicStroke(
1f,
BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND));
Canvas.setPaint(Color.BLACK);
DrawPagina(Canvas);
}