List of usage examples for java.awt BasicStroke CAP_BUTT
int CAP_BUTT
To view the source code for java.awt BasicStroke CAP_BUTT.
Click Source Link
From source file:edu.asu.mgb.gui.AggregateTransformer.java
@Override public Transformer<Action, Stroke> getEdgeStrokeTransformer() { return new Transformer<Action, Stroke>() { final float dash[] = { 1.0f }; @Override/*from ww w . j av a 2 s .co m*/ public Stroke transform(Action s) { if (s.isHighlighted()) { return new BasicStroke(HIGHLIGHT_STROKE); } else { return new BasicStroke(1.0f + ((float) 10.0 * s.getNormalizedCount()), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); } } }; }
From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.CompassRenderer.java
@Override public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex) { // compute the right color for the paint int length = GuiUtils.getAvailableColors().length; Color color = GuiUtils.getAvailableColors()[index % length]; // get all the data points int numPoints = dataset.getItemCount(seriesIndex); // set STroke and Paint of the graphics g2.setStroke(new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); g2.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 175)); // iterate through the points of the dataset for (int i = 0; i < numPoints; i++) { double theta = dataset.getXValue(seriesIndex, i); // the angle at the center double radius = dataset.getYValue(seriesIndex, i); // the frequency Point p0 = plot.translateToJava2D(0, 0, plot.getAxis(), dataArea); Point p1 = plot.translateToJava2D(theta, radius, plot.getAxis(), dataArea); Line2D line = new Line2D.Double(p0, p1); g2.draw(line);/* w w w.j a v a 2s.c o m*/ } }
From source file:grafos.JUNGraph.java
/** * Cria visualizao grfica do grafo// w w w . ja v a2s. co m * @param grafo * @return */ //public static void createGraphVisualization(List<Grafo> grafo, List<Vertex> path, String origem, String destino){ public static BasicVisualizationServer<Integer, String> createGraphVisualization(List<Grafo> grafo) { JUNGraph sgv = new JUNGraph(grafo); Layout<Integer, String> layout = new CircleLayout(sgv.g); layout.setSize(new Dimension(500, 500)); BasicVisualizationServer<Integer, String> vv = new BasicVisualizationServer<>(layout); vv.setPreferredSize(new Dimension(500, 500)); Transformer<Integer, Paint> vertexPaint = new Transformer<Integer, Paint>() { @Override public Paint transform(Integer i) { return Color.ORANGE; } }; float dash[] = { 5.0f }; final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f, dash, 0.0f); Transformer<String, Stroke> edgeStrokeTransformer = new Transformer<String, Stroke>() { @Override public Stroke transform(String s) { return edgeStroke; } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); return vv; }
From source file:inet.CalculationNetworkEditor.Transformers.EdgeStrokeTransformer.java
@Override public Stroke transform(E i) { switch (jtp.getSelectedIndex()) { case 0: //Physical case 1: { //Virtual //return new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); return new BasicStroke(3.0f); }//from w w w .j a va 2s .c o m case 2: { //Both if (logic.containsEdge(i)) { if (logic.getTypeOfEdge(i) == IStorage.Type.PHYSICAL) { return new BasicStroke(3.0f); } else if (logic.getTypeOfEdge(i) == IStorage.Type.VIRTUAL) { if (logic.getStackedEdgePath(i) == null) { // edge is not stacked BasicStroke dashed = new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); return dashed; } else { return new BasicStroke(3.0f); } } else { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "unknown edge type"); } } else { // it is an edge which only exists in frontend for visualization purpose return new BasicStroke(3.0f); } } break; default: { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "unknown view"); } } return new BasicStroke(3.0f); }
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:org.openfaces.component.chart.impl.configuration.PlotSelectionConfigurator.java
private void setupGridChartSelection(Plot plot, GridChartView chartView) { if (chartView.getPoint() != null) { GridPointInfo point = chartView.getPoint(); final ChartSelection selection = chartView.getChart().getChartSelection(); final LineStyle lineStyle = selection.getLineStyle(); Paint outlinePaint = lineStyle.getColor() != null ? lineStyle.getColor() : Color.BLUE; final Stroke outlineStroke = lineStyle.getStroke() != null ? lineStyle.getStroke() : new BasicStroke(5.0F, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); final Paint selectionPaint = selection.getFillPaint(); Object itemRenderer = null; if (plot instanceof XYPlot) { itemRenderer = ((XYPlot) plot).getRenderer(); } else if (plot instanceof CategoryPlot) { itemRenderer = ((CategoryPlot) plot).getRenderer(); }// w w w. j a v a2 s . c o m if (itemRenderer != null && itemRenderer instanceof CustomizedRenderer) { if (itemRenderer instanceof BarRenderer) { ((BarRenderer) itemRenderer).setDrawBarOutline(true); } else if (itemRenderer instanceof XYBarRenderer) { ((XYBarRenderer) itemRenderer).setDrawBarOutline(true); } else if (itemRenderer instanceof XYRendererAdapter) { ((XYRendererAdapter) itemRenderer).setDrawOutlines(true); } else if (itemRenderer instanceof XYLineAndShapeRenderer) { ((XYLineAndShapeRenderer) itemRenderer).setDrawOutlines(true); } final SeriesInfo series = point.getSeries(); ((CustomizedRenderer) itemRenderer).setItemOutlinePaint(series.getIndex(), point.getIndex(), outlinePaint); ((CustomizedRenderer) itemRenderer).setItemOutlineStroke(series.getIndex(), point.getIndex(), outlineStroke); ((CustomizedRenderer) itemRenderer).setItemPaint(series.getIndex(), point.getIndex(), selectionPaint); } } }
From source file:org.openfaces.component.chart.impl.PropertiesConverter.java
public static Stroke toStroke(StyleBorderModel border) { Stroke stroke = null;/*from ww w.j av a 2 s. c o m*/ 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: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 ww . jav a2 s . com // 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);/*from w w w .ja v a 2 s . 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.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 ww. ja v a 2 s .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.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); }