Posts

Showing posts from February, 2011

Blackberry Bar-Graph Field & Output

Image
Pass the values to Bar-Graph Field VerticalFieldManager graphLayout = new VerticalFieldManager( VerticalFieldManager.FIELD_HCENTER); // Graph BarGraphField _barGraph = new BarGraphField(values, colors, 10, 1, 10, BarGraphField.PADDING_MEDIUM, BarGraphField.PADDING_MEDIUM,true); _barGraph.setPadding(2, 10, 5, 10); graphLayout.add(_barGraph); Output:

Blackberry Bar-Graph (Class 2)

import net.rim.device.api.ui.Font; import net.rim.device.api.ui.Graphics; import net.rim.device.api.util.Arrays; /** * A field that can display data in a bar graph format. */ public class BarGraphField extends GraphField { /** * * Use no padding. */ public static final int PADDING_NONE = 0; /** * * Use low padding. */ public static final int PADDING_LOW = 4; /** * * Use medium padding. */ public static final int PADDING_MEDIUM = 8; /** * * Use high padding. */ public static final int PADDING_HIGH = 12; private int _scale, _increment, _barWidth, _barPadding, _scalePadding; private boolean _showScale; /** * * Constructs a bar graph using the default (PADDING_MEDIUM) padding without * scale labels. * * @param values * The values (data) to be graphed. * @param colors * The colors used to draw each bar. * @param scale * The maximum possible value of the graph, the top scale value. * @param increment * The increment a

Blackberry Bar-Graph (Class 1)

import net.rim.device.api.ui.Field; /** * The base class for which other graph fields are derived from. */ public abstract class GraphField extends Field { /* * The values (data) used to create the graph. */ protected int[] _values; /** * The colors used to display the data sets. */ protected int[] _colors; /** * The width of the field. */ protected int _width; /** * The height of the field. */ protected int _height; /** * Creates a plain empty graph field. */ GraphField() { super(); } /** * Retrieves the color at the specified index. * * @param index * The index of the color. * @return an integer in form 0x00RRGGBB */ public int getColor(int index) { return _colors[index]; } /** * Retrieves an array of colors. * * @return an array of integers in the form 0x00RRGGBB */ public int[] getColors() { return _colors; } /** * Retrieves the value at the specified index. * * @param index *