Skip to content

Commit

Permalink
Fixed code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
pagrzybe committed May 9, 2018
1 parent e416736 commit 92c14db
Showing 1 changed file with 24 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,12 @@ public class YAxis extends AxisBase {
/**
* flag indicating that auto scale min restriction should be used
*/

private boolean mUseAutoScaleRestrictionMin = false;

/**
* flag indicating that auto scale max restriction should be used
*/

private boolean mUseAutoScaleRestrictionMax = false;
/**
* restriction value of autoscale min
*/

private float mAutoScaleMinRestriction = 0f;

/**
* restriction value of autoscale max
*/
private float mAutoScaleMaxRestriction = 0f;

/**
* Color of the zero line
Expand Down Expand Up @@ -379,35 +368,34 @@ public boolean needsOffset() {
}

/**
* Sets min value restriction for autoscale
* Returns true if autoscale restriction for axis min value is enabled
*/
public void setAutoScaleMinRestriction(float restrictionValue) {
mUseAutoScaleRestrictionMin = true;
mAutoScaleMinRestriction = restrictionValue;
public boolean isUseAutoScaleMinRestriction( ) {
return mUseAutoScaleRestrictionMin;
}

/**
* Sets max value restriction for autoscale
* Sets autoscale restriction for axis min value as enabled/disabled
*/
public void setAutoScaleMaxRestriction(float restrictionValue) {
mUseAutoScaleRestrictionMax = true;
mAutoScaleMaxRestriction = restrictionValue;
public void setUseAutoScaleMinRestriction( boolean isEnabled ) {
mUseAutoScaleRestrictionMin = isEnabled;
}

/**
* Resets min value restriction for autoscale
* Returns true if autoscale restriction for axis max value is enabled
*/
public void resetAutoScaleMinRestriction() {
mUseAutoScaleRestrictionMin = false;
public boolean isUseAutoScaleMaxRestriction() {
return mUseAutoScaleRestrictionMax;
}

/**
* Resets max value restriction for autoscale
* Sets autoscale restriction for axis max value as enabled/disabled
*/
public void resetAutoScaleMaxRestriction() {
mUseAutoScaleRestrictionMax = false;
public void setUseAutoScaleMaxRestriction( boolean isEnabled ) {
mUseAutoScaleRestrictionMax = isEnabled;
}


@Override
public void calculate(float dataMin, float dataMax) {

Expand All @@ -416,15 +404,19 @@ public void calculate(float dataMin, float dataMax) {

// if custom, use value as is, else use data value
if( mCustomAxisMin ) {
min = mAxisMinimum;
} else if( mUseAutoScaleRestrictionMin ) {
min = Math.min( min, mAutoScaleMinRestriction );
if( mUseAutoScaleRestrictionMin ) {
min = Math.min( dataMin, mAxisMinimum );
} else {
min = mAxisMinimum;
}
}

if( mCustomAxisMax ) {
max = mAxisMaximum;
} else if( mUseAutoScaleRestrictionMax ) {
max = Math.max( max, mAutoScaleMaxRestriction );
if( mUseAutoScaleRestrictionMax ) {
max = Math.max( max, mAxisMaximum );
} else {
max = mAxisMaximum;
}
}

// temporary range (before calculations)
Expand Down

0 comments on commit 92c14db

Please sign in to comment.