If you think the Android project customhellochartdemo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package lecho.lib.hellocharts.model;
/*www.java2s.com*/import lecho.lib.hellocharts.util.Utils;
import lecho.lib.hellocharts.view.Chart;
/**
* Single value drawn as bubble on BubbleChart.
*
*/publicclass BubbleValue {
/** Current X value. */privatefloat x;
/** Current Y value. */privatefloat y;
/** Current Z value , third bubble value interpreted as bubble area. */privatefloat z;
/** Origin X value, used during value animation. */privatefloat orginX;
/** Origin Y value, used during value animation. */privatefloat orginY;
/** Origin Z value, used during value animation. */privatefloat orginZ;
/** Difference between originX value and target X value. */privatefloat diffX;
/** Difference between originX value and target X value. */privatefloat diffY;
/** Difference between originX value and target X value. */privatefloat diffZ;
privateint color = Utils.DEFAULT_COLOR;
privateint darkenColor = Utils.DEFAULT_DARKEN_COLOR;
private ValueShape shape = ValueShape.CIRCLE;
privatechar[] label;
public BubbleValue() {
set(0, 0, 0);
}
public BubbleValue(float x, float y, float z) {
set(x, y, z);
}
public BubbleValue(float x, float y, float z, int color) {
set(x, y, z);
setColor(color);
}
public BubbleValue(BubbleValue bubbleValue) {
set(bubbleValue.x, bubbleValue.y, bubbleValue.z);
setColor(bubbleValue.color);
this.label = bubbleValue.label;
}
publicvoid update(float scale) {
x = orginX + diffX * scale;
y = orginY + diffY * scale;
z = orginZ + diffZ * scale;
}
publicvoid finish() {
set(orginX + diffX, orginY + diffY, orginZ + diffZ);
}
public BubbleValue set(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
this.orginX = x;
this.orginY = y;
this.orginZ = z;
this.diffX = 0;
this.diffY = 0;
this.diffZ = 0;
returnthis;
}
/**
* Set target values that should be reached when data animation finish then call {@link Chart#startDataAnimation()}
*
* @param target
* @return
*/public BubbleValue setTarget(float targetX, float targetY, float targetZ) {
set(x, y, z);
this.diffX = targetX - orginX;
this.diffY = targetY - orginY;
this.diffZ = targetZ - orginZ;
returnthis;
}
publicfloat getX() {
return this.x;
}
publicfloat getY() {
return this.y;
}
publicfloat getZ() {
return this.z;
}
publicint getColor() {
return color;
}
public BubbleValue setColor(int color) {
this.color = color;
this.darkenColor = Utils.darkenColor(color);
returnthis;
}
publicint getDarkenColor() {
return darkenColor;
}
public ValueShape getShape() {
return shape;
}
public BubbleValue setShape(ValueShape shape) {
this.shape = shape;
returnthis;
}
publicchar[] getLabel() {
return label;
}
public BubbleValue setLabel(char[] label) {
this.label = label;
returnthis;
}
@Override
public String toString() {
return"BubbleValue [x=" + x + ", y=" + y + ", z=" + z + "]";
}
}