Skip to content

Commit

Permalink
Update and reorganise copy data sets methods (Fix for PhilJay#1604).
Browse files Browse the repository at this point in the history
Copying class properties is always done in protected copy method.
  • Loading branch information
RobertZagorski authored and Robert Zagorski committed May 8, 2018
1 parent 8c4fb9f commit 64a5053
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,19 @@ public DataSet<BarEntry> copy() {
entries.add(mValues.get(i).copy());
}
BarDataSet copied = new BarDataSet(entries, getLabel());
super.copy(copied);
copied.mStackSize = mStackSize;
copied.mBarShadowColor = mBarShadowColor;
copied.mBarBorderWidth = mBarBorderWidth;
copied.mStackLabels = mStackLabels;
copied.mHighLightAlpha = mHighLightAlpha;
copy(copied);
return copied;
}

protected void copy(BarDataSet barDataSet) {
super.copy(barDataSet);
barDataSet.mStackSize = mStackSize;
barDataSet.mBarShadowColor = mBarShadowColor;
barDataSet.mBarBorderWidth = mBarBorderWidth;
barDataSet.mStackLabels = mStackLabels;
barDataSet.mHighLightAlpha = mHighLightAlpha;
}

/**
* Calculates the total number of entries this DataSet represents, including
* stacks. All values belonging to a stack are calculated separately.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ public DataSet<BubbleEntry> copy() {
entries.add(mValues.get(i).copy());
}
BubbleDataSet copied = new BubbleDataSet(entries, getLabel());
super.copy(copied);
copy(copied);
return copied;
}

protected void copy(BubbleDataSet bubbleDataSet) {
bubbleDataSet.mHighlightCircleWidth = mHighlightCircleWidth;
bubbleDataSet.mNormalizeSize = mNormalizeSize;
}

@Override
public float getMaxSize() {
return mMaxSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,25 @@ public DataSet<CandleEntry> copy() {
entries.add(mValues.get(i).copy());
}
CandleDataSet copied = new CandleDataSet(entries, getLabel());
super.copy(copied);
copied.mShadowWidth = mShadowWidth;
copied.mShowCandleBar = mShowCandleBar;
copied.mBarSpace = mBarSpace;
copied.mShadowColorSameAsCandle = mShadowColorSameAsCandle;
copied.mHighLightColor = mHighLightColor;
copied.mIncreasingPaintStyle = mIncreasingPaintStyle;
copied.mDecreasingPaintStyle = mDecreasingPaintStyle;
copied.mNeutralColor = mNeutralColor;
copied.mIncreasingColor = mIncreasingColor;
copied.mDecreasingColor = mDecreasingColor;
copied.mShadowColor = mShadowColor;
copy(copied);
return copied;
}

protected void copy(CandleDataSet candleDataSet) {
super.copy(candleDataSet);
candleDataSet.mShadowWidth = mShadowWidth;
candleDataSet.mShowCandleBar = mShowCandleBar;
candleDataSet.mBarSpace = mBarSpace;
candleDataSet.mShadowColorSameAsCandle = mShadowColorSameAsCandle;
candleDataSet.mHighLightColor = mHighLightColor;
candleDataSet.mIncreasingPaintStyle = mIncreasingPaintStyle;
candleDataSet.mDecreasingPaintStyle = mDecreasingPaintStyle;
candleDataSet.mNeutralColor = mNeutralColor;
candleDataSet.mIncreasingColor = mIncreasingColor;
candleDataSet.mDecreasingColor = mDecreasingColor;
candleDataSet.mShadowColor = mShadowColor;
}

@Override
protected void calcMinMax(CandleEntry e) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,24 @@ public DataSet<Entry> copy() {
entries.add(mValues.get(i).copy());
}
LineDataSet copied = new LineDataSet(entries, getLabel());
super.copy(copied);
copied.mCircleColors = mCircleColors;
copied.mCircleHoleColor = mCircleHoleColor;
copied.mCircleHoleRadius = mCircleHoleRadius;
copied.mCircleRadius = mCircleRadius;
copied.mCubicIntensity = mCubicIntensity;
copied.mDashPathEffect = mDashPathEffect;
copied.mDrawCircleHole = mDrawCircleHole;
copied.mDrawCircles = mDrawCircleHole;
copied.mFillFormatter = mFillFormatter;
copied.mMode = mMode;
copy(copied);
return copied;
}

protected void copy(LineDataSet lineDataSet) {
super.copy(lineDataSet);
lineDataSet.mCircleColors = mCircleColors;
lineDataSet.mCircleHoleColor = mCircleHoleColor;
lineDataSet.mCircleHoleRadius = mCircleHoleRadius;
lineDataSet.mCircleRadius = mCircleRadius;
lineDataSet.mCubicIntensity = mCubicIntensity;
lineDataSet.mDashPathEffect = mDashPathEffect;
lineDataSet.mDrawCircleHole = mDrawCircleHole;
lineDataSet.mDrawCircles = mDrawCircleHole;
lineDataSet.mFillFormatter = mFillFormatter;
lineDataSet.mMode = mMode;
}

/**
* Returns the drawing mode for this line dataset
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@

public class PieDataSet extends DataSet<PieEntry> implements IPieDataSet {

/** the space in pixels between the chart-slices, default 0f */
/**
* the space in pixels between the chart-slices, default 0f
*/
private float mSliceSpace = 0f;
private boolean mAutomaticallyDisableSliceSpacing;

