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:eu.udig.style.advanced.utils.Utilities.java
/** * Convert a sld line join definition to the java awt value. * /*w w w. j a v a 2 s . c om*/ * @param sldJoin the sld join string. * @return the awt value. */ public static int sld2awtJoin(String sldJoin) { if (sldJoin.equals(lineJoinNames[1])) { return BasicStroke.JOIN_BEVEL; } else if (sldJoin.equals("") || sldJoin.equals(lineJoinNames[2])) { return BasicStroke.JOIN_MITER; } else if (sldJoin.equals(lineJoinNames[3])) { return BasicStroke.JOIN_ROUND; } else { throw new IllegalArgumentException("unsupported line join"); } }
From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java
private byte[] createDailyLoginChart(int width, int height) { IntervalXYDataset dataset1 = getDailyLoginsDataSet(); IntervalXYDataset dataset2 = getDailySiteUserDataSet(); if ((dataset1 == null) || (dataset2 == null)) { return generateNoDataChart(width, height); }//from w ww . j a v a2 s . c om // create plot ... XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setSeriesPaint(0, Color.RED); renderer1.setSeriesPaint(1, Color.BLUE); renderer1.setSeriesPaint(2, Color.RED); renderer1.setSeriesPaint(3, Color.BLUE); renderer1.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer1.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); BasicStroke dashLineStroke = new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0, new float[] { 4 }, 0); renderer1.setSeriesStroke(2, dashLineStroke); renderer1.setSeriesStroke(3, dashLineStroke); DateAxis domainAxis = new DateAxis(""); domainAxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat("yyyy-MM-dd"))); domainAxis.setTickMarkPosition(DateTickMarkPosition.START); domainAxis.setVerticalTickLabels(true); domainAxis.setLowerMargin(0.01); domainAxis.setUpperMargin(0.01); NumberAxis rangeAxis = new NumberAxis("count"); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYPlot plot1 = new XYPlot(dataset1, null, rangeAxis, renderer1); plot1.setBackgroundPaint(Color.lightGray); plot1.setDomainGridlinePaint(Color.white); plot1.setRangeGridlinePaint(Color.white); // add a second dataset and renderer... XYItemRenderer renderer2 = new XYLineAndShapeRenderer(true, false); renderer2.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer2.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer2.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer2.setSeriesPaint(0, Color.GREEN); renderer2.setSeriesPaint(1, Color.BLACK); renderer2.setSeriesPaint(2, Color.CYAN); rangeAxis = new NumberAxis("count"); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYPlot plot2 = new XYPlot(dataset2, null, rangeAxis, renderer2); plot2.setBackgroundPaint(Color.lightGray); plot2.setDomainGridlinePaint(Color.white); plot2.setRangeGridlinePaint(Color.white); CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis); cplot.add(plot1, 3); cplot.add(plot2, 2); cplot.setGap(8.0); cplot.setDomainGridlinePaint(Color.white); cplot.setDomainGridlinesVisible(true); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, cplot, false); LegendTitle legend = new LegendTitle(cplot); chart.addSubtitle(legend); // set background chart.setBackgroundPaint(parseColor(statsManager.getChartBackgroundColor())); // set chart border chart.setPadding(new RectangleInsets(10, 5, 5, 5)); chart.setBorderVisible(true); chart.setBorderPaint(parseColor("#cccccc")); // set anti alias chart.setAntiAlias(true); BufferedImage img = chart.createBufferedImage(width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try { ImageIO.write(img, "png", out); } catch (IOException e) { log.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }
From source file:spinworld.gui.RadarPlot.java
/** * Draws a radar plot polygon./*from w w w . j ava 2s. com*/ * * @param g2 the graphics device. * @param plotArea the area we are plotting in (already adjusted). * @param centre the centre point of the radar axes * @param info chart rendering info. * @param series the series within the dataset we are plotting * @param catCount the number of categories per radar plot * @param headH the data point height * @param headW the data point width */ protected void drawRadarPoly(Graphics2D g2, Rectangle2D plotArea, Point2D centre, PlotRenderingInfo info, int series, int catCount, double headH, double headW) { Polygon polygon = new Polygon(); EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } // plot the data... for (int cat = 0; cat < catCount; cat++) { Number dataValue = getPlotValue(series, cat); if (dataValue != null) { double value = dataValue.doubleValue(); // Finds our starting angle from the centre for this axis double angle = getStartAngle() + (getDirection().getFactor() * cat * 360 / catCount); // The following angle calc will ensure there isn't a top // vertical axis - this may be useful if you don't want any // given criteria to 'appear' move important than the // others.. // + (getDirection().getFactor() // * (cat + 0.5) * 360 / catCount); // find the point at the appropriate distance end point // along the axis/angle identified above and add it to the // polygon double _maxValue = getMaxValue(cat).doubleValue(); double _origin = getOrigin(cat).doubleValue(); double lowerBound = Math.min(_origin, _maxValue); double upperBound = Math.max(_origin, _maxValue); boolean lesser = value < lowerBound; boolean greater = value > upperBound; if ((lesser || greater) && !drawOutOfRangePoints) { continue; } if (lesser) { value = lowerBound; } if (greater) { value = upperBound; } double length = _maxValue == _origin ? 0 : (value - lowerBound) / (upperBound - lowerBound); if (_maxValue < _origin) { // inversed length = 1 - length; } Point2D point = getWebPoint(plotArea, angle, length); polygon.addPoint((int) point.getX(), (int) point.getY()); Paint paint = getSeriesPaint(series); Paint outlinePaint = getSeriesOutlinePaint(series); double px = point.getX(); double py = point.getY(); g2.setPaint(paint); if (lesser || greater) { // user crosshair for out-of-range data points distinguish g2.setStroke(new BasicStroke(1.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL)); double delta = 3; g2.draw(new Line2D.Double(px - delta, py, px + delta, py)); g2.draw(new Line2D.Double(px, py - delta, px, py + delta)); } else { // put an elipse at the point being plotted.. Ellipse2D head = new Ellipse2D.Double(px - headW / 2, py - headH / 2, headW, headH); g2.fill(head); g2.setStroke(getHeadOutlineStroke(series)); g2.setPaint(outlinePaint); g2.draw(head); } if (entities != null) { int row = 0; int col = 0; if (this.dataExtractOrder == TableOrder.BY_ROW) { row = series; col = cat; } else { row = cat; col = series; } String tip = null; if (this.toolTipGenerator != null) { tip = this.toolTipGenerator.generateToolTip(this.dataset, row, col); } String url = null; if (this.urlGenerator != null) { url = this.urlGenerator.generateURL(this.dataset, row, col); } Shape area = new Rectangle((int) (point.getX() - headW), (int) (point.getY() - headH), (int) (headW * 2), (int) (headH * 2)); CategoryItemEntity entity = new CategoryItemEntity(area, tip, url, this.dataset, this.dataset.getRowKey(row), this.dataset.getColumnKey(col)); entities.add(entity); } } } // Plot the polygon Paint paint = getSeriesPaint(series); g2.setPaint(paint); g2.setStroke(getSeriesOutlineStroke(series)); g2.draw(polygon); // Lastly, fill the web polygon if this is required if (this.webFilled) { g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f)); g2.fill(polygon); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); } }
From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java
private static void drawJumps(final Graphics2D gfx, final MindMap map, final MindMapPanelConfig cfg) { final List<Topic> allTopicsWithJumps = map.findAllTopicsForExtraType(Extra.ExtraType.TOPIC); final float scaledSize = cfg.safeScaleFloatValue(cfg.getJumpLinkWidth(), 0.1f); final Stroke lineStroke = new BasicStroke(scaledSize, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 0, new float[] { scaledSize, scaledSize * 3.0f }, 0); final Stroke arrowStroke = new BasicStroke(cfg.safeScaleFloatValue(cfg.getJumpLinkWidth() * 1.0f, 0.3f)); gfx.setColor(cfg.getJumpLinkColor()); final float arrowSize = cfg.safeScaleFloatValue(10.0f * cfg.getJumpLinkWidth(), 0.2f); for (Topic src : allTopicsWithJumps) { final ExtraTopic extra = (ExtraTopic) src.getExtras().get(Extra.ExtraType.TOPIC); src = MindMapUtils.isHidden(src) ? MindMapUtils.findFirstVisibleAncestor(src) : src; final AbstractElement srcElement = (AbstractElement) src.getPayload(); if (extra != null) { Topic dst = map.findTopicForLink(extra); if (dst != null) { if (MindMapUtils.isHidden(dst)) { dst = MindMapUtils.findFirstVisibleAncestor(dst); if (dst == src) { dst = null;//from w ww . j a v a 2 s .c om } } if (dst != null) { final AbstractElement dstElement = (AbstractElement) dst.getPayload(); if (!MindMapUtils.isHidden(dst)) { final Rectangle2D srcRect = srcElement.getBounds(); final Rectangle2D dstRect = dstElement.getBounds(); drawArrowToDestination(gfx, srcRect, dstRect, lineStroke, arrowStroke, arrowSize); } } } } } }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartHelper.java
/*********************************************************************************************** * Create a simple Chart from the specified XYDataset. * Choose a TimeSeriesChart or a XYLineChart appropriately. * Called from createCustomisedChart() in each ChartUIComponent subclass. * * * @param dataset//from w w w . j a va2 s .c o m * @param timezone * @param metadatalist * @param channelcount * @param temperaturechannel * @param updatetype * @param displaylimit * @param channelselector * @param debug * * @return JFreeChart */ public static JFreeChart createChart(final XYDataset dataset, final TimeZone timezone, final List<Metadata> metadatalist, final int channelcount, final boolean temperaturechannel, final DataUpdateType updatetype, final int displaylimit, final ChannelSelectorUIComponentInterface channelselector, final boolean debug) { final String SOURCE = "ChartHelper.createChart() "; final JFreeChart chart; final String strTitle; final String strLabelX; final String strLabelY; final XYDataset xyDatasetToDisplay; // The set of Metadata available should include the Instrument // and any items from the current observation strTitle = MetadataHelper.getMetadataValueByKey(metadatalist, MetadataDictionary.KEY_OBSERVATION_TITLE.getKey()); strLabelX = MetadataHelper.getMetadataValueByKey(metadatalist, MetadataDictionary.KEY_OBSERVATION_AXIS_LABEL_X.getKey()); // Axis.Y.0 only in this version strLabelY = MetadataHelper.getMetadataValueByKey(metadatalist, MetadataDictionary.KEY_OBSERVATION_AXIS_LABEL_Y.getKey() + MetadataDictionary.SUFFIX_SERIES_ZERO); // Transform the XYdataset in accordance with the current ChannelSelection Mode before displaying channelselector.debugSelector(debug, SOURCE); xyDatasetToDisplay = copyTransformedXYDataset(dataset, timezone, updatetype, displaylimit, channelselector.isDecimating(), channelselector.getChannelSelectionModes()); if (dataset instanceof TimeSeriesCollection) { chart = ChartFactory.createTimeSeriesChart(strTitle, strLabelX, strLabelY, xyDatasetToDisplay, channelselector.hasLegend(), true, false); } else { chart = ChartFactory.createXYLineChart(strTitle, strLabelX, strLabelY, xyDatasetToDisplay, PlotOrientation.VERTICAL, channelselector.hasLegend(), true, false); } if ((chart != null) && (chart.getXYPlot() != null) && (chart.getXYPlot().getRangeAxis() != null)) { final Stroke strokeCrosshair; final XYPlot plot; final XYItemRenderer renderer; chart.setBackgroundPaint(UIComponentPlugin.DEFAULT_COLOUR_CANVAS.getColor()); // Experimental chart configuration chart.getTitle().setFont(UIComponentPlugin.DEFAULT_FONT.getFont().deriveFont(20.0f)); plot = chart.getXYPlot(); plot.setBackgroundPaint(COLOR_PLOT); plot.setDomainGridlinePaint(COLOR_GRIDLINES); plot.setRangeGridlinePaint(COLOR_GRIDLINES); plot.setAxisOffset(PLOT_RECTANGLE_INSETS); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(false); plot.setRangeCrosshairVisible(false); // Make the Crosshair more visible by changing the width from the default strokeCrosshair = new BasicStroke(2.0f, // The width of this BasicStroke BasicStroke.CAP_BUTT, // The decoration of the ends of a BasicStroke BasicStroke.JOIN_BEVEL, // The decoration applied where path segments meet 0.0f, // The limit to trim the miter join new float[] { 2.0f, 2.0f }, // The array representing the dashing pattern 0.0f); // The offset to start the dashing pattern plot.setDomainCrosshairStroke(strokeCrosshair); renderer = plot.getRenderer(); if ((renderer != null) && (renderer instanceof XYLineAndShapeRenderer)) { final XYLineAndShapeRenderer xyItemRenderer; int intSeriesCount; xyItemRenderer = (XYLineAndShapeRenderer) renderer; xyItemRenderer.setBaseLinesVisible(true); xyItemRenderer.setBaseShapesVisible(false); xyItemRenderer.setBaseShapesFilled(true); xyItemRenderer.setItemLabelsVisible(true); // Set the shape for the Chart legend items ChartUIHelper.setLegendShape(xyItemRenderer); // Colour only as many Series as we know about intSeriesCount = 0; // Examine the state of each channel's selection for (int channel = 0; channel < channelcount; channel++) { final ChannelSelectionMode selectionMode; if ((channelselector.getChannelSelectionModes() != null) && (channelselector.getChannelSelectionModes().size() == channelcount)) { // If there is a ChannelSelector, get the gain setting, or OFF selectionMode = channelselector.getChannelSelectionModes().get(channel); } else if (!channelselector.showChannels()) { // If there is no ChannelSelector, we assume that all Channels are ON, at X1 selectionMode = ChannelSelectionMode.X1; } else { // Not sure what to do, so just show all selectionMode = ChannelSelectionMode.X1; } if (!ChannelSelectionMode.OFF.equals(selectionMode)) { final ColourInterface colour; colour = MetadataHelper.getChannelColour(metadatalist, channel, temperaturechannel); MetadataHelper.showMetadataList(metadatalist, SOURCE + " COLOURS FOR CHART", LOADER_PROPERTIES.isMetadataDebug()); if (colour != null) { // Map the Colour to the Series xyItemRenderer.setSeriesPaint(intSeriesCount, colour.getColor()); } else { // Use the default colour if the metadata doesn't have it LOGGER.error(SOURCE + "The channel colour was missing or incorrectly specified in the Metadata, using default colour" + " [channel=" + channel + "]"); xyItemRenderer.setSeriesPaint(intSeriesCount, ChartUIHelper.getStandardColour(channel).getColor()); } // Prepare for the next Series intSeriesCount++; } } } } return (chart); }
From source file:beproject.MainGUI.java
void createTimeLine() throws SQLException { TimeSeriesCollection dataset = new TimeSeriesCollection(); getTimeLineData(dataset);/*from ww w . j a v a 2 s . c o m*/ DateAxis domain = new DateAxis("Time"); NumberAxis range = new NumberAxis("Tweet Count"); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesStroke(0, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); renderer.setSeriesStroke(1, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); XYPlot plot = new XYPlot(dataset, domain, range, renderer); domain.setAutoRange(true); domain.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 2, Regression.sdf)); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); range.setTickLabelsVisible(true); plot.setDomainGridlinesVisible(false); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setBaseItemLabelsVisible(true); JFreeChart liveTweetAnalysisChart = new JFreeChart("Rate of tweets per hour", new Font("Tahoma", Font.BOLD, 24), plot, true); liveTweetAnalysisChart.setBorderVisible(false); ChartUtilities.applyCurrentTheme(liveTweetAnalysisChart); domain.setTickLabelInsets(RectangleInsets.ZERO_INSETS); range.setTickMarksVisible(false); range.setTickLabelInsets(RectangleInsets.ZERO_INSETS); domain.setTickMarksVisible(false); liveTweetAnalysisChart.setPadding(RectangleInsets.ZERO_INSETS); ChartPanel liveTweetAnalysisChartPanel = new ChartPanel(liveTweetAnalysisChart, true); liveTweetAnalysisChartPanel.setBorder(null); if (timeLineChart == null) { timeLineChart = liveTweetAnalysisChartPanel; } else { timeLinePanel.remove(timeLineChart); timeLineChart = liveTweetAnalysisChartPanel; } timeLinePanel.add(timeLineChart); timeLinePanel.validate(); }
From source file:beproject.MainGUI.java
void liveTweetAnalysis() { new DataGenerator(1000).start(); rate = new TimeSeries("Total count", Second.class); rate.setMaximumItemAge(15);/*from www. j ava2s. c o m*/ TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(rate); DateAxis domain = new DateAxis("Time"); NumberAxis range = new NumberAxis("Tweet Count"); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesStroke(0, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); renderer.setSeriesStroke(1, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); XYPlot plot = new XYPlot(dataset, domain, range, renderer); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); range.setTickLabelsVisible(true); plot.setDomainGridlinesVisible(false); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setBaseItemLabelsVisible(true); JFreeChart liveTweetAnalysisChart = new JFreeChart("Tweets Per Second", new Font("Tahoma", Font.BOLD, 24), plot, true); liveTweetAnalysisChart.setBorderVisible(false); liveTweetAnalysisChart.setBorderPaint(null); ChartUtilities.applyCurrentTheme(liveTweetAnalysisChart); domain.setTickLabelInsets(RectangleInsets.ZERO_INSETS); range.setTickMarksVisible(false); range.setTickLabelInsets(RectangleInsets.ZERO_INSETS); domain.setTickMarksVisible(false); liveTweetAnalysisChart.setPadding(RectangleInsets.ZERO_INSETS); ChartPanel liveTweetAnalysisChartPanel = new ChartPanel(liveTweetAnalysisChart, true); liveTweetAnalysisChartPanel.setBorder(null); liveTweetsAnalysisPanel.add(liveTweetAnalysisChartPanel, BorderLayout.CENTER); liveTweetsAnalysisPanel.validate(); }
From source file:org.drools.semantics.builder.model.GraphModelImpl.java
public void display() { KKLayout<Concept, Relation> layout = new KKLayout<Concept, Relation>(cgraph); layout.setExchangeVertices(true);//from w ww . ja va 2 s.co m layout.setAdjustForGravity(false); layout.setDisconnectedDistanceMultiplier(2.0); layout.setLengthFactor(5.0); layout.setSize(new Dimension(1800, 1000)); VisualizationViewer<Concept, Relation> vv = new VisualizationViewer<Concept, Relation>(layout); vv.setPreferredSize(new Dimension(1850, 1050)); //Sets the viewing area size final Stroke sccStroke = new BasicStroke(5.0f); final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 10.0f, null, 0.0f); Transformer<Relation, Stroke> edgeStrokeTransformer = new Transformer<Relation, Stroke>() { public Stroke transform(Relation rel) { return rel.getProperty().contains("subConceptOf") ? sccStroke : edgeStroke; } }; Transformer<Concept, Paint> vertexPaint = new Transformer<Concept, Paint>() { public Paint transform(Concept c) { return c.getIri().contains("XMLSchema") ? Color.GREEN : Color.BLUE; } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vv.setGraphMouse(gm); // EditingModalGraphMouse gm = // new EditingModalGraphMouse(vv.getRenderContext(), // cgraph.get, cgraph.edgeFactory); vv.addKeyListener(gm.getModeKeyListener()); JFrame frame = new JFrame("Simple Graph View"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); }
From source file:org.eclipse.birt.chart.device.svg.SVGGraphics2D.java
/** * Adds stroke color and style information to the element passed in. * /*from w w w .ja v a 2 s.c o m*/ * @param currentElement * the element to add style information to. * @param isClipped * boolean that determines whether to defer the clipping of the * element */ protected void setStrokeStyle(Element currentElement, boolean deferClipped) { Element element = currentElement; if (deferStrokColor != null) { // Need to get the parent element. element = deferStrokColor; } String style = element.getAttribute("style"); //$NON-NLS-1$ if (style == null) style = ""; //$NON-NLS-1$ if (color != null) { style += "stroke:" + serializeToString(color) + ";"; //$NON-NLS-1$ //$NON-NLS-2$ } if ((stroke != null) && (stroke instanceof BasicStroke)) { BasicStroke bs = (BasicStroke) stroke; if (bs.getLineWidth() > 0) style += "stroke-width:" + bs.getLineWidth() + ";"; //$NON-NLS-1$ //$NON-NLS-2$ if (bs.getDashArray() != null) { StringBuffer dashArrayStr = new StringBuffer(); for (int x = 0; x < bs.getDashArray().length; x++) { dashArrayStr.append(" ").append(bs.getDashArray()[x]); //$NON-NLS-1$ } if (!(dashArrayStr.toString().equals(""))) //$NON-NLS-1$ style += "stroke-dasharray:" + dashArrayStr + ";"; //$NON-NLS-1$ //$NON-NLS-2$ } style += "stroke-miterlimit:" + bs.getMiterLimit() + ";"; //$NON-NLS-1$ //$NON-NLS-2$ switch (bs.getLineJoin()) { case BasicStroke.JOIN_BEVEL: style += "stroke-linejoin:bevel;"; //$NON-NLS-1$ break; case BasicStroke.JOIN_ROUND: style += "stroke-linejoin:round;"; //$NON-NLS-1$ break; } switch (bs.getEndCap()) { case BasicStroke.CAP_ROUND: style += "stroke-linecap:round;"; //$NON-NLS-1$ break; case BasicStroke.CAP_SQUARE: style += "stroke-linecap:square;"; //$NON-NLS-1$ break; } } element.setAttribute("style", style); //$NON-NLS-1$ if (styleClass != null) element.setAttribute("class", styleClass); //$NON-NLS-1$ if (id != null) element.setAttribute("id", id); //$NON-NLS-1$ if ((clip != null) && (!deferClipped)) element.setAttribute("clip-path", "url(#clip" + clip.hashCode() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }
From source file:org.global.canvas.services.impl.DrawServiceImpl.java
public void draw(DrawEvent event) { currentUser = event.getUser();/* w ww .j ava 2 s . co m*/ if (event.getType().equals("dragstart")) { domImpl = GenericDOMImplementation.getDOMImplementation(); document = domImpl.createDocument(svgNS, "svg", null); svgGenerator = new SVGGraphics2D(document); System.out.println("Color here: " + event.getColor()); svgGenerator.setColor(Color.decode(event.getColor())); svgGenerator.setStroke( new BasicStroke(5, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0)); } currentX.add(event.getX()); currentY.add(event.getY()); if (event.getType().equals("dragend")) { svgGenerator.drawPolyline(ArrayUtils.toPrimitive(currentX.toArray(new Integer[0])), ArrayUtils.toPrimitive(currentY.toArray(new Integer[0])), currentX.size()); export(); domImpl = null; document = null; svgGenerator = null; currentX.clear(); currentY.clear(); } }