List of usage examples for java.awt BasicStroke CAP_SQUARE
int CAP_SQUARE
To view the source code for java.awt BasicStroke CAP_SQUARE.
Click Source Link
From source file:Main.java
public static Stroke getDotStroke() { int w = 1;/*from w w w .ja v a 2 s.c o m*/ float[] dash = { 1, 3 }; float dash_phase = 1; return new BasicStroke(w, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10, dash, dash_phase); }
From source file:Main.java
public static Stroke getDotStroke2() { int w = 1;/* w ww. jav a2 s .c om*/ float[] dash = { 6, 3 }; float dash_phase = 2; return new BasicStroke(w, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10, dash, dash_phase); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; BasicStroke bs = new BasicStroke(16.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL); g2.setStroke(bs);// w ww . j av a2 s. c o m g.drawLine(30, 20, 270, 20); }
From source file:com.itemanalysis.jmetrik.swing.JmetrikXYLineAndShapeRenderer.java
@Override public Stroke getItemStroke(int row, int col) { Stroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, getLineStyle(row), 0.0f);/*from w w w.j a v a 2 s . co m*/ return stroke; }
From source file:StrokeUtility.java
/** * Creates a new Stroke-Object for the given type and with. * /*w ww . jav a2s.c o m*/ * @param type * the stroke-type. (Must be one of the constants defined in this * class.) * @param width * the stroke's width. * @return the stroke, never null. */ public static Stroke createStroke(final int type, final float width) { final boolean useWidthForStrokes = true; final float effectiveWidth; if (useWidthForStrokes) { effectiveWidth = width; } else { effectiveWidth = 1; } switch (type) { case STROKE_DASHED: return new BasicStroke(width, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] { 6 * effectiveWidth, 6 * effectiveWidth }, 0.0f); case STROKE_DOTTED: return new BasicStroke(width, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 5.0f, new float[] { 0.0f, 2 * effectiveWidth }, 0.0f); case STROKE_DOT_DASH: return new BasicStroke(width, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] { 0, 2 * effectiveWidth, 6 * effectiveWidth, 2 * effectiveWidth }, 0.0f); case STROKE_DOT_DOT_DASH: return new BasicStroke( width, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] { 0, 2 * effectiveWidth, 0, 2 * effectiveWidth, 6 * effectiveWidth, 2 * effectiveWidth }, 0.0f); default: return new BasicStroke(width); } }
From source file:StrokeTest.java
public StrokeTestFrame() { setTitle("StrokeTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); canvas = new StrokeComponent(); add(canvas, BorderLayout.CENTER); buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(3, 3)); add(buttonPanel, BorderLayout.NORTH); ButtonGroup group1 = new ButtonGroup(); makeCapButton("Butt Cap", BasicStroke.CAP_BUTT, group1); makeCapButton("Round Cap", BasicStroke.CAP_ROUND, group1); makeCapButton("Square Cap", BasicStroke.CAP_SQUARE, group1); ButtonGroup group2 = new ButtonGroup(); makeJoinButton("Miter Join", BasicStroke.JOIN_MITER, group2); makeJoinButton("Bevel Join", BasicStroke.JOIN_BEVEL, group2); makeJoinButton("Round Join", BasicStroke.JOIN_ROUND, group2); ButtonGroup group3 = new ButtonGroup(); makeDashButton("Solid Line", false, group3); makeDashButton("Dashed Line", true, group3); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.renderer.FormattedXYErrorRenderer.java
@Override public void renderFormatDelegateChanged(RenderFormatDelegate source) { SeriesFormat seriesFormat = source.getSeriesFormat(); if (seriesFormat != null) { setErrorStroke(new BasicStroke(Math.round(seriesFormat.getLineWidth() / 2.0), BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER)); }//from w w w .j a v a2 s. co m }
From source file:peakmlviewer.dialog.peakinformation.Graph.java
public Graph(Composite parent) { super(parent, SWT.EMBEDDED); setLayout(new FillLayout()); // create the chart linechart = ChartFactory.createLineChart(null, "", "Abundance", dataset_intensity, PlotOrientation.VERTICAL, false, // legend false, // tooltips false // urls );/*from w ww .j a va 2 s . co m*/ CategoryPlot plot = (CategoryPlot) linechart.getPlot(); // make the labels for the xaxis 45 degrees CategoryAxis xaxis = (CategoryAxis) plot.getDomainAxis(); xaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // add the mass accuracy yaxis NumberAxis yaxis_massacc = new NumberAxis("Mass accuracy (ppm)"); plot.setRangeAxis(1, yaxis_massacc); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); // create the mass accuracy dataset dataset_ppm = new DefaultCategoryDataset(); plot.setDataset(1, dataset_ppm); plot.mapDatasetToRangeAxis(1, 1); // create the renderer for the mass accuracy dataset LineAndShapeRenderer renderer_ppm = new LineAndShapeRenderer(); renderer_ppm.setBaseShapesFilled(true); renderer_ppm.setBaseShapesVisible(true); renderer_ppm.setBaseStroke( new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1, new float[] { 5, 5 }, 0)); plot.setRenderer(1, renderer_ppm); // setup the renderer for the intensity dataset LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesFilled(true); renderer.setBaseShapesVisible(true); // general properties linechart.setBackgroundPaint(Color.WHITE); linechart.setBorderVisible(false); linechart.setAntiAlias(true); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); // add the components // -------------------------------------------------------------------------------- // This uses the SWT-trick for embedding awt-controls in an SWT-Composit. try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { ; } java.awt.Frame frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(this); // create a new ChartPanel, without the popup-menu (5x false) frame.add(new ChartPanel(linechart, false, false, false, false, false)); // -------------------------------------------------------------------------------- }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.renderer.FormattedStatisticalLineAndShapeRenderer.java
@Override public void renderFormatDelegateChanged(RenderFormatDelegate source) { SeriesFormat seriesFormat = source.getSeriesFormat(); if (seriesFormat != null) { setErrorIndicatorStroke(new BasicStroke(Math.round(seriesFormat.getLineWidth() / 2.0), BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER)); }//from w ww.j a va 2s . c o m }
From source file:GeMSE.Visualization.ElbowPlot.java
public void Plot(ArrayList<Double[]> pvData, ArrayList<Double[]> dData, int cut) { double maxY = 0; float[] secYColor = new float[3]; Color.RGBtoHSB(153, 245, 255, secYColor); float[] priYColor = new float[3]; Color.RGBtoHSB(255, 255, 255, priYColor); float[] cutColor = new float[3]; Color.RGBtoHSB(255, 255, 0, cutColor); //create the series - add some dummy data XYSeries pvSeries = new XYSeries("Percentage of variance "); for (int i = 1; i < pvData.size(); i++) { pvSeries.add(pvData.get(i)[0], pvData.get(i)[1]); maxY = Math.max(maxY, pvData.get(i)[1]); }//from w ww. java 2s . c o m XYSeries dSeries = new XYSeries("Percentage of differences between slopes "); for (int i = 0; i < dData.size(); i++) dSeries.add(dData.get(i)[0], dData.get(i)[1]); XYSeries cutSeries = new XYSeries("Cut "); cutSeries.add(cut, 0.0); cutSeries.add(cut, maxY); //create the datasets XYSeriesCollection pvDataSeries = new XYSeriesCollection(); pvDataSeries.addSeries(pvSeries); XYSeriesCollection cutDataSeries = new XYSeriesCollection(); cutDataSeries.addSeries(cutSeries); XYSeriesCollection dDataSeries = new XYSeriesCollection(); dDataSeries.addSeries(dSeries); //construct the plot XYPlot plot = new XYPlot(); plot.setDataset(0, pvDataSeries); plot.setDataset(1, cutDataSeries); plot.setDataset(2, dDataSeries); // use XYSplineRenderer if you want to smooth the lines. XYLineAndShapeRenderer pvRenderer = new XYLineAndShapeRenderer(); pvRenderer.setSeriesPaint(0, Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2])); BasicStroke dstroke = new BasicStroke(2.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 1.0f, 10.0f }, 0.0f); XYLineAndShapeRenderer dRenderer = new XYLineAndShapeRenderer(); dRenderer.setSeriesPaint(0, Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2])); dRenderer.setSeriesStroke(0, dstroke); BasicStroke cutStoke = new BasicStroke(4); // use XYSplineRenderer if you want to smooth the lines. //XYSplineRenderer cutRenderer = new XYSplineRenderer(); XYLineAndShapeRenderer cutRenderer = new XYLineAndShapeRenderer(); cutRenderer.setSeriesPaint(0, Color.getHSBColor(cutColor[0], cutColor[1], cutColor[2])); cutRenderer.setSeriesStroke(0, cutStoke); plot.setRenderer(0, pvRenderer); plot.setRenderer(1, cutRenderer); plot.setRenderer(2, dRenderer); plot.setRangeAxis(0, new NumberAxis("\n\nPercentage of Variance")); plot.setRangeAxis(1, new NumberAxis("Percentage of Difference Between Slopes")); plot.setDomainAxis(new NumberAxis("Number of Clusters\n\n")); //Map the data to the appropriate axis plot.mapDatasetToRangeAxis(0, 0); plot.mapDatasetToRangeAxis(1, 0); plot.mapDatasetToRangeAxis(2, 1); float[] hsbValues = new float[3]; Color.RGBtoHSB(16, 23, 67, hsbValues); plot.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2])); Font axisLabelFont = new Font("Dialog", Font.PLAIN, 14); Font axisTickLabelFont = new Font("Dialog", Font.PLAIN, 12); Font legendFont = new Font("Dialog", Font.PLAIN, 14); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.white); plot.getDomainAxis().setLabelPaint(Color.white); plot.getDomainAxis().setLabelFont(axisLabelFont); plot.getDomainAxis().setTickLabelFont(axisTickLabelFont); plot.getRangeAxis().setTickLabelPaint(Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2])); plot.getRangeAxis().setLabelPaint(Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2])); plot.getRangeAxis().setLabelFont(axisLabelFont); plot.getRangeAxis().setTickLabelFont(axisTickLabelFont); plot.getRangeAxis(1).setTickLabelPaint(Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2])); plot.getRangeAxis(1).setLabelPaint(Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2])); plot.getRangeAxis(1).setLabelFont(axisLabelFont); plot.getRangeAxis(1).setTickLabelFont(axisTickLabelFont); //generate the chart JFreeChart chart = new JFreeChart("\nSuggested number of clusters determined using Elbow method", getFont(), plot, true); chart.getTitle().setPaint(Color.white); chart.getLegend().setBackgroundPaint(Color.black); chart.getLegend().setItemPaint(Color.white); chart.getLegend().setPosition(RectangleEdge.BOTTOM); chart.getLegend().setItemFont(legendFont); float[] hsbValues2 = new float[3]; Color.RGBtoHSB(36, 43, 87, hsbValues2); chart.setBackgroundPaint(Color.getHSBColor(hsbValues2[0], hsbValues2[1], hsbValues2[2])); JPanel chartPanel = new ChartPanel(chart); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); chartPanel.setPreferredSize( new java.awt.Dimension((int) Math.round((gd.getDisplayMode().getWidth() * 1.5) / 3.0), (int) Math.round((gd.getDisplayMode().getHeight() * 1.5) / 3.0))); setContentPane(chartPanel); }