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:com.anrisoftware.prefdialog.miscswing.multichart.freechart.FreechartXYChart.java
private XYLineAndShapeRenderer createLineShapeRenderer() { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); renderer.setBaseStroke(new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true);// ww w .j a v a 2s. co m renderer.setDrawOutlines(true); int columns = model == null ? 1 : model.getColumnCount(); if (blackWhite) { for (int i = 0; i < columns; i++) { renderer.setSeriesPaint(i, Color.black, false); } } else { Iterator<Color> it = paletteFactory.createBright().iterator(); for (int i = 0; i < columns; i++, it.hasNext()) { renderer.setSeriesPaint(i, it.next(), false); } } if (!showShapes) { for (int i = 0; i < columns; i++) { renderer.setSeriesShapesVisible(i, false); } } renderer.notifyListeners(new RendererChangeEvent(renderer)); return renderer; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.SparkLine.java
private void addMarker(int index, double value, final Color color, float stoke, XYPlot plot) { logger.debug("IN"); TimeSeries markerSeries = new TimeSeries("Marker" + index, Month.class); for (Iterator iterator = yearsDefined.iterator(); iterator.hasNext();) { String currentYear = (String) iterator.next(); boolean stop = false; for (int i = 1; i < 13 && stop == false; i++) { if (!(currentYear.equalsIgnoreCase(yearsDefined.first()) && i < firstMonth.getMonth())) { markerSeries.add(new Month(i, Integer.valueOf(currentYear).intValue()), value); }/* w w w.j a v a 2 s. c om*/ if (currentYear.equalsIgnoreCase(lastYear) && i >= lastMonth.getMonth()) { stop = true; } } } final TimeSeriesCollection dataset = new TimeSeriesCollection(markerSeries); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) { public boolean getItemShapeVisible(int _series, int item) { return (false); } public Paint getItemPaint(int row, int column) { return color; } }; renderer.setBaseStroke(new BasicStroke(stoke, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.GRAY); renderer.setBaseOutlinePaint(Color.BLACK); renderer.setUseOutlinePaint(true); plot.setDataset(index, dataset); plot.setRenderer(index, renderer); logger.debug("OUT"); }
From source file:com.diversityarrays.kdxplore.scatterplot.ScatterPlotPanel.java
private void drawRectangle() { if (mouseDownPoint != null && mouseUpPoint != null) { double dn = mouseDownPoint.getX(); double up = mouseUpPoint.getX(); double x0 = Math.min(dn, up); double x1 = Math.max(dn, up); dn = mouseDownPoint.getY();/*from w w w. j a v a 2 s . c o m*/ up = mouseUpPoint.getY(); double y0 = Math.min(dn, up); double y1 = Math.max(dn, up); removeAnnotations(); Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3 }, 0); Paint paint = Color.BLACK; Rectangle2D rect = new Rectangle2D.Double(x0, y0, x1 - x0, y1 - y0); intervalAnnotation = new XYShapeAnnotation(rect, stroke, paint); addRangeMarker(intervalAnnotation); getChartPanel().repaint(); } }
From source file:ch.algotrader.client.chart.ChartTab.java
private void initMarker(SeriesDefinitionVO seriesDefinition) { final MarkerDefinitionVO markerDefinition = (MarkerDefinitionVO) seriesDefinition; final Marker marker; if (markerDefinition.isInterval()) { marker = new IntervalMarker(0, 0); marker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); // position of the label marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); // position of the text within the label } else {//from w w w .j ava2 s .c o m marker = new ValueMarker(0); marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); } marker.setPaint(getColor(markerDefinition.getColor())); marker.setLabel(markerDefinition.getLabel()); marker.setLabelFont(new Font("SansSerif", 0, 9)); if (seriesDefinition.isDashed()) { marker.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 5.0f }, 0.0f)); } else { marker.setStroke(new BasicStroke(1.0f)); } getPlot().addRangeMarker(marker, markerDefinition.isInterval() ? Layer.BACKGROUND : Layer.FOREGROUND); this.markers.put(markerDefinition.getName(), marker); this.markersSelectionStatus.put(markerDefinition.getName(), seriesDefinition.isSelected()); // add the menu item JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(seriesDefinition.getLabel()); menuItem.setSelected(seriesDefinition.isSelected()); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { resetAxis(); boolean selected = ((JCheckBoxMenuItem) e.getSource()).isSelected(); ChartTab.this.markersSelectionStatus.put(markerDefinition.getName(), selected); if (selected) { if (marker instanceof ValueMarker) { marker.setAlpha(1.0f); } else { marker.setAlpha(0.5f); } } else { marker.setAlpha(0); } initAxis(); } }); this.getPopupMenu().add(menuItem); }
From source file:windows.sensorWindow.java
/** * creates all relevant data and adds it into the corresponding maps * /*from w w w .jav a2 s . c om*/ * @param UID * UID of the plotting sensor */ @SuppressWarnings("deprecation") public static void addPlot(Brick newBrick) { // create series TimeSeries newSeries = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries2 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries3 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries4 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries5 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries6 = new TimeSeries("" + 0, Millisecond.class); Measurement m1 = new Measurement(maxValues, maxCycles, newBrick.uid, 0); valuesMap.put(newBrick.uid, m1); if (newBrick.checked3 == true) { Measurement m2 = new Measurement(maxValues, maxCycles, newBrick.uid, 1); values2Map.put(newBrick.uid, m2); } // create entry in state map plot1StateMap.put(newBrick.uid, 0); plot2StateMap.put(newBrick.uid, 0); // create index map entry tmplindex.put(newBrick.uid, 0); // create avrgCtrlEnabled maps if (newBrick.controlAverage == true) avrgCtrl1Enabled.put(newBrick.uid, true); else avrgCtrl1Enabled.put(newBrick.uid, false); if (newBrick.controlAverage2 == true) avrgCtrl2Enabled.put(newBrick.uid, true); else avrgCtrl2Enabled.put(newBrick.uid, false); // create series map entry seriesMap.put(newBrick.uid, newSeries); seriesMap2.put(newBrick.uid, newSeries2); seriesMap3.put(newBrick.uid, newSeries3); seriesMap4.put(newBrick.uid, newSeries4); seriesMap5.put(newBrick.uid, newSeries3); seriesMap6.put(newBrick.uid, newSeries4); // create collection map entry seriesCollectionMap.put(newBrick.uid, new TimeSeriesCollection(newSeries)); seriesCollectionMap2.put(newBrick.uid, new TimeSeriesCollection(newSeries2)); tmplCollection1_1.put(newBrick.uid, new TimeSeriesCollection(newSeries3)); tmplCollection1_2.put(newBrick.uid, new TimeSeriesCollection(newSeries4)); tmplCollection2_1.put(newBrick.uid, new TimeSeriesCollection(newSeries5)); tmplCollection2_2.put(newBrick.uid, new TimeSeriesCollection(newSeries6)); // create plot map entry, special case for current/voltage brick, since // it has 2 parallel measurements and therefore 2 graphs must be treated XYPlot tmpSubPlot; tmpSubPlot = new XYPlot(seriesCollectionMap.get(newBrick.uid), null, null, new StandardXYItemRenderer()); // create the 1st graph if (newBrick.checked2 == true) { // create plot map entry NumberAxis rangeAxis = new NumberAxis( String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier))); rangeAxis.setAutoRangeIncludesZero(true); tmpSubPlot.setRangeAxis(0, rangeAxis); rangeAxis.setLabelPaint(Color.BLUE); rangeAxis.setVisible(newBrick.checked2); tmpSubPlot.setDataset(0, seriesCollectionMap.get(newBrick.uid)); // set dot - shape // Shape cross = ShapeUtilities.createDiagonalCross(3, 1); // create and store renderer XYItemRenderer renderer1 = new XYLineAndShapeRenderer(); renderer1 = tmpSubPlot.getRenderer(); renderer1.setSeriesPaint(0, Color.BLUE); renderer1.setSeriesStroke(0, new BasicStroke(3)); // line = dashes: // float dash[] = {5.0f}; // renderer1.setSeriesStroke( 0, new // BasicStroke(3,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, // 10.0f, dash, 0.0f)); // renderer1.setSeriesShape(0, cross); tmpSubPlot.setRenderer(0, renderer1); // set colors tmpSubPlot.setBackgroundPaint(Color.white); tmpSubPlot.setDomainGridlinePaint(Color.lightGray); tmpSubPlot.setRangeGridlinePaint(Color.lightGray); // tmpSubPlot.setRenderer(renderer2); // set font rangeAxis.setLabelFont(customFonts.get("axisLabelFont")); rangeAxis.setTickLabelFont(customFonts.get("axisValueFont")); // create template graph // if (newBrick.ctrlTmpl[0] == true) // { tmpSubPlot.setDataset(2, tmplCollection1_1.get(newBrick.uid)); XYItemRenderer renderer3 = new XYLineAndShapeRenderer(); int width = computeTmplPlotWidth(newBrick.tmpl1Width); BasicStroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);// , 10.0f, dash, 0.0f); renderer3.setSeriesPaint(0, Color.GREEN); // renderer3.setSeriesStroke( 0, new BasicStroke( 1 ) ); renderer3.setSeriesStroke(0, stroke); renderer3.setSeriesVisible(0, newBrick.ctrlTmpl[0]); rendererMap3.put(newBrick.uid, renderer3); tmpSubPlot.setRenderer(2, rendererMap3.get(newBrick.uid)); // } // put everything to the maps rendererMap.put(newBrick.uid, renderer1); plotMap.put(newBrick.uid, tmpSubPlot); axisMap.put(newBrick.uid, rangeAxis); } // create the 2nd graph if (newBrick.checked3 == true) { // set second axis for voltage/ampere brick NumberAxis secondaryAxis = new NumberAxis( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier))); secondaryAxis.setAutoRangeIncludesZero(true); tmpSubPlot.setRangeAxis(1, secondaryAxis); secondaryAxis.setLabelPaint(Color.RED); secondaryAxis.setVisible(newBrick.checked3); tmpSubPlot.setDataset(1, seriesCollectionMap2.get(newBrick.uid)); tmpSubPlot.mapDatasetToRangeAxis(1, 1); // set font secondaryAxis.setLabelFont(customFonts.get("axisLabelFont")); secondaryAxis.setTickLabelFont(customFonts.get("axisValueFont")); // create and store renderer XYItemRenderer renderer2 = new StandardXYItemRenderer(); // renderer2 = tmpSubPlot.getRenderer(); renderer2.setSeriesPaint(1, Color.RED); renderer2.setSeriesStroke(0, new BasicStroke(3)); tmpSubPlot.setRenderer(1, renderer2); // set colors tmpSubPlot.setBackgroundPaint(Color.white); tmpSubPlot.setDomainGridlinePaint(Color.lightGray); tmpSubPlot.setRangeGridlinePaint(Color.lightGray); // ---------------------------------------------------------------------------------- // create min1 critical map value ValueMarker vm5 = new ValueMarker(newBrick.tresholdMin2); markerMapMin2Critical.put(newBrick.uid, vm5); // set critical line markerMapMin2Critical.get(newBrick.uid).setPaint(Color.red); markerMapMin2Critical.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " critical min"); markerMapMin2Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMin2Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); tmpSubPlot.addRangeMarker(1, markerMapMin2Critical.get(newBrick.uid), Layer.BACKGROUND); // create min1 warning map value ValueMarker vm6 = new ValueMarker( newBrick.tresholdMin2 + newBrick.tresholdMin2 * warningPercentage / 100); markerMapMin2Warning.put(newBrick.uid, vm6); // set warning line markerMapMin2Warning.get(newBrick.uid).setPaint(Color.orange); markerMapMin2Warning.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " warning min"); markerMapMin2Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMin2Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); // tmpSubPlot.addRangeMarker(markerMapMin2Warning.get(newBrick.uid)); tmpSubPlot.addRangeMarker(1, markerMapMin2Warning.get(newBrick.uid), Layer.BACKGROUND); // create max1 critical map value ValueMarker vm7 = new ValueMarker(newBrick.tresholdMax2); markerMapMax2Critical.put(newBrick.uid, vm7); // set critical line markerMapMax2Critical.get(newBrick.uid).setPaint(Color.red); markerMapMax2Critical.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " critical max"); markerMapMax2Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMax2Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); tmpSubPlot.addRangeMarker(1, markerMapMax2Critical.get(newBrick.uid), Layer.BACKGROUND); // create max1 warning map value ValueMarker vm8 = new ValueMarker( newBrick.tresholdMax2 + newBrick.tresholdMax2 * warningPercentage / 100); markerMapMax2Warning.put(newBrick.uid, vm8); // set warning line markerMapMax2Warning.get(newBrick.uid).setPaint(Color.orange); markerMapMax2Warning.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " warning max"); markerMapMax2Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMax2Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); tmpSubPlot.addRangeMarker(1, markerMapMax2Warning.get(newBrick.uid), Layer.BACKGROUND); // create and add min, max and average markers // create maxima marker ValueMarker vmMax = new ValueMarker(0); vmMax.setPaint(Color.orange); vmMax.setLabel("max"); vmMax.setLabelAnchor(RectangleAnchor.TOP_RIGHT); vmMax.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // create minima marker ValueMarker vmMin = new ValueMarker(0); vmMin.setPaint(Color.orange); vmMin.setLabel("min"); vmMin.setLabelAnchor(RectangleAnchor.TOP_RIGHT); vmMin.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // create average marker ValueMarker vmAvg = new ValueMarker(0); vmAvg.setPaint(Color.red); vmAvg.setLabel("average"); vmAvg.setLabelAnchor(RectangleAnchor.TOP_RIGHT); vmAvg.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // add to maps marker2Maxima.put(newBrick.uid, vmMax); marker2Minima.put(newBrick.uid, vmMin); marker2Average.put(newBrick.uid, vmAvg); // add to plot tmpSubPlot.addRangeMarker(1, vmMax, Layer.BACKGROUND); tmpSubPlot.addRangeMarker(1, vmMin, Layer.BACKGROUND); tmpSubPlot.addRangeMarker(1, vmAvg, Layer.BACKGROUND); // create and add avrgCntrMarkers // create upper marker ValueMarker avrgCtrl2high = new ValueMarker(newBrick.getAvg2high()); avrgCtrl2high.setPaint(Color.orange); avrgCtrl2high.setLabel("avrg high"); avrgCtrl2high.setLabelAnchor(RectangleAnchor.TOP_RIGHT); avrgCtrl2high.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // create lower marker ValueMarker avrgCtrl2low = new ValueMarker(newBrick.getAvg2low()); avrgCtrl2low.setPaint(Color.orange); avrgCtrl2low.setLabel("avrg low"); avrgCtrl2low.setLabelAnchor(RectangleAnchor.TOP_RIGHT); avrgCtrl2low.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // add both markers avrg2High.put(newBrick.uid, avrgCtrl2high); avrg2Low.put(newBrick.uid, avrgCtrl2low); // add both to plot if (newBrick.controlAverage2) { tmpSubPlot.addRangeMarker(1, avrgCtrl2high, Layer.BACKGROUND); tmpSubPlot.addRangeMarker(1, avrgCtrl2low, Layer.BACKGROUND); } // ---------------------------------------------------------------------------------- // put everything to the map rendererMap2.put(newBrick.uid, renderer2); plotMap.put(newBrick.uid, tmpSubPlot); axisMap2.put(newBrick.uid, secondaryAxis); } // 1st graph // markers-------------------------------------------------------------------------------------------------- // create min1 critical map value ValueMarker vm1 = new ValueMarker(newBrick.tresholdMin1); markerMapMin1Critical.put(newBrick.uid, vm1); // set critical line markerMapMin1Critical.get(newBrick.uid).setPaint(Color.red); // / .setLabel("critical"); // markerMapMin1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.BOTTOM); markerMapMin1Critical.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " critical min"); markerMapMin1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMin1Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMin1Critical.get(newBrick.uid)); // create min1 warning map value ValueMarker vm2 = new ValueMarker(newBrick.tresholdMin1 + newBrick.tresholdMin1 * warningPercentage / 100); markerMapMin1Warning.put(newBrick.uid, vm2); // set warning line markerMapMin1Warning.get(newBrick.uid).setPaint(Color.orange); // marker2Map.get(newBrick.uid).setPaint(Color.); // / marker2Map.get(newBrick.uid).setLabel("warning"); markerMapMin1Warning.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " warning min"); markerMapMin1Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMin1Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMin1Warning.get(newBrick.uid)); // create max1 critical map value ValueMarker vm3 = new ValueMarker(newBrick.tresholdMax1); markerMapMax1Critical.put(newBrick.uid, vm3); // set critical line markerMapMax1Critical.get(newBrick.uid).setPaint(Color.red); // / .setLabel("critical"); // markerMapMax1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.BOTTOM); markerMapMax1Critical.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " critical max"); markerMapMax1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMax1Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMax1Critical.get(newBrick.uid)); // create max1 warning map value ValueMarker vm4 = new ValueMarker(newBrick.tresholdMax1 + newBrick.tresholdMax1 * warningPercentage / 100); markerMapMax1Warning.put(newBrick.uid, vm4); // set warning line markerMapMax1Warning.get(newBrick.uid).setPaint(Color.orange); markerMapMax1Warning.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " warning max"); markerMapMax1Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMax1Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMax1Warning.get(newBrick.uid)); // create and add min, max and average markers // create maxima marker ValueMarker vmMax = new ValueMarker(0); vmMax.setPaint(Color.cyan); vmMax.setLabel("max"); vmMax.setLabelAnchor(RectangleAnchor.TOP_LEFT); vmMax.setLabelTextAnchor(TextAnchor.TOP_LEFT); // create minima marker ValueMarker vmMin = new ValueMarker(0); vmMin.setPaint(Color.cyan); vmMin.setLabel("min"); vmMin.setLabelAnchor(RectangleAnchor.TOP_LEFT); vmMin.setLabelTextAnchor(TextAnchor.TOP_LEFT); // create average marker ValueMarker vmAvg = new ValueMarker(0); vmAvg.setPaint(Color.blue); vmAvg.setLabel("average"); vmAvg.setLabelAnchor(RectangleAnchor.TOP_LEFT); vmAvg.setLabelTextAnchor(TextAnchor.TOP_LEFT); // add to maps markerMaxima.put(newBrick.uid, vmMax); markerMinima.put(newBrick.uid, vmMin); markerAverage.put(newBrick.uid, vmAvg); // add to plot plotMap.get(newBrick.uid).addRangeMarker(vmMax); plotMap.get(newBrick.uid).addRangeMarker(vmMin); plotMap.get(newBrick.uid).addRangeMarker(vmAvg); // create and add avrgCntrMarkers // create upper marker ValueMarker avrgCtrl1high = new ValueMarker(newBrick.getAvg1high()); avrgCtrl1high.setPaint(Color.orange); avrgCtrl1high.setLabel("avrg high"); avrgCtrl1high.setLabelAnchor(RectangleAnchor.TOP_LEFT); avrgCtrl1high.setLabelTextAnchor(TextAnchor.TOP_LEFT); // create lower marker ValueMarker avrgCtrl1low = new ValueMarker(newBrick.getAvg1low()); avrgCtrl1low.setPaint(Color.orange); avrgCtrl1low.setLabel("avrg low"); avrgCtrl1low.setLabelAnchor(RectangleAnchor.TOP_LEFT); avrgCtrl1low.setLabelTextAnchor(TextAnchor.TOP_LEFT); // add both markers avrg1High.put(newBrick.uid, avrgCtrl1high); avrg1Low.put(newBrick.uid, avrgCtrl1low); // add both to plot if (newBrick.controlAverage) { plotMap.get(newBrick.uid).addRangeMarker(avrgCtrl1high); plotMap.get(newBrick.uid).addRangeMarker(avrgCtrl1low); } // ----------------------------------------------------------------------------------------------------- // set title NumberAxis axisForTitleOnly = new NumberAxis( data.constants.brickIdMap.get(newBrick.deviceIdentifier) + " (" + newBrick.uid + ")"); axisForTitleOnly.setLabelFont(customFonts.get("titleFont")); axisForTitleOnly.setTickLabelsVisible(false); axisForTitleOnly.setTickMarksVisible(false); axisForTitleOnly.setMinorTickMarksVisible(false); axisForTitleOnly.setAxisLineVisible(false); plotMap.get(newBrick.uid).setDomainAxis(1, axisForTitleOnly); // add subplot to the main plot plot.add(plotMap.get(newBrick.uid)); }
From source file:sim.app.sugarscape.util.ResultsGrapher.java
JFreeChart createChart1(XYSeries[] series) { JFreeChart chart3 = ChartFactory.createXYLineChart("Results", x_axis_fieldname, y_axis_fieldname, null, //new XYSeriesCollection(series[2]), PlotOrientation.VERTICAL, true, true, false); //System.out.println("Series count = " +series[0].getItemCount()); XYPlot plot = chart3.getXYPlot();/*from w w w . j a v a2s. c o m*/ ValueAxis yAxis = plot.getRangeAxis(); //xAxis.setFixedDimension(100); //yAxis.setFixedDimension(1.0); //yAxis.setRange(0,1); ValueAxis xAxis = plot.getDomainAxis(); //xAxis.setFixedDimension(50); StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); renderer.setStroke(new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 20)); renderer.setItemLabelsVisible(true); renderer.setSeriesItemLabelsVisible(1, true); renderer.setBaseShapesVisible(true); //XYLabelGenerator generator = new StandardXYLabelGenerator(); //"{2}", new DecimalFormat("0.00") ); //renderer.setLabelGenerator(generator); //NumberAxis axis2 = new NumberAxis("Average Agent Vision"); //renderer.setItemLabelsVisible(true); //axis2.setAutoRangeIncludesZero(false); //axis2.setRange(0,12); //plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); //XYSeriesCollection vision = new XYSeriesCollection(lorenz_agent_vision); //plot.setDataset(1, vision); //String first_letter = x_param_fieldname.substring(0,1)+"="; XYSeriesCollection xys = new XYSeriesCollection(); for (int a = 0; a < series.length; a++) { xys.addSeries(series[a]); //xys. //xys.getSeriesName(4); System.out.println(xys.getSeries(a).getDescription()); } plot.setDataset(0, xys); return chart3; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.PlotInstanceLegendCreator.java
private CustomLegendItem createValueSourceLegendItem(PlotConfiguration plotConfig, ValueSource valueSource) { Set<PlotDimension> dimensions = new HashSet<PlotDimension>(); for (PlotDimension dimension : PlotDimension.values()) { switch (dimension) { case DOMAIN: case VALUE: break; default://ww w. j a v a 2 s .co m if (valueSource.useSeriesFormatForDimension(plotConfig, dimension)) { dimensions.add(dimension); } } } if (dimensions.isEmpty()) { return null; } SeriesFormat format = valueSource.getSeriesFormat(); String description = ""; String toolTipText = ""; String urlText = ""; boolean shapeVisible = true; Shape shape; boolean shapeFilled = true; Paint fillPaint = UNDEFINED_COLOR_PAINT; boolean shapeOutlineVisible = true; Paint outlinePaint = PlotConfiguration.DEFAULT_OUTLINE_COLOR; Stroke outlineStroke = DEFAULT_OUTLINE_STROKE; boolean lineVisible = format.getLineStyle() != LineStyle.NONE && format.getSeriesType() == SeriesFormat.VisualizationType.LINES_AND_SHAPES; // configure fill paint and line paint Paint linePaint; String label = valueSource.toString(); if (label == null) { label = ""; } if (dimensions.contains(PlotDimension.COLOR)) { Color color = format.getItemColor(); fillPaint = format.getAreaFillPaint(color); linePaint = fillPaint; } else { if (format.getAreaFillStyle() == FillStyle.NONE) { fillPaint = new Color(0, 0, 0, 0); linePaint = fillPaint; } else if (format.getAreaFillStyle() == FillStyle.SOLID) { fillPaint = UNDEFINED_COLOR_PAINT; linePaint = UNDEFINED_LINE_COLOR; } else { fillPaint = format.getAreaFillPaint(UNDEFINED_COLOR); linePaint = fillPaint; } } VisualizationType seriesType = valueSource.getSeriesFormat().getSeriesType(); if (seriesType == VisualizationType.LINES_AND_SHAPES) { if (dimensions.contains(PlotDimension.SHAPE)) { shape = format.getItemShape().getShape(); } else if (dimensions.contains(PlotDimension.COLOR)) { shape = UNDEFINED_SHAPE; } else { shape = UNDEFINED_SHAPE_AND_COLOR; } if (dimensions.contains(PlotDimension.SIZE)) { AffineTransform transformation = new AffineTransform(); double scalingFactor = format.getItemSize(); transformation.scale(scalingFactor, scalingFactor); shape = transformation.createTransformedShape(shape); } } else if (seriesType == VisualizationType.BARS) { shape = BAR_SHAPE; } else if (seriesType == VisualizationType.AREA) { shape = AREA_SHAPE; } else { throw new RuntimeException("Unknown SeriesType. This should not happen."); } // configure line shape float lineLength = 0; if (lineVisible) { lineLength = format.getLineWidth(); if (lineLength < 1) { lineLength = 1; } if (lineLength > 1) { lineLength = 1 + (float) Math.log(lineLength) / 2; } // line at least 30 pixels long, and show at least 2 iterations of stroke lineLength = Math.max(lineLength * 30, format.getStrokeLength() * 2); // line at least 2x longer than shape width if (shape != null) { lineLength = Math.max(lineLength, (float) shape.getBounds().getWidth() * 2f); } } // now create line shape and stroke Shape line = new Line2D.Float(0, 0, lineLength, 0); BasicStroke lineStroke = format.getStroke(); if (lineStroke == null) { lineStroke = new BasicStroke(); } // unset line ending decoration to prevent drawing errors in legend { BasicStroke s = lineStroke; lineStroke = new BasicStroke(s.getLineWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, s.getMiterLimit(), s.getDashArray(), s.getDashPhase()); } return new CustomLegendItem(label, description, toolTipText, urlText, shapeVisible, shape, shapeFilled, fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, lineVisible, line, lineStroke, linePaint); }
From source file:jboost.visualization.HistogramFrame.java
private JFreeChart createHistogramChart() { XYBarRenderer renderer1 = new XYBarRenderer(); renderer1.setSeriesPaint(0, Color.cyan); renderer1.setSeriesPaint(1, Color.pink); XYPlot histPlot = new XYPlot(histogramDataset, null, new NumberAxis("count"), renderer1); XYBarRenderer renderer2 = new XYBarRenderer(); renderer2.setSeriesPaint(0, Color.green); renderer2.setSeriesPaint(1, Color.orange); renderer2.setUseYInterval(true);/*w ww.ja v a 2 s.co m*/ // weight and potential if (infoParser.isRobustBoost || infoParser.isAdaBoost || infoParser.isLogLossBoost) { StandardXYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); renderer3.setSeriesPaint(1, Color.red); renderer3.setBaseStroke(new BasicStroke(2)); StandardXYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.blue); renderer4.setSeriesPaint(1, Color.red); renderer4.setBaseStroke( new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 2, new float[] { 2 }, 0)); histPlot.setDataset(1, weightDataset); histPlot.setRenderer(1, renderer3); histPlot.setDataset(2, potentialDataset); histPlot.setRenderer(2, renderer4); histPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); } XYPlot fluctPlot = new XYPlot(fluctDataset, null, new NumberAxis("bin"), renderer2); double initialLocation = (upper_limit + lower_limit) / 2.0; histMarker = new IntervalMarker(initialLocation, initialLocation); histPlot.addDomainMarker(histMarker, Layer.BACKGROUND); fluctPlot.addDomainMarker(histMarker, Layer.BACKGROUND); // plot.setBackgroundPaint(Color.lightGray); // plot.setDomainGridlinePaint(Color.white); // plot.setRangeGridlinePaint(Color.white); CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(new NumberAxis("score")); combinedPlot.setGap(10.0); // add the subplots... ValueAxis axis = new NumberAxis(); axis.setRange(rawData.getMinRange(iter), rawData.getMaxRange(iter)); combinedPlot.add(histPlot, 3); combinedPlot.add(fluctPlot, 1); combinedPlot.setOrientation(PlotOrientation.VERTICAL); combinedPlot.setDomainAxis(axis); JFreeChart chart = new JFreeChart("Histogram", JFreeChart.DEFAULT_TITLE_FONT, combinedPlot, false // legend ); return chart; }
From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java
/** * Creates a chart displaying the distribution of certain selected statistical * values. Uses red for normal rooms and blue for cellar rooms. * //from w ww. ja v a 2s. co m * @param title * The headline of the chart. Will be hidden if set to null. * @param statistics * The selected statistics of a campaign containing all needed * values. * @param roomType * The room type to determine the colour of the chart. * @param preview * Will hide annotations, labels and headlines if true. * @return A chart displaying the distribution of certain selected statistical * values. */ public static JFreeChart createDistributionChart(String title, DescriptiveStatistics statistics, OMRoomType roomType, boolean preview) { Color lineColor = new Color(0, 0, 0, 128); Color rangeColor = new Color(222, 222, 222, 128); if (roomType == OMRoomType.Room) { lineColor = new Color(255, 0, 0, 128); rangeColor = new Color(255, 222, 222, 128); } else { if (roomType == OMRoomType.Cellar) { lineColor = new Color(0, 0, 255, 128); rangeColor = new Color(222, 222, 255, 128); } else { lineColor = new Color(0, 128, 0, 255); rangeColor = new Color(222, 255, 222, 128); } } double[] distValues = statistics.getSortedValues(); XYSeriesCollection dataSet = new XYSeriesCollection(); XYSeries distSeries = new XYSeries("Distribution"); for (int i = 0; i < distValues.length; i++) { distSeries.add(distValues[i], (0.5 + (double) i) / (double) distValues.length); } dataSet.addSeries(distSeries); JFreeChart chart = ChartFactory.createXYLineChart(title, "Rn [Bq/m\u00B3]", "F(emp)", dataSet, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); float[] dash = { 5, 3 }; int pos = 0; double y = (Double) distSeries.getY(pos); XYPointerAnnotation minPointer = new XYPointerAnnotation("MIN=" + (int) distValues[pos], distValues[pos], y, Math.PI * 1.5); plot.addAnnotation(minPointer); pos = (int) (((double) distValues.length / 100. * 5.0) - 1.0); while (pos < 0) { pos++; } if (pos > 0) { y = (Double) distSeries.getY(pos); } else { y = (Double) distSeries.getY(pos + 1); } final double posQ5 = distValues[pos]; XYPointerAnnotation q05Pointer = new XYPointerAnnotation("Q5=" + (int) distValues[pos], distValues[pos], y, Math.PI * 1.5); plot.addAnnotation(q05Pointer); pos = (int) (((double) distValues.length / 2.0) - 1.0); y = (Double) distSeries.getY(pos); XYPointerAnnotation q50Pointer = new XYPointerAnnotation("Q50=" + (int) distValues[pos], distValues[pos], y, Math.PI * 1.5); plot.addAnnotation(q50Pointer); ValueMarker medMarker = new ValueMarker(distValues[pos], lineColor, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addDomainMarker(medMarker); pos = (int) (((double) distValues.length / 100.0 * 95.0) - 1.0); if (pos < distValues.length - 1) { y = (Double) distSeries.getY(pos); } else { y = (Double) distSeries.getY(pos - 1); } final double posQ95 = distValues[pos]; XYPointerAnnotation q95Pointer = new XYPointerAnnotation("Q95=" + (int) distValues[pos], distValues[pos], y, Math.PI * 0.5); plot.addAnnotation(q95Pointer); pos = distValues.length - 1; y = (Double) distSeries.getY(pos); XYPointerAnnotation maxPointer = new XYPointerAnnotation("MAX=" + (int) distValues[pos], distValues[pos], y, Math.PI * 0.5); plot.addAnnotation(maxPointer); IntervalMarker percentiles = new IntervalMarker(posQ5, posQ95); percentiles.setPaint(rangeColor); percentiles.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addDomainMarker(percentiles, Layer.BACKGROUND); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, lineColor); return chart; }
From source file:com.planetmayo.debrief.satc_rcp.views.SpatialView.java
private int plotTheseCoordsAsALine(String title, Coordinate[] coords) { int num = addSeries(title, coords); final float dash1[] = { 10f, 10f }; final BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);//from www .j a v a 2 s . c o m _renderer.setSeriesStroke(num, dashed); _renderer.setSeriesLinesVisible(num, true); _renderer.setSeriesShapesVisible(num, false); _renderer.setSeriesVisibleInLegend(num, false); return num; }