Added gradients to bar chart

This commit is contained in:
nifi 2010-09-15 15:52:28 +00:00
parent b783aebfcd
commit 819c55ba14

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: BarChartPanel.java,v 1.3 2010/09/14 10:35:00 nifi Exp $ * $Id: BarChartPanel.java,v 1.4 2010/09/15 15:52:28 nifi Exp $
* *
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* *
@ -34,14 +34,16 @@
* *
* Authors : Joakim Eriksson, Niclas Finne * Authors : Joakim Eriksson, Niclas Finne
* Created : 5 jul 2008 * Created : 5 jul 2008
* Updated : $Date: 2010/09/14 10:35:00 $ * Updated : $Date: 2010/09/15 15:52:28 $
* $Revision: 1.3 $ * $Revision: 1.4 $
*/ */
package se.sics.contiki.collect.gui; package se.sics.contiki.collect.gui;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -115,6 +117,23 @@ public abstract class BarChartPanel extends JPanel implements Visualizer {
}); });
} }
CategoryPlot plot = (CategoryPlot) chart.getPlot();
BarRenderer renderer = (BarRenderer) plot.getRenderer();
if (categories.length < 3) {
renderer.setDrawBarOutline(false);
GradientPaint gp = new GradientPaint(0.0f, 0.0f, Color.RED,
0.0f, 0.0f, new Color(128, 0, 0));
renderer.setSeriesPaint(0, gp);
if (categories.length > 1) {
gp = new GradientPaint(0.0f, 0.0f, Color.BLUE,
0.0f, 0.0f, new Color(0, 0, 128));
renderer.setSeriesPaint(1, gp);
}
} else {
renderer.setDrawBarOutline(true);
}
add(chartPanel, BorderLayout.CENTER); add(chartPanel, BorderLayout.CENTER);
} }