List of usage examples for org.jfree.chart.renderer.xy XYItemRenderer getItemPaint
public Paint getItemPaint(int row, int column);
From source file:sim.util.media.chart.TimeSeriesAttributes.java
public void buildAttributes() { // The following three variables aren't defined until AFTER construction if // you just define them above. So we define them below here instead. dashPattern = 0; // dashPatterns[0]; stretch = 1.0f;/*from w ww .j a va2 s . c om*/ thickness = 2.0f; // strokeColor = Color.black; // rebuildGraphicsDefinitions will get called by our caller afterwards XYItemRenderer renderer = (((XYPlot) getPlot()).getRenderer()); // NOTE: // Paint paint = renderer.getSeriesPaint(getSeriesIndex()); // In JFreeChart 1.0.6 getSeriesPaint returns null!!! // You need lookupSeriesPaint(), but that's not backward compatible. // The only thing consistent in all versions is getItemPaint // (which looks like a gross miss-use, but gets the job done) Paint paint = renderer.getItemPaint(getSeriesIndex(), -1); strokeColor = (Color) paint; strokeColorWell = new ColorWell(strokeColor) { public Color changeColor(Color c) { strokeColor = c; rebuildGraphicsDefinitions(); return c; } }; addLabelled("Color", strokeColorWell); thicknessField = new NumberTextField(2.0, true) { public double newValue(double newValue) { if (newValue < 0.0) newValue = currentValue; thickness = (float) newValue; rebuildGraphicsDefinitions(); return newValue; } }; addLabelled("Width", thicknessField); dashPatternList = new JComboBox(); dashPatternList.setEditable(false); dashPatternList.setModel(new DefaultComboBoxModel( new java.util.Vector(Arrays.asList(new String[] { "Solid", "__ __ __", "_ _ _ _", "_ _ _ _ _", "_ _ . _ _ .", "_ . _ . _ .", "_ . . _ . .", ". . . . . . .", ". . . . ." })))); dashPatternList.setSelectedIndex(0); dashPatternList.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dashPattern = dashPatternList.getSelectedIndex(); // dashPatterns[dashPatternList.getSelectedIndex()]; rebuildGraphicsDefinitions(); } }); addLabelled("Dash", dashPatternList); stretchField = new NumberTextField(1.0, true) { public double newValue(double newValue) { if (newValue < 0.0) newValue = currentValue; stretch = (float) newValue; rebuildGraphicsDefinitions(); return newValue; } }; addLabelled("Stretch", stretchField); }
From source file:edu.gmu.cs.sim.util.media.chart.TimeSeriesAttributes.java
public void buildAttributes() { // The following three variables aren't defined until AFTER construction if // you just define them above. So we define them below here instead. dashPattern = 0; // dashPatterns[0]; stretch = 1.0f;/*from w ww . ja va 2s.c o m*/ thickness = 2.0f; // strokeColor = Color.black; // rebuildGraphicsDefinitions will get called by our caller afterwards XYItemRenderer renderer = (((XYPlot) getPlot()).getRenderer()); // NOTE: // Paint paint = renderer.getSeriesPaint(getSeriesIndex()); // In JFreeChart 1.0.6 getSeriesPaint returns null!!! // You need lookupSeriesPaint(), but that's not backward compatible. // The only thing consistent in all versions is getItemPaint // (which looks like a gross miss-use, but gets the job done) Paint paint = renderer.getItemPaint(getSeriesIndex(), -1); strokeColor = (Color) paint; strokeColorWell = new ColorWell(strokeColor) { public Color changeColor(Color c) { strokeColor = c; rebuildGraphicsDefinitions(); return c; } }; addLabelled("Color", strokeColorWell); thicknessField = new NumberTextField(2.0, true) { public double newValue(double newValue) { if (newValue < 0.0) { newValue = currentValue; } thickness = (float) newValue; rebuildGraphicsDefinitions(); return newValue; } }; addLabelled("Width", thicknessField); dashPatternList = new JComboBox(); dashPatternList.setEditable(false); dashPatternList.setModel(new DefaultComboBoxModel( new java.util.Vector(Arrays.asList(new String[] { "Solid", "__ __ __", "_ _ _ _", "_ _ _ _ _", "_ _ . _ _ .", "_ . _ . _ .", "_ . . _ . .", ". . . . . . .", ". . . . ." })))); dashPatternList.setSelectedIndex(0); dashPatternList.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dashPattern = dashPatternList.getSelectedIndex(); // dashPatterns[dashPatternList.getSelectedIndex()]; rebuildGraphicsDefinitions(); } }); addLabelled("Dash", dashPatternList); stretchField = new NumberTextField(1.0, true) { public double newValue(double newValue) { if (newValue < 0.0) { newValue = currentValue; } stretch = (float) newValue; rebuildGraphicsDefinitions(); return newValue; } }; addLabelled("Stretch", stretchField); }