/** indicates the selection distance of a pie slice */
/**
* indicates the selection distance of a pie slice
*/
private float mShift = 18f;

private ValuePosition mXValuePosition = ValuePosition.INSIDE_SLICE;
Expand All @@ -38,10 +42,14 @@ public DataSet<PieEntry> copy() {
entries.add(mValues.get(i).copy());
}
PieDataSet copied = new PieDataSet(entries, getLabel());
super.copy(copied);
copy(copied);
return copied;
}

protected void copy(PieDataSet pieDataSet) {
super.copy(pieDataSet);
}

@Override
protected void calcMinMax(PieEntry e) {

Expand Down Expand Up @@ -74,7 +82,7 @@ public float getSliceSpace() {

/**
* When enabled, slice spacing will be 0.0 when the smallest value is going to be
* smaller than the slice spacing itself.
* smaller than the slice spacing itself.
*
* @param autoDisable
*/
Expand All @@ -84,7 +92,7 @@ public void setAutomaticallyDisableSliceSpacing(boolean autoDisable) {

/**
* When enabled, slice spacing will be 0.0 when the smallest value is going to be
* smaller than the slice spacing itself.
* smaller than the slice spacing itself.
*
* @return
*/
Expand All @@ -96,7 +104,7 @@ public boolean isAutomaticallyDisableSliceSpacingEnabled() {
/**
* sets the distance the highlighted piechart-slice of this DataSet is
* "shifted" away from the center of the chart, default 12f
*
*
* @param shift
*/
public void setSelectionShift(float shift) {
Expand All @@ -109,30 +117,26 @@ public float getSelectionShift() {
}

@Override
public ValuePosition getXValuePosition()
{
public ValuePosition getXValuePosition() {
return mXValuePosition;
}

public void setXValuePosition(ValuePosition xValuePosition)
{
public void setXValuePosition(ValuePosition xValuePosition) {
this.mXValuePosition = xValuePosition;
}

@Override
public ValuePosition getYValuePosition()
{
public ValuePosition getYValuePosition() {
return mYValuePosition;
}

public void setYValuePosition(ValuePosition yValuePosition)
{
public void setYValuePosition(ValuePosition yValuePosition) {
this.mYValuePosition = yValuePosition;
}

/**
* When valuePosition is OutsideSlice, use slice colors as line color if true
* */
*/
@Override
public boolean isUsingSliceColorAsValueLineColor() {
return mUsingSliceColorAsValueLineColor;
Expand All @@ -142,69 +146,71 @@ public void setUsingSliceColorAsValueLineColor(boolean usingSliceColorAsValueLin
this.mUsingSliceColorAsValueLineColor = usingSliceColorAsValueLineColor;
}

/** When valuePosition is OutsideSlice, indicates line color */
/**
* When valuePosition is OutsideSlice, indicates line color
*/
@Override
public int getValueLineColor()
{
public int getValueLineColor() {
return mValueLineColor;
}

public void setValueLineColor(int valueLineColor) {
this.mValueLineColor = valueLineColor;
}

/** When valuePosition is OutsideSlice, indicates line width */
/**
* When valuePosition is OutsideSlice, indicates line width
*/
@Override
public float getValueLineWidth()
{
public float getValueLineWidth() {
return mValueLineWidth;
}

public void setValueLineWidth(float valueLineWidth)
{
public void setValueLineWidth(float valueLineWidth) {
this.mValueLineWidth = valueLineWidth;
}

/** When valuePosition is OutsideSlice, indicates offset as percentage out of the slice size */
/**
* When valuePosition is OutsideSlice, indicates offset as percentage out of the slice size
*/
@Override
public float getValueLinePart1OffsetPercentage()
{
public float getValueLinePart1OffsetPercentage() {
return mValueLinePart1OffsetPercentage;
}

public void setValueLinePart1OffsetPercentage(float valueLinePart1OffsetPercentage)
{
public void setValueLinePart1OffsetPercentage(float valueLinePart1OffsetPercentage) {
this.mValueLinePart1OffsetPercentage = valueLinePart1OffsetPercentage;
}

/** When valuePosition is OutsideSlice, indicates length of first half of the line */
/**
* When valuePosition is OutsideSlice, indicates length of first half of the line
*/
@Override
public float getValueLinePart1Length()
{
public float getValueLinePart1Length() {
return mValueLinePart1Length;
}

public void setValueLinePart1Length(float valueLinePart1Length)
{
public void setValueLinePart1Length(float valueLinePart1Length) {
this.mValueLinePart1Length = valueLinePart1Length;
}

/** When valuePosition is OutsideSlice, indicates length of second half of the line */
/**
* When valuePosition is OutsideSlice, indicates length of second half of the line
*/
@Override
public float getValueLinePart2Length()
{
public float getValueLinePart2Length() {
return mValueLinePart2Length;
}

public void setValueLinePart2Length(float valueLinePart2Length)
{
public void setValueLinePart2Length(float valueLinePart2Length) {
this.mValueLinePart2Length = valueLinePart2Length;
}

/** When valuePosition is OutsideSlice, this allows variable line length */
/**
* When valuePosition is OutsideSlice, this allows variable line length
*/
@Override
public boolean isValueLineVariableLength()
{
public boolean isValueLineVariableLength() {
return mValueLineVariableLength;
}

Expand Down
Loading

0 comments on commit 64a5053

Please sign in to comment.