本文整理汇总了Java中lecho.lib.hellocharts.model.Line类的典型用法代码示例。如果您正苦于以下问题:Java Line类的具体用法?Java Line怎么用?Java Line使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Line类属于lecho.lib.hellocharts.model包,在下文中一共展示了Line类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateLineData
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private LineChartData generateLineData() {
List<Line> lines = new ArrayList<Line>();
for (int i = 0; i < numberOfLines; ++i) {
List<PointValue> values = new ArrayList<PointValue>();
for (int j = 0; j < numberOfPoints; ++j) {
values.add(new PointValue(j, randomNumbersTab[i][j]));
}
Line line = new Line(values);
line.setColor(ChartUtils.COLORS[i]);
line.setCubic(isCubic);
line.setHasLabels(hasLabels);
line.setHasLines(hasLines);
line.setHasPoints(hasPoints);
lines.add(line);
}
LineChartData lineChartData = new LineChartData(lines);
return lineChartData;
}
示例2: checkTouch
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
@Override
public boolean checkTouch(float touchX, float touchY) {
selectedValue.clear();
final LineChartData data = dataProvider.getLineChartData();
int lineIndex = 0;
for (Line line : data.getLines()) {
if (checkIfShouldDrawPoints(line)) {
int pointRadius = ChartUtils.dp2px(density, line.getPointRadius());
int valueIndex = 0;
for (PointValue pointValue : line.getValues()) {
final float rawValueX = computator.computeRawX(pointValue.getX());
final float rawValueY = computator.computeRawY(pointValue.getY());
if (isInArea(rawValueX, rawValueY, touchX, touchY, pointRadius + touchToleranceMargin)) {
selectedValue.set(lineIndex, valueIndex, SelectedValueType.LINE);
}
++valueIndex;
}
}
++lineIndex;
}
return isTouched();
}
示例3: calculateMaxViewport
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private void calculateMaxViewport() {
tempMaximumViewport.set(Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MAX_VALUE);
LineChartData data = dataProvider.getLineChartData();
for (Line line : data.getLines()) {
// Calculate max and min for viewport.
for (PointValue pointValue : line.getValues()) {
if (pointValue.getX() < tempMaximumViewport.left) {
tempMaximumViewport.left = pointValue.getX();
}
if (pointValue.getX() > tempMaximumViewport.right) {
tempMaximumViewport.right = pointValue.getX();
}
if (pointValue.getY() < tempMaximumViewport.bottom) {
tempMaximumViewport.bottom = pointValue.getY();
}
if (pointValue.getY() > tempMaximumViewport.top) {
tempMaximumViewport.top = pointValue.getY();
}
}
}
}
示例4: drawPoints
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private void drawPoints(Canvas canvas, Line line, int lineIndex, int mode) {
pointPaint.setColor(line.getPointColor());
int valueIndex = 0;
for (PointValue pointValue : line.getValues()) {
int pointRadius = ChartUtils.dp2px(density, line.getPointRadius());
final float rawX = computator.computeRawX(pointValue.getX());
final float rawY = computator.computeRawY(pointValue.getY());
if (computator.isWithinContentRect(rawX, rawY, checkPrecision)) {
// Draw points only if they are within contentRectMinusAllMargins, using contentRectMinusAllMargins
// instead of viewport to avoid some
// float rounding problems.
if (MODE_DRAW == mode) {
drawPoint(canvas, line, pointValue, rawX, rawY, pointRadius);
if (line.hasLabels()) {
drawLabel(canvas, line, pointValue, rawX, rawY, pointRadius + labelOffset);
}
} else if (MODE_HIGHLIGHT == mode) {
highlightPoint(canvas, line, pointValue, rawX, rawY, lineIndex, valueIndex);
} else {
throw new IllegalStateException("Cannot process points in mode: " + mode);
}
}
++valueIndex;
}
}
示例5: drawPoint
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private void drawPoint(Canvas canvas, Line line, PointValue pointValue, float rawX, float rawY,
float pointRadius) {
if (ValueShape.SQUARE.equals(line.getShape())) {
canvas.drawRect(rawX - pointRadius, rawY - pointRadius, rawX + pointRadius, rawY + pointRadius,
pointPaint);
} else if (ValueShape.CIRCLE.equals(line.getShape())) {
canvas.drawCircle(rawX, rawY, pointRadius, pointPaint);
} else if (ValueShape.DIAMOND.equals(line.getShape())) {
canvas.save();
canvas.rotate(45, rawX, rawY);
canvas.drawRect(rawX - pointRadius, rawY - pointRadius, rawX + pointRadius, rawY + pointRadius,
pointPaint);
canvas.restore();
} else {
throw new IllegalArgumentException("Invalid point shape: " + line.getShape());
}
}
示例6: generateLineChartData
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private LineChartData generateLineChartData() {
int numValues = 20;
List<PointValue> values = new ArrayList<PointValue>();
for (int i = 0; i < numValues; ++i) {
values.add(new PointValue(i, (float) Math.random() * 100f));
}
Line line = new Line(values);
line.setColor(ChartUtils.COLOR_GREEN);
List<Line> lines = new ArrayList<Line>();
lines.add(line);
LineChartData data = new LineChartData(lines);
data.setAxisXBottom(new Axis().setName("Axis X"));
data.setAxisYLeft(new Axis().setName("Axis Y").setHasLines(true));
return data;
}
示例7: generatePreviewLineChartData
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private LineChartData generatePreviewLineChartData() {
int numValues = 50;
List<PointValue> values = new ArrayList<PointValue>();
for (int i = 0; i < numValues; ++i) {
values.add(new PointValue(i, (float) Math.random() * 100f));
}
Line line = new Line(values);
line.setColor(ChartUtils.DEFAULT_DARKEN_COLOR);
line.setHasPoints(false);// too many values so don't draw points.
List<Line> lines = new ArrayList<Line>();
lines.add(line);
LineChartData data = new LineChartData(lines);
data.setAxisXBottom(new Axis());
data.setAxisYLeft(new Axis().setHasLines(true));
return data;
}
示例8: generateDefaultData
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private void generateDefaultData() {
int numValues = 50;
List<PointValue> values = new ArrayList<PointValue>();
for (int i = 0; i < numValues; ++i) {
values.add(new PointValue(i, (float) Math.random() * 100f));
}
Line line = new Line(values);
line.setColor(ChartUtils.COLOR_GREEN);
line.setHasPoints(false);// too many values so don't draw points.
List<Line> lines = new ArrayList<Line>();
lines.add(line);
data = new LineChartData(lines);
data.setAxisXBottom(new Axis());
data.setAxisYLeft(new Axis().setHasLines(true));
// prepare preview data, is better to use separate deep copy for preview chart.
// Set color to grey to make preview area more visible.
previewData = new LineChartData(data);
previewData.getLines().get(0).setColor(ChartUtils.DEFAULT_DARKEN_COLOR);
}
示例9: callTouchListener
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
public void callTouchListener() {
SelectedValue selectedValue = this.chartRenderer.getSelectedValue();
if (selectedValue.isSet()) {
Line line = (Line) this.data.getLines().get(selectedValue.getFirstIndex());
PointValue point = (PointValue) line.getValues().get(selectedValue.getSecondIndex());
switch (selectedValue.getSelectedType()) {
case 0:
this.onValueTouchListener.onValueSelected(selectedValue.getFirstIndex(), selectedValue.getSecondIndex(), point);
return;
case 1:
this.onValueTouchListener.onImageSelected(selectedValue.getFirstIndex(), selectedValue.getSecondIndex(), point);
return;
case 2:
if (line.hasLabels()) {
this.onValueTouchListener.onPopSelected(selectedValue.getFirstIndex(), selectedValue.getSecondIndex(), point);
return;
}
return;
default:
return;
}
}
this.onValueTouchListener.onValueDeselected();
}
示例10: calculateMaxViewport
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private void calculateMaxViewport() {
this.tempMaximumViewport.set(AutoScrollHelper.NO_MAX, Float.MIN_VALUE, Float.MIN_VALUE, AutoScrollHelper.NO_MAX);
for (Line line : this.dataProvider.getLineChartData().getLines()) {
for (PointValue pointValue : line.getValues()) {
if (pointValue.getX() < this.tempMaximumViewport.left) {
this.tempMaximumViewport.left = pointValue.getX();
}
if (pointValue.getX() > this.tempMaximumViewport.right) {
this.tempMaximumViewport.right = pointValue.getX();
}
if (pointValue.getY() < this.tempMaximumViewport.bottom) {
this.tempMaximumViewport.bottom = pointValue.getY();
}
if (pointValue.getY() > this.tempMaximumViewport.top) {
this.tempMaximumViewport.top = pointValue.getY();
}
}
}
}
示例11: drawPath
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private void drawPath(Canvas canvas, Line line) {
prepareLinePaint(line);
int valueIndex = 0;
for (PointValue pointValue : line.getValues()) {
float rawX = this.computator.computeRawX(pointValue.getX());
float rawY = this.computator.computeRawY(pointValue.getY());
if (valueIndex == 0) {
this.path.moveTo(rawX, rawY);
} else {
this.path.lineTo(rawX, rawY);
}
valueIndex++;
}
canvas.drawPath(this.path, this.linePaint);
if (line.isFilled()) {
drawArea(canvas, line);
}
this.path.reset();
}
示例12: drawSquarePath
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private void drawSquarePath(Canvas canvas, Line line) {
prepareLinePaint(line);
int valueIndex = 0;
float previousRawY = 0.0f;
for (PointValue pointValue : line.getValues()) {
float rawX = this.computator.computeRawX(pointValue.getX());
float rawY = this.computator.computeRawY(pointValue.getY());
if (valueIndex == 0) {
this.path.moveTo(rawX, rawY);
} else {
this.path.lineTo(rawX, previousRawY);
this.path.lineTo(rawX, rawY);
}
previousRawY = rawY;
valueIndex++;
}
canvas.drawPath(this.path, this.linePaint);
if (line.isFilled()) {
drawArea(canvas, line);
}
this.path.reset();
}
示例13: drawArea
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private void drawArea(Canvas canvas, Line line) {
int lineSize = line.getValues().size();
if (lineSize >= 2) {
Rect contentRect = this.computator.getContentRectMinusAllMargins();
float baseRawValue = Math.min((float) contentRect.bottom, Math.max(this.computator.computeRawY(this.baseValue), (float) contentRect.top));
float left = Math.max(this.computator.computeRawX(((PointValue) line.getValues().get(0)).getX()), (float) contentRect.left);
this.path.lineTo(Math.min(this.computator.computeRawX(((PointValue) line.getValues().get(lineSize - 1)).getX()), (float) contentRect.right), baseRawValue);
this.path.lineTo(left, baseRawValue);
this.path.close();
this.linePaint.setStyle(Style.FILL);
this.linePaint.setAlpha(line.getAreaTransparency());
this.linePaint.setColor(line.getAreaColor());
canvas.drawPath(this.path, this.linePaint);
this.linePaint.setStyle(Style.STROKE);
}
}
示例14: getLines
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private List<Line> getLines() {
Line line = new Line(this.mPointValues);
line.setColor(this.resources.getColor(R.color.js));
line.setLabelColor(this.resources.getColor(R.color.js));
line.setFilled(true);
line.setCubic(false);
line.setHasLabels(true);
if (this.mWeightRecords == null || this.mWeightRecords.size() == 0 || this.mTypeMode > 0) {
line.setHasPoints(false);
} else {
line.setHasPoints(true);
}
line.setFormatter(new SimpleLineChartValueFormatter().setDecimalDigitsNumber(1));
List<Line> lines = new ArrayList();
Line target = getTargetLine();
if (target != null) {
lines.add(target);
}
lines.add(line);
return lines;
}
示例15: getTargetLine
import lecho.lib.hellocharts.model.Line; //导入依赖的package包/类
private Line getTargetLine() {
if (!needDrawTargetLine()) {
return null;
}
PointValue lastRecordPoint = (PointValue) this.mPointValues.get(this.mPointValues.size()
- 1);
PointValue targetPoint = new PointValue(((AxisValue) this.mAxisValues.get(this
.mAxisValues.size() - 1)).getValue(), this.mTargetWeight);
List<PointValue> points = new ArrayList();
points.add(lastRecordPoint);
points.add(targetPoint);
Line line = new Line(points);
line.setColor(this.resources.getColor(R.color.da));
line.setPathEffect(new DashPathEffect(new float[]{15.0f, 15.0f, 15.0f, 15.0f}, 0.0f));
line.setHasLabels(false);
if (this.mTypeMode > 0) {
line.setHasPoints(false);
return line;
}
line.setHasPoints(true);
return line;
}