This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Exception to be thrown when a bound value isn't supported by the logarithmic axis<br> | |
* <br> | |
* | |
* @author Kevin Senechal mailto: kevin.senechal@dooapp.com | |
* | |
*/ | |
public class IllegalLogarithmicRangeException extends Exception { | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.NumberFormat; | |
import java.util.ArrayList; | |
import java.util.List; | |
import javafx.animation.KeyFrame; | |
import javafx.animation.KeyValue; | |
import javafx.animation.Timeline; | |
import javafx.beans.binding.DoubleBinding; | |
import javafx.beans.property.DoubleProperty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public Number getValueForDisplay(double displayPosition) { | |
double delta = logUpperBound.get() - logLowerBound.get(); | |
if (getSide().isVertical()) { | |
return Math.pow(10, (((displayPosition - getHeight()) / -getHeight()) * delta) + logLowerBound.get()); | |
} else { | |
return Math.pow(10, (((displayPosition / getWidth()) * delta) + logLowerBound.get())); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The time of animation in ms | |
*/ | |
private static final double ANIMATION_TIME = 2000; | |
private final Timeline lowerRangeTimeline = new Timeline(); | |
private final Timeline upperRangeTimeline = new Timeline(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@inheritDoc} | |
*/ | |
@Override | |
protected void setRange(Object range, boolean animate) { | |
if (range != null) { | |
Number lowerBound = ((Number[]) range)[0]; | |
Number upperBound = ((Number[]) range)[1]; | |
try { | |
validateBounds(lowerBound.doubleValue(), upperBound.doubleValue()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@inheritDoc} | |
*/ | |
@Override | |
protected void setRange(Object range, boolean animate) { | |
if (range != null) { | |
Number lowerBound = ((Number[]) range)[0]; | |
Number upperBound = ((Number[]) range)[1]; | |
try { | |
validateBounds(lowerBound.doubleValue(), upperBound.doubleValue()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@inheritDoc} | |
*/ | |
@Override | |
protected List<Number> calculateTickValues(double length, Object range) { | |
List<Number> tickPositions = new ArrayList<Number>(); | |
if (range != null) { | |
Number lowerBound = ((Number[]) range)[0]; | |
Number upperBound = ((Number[]) range)[1]; | |
double logLowerBound = Math.log10(lowerBound.doubleValue()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@inheritDoc} | |
*/ | |
@Override | |
protected List<Number> calculateMinorTickMarks() { | |
Number[] range = getRange(); | |
List<Number> minorTickMarksPositions = new ArrayList<Number>(); | |
if (range != null) { | |
Number upperBound = range[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.scene.chart.ValueAxis; | |
/** | |
* A logarithmic axis implementation for JavaFX 2 charts<br> | |
* <br> | |
* | |
* @author Kevin Senechal | |
* | |
*/ | |
public class LogarithmicAxis extends ValueAxis<Number> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected Object getRange() { | |
return new Number[] { lowerBoundProperty().get(), upperBoundProperty().get() }; | |
} |
NewerOlder