List of usage examples for java.awt BasicStroke BasicStroke
@ConstructorProperties({ "lineWidth", "endCap", "lineJoin", "miterLimit", "dashArray", "dashPhase" }) public BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase)
From source file:org.openfaces.component.chart.impl.PropertiesConverter.java
public static Stroke toStroke(StyleBorderModel border) { Stroke stroke = null;/*from www.java 2 s. c om*/ if (border != null) { int width = border.getWidth(); String style = border.getStyle(); if (style.equalsIgnoreCase("DASHED")) { float[] dash = { width * 4 }; stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, width * 3, dash, 1F); } else if (style.equalsIgnoreCase("DOTTED")) { float[] dash = { width }; stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, width * 3, dash, 1F); } else { stroke = new BasicStroke(width); } } return stroke; }
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 w w. j a v a 2 s . c o 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:TransformTranslation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);//from w w w. j a v a2s . c om // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. g2.transform(AffineTransform.getTranslateInstance(150, 0)); // Draw the "new" shapes in dashed. Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:TransformersRotation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);/* ww w .j a v a 2s. co m*/ // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. g2.transform(AffineTransform.getRotateInstance(-Math.PI / 6)); // Draw the "new" shapes in dashed. Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:TransformScale.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);/*from w w w . j av a 2 s. c o m*/ // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. g2.transform(AffineTransform.getScaleInstance(3, 3)); // Draw the "new" shapes in dashed. g2.transform(AffineTransform.getTranslateInstance(75, 75)); Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:TransformTranslatedRotation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);/* ww w . j a v a 2s . co m*/ // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. float cm = 72 / 2.54f; g2.transform(AffineTransform.getRotateInstance(-Math.PI / 6, 3 * cm, 2 * cm)); // Draw the "new" shapes in dashed. Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:TransformTransRotation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);/*from w ww.j a va 2 s . c o m*/ // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. AffineTransform rat = new AffineTransform(); rat.setToTranslation(100, 0); rat.rotate(Math.PI / 6); g2.transform(rat); // Draw the "new" shapes in dashed. Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:TransformersRotationTranslation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);/*from www . j av a2s. co m*/ // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. AffineTransform rat = new AffineTransform(); rat.setToRotation(Math.PI / 6); rat.translate(100, 100); g2.transform(rat); // Draw the "new" shapes in dashed. Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:TransformShear.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Use antialiasing. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Move the origin to 75, 75. AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at);/* ww w . ja v a 2 s . c o m*/ // Draw the shapes in their original locations. g2.setPaint(Color.black); g2.draw(axes); g2.draw(shape); // Transform the Graphics2D. AffineTransform sat = AffineTransform.getTranslateInstance(150, 0); sat.shear(-.5, 0); g2.transform(sat); // Draw the "new" shapes in dashed. g2.transform(AffineTransform.getTranslateInstance(75, 75)); Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0); g2.setStroke(stroke); g2.draw(axes); g2.draw(shape); }
From source file:sturesy.votinganalysis.TimeChart.java
/** * Creates an XYSeries-ChartPanel//from w w w .j av a2 s . co m * * @param votes * votes to use * @return ChartPanel */ private ChartPanel getXYSeriesChart(Set<Vote> votes) { final XYSeries series = new XYSeries(Localize.getString("label.votes.over.time")); if (votes.size() != 0) { double[] dubble = createArrayOfVotes(votes); for (int i = 0; i < dubble.length; i++) { series.add(i, dubble[i]); } } final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart(Localize.getString("label.votes.over.time"), Localize.getString("label.time.seconds"), Localize.getString("label.amount.votes"), data, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(_background); chart.getPlot().setNoDataMessage("NO DATA"); chart.getXYPlot().getRenderer().setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f)); chart.getXYPlot().getRenderer().setSeriesPaint(0, new Color(255, 140, 0)); chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel chartpanel = new ChartPanel(chart); return chartpanel; }