Java Code Examples for java.awt.BasicStroke#JOIN_ROUND
The following examples show how to use
java.awt.BasicStroke#JOIN_ROUND .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BorderFactory.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 2
Source File: DirectBondDrawer.java From ReactionDecoder with GNU Lesser General Public License v3.0 | 6 votes |
private void setBondStroke() { int cap = BasicStroke.CAP_BUTT; int join = BasicStroke.JOIN_BEVEL; if (params.bondStrokeCap == BondStrokeCap.ROUND) { cap = BasicStroke.CAP_ROUND; } else if (params.bondStrokeCap == BondStrokeCap.SQUARE) { cap = BasicStroke.CAP_SQUARE; } if (params.bondStrokeJoin == BondStrokeJoin.BEVEL) { join = BasicStroke.JOIN_BEVEL; } else if (params.bondStrokeJoin == BondStrokeJoin.ROUND) { join = BasicStroke.JOIN_ROUND; } bondStroke = new BasicStroke(params.bondStrokeWidth, cap, join); }
Example 3
Source File: BorderFactory.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 4
Source File: BorderFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 5
Source File: SWTGraphics2D.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Returns the AWT line join corresponding to the specified SWT line join. * * @param swtLineJoin the SWT line join. * * @return The AWT line join. */ private int toAwtLineJoin(int swtLineJoin) { if (swtLineJoin == SWT.JOIN_BEVEL) { return BasicStroke.JOIN_BEVEL; } else if (swtLineJoin == SWT.JOIN_MITER) { return BasicStroke.JOIN_MITER; } else if (swtLineJoin == SWT.JOIN_ROUND) { return BasicStroke.JOIN_ROUND; } else { throw new IllegalArgumentException("SWT LineJoin " + swtLineJoin + " not recognised"); } }
Example 6
Source File: CrescendoSymbol.java From libreveris with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Params getParams (MusicFont font) { MyParams p = new MyParams(); double interline = font.getFontInterline(); p.rect = new Rectangle( (int) Math.ceil(5 * interline), (int) Math.ceil(1.5 * interline)); p.stroke = new BasicStroke( Math.max(1f, (float) interline / 7f), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); return p; }
Example 7
Source File: BorderFactory.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 8
Source File: CrescendoSymbol.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
@Override protected Params getParams (MusicFont font) { MyParams p = new MyParams(); double interline = font.getStaffInterline(); p.rect = new Rectangle((int) Math.ceil(5 * interline), (int) Math.ceil(1.5 * interline)); p.stroke = new BasicStroke( Math.max(1f, (float) interline / 7f), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); return p; }
Example 9
Source File: WPrinterJob.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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))); }
Example 10
Source File: WPrinterJob.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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))); }
Example 11
Source File: SigPainter.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates a new {@code SigPainter} object. * * @param g Graphic context * @param scale the global scale */ public SigPainter (Graphics g, Scale scale) { this.g = (Graphics2D) g; this.clip = g.getClipBounds(); // Determine proper music fonts if (scale == null) { musicFontLarge = musicFontSmall = null; musicHeadFontLarge = musicHeadFontSmall = null; } else { // Standard size final int large = scale.getInterline(); musicFontLarge = MusicFont.getBaseFont(large); musicHeadFontLarge = MusicFont.getHeadFont(scale, large); // Smaller size final Integer small = scale.getSmallInterline(); musicFontSmall = (small != null) ? MusicFont.getBaseFont(small) : null; musicHeadFontSmall = (small != null) ? MusicFont.getHeadFont(scale, small) : null; } // Determine lines parameters lineStroke = new BasicStroke( (scale != null) ? scale.getFore() : 2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); stemStroke = new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); ledgerStroke = new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); }
Example 12
Source File: GraphicsContext.java From Freerouting with GNU General Public License v3.0 | 5 votes |
/** * initialise some values in p_graphics */ private static void init_draw_graphics(Graphics2D p_graphics, Color p_color, float p_width) { BasicStroke bs = new BasicStroke(Math.max(p_width, 0), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); p_graphics.setStroke(bs); p_graphics.setColor(p_color); p_graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); }
Example 13
Source File: LineFormat.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
static public BasicStroke getDashDotStroke() { return new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 10.0f, new float[] { 6f, 2f, 1f, 2f }, 0.0f); }
Example 14
Source File: ROCChartPlotter.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
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; }
Example 15
Source File: DeviationChartPlotter.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
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; }
Example 16
Source File: java_awt_BasicStroke.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
protected BasicStroke getAnotherObject() { float[] f = {1.0f, 2.0f, 3.0f, 4.0f}; return new BasicStroke(f[1], BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, f[2], f, f[3]); }
Example 17
Source File: Paint.java From RipplePower with Apache License 2.0 | 4 votes |
private void createStroke() { if (this.strokeWidth <= 0) { return; } this.stroke = new BasicStroke(this.strokeWidth, this.cap, BasicStroke.JOIN_ROUND, 0, this.strokeDasharray, 0); }
Example 18
Source File: java_awt_BasicStroke.java From hottub with GNU General Public License v2.0 | 4 votes |
protected BasicStroke getAnotherObject() { float[] f = {1.0f, 2.0f, 3.0f, 4.0f}; return new BasicStroke(f[1], BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, f[2], f, f[3]); }
Example 19
Source File: java_awt_BasicStroke.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
protected BasicStroke getAnotherObject() { float[] f = {1.0f, 2.0f, 3.0f, 4.0f}; return new BasicStroke(f[1], BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, f[2], f, f[3]); }
Example 20
Source File: PDFGraphics.java From jpexs-decompiler with GNU General Public License v3.0 | votes |
private void setLineJoin(int join) { int lineJoin = 0; switch (join) { case BasicStroke.JOIN_MITER: lineJoin = 0; break; case BasicStroke.JOIN_ROUND: lineJoin = 1; break; case BasicStroke.JOIN_BEVEL: lineJoin = 2; break; } if (this.lineJoin != lineJoin) { closeBlock(); // draw any path before we change the line width this.lineJoin = lineJoin; pw.println(""+lineJoin+" j"); } }