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:demo.EdgeLabelDemo.java
/** * create an instance of a simple graph with controls to * demo the label positioning features/* ww w . j av a 2 s .c o m*/ * */ @SuppressWarnings("serial") public EdgeLabelDemo() { // create a simple graph for the demo graph = new SparseMultigraph<Integer, Number>(); Integer[] v = createVertices(3); createEdges(v); Layout<Integer, Number> layout = new CircleLayout<Integer, Number>(graph); vv = new VisualizationViewer<Integer, Number>(layout, new Dimension(600, 400)); vv.setBackground(Color.white); vertexLabelRenderer = vv.getRenderContext().getVertexLabelRenderer(); edgeLabelRenderer = vv.getRenderContext().getEdgeLabelRenderer(); Transformer<Number, String> stringer = new Transformer<Number, String>() { public String transform(Number e) { return "Edge:" + graph.getEndpoints(e).toString(); } }; vv.getRenderContext().setEdgeLabelTransformer(stringer); float dash[] = { 10.0f }; final Stroke edgeStroke2 = new BasicStroke(); final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); Transformer<Number, Stroke> edgeStrokeTransformer = new Transformer<Number, Stroke>() { public Stroke transform(Number s) { return edgeStroke; } }; vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, Number>()); //vv.getRenderContext().setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); //vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow)); // add my listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>()); // create a frome to hold the graph final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); Container content = getContentPane(); content.add(panel); /* final DefaultModalGraphMouse<Integer,Number> graphMouse = new DefaultModalGraphMouse<Integer,Number>(); vv.setGraphMouse(graphMouse); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1/1.1f, vv.getCenter()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton lineButton = new JRadioButton("Line"); lineButton.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e) { if(e.getStateChange() == ItemEvent.SELECTED) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer,Number>()); vv.repaint(); } } }); JRadioButton quadButton = new JRadioButton("QuadCurve"); quadButton.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e) { if(e.getStateChange() == ItemEvent.SELECTED) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer,Number>()); vv.repaint(); } } }); JRadioButton cubicButton = new JRadioButton("CubicCurve"); cubicButton.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e) { if(e.getStateChange() == ItemEvent.SELECTED) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer,Number>()); vv.repaint(); } } }); radio.add(lineButton); radio.add(quadButton); radio.add(cubicButton); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); JCheckBox rotate = new JCheckBox("<html><center>EdgeType<p>Parallel</center></html>"); rotate.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e) { AbstractButton b = (AbstractButton)e.getSource(); edgeLabelRenderer.setRotateEdgeLabels(b.isSelected()); vv.repaint(); } }); rotate.setSelected(true); MutableDirectionalEdgeValue mv = new MutableDirectionalEdgeValue(.5, .7); vv.getRenderContext().setEdgeLabelClosenessTransformer(mv); JSlider directedSlider = new JSlider(mv.getDirectedModel()) { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width /= 2; return d; } }; JSlider undirectedSlider = new JSlider(mv.getUndirectedModel()) { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width /= 2; return d; } }; JSlider edgeOffsetSlider = new JSlider(0,50) { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width /= 2; return d; } }; edgeOffsetSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider s = (JSlider)e.getSource(); AbstractEdgeShapeTransformer<Integer,Number> aesf = (AbstractEdgeShapeTransformer<Integer,Number>)vv.getRenderContext().getEdgeShapeTransformer(); aesf.setControlOffsetIncrement(s.getValue()); vv.repaint(); } }); Box controls = Box.createHorizontalBox(); JPanel zoomPanel = new JPanel(new GridLayout(0,1)); zoomPanel.setBorder(BorderFactory.createTitledBorder("Scale")); zoomPanel.add(plus); zoomPanel.add(minus); JPanel edgePanel = new JPanel(new GridLayout(0,1)); edgePanel.setBorder(BorderFactory.createTitledBorder("EdgeType Type")); edgePanel.add(lineButton); edgePanel.add(quadButton); edgePanel.add(cubicButton); JPanel rotatePanel = new JPanel(); rotatePanel.setBorder(BorderFactory.createTitledBorder("Alignment")); rotatePanel.add(rotate); JPanel labelPanel = new JPanel(new BorderLayout()); JPanel sliderPanel = new JPanel(new GridLayout(3,1)); JPanel sliderLabelPanel = new JPanel(new GridLayout(3,1)); JPanel offsetPanel = new JPanel(new BorderLayout()); offsetPanel.setBorder(BorderFactory.createTitledBorder("Offset")); sliderPanel.add(directedSlider); sliderPanel.add(undirectedSlider); sliderPanel.add(edgeOffsetSlider); sliderLabelPanel.add(new JLabel("Directed", JLabel.RIGHT)); sliderLabelPanel.add(new JLabel("Undirected", JLabel.RIGHT)); sliderLabelPanel.add(new JLabel("Edges", JLabel.RIGHT)); offsetPanel.add(sliderLabelPanel, BorderLayout.WEST); offsetPanel.add(sliderPanel); labelPanel.add(offsetPanel); labelPanel.add(rotatePanel, BorderLayout.WEST); JPanel modePanel = new JPanel(new GridLayout(2,1)); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(graphMouse.getModeComboBox()); controls.add(zoomPanel); controls.add(edgePanel); controls.add(labelPanel); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); quadButton.setSelected(true); */ }
From source file:ancat.visualizers.UndirectedModelVisualizer.java
private void produce(String fileName) { _currentLayout.setSize(new Dimension(600, 600)); VisualizationImageServer<V, E> vv = new VisualizationImageServer<V, E>(_currentLayout, new Dimension(600, 600)); vv.setPreferredSize(new Dimension(600, 600)); // Setup up a new vertex to paint transformer... Transformer<V, Paint> vertexPaint = new Transformer<V, Paint>() { public Paint transform(V v) { //return Color.GREEN; ancat.common.Vertex vertex = (Vertex) v; if (vertex instanceof ancat.common.ExecutableFile) return Color.BLUE; if (vertex instanceof ancat.common.DynamicLibrary) return Color.YELLOW; if (vertex instanceof ancat.common.ConfigurationFile) return Color.ORANGE; if (vertex instanceof ancat.common.Unspecified) return Color.RED; return Color.darkGray; }//from w ww . j a va2 s .co m }; // 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, 10.0f, dash, 0.0f); Transformer<E, Stroke> edgeStrokeTransformer = new Transformer<E, Stroke>() { public Stroke transform(E s) { return edgeStroke; } }; Transformer<E, Font> edgeFontTransformer = new Transformer<E, Font>() { public Font transform(E e) { return new Font("Dialog", Font.PLAIN, 10); } }; Transformer<E, String> lblTransformer = new Transformer<E, String>() { public String transform(E e) { Edge edge = (Edge) e; //return edge.getXMLId(); return edge.getXMLId() != null ? edge.getXMLId() : ""; } }; Transformer<V, Font> vertexFontTransformer = new Transformer<V, Font>() { public Font transform(V v) { return new Font("Dialog", Font.PLAIN, 10); } }; Transformer<V, String> vLblTransformer = new Transformer<V, String>() { public String transform(V v) { Vertex vertex = (Vertex) v; return vertex.getElementID(); } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<V>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<E>()); // ----> vv.getRenderContext().setEdgeFontTransformer(edgeFontTransformer); vv.getRenderContext().setLabelOffset(20); vv.getRenderContext().setEdgeLabelTransformer(lblTransformer); vv.getRenderContext().setVertexFontTransformer(vertexFontTransformer); vv.getRenderContext().setVertexLabelTransformer(vLblTransformer); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.N); BufferedImage img = new BufferedImage((int) _currentLayout.getSize().getWidth(), (int) _currentLayout.getSize().getHeight(), BufferedImage.TYPE_INT_ARGB); vv.getImage(new Point(0, 0), new Dimension(700, 700)); Graphics2D g2d = (Graphics2D) img.getGraphics(); vv.paint(g2d); setDisclaimer(g2d); g2d.dispose(); try { File file = new File(fileName); ImageIO.write(img, "png", file); } catch (IOException e) { e.printStackTrace(); } }
From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java
/** * Creates a chart displaying the radon concentration of a single room. Uses * red for normal rooms, blue for cellar rooms and green for misc rooms. * /*from w ww . ja v a 2s.c o m*/ * @param title * The headline of the chart. Will be hidden if set to null. * @param room * The room object containing the radon data. * @param preview * Will hide annotations, labels and headlines if true. * @return A chart displaying the radon concentration of a single room. */ public static JFreeChart createRoomChart(String title, OMRoom room, boolean preview) { Color lineColor = new Color(0, 0, 0, 128); Color rangeColor = new Color(222, 222, 222, 128); if (room.getType() == OMRoomType.Room) { lineColor = new Color(255, 0, 0, 128); rangeColor = new Color(255, 222, 222, 128); } else { if (room.getType() == 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[] values = room.getValues(); XYSeriesCollection dataSet = new XYSeriesCollection(); XYSeries series = new XYSeries("Radon"); int count = room.getCount(); double maxPointerKey = 0; for (int i = 0; i < count; i++) { series.add(i, values[i]); if (values[i] == room.getMaximum()) { maxPointerKey = i; } } dataSet.addSeries(series); title = title + ": " + room.getType().toString() + " " + room.getId(); JFreeChart chart = ChartFactory.createXYLineChart(title, "T [h]", "Rn [Bq/m\u00B3]", dataSet, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); double positiveDeviation = room.getAverage() + room.getDeviation(); double negativeDeviation = room.getAverage() - room.getDeviation(); IntervalMarker deviation = new IntervalMarker(negativeDeviation, positiveDeviation); float[] dash = { 5, 3 }; deviation.setPaint(rangeColor); deviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(deviation, Layer.BACKGROUND); ValueMarker arithMarker = new ValueMarker(room.getAverage(), lineColor, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(arithMarker); ValueMarker maxiMarker = new ValueMarker(room.getMaximum(), lineColor, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(maxiMarker); XYTextAnnotation amLabel = new XYTextAnnotation("AM=" + (int) room.getAverage(), count, room.getAverage() * 1.01); plot.addAnnotation(amLabel); XYTextAnnotation sdLabel = new XYTextAnnotation("SD=" + (int) room.getDeviation(), count, (room.getAverage() + room.getDeviation()) * 1.01); plot.addAnnotation(sdLabel); XYTextAnnotation maxLabel = new XYTextAnnotation("MAX=" + (int) room.getMaximum(), count, room.getMaximum() * 1.01); plot.addAnnotation(maxLabel); XYPointerAnnotation maxPointer = new XYPointerAnnotation("", maxPointerKey, room.getMaximum(), Math.PI * 1.1); plot.addAnnotation(maxPointer); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, lineColor); if (preview) { chart.setTitle(""); plot.clearAnnotations(); } return chart; }
From source file:org.jstockchart.plot.TimeseriesPlot.java
private CombinedDomainXYPlot createCombinedXYPlot() { Font axisFont = new Font("Arial", 0, 12); Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); LogicDateAxis logicDateAxis = timeseriesArea.getlogicDateAxis(); TimeseriesDateAxis dateAxis = new TimeseriesDateAxis(logicDateAxis.getLogicTicks()); if (timeline != null) { dateAxis.setTimeline(timeline);//from w ww .j a v a2s .co m } dateAxis.setTickLabelFont(axisFont); dateAxis.setTickMarkStroke(stroke); List<String> hideTick = new ArrayList<String>(); hideTick.add("10:00"); hideTick.add("11:00"); hideTick.add("13:30"); //hideTick.add("14:30"); hideTick.add("14:30"); dateAxis.setHideTickLabel(hideTick); dateAxis.setTickMarkPosition(DateTickMarkPosition.START); dateAxis.setTickMarksVisible(false); Date startTime = DateUtils.createDate(2008, 1, 1, 9, 30, 0); Date endTime = DateUtils.createDate(2008, 1, 1, 15, 0, 0); dateAxis.setRange(timeseriesArea.getStartDate(), timeseriesArea.getEndDate()); dateAxis.setAxisLineVisible(false); CFXCombinedPlot combinedDomainXYPlot = new CFXCombinedPlot(dateAxis); combinedDomainXYPlot.setInsets(new RectangleInsets(5, 2, 4, 2)); AxisSpace axisSpace = new AxisSpace(); axisSpace.setBottom(22); axisSpace.setLeft(0); axisSpace.setRight(0); axisSpace.setTop(0); combinedDomainXYPlot.setFixedDomainAxisSpace(axisSpace); combinedDomainXYPlot.setGap(0); combinedDomainXYPlot.setOrientation(timeseriesArea.getOrientation()); combinedDomainXYPlot.setDomainAxis(dateAxis); combinedDomainXYPlot.setDomainAxisLocation(timeseriesArea.getDateAxisLocation()); if (timeseriesArea.getPriceWeight() <= 0 && timeseriesArea.getVolumeWeight() <= 0) { throw new IllegalArgumentException("Illegal weight value: priceWeight=" + timeseriesArea.getPriceWeight() + ", volumeWeight=" + timeseriesArea.getVolumeWeight()); } if (timeseriesArea.getPriceWeight() > 0) { XYPlot pricePlot = createPricePlot(); combinedDomainXYPlot.add(pricePlot, timeseriesArea.getPriceWeight()); } if (timeseriesArea.getVolumeWeight() > 0) { XYPlot volumePlot = createVolumePlot(); combinedDomainXYPlot.add(volumePlot, timeseriesArea.getVolumeWeight()); } return combinedDomainXYPlot; }
From source file:com.github.errantlinguist.latticevisualiser.EdgeStrokeTransformer.java
@Override public Stroke transform(final Edge edge) { // Edges are negative log probabilities final double probability = Math.pow(10, -edge.getWeight()); final float weight = (float) probability * WEIGHT_FACTOR; // System.out.println(Float.toString(weight)); Stroke stroke;/*w w w .jav a 2s.co m*/ if (nonwords != null && nonwords.contains(edge.getOutputSymbol())) { stroke = new BasicStroke(weight, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, STROKE_DASH, 0.0f); } else { stroke = new BasicStroke(weight); } return stroke; }
From source file:org.sonar.server.charts.deprecated.BaseChart.java
protected BasicStroke getDashedStroke(float width) { return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 5.0f }, 0.0f);//w w w .ja v a 2s.c om }
From source file:hudson.plugins.testlink.TestLinkGraph.java
/** * Creates TestLink trend graph.//from ww w .j a v a 2s. co m * * @return the JFreeChart graph object. */ protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createLineChart(null, null, yLabel, categoryDataset, PlotOrientation.VERTICAL, true, true, false); final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.8f); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.darkGray); final CategoryAxis domainAxis = new ShiftedCategoryAxis(xLabel); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); plot.setDomainAxis(domainAxis); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRange(true); rangeAxis.setAutoRangeMinimumSize(5); rangeAxis.setLowerBound(0); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(0, new Color(35, 20, 89)); renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(1, new Color(0, 145, 0)); renderer.setSeriesStroke(2, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(2, new Color(207, 69, 21)); renderer.setSeriesStroke(3, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(3, Color.orange); plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }
From source file:net.sf.statcvs.output.xml.chart.LocChart.java
public LocChart(CvsContent content, Author author) { super("loc_per_author.png", I18n.tr("Lines Of Code (per Author)")); // init timelines per author Iterator authorsIt = content.getAuthors().iterator(); Map authorTimeLineMap = new HashMap(); IntegerMap authorsLoc = new IntegerMap(); while (authorsIt.hasNext()) { Author aut = (Author) authorsIt.next(); TimeLine locTL = new TimeLine(aut.getName()); locTL.setInitialValue(0);/* ww w.j av a 2 s. c o m*/ authorTimeLineMap.put(aut, locTL); } // fill timelines and symbolic names map RevisionIterator allRevs = new RevisionSortIterator(content.getRevisionIterator()); while (allRevs.hasNext()) { CvsRevision rev = allRevs.next(); updateSymbolicNamesMap(rev); TimeLine timeline = (TimeLine) authorTimeLineMap.get(rev.getAuthor()); if (!rev.getFile().isBinary()) { authorsLoc.addInt(rev.getAuthor(), rev.getLinesOfCodeChange()); timeline.addTimePoint(rev.getDate(), authorsLoc.get(rev.getAuthor())); } } // create chart Iterator it = authorTimeLineMap.keySet().iterator(); int i = 0; while (it.hasNext()) { Author aut = (Author) it.next(); addTimeLine((TimeLine) authorTimeLineMap.get(aut)); if (author != null) { setFilename("loc_" + AuthorDocument.escapeAuthorName(author.getName()) + ".png"); // make line thicker if (author.equals(aut)) { getChart().getXYPlot().getRenderer().setSeriesStroke(i, new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); } } i++; } setupLocChart(); }
From source file:com.bdb.weather.display.freeplot.FreePlot.java
/** * Build the Stroke objects that will be used for each series collection. *///from w ww .j ava 2s . c om private void buildStrokes() { strokes = new BasicStroke[STROKE_DASH.length + 1]; // // The zeroith series is a solid line // strokes[0] = new BasicStroke(STROKE_WEIGHT); // // The rest of the strokes are build from the STROKE_DASH array // for (int i = 1; i < strokes.length; i++) { strokes[i] = new BasicStroke(STROKE_WEIGHT, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, STROKE_DASH[i - 1], 0.0f); } }
From source file:ruc.edu.window.DynamicDataDemo2.java
/** * Constructs a new demonstration application. * * @param title the frame title.// w ww .java 2 s.com */ public DynamicDataDemo2(final String title) { super(title); this.series1 = new TimeSeries("Random 1"); this.series2 = new TimeSeries("Random 2"); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(this.series1); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(this.series2); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Dynamic Data Demo 2", "Time", "Value", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainPannable(true); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4)); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); //axis.setAutoRangeMinimumSize(600000.0); axis.setFixedAutoRange(5000.0); // 60 seconds plot.setDataset(1, dataset2); //final NumberAxis rangeAxis2 = new NumberAxis("Range Axis 2"); /// rangeAxis2.setAutoRangeIncludesZero(false); plot.setRenderer(0, new DefaultXYItemRenderer()); plot.setRenderer(1, new DefaultXYItemRenderer()); //plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 0); plot.getRenderer().setSeriesPaint(0, new Color(91, 155, 213)); plot.getRenderer(1).setSeriesPaint(0, Color.BLUE); XYLineAndShapeRenderer render2 = new XYLineAndShapeRenderer() { Stroke soild = new BasicStroke(2.0f); Stroke dashed = new BasicStroke(10.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f); @Override public Stroke getItemStroke(int row, int column) { return dashed; } }; plot.setRenderer(1, render2); final JPanel content = new JPanel(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); final JButton button1 = new JButton("Add To Series 1"); button1.setActionCommand("ADD_DATA_1"); button1.addActionListener(this); final JButton button2 = new JButton("Add To Series 2"); button2.setActionCommand("ADD_DATA_2"); button2.addActionListener(this); final JButton button3 = new JButton("Add To Both"); button3.setActionCommand("ADD_BOTH"); button3.addActionListener(this); final JPanel buttonPanel = new JPanel(new FlowLayout()); buttonPanel.add(button1); buttonPanel.add(button2); buttonPanel.add(button3); content.add(buttonPanel, BorderLayout.SOUTH); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(content); }