List of usage examples for java.awt BasicStroke JOIN_BEVEL
int JOIN_BEVEL
To view the source code for java.awt BasicStroke JOIN_BEVEL.
Click Source Link
From source file:org.kalypso.zml.core.base.TSLinkWithName.java
public Stroke getStroke() { final float width = getLineWidth(); final float[] dash = getLineDash(); return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, dash, 1f); }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java
private void setStrokeDiff(final Stroke newStroke, final Stroke oldStroke) { if (newStroke == oldStroke) { return;//from w w w .ja v a 2 s .c om } if (!(newStroke instanceof BasicStroke)) { return; } final BasicStroke nStroke = (BasicStroke) newStroke; final boolean oldOk = (oldStroke instanceof BasicStroke); BasicStroke oStroke = null; if (oldOk) { oStroke = (BasicStroke) oldStroke; } if (!oldOk || nStroke.getLineWidth() != oStroke.getLineWidth()) { cb.setLineWidth(nStroke.getLineWidth()); } if (!oldOk || nStroke.getEndCap() != oStroke.getEndCap()) { switch (nStroke.getEndCap()) { case BasicStroke.CAP_BUTT: cb.setLineCap(0); break; case BasicStroke.CAP_SQUARE: cb.setLineCap(2); break; default: cb.setLineCap(1); } } if (!oldOk || nStroke.getLineJoin() != oStroke.getLineJoin()) { switch (nStroke.getLineJoin()) { case BasicStroke.JOIN_MITER: cb.setLineJoin(0); break; case BasicStroke.JOIN_BEVEL: cb.setLineJoin(2); break; default: cb.setLineJoin(1); } } if (!oldOk || nStroke.getMiterLimit() != oStroke.getMiterLimit()) { cb.setMiterLimit(nStroke.getMiterLimit()); } final boolean makeDash; if (oldOk) { if (nStroke.getDashArray() != null) { if (nStroke.getDashPhase() != oStroke.getDashPhase()) { makeDash = true; } else if (!Arrays.equals(nStroke.getDashArray(), oStroke.getDashArray())) { makeDash = true; } else { makeDash = false; } } else if (oStroke.getDashArray() != null) { makeDash = true; } else { makeDash = false; } } else { makeDash = true; } if (makeDash) { final float[] dash = nStroke.getDashArray(); if (dash == null) { cb.setLiteral("[]0 d\n"); } else { cb.setLiteral('['); final int lim = dash.length; for (int k = 0; k < lim; ++k) { cb.setLiteral(dash[k]); cb.setLiteral(' '); } cb.setLiteral(']'); cb.setLiteral(nStroke.getDashPhase()); cb.setLiteral(" d\n"); } } }
From source file:org.tellervo.desktop.graph.SkeletonPlot.java
protected BasicStroke makeStroke(float width, boolean dotted) { if (dotted)//ww w . java 2 s . c o m return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10f, new float[] { 8f }, 0f); else return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); }
From source file:paquete.HollywoodUI.java
private void Mostrar_grafoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Mostrar_grafoActionPerformed SimpleGraphView sgv = new SimpleGraphView(); sgv.setGrafo(HollyUniverseGraph);//w w w . ja v a2 s . co m Layout<Actor, Arista> layout = new CircleLayout(sgv.grafo); layout.setSize(new Dimension(800, 600)); BasicVisualizationServer<Actor, Arista> bvs = new BasicVisualizationServer<>(layout); bvs.setPreferredSize(new Dimension(850, 650)); //agregando etiquetas al grafo Transformer<Actor, Paint> vertexPaint = new Transformer<Actor, Paint>() { public Paint transform(Actor i) { return Color.GREEN; } }; float dash[] = { 10.0f }; final Stroke edgeStroke = new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, dash, 0.0f); Transformer<Arista, Stroke> edgeStrokeTransformer = new Transformer<Arista, Stroke>() { public Stroke transform(Arista s) { return edgeStroke; } }; bvs.getRenderContext().setVertexFillPaintTransformer(vertexPaint); // bvs.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); bvs.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); bvs.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); bvs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); JFrame frame = new JFrame("Vista del grafo con libreria JUNG2"); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); frame.getContentPane().add(bvs); frame.pack(); frame.setLocationRelativeTo(this); frame.setVisible(true); }
From source file:ucar.unidata.idv.ui.ImageGenerator.java
/** * Process the lat/lon labels tag/*from www . j a v a2 s . c om*/ * * @param child the XML * @param viewManager the associated view manager * @param image the image to draw on * @param imageProps the image properties * * @return a new image * * @throws Exception on badness */ public BufferedImage doLatLonLabels(Element child, ViewManager viewManager, BufferedImage image, Hashtable imageProps) throws Exception { if (viewManager == null) { throw new IllegalArgumentException("Tag " + TAG_LATLONLABELS + " requires a view"); } if (!(viewManager instanceof MapViewManager)) { throw new IllegalArgumentException("Tag " + TAG_LATLONLABELS + " requires a map view"); } MapViewManager mvm = (MapViewManager) viewManager; NavigatedDisplay display = (NavigatedDisplay) viewManager.getMaster(); DecimalFormat format = new DecimalFormat(applyMacros(child, ATTR_FORMAT, "##0.0")); Color color = applyMacros(child, ATTR_COLOR, Color.red); Color lineColor = applyMacros(child, ATTR_LINECOLOR, color); Color bg = applyMacros(child, ATTR_LABELBACKGROUND, (Color) null); double[] latValues = Misc.parseDoubles(applyMacros(child, ATTR_LAT_VALUES, "")); List<String> latLabels = StringUtil.split(applyMacros(child, ATTR_LAT_LABELS, ""), ",", true, true); double[] lonValues = Misc.parseDoubles(applyMacros(child, ATTR_LON_VALUES, "")); List<String> lonLabels = StringUtil.split(applyMacros(child, ATTR_LON_LABELS, ""), ",", true, true); boolean drawLonLines = applyMacros(child, ATTR_DRAWLONLINES, false); boolean drawLatLines = applyMacros(child, ATTR_DRAWLATLINES, false); boolean showTop = applyMacros(child, ATTR_SHOWTOP, false); boolean showBottom = applyMacros(child, ATTR_SHOWBOTTOM, true); boolean showLeft = applyMacros(child, ATTR_SHOWLEFT, true); boolean showRight = applyMacros(child, ATTR_SHOWRIGHT, false); int width = image.getWidth(null); int height = image.getHeight(null); int centerX = width / 2; int centerY = height / 2; EarthLocation nw, ne, se, sw; //don: this what I added Double north = (Double) imageProps.get(ATTR_NORTH); Double south = (Double) imageProps.get(ATTR_SOUTH); Double east = (Double) imageProps.get(ATTR_EAST); Double west = (Double) imageProps.get(ATTR_WEST); //Assume if we have one we have them all if (north != null) { nw = DisplayControlImpl.makeEarthLocation(north.doubleValue(), west.doubleValue(), 0); ne = DisplayControlImpl.makeEarthLocation(north.doubleValue(), east.doubleValue(), 0); sw = DisplayControlImpl.makeEarthLocation(south.doubleValue(), west.doubleValue(), 0); se = DisplayControlImpl.makeEarthLocation(south.doubleValue(), east.doubleValue(), 0); } else { nw = display.screenToEarthLocation(0, 0); ne = display.screenToEarthLocation(width, 0); se = display.screenToEarthLocation(0, height); sw = display.screenToEarthLocation(width, height); } double widthDegrees = ne.getLongitude().getValue() - nw.getLongitude().getValue(); double heightDegrees = ne.getLatitude().getValue() - se.getLatitude().getValue(); Insets insets = getInsets(child, 0); int delta = 2; int bgPad = 1; image = doMatte(image, child, 0); Graphics2D g = (Graphics2D) image.getGraphics(); g.setFont(getFont(child)); FontMetrics fm = g.getFontMetrics(); int lineOffsetRight = applyMacros(child, ATTR_LINEOFFSET_RIGHT, 0); int lineOffsetLeft = applyMacros(child, ATTR_LINEOFFSET_LEFT, 0); int lineOffsetTop = applyMacros(child, ATTR_LINEOFFSET_TOP, 0); int lineOffsetBottom = applyMacros(child, ATTR_LINEOFFSET_BOTTOM, 0); Stroke lineStroke; if (XmlUtil.hasAttribute(child, ATTR_DASHES)) { lineStroke = new BasicStroke((float) applyMacros(child, ATTR_LINEWIDTH, 1.0), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, Misc.parseFloats(applyMacros(child, ATTR_DASHES, "8")), 0.0f); } else { lineStroke = new BasicStroke((float) applyMacros(child, ATTR_LINEWIDTH, 1.0)); } g.setStroke(lineStroke); double leftLon = nw.getLongitude().getValue(CommonUnit.degree); double rightLon = ne.getLongitude().getValue(CommonUnit.degree); Range lonRange = new Range(leftLon, rightLon); for (int i = 0; i < lonValues.length; i++) { double lon = GeoUtils.normalizeLongitude(lonRange, lonValues[i]); double percent = (lon - nw.getLongitude().getValue()) / widthDegrees; // if(percent<0 || percent>1) continue; String label; if (i < lonLabels.size()) { label = lonLabels.get(i); } else { label = format.format(lonValues[i]); } Rectangle2D rect = fm.getStringBounds(label, g); int baseX = insets.left + (int) (percent * width); int x = baseX - (int) rect.getWidth() / 2; int topY; if (insets.top == 0) { topY = (int) rect.getHeight() + delta; } else { topY = insets.top - delta; } if (drawLonLines) { g.setColor(lineColor); g.drawLine(baseX, insets.top + lineOffsetTop, baseX, insets.top + height - lineOffsetBottom); } if (showTop) { if (bg != null) { g.setColor(bg); g.fillRect(x - bgPad, topY - (int) rect.getHeight() - bgPad, (int) rect.getWidth() + bgPad * 2, (int) rect.getHeight() + bgPad * 2); } g.setColor(color); g.drawString(label, x, topY); } int bottomY; if (insets.bottom == 0) { bottomY = insets.top + height - delta; } else { bottomY = insets.top + height + (int) rect.getHeight() + delta; } if (showBottom) { if (bg != null) { g.setColor(bg); g.fillRect(x - bgPad, bottomY - (int) rect.getHeight() - bgPad, (int) rect.getWidth() + bgPad * 2, (int) rect.getHeight() + bgPad * 2); } g.setColor(color); g.drawString(label, x, bottomY); } } for (int i = 0; i < latValues.length; i++) { double lat = latValues[i]; double percent = 1.0 - (lat - se.getLatitude().getValue()) / heightDegrees; int baseY = insets.top + (int) (percent * height); // if(percent<0 || percent>1) continue; String label; if (i < latLabels.size()) { label = latLabels.get(i); } else { label = format.format(lat); } Rectangle2D rect = fm.getStringBounds(label, g); int y = baseY + (int) rect.getHeight() / 2; int leftX; if (insets.left == 0) { leftX = 0 + delta; } else { leftX = insets.left - (int) rect.getWidth() - delta; } if (drawLonLines) { g.setColor(lineColor); g.drawLine(insets.left + lineOffsetRight, baseY, insets.left + width - lineOffsetRight, baseY); } if (showLeft) { if (bg != null) { g.setColor(bg); g.fillRect(leftX - bgPad, y - (int) rect.getHeight() - bgPad, (int) rect.getWidth() + bgPad * 2, (int) rect.getHeight() + bgPad * 2); } g.setColor(color); g.drawString(label, leftX, y); } if (insets.right == 0) { leftX = insets.left + width - (int) rect.getWidth() - delta; } else { leftX = insets.left + width + delta; } if (showRight) { if (bg != null) { g.setColor(bg); g.fillRect(leftX - bgPad, y - (int) rect.getHeight() - bgPad, (int) rect.getWidth() + bgPad * 2, (int) rect.getHeight() + bgPad * 2); } g.setColor(color); g.drawString(label, leftX, y); } } return image; }