List of usage examples for java.awt BasicStroke JOIN_MITER
int JOIN_MITER
To view the source code for java.awt BasicStroke JOIN_MITER.
Click Source Link
From source file:ega.projekt.graphDraw.DrawGraph.java
/** * @param args the command line arguments *///from ww w .j ava 2 s . c o m public static void main(String[] args) { ega.projekt.graph.Graph dataGraph = new ega.projekt.graph.Graph(5, 100, 295, 295); if (dataGraph.getEdges().isEmpty()) System.out.println("Error initializing graph"); DrawGraph graphView = new DrawGraph(dataGraph); // This builds the graph // Layout<V, E>, VisualizationComponent<V,E> Layout<Node, Edge> layout = new StaticLayout(graphView.drawGraph); for (Node n : graphView.drawGraph.getVertices()) { layout.setLocation(n, new java.awt.geom.Point2D.Double(n.getX(), n.getY())); } layout.setSize(new Dimension(300, 300)); BasicVisualizationServer<Node, Edge> vv = new BasicVisualizationServer<>(layout); vv.setPreferredSize(new Dimension(350, 350)); // Setup up a new vertex to paint transformer... Transformer<Node, Paint> vertexPaint = new Transformer<Node, Paint>() { public Paint transform(Node i) { return Color.GREEN; } }; // Set up a new stroke Transformer for the edges //float dash[] = {10.0f}; final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); Transformer<Edge, Stroke> edgeStrokeTransformer = new Transformer<Edge, Stroke>() { public Stroke transform(Edge e) { if (e.isMarked()) { final Stroke modStroke = new BasicStroke(5.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); return modStroke; } return edgeStroke; } }; Transformer<Edge, Paint> edgePaint = new Transformer<Edge, Paint>() { public Paint transform(Edge e) { if (e.isMarked()) { return Color.RED; } return Color.BLACK; } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Node, Edge>()); vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Edge, String>() { public String transform(Edge e) { return (e.getFlowString() + "/" + Integer.toString(e.getCapacity())); } }); vv.getRenderContext().setVertexLabelTransformer(new Transformer<Node, String>() { public String transform(Node n) { return (Integer.toString(n.getID())); } }); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); JFrame frame = new JFrame("Simple Graph View 2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static Stroke getDotStroke() { int w = 1;//from www . j a 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;//from w w w . j a va2 s . co m 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 static String convertLineJoinToString(int lineJoin) { if (lineJoin == BasicStroke.JOIN_BEVEL) return "bevel"; else if (lineJoin == BasicStroke.JOIN_MITER) return "miter"; else if (lineJoin == BasicStroke.JOIN_ROUND) return "round"; return null;// ww w.j a v a 2 s . c o m }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; RenderingHints rh = g2.getRenderingHints(); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHints(rh);/*from w w w.ja v a2 s. c om*/ BasicStroke bs = new BasicStroke(36.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); g2.setStroke(bs); GeneralPath path = new GeneralPath(); path.moveTo(30.0f, 90.0f); path.lineTo(150.0f, 20.0f); path.lineTo(270.0f, 90.0f); g2.draw(path); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; RenderingHints rh = g2.getRenderingHints(); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHints(rh);/*from w ww. jav a2 s. c o m*/ BasicStroke bs = new BasicStroke(36.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); g2.setStroke(bs); GeneralPath path = new GeneralPath(); path.moveTo(30.0f, 90.0f); path.lineTo(150.0f, 20.0f); path.lineTo(270.0f, 90.0f); g2.draw(path); }
From source file:DashedStrokeDemo.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; float dash[] = { 10.0f }; g2.setStroke(new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f)); g2.setPaint(Color.blue);// w ww . jav a 2 s . c om Rectangle r = new Rectangle(5, 5, 200, 200); g2.draw(r); }
From source file:BasicDraw.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; float strokeThickness = 5.0f; float miterLimit = 10f; float[] dashPattern = { 10f }; float dashPhase = 5f; BasicStroke stroke = new BasicStroke(strokeThickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, miterLimit, dashPattern, dashPhase); g2d.setStroke(stroke);//from w w w. j av a2s. c om g2d.draw(new Rectangle(20, 20, 200, 200)); }
From source file:edu.asu.mgb.gui.IndividualTransformer.java
@Override public Transformer<Action, Stroke> getEdgeStrokeTransformer() { return new Transformer<Action, Stroke>() { final float dash[] = { 1.0f }; @Override/* w w w. ja v a 2 s .c om*/ public Stroke transform(Action s) { return new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); } }; }
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// w ww . java 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); } } }; }