use of com.android.tools.adtui.common.formatter.SingleUnitAxisFormatter in project android by JetBrains.
the class AxisComponentTest method testClampToMajorTickOnFirstUpdate.
@Test
public void testClampToMajorTickOnFirstUpdate() throws Exception {
// Test that during the first update, if the AxisComponent is set to clamp to the next major tick,
// The range will be immediately snapped to the major tick value instead of going through interpolation.
// Subsequent updates will interpolate to the major tick.
// Setting the minimum tick value to 10, so that a Range of {0,5} should adjust to {0,10} by the axis.
SingleUnitAxisFormatter formatter = new SingleUnitAxisFormatter(1, 1, 10, "");
Range range = new Range(0, 5);
Choreographer choreographer = new Choreographer(new JPanel());
choreographer.setUpdate(false);
AxisComponent.Builder builder = new AxisComponent.Builder(range, formatter, AxisComponent.AxisOrientation.LEFT).clampToMajorTicks(true);
AxisComponent axis = builder.build();
choreographer.register(axis);
// before update.
assertThat(axis.getRange().getMax()).isWithin(0.0).of(5);
choreographer.step();
// after update.
assertThat(axis.getRange().getMax()).isWithin(0.0).of(10);
choreographer.stop();
}
use of com.android.tools.adtui.common.formatter.SingleUnitAxisFormatter in project android by JetBrains.
the class DataReducerVisualTest method createComponentsList.
@Override
protected List<Animatable> createComponentsList() {
myGlobalXRange = new Range(0, 0);
myViewXRange = new AnimatedRange();
mySelectionXRange = new AnimatedRange();
myYRange = new Range(0, 0);
myLineChart = new LineChart((shape, config) -> shape);
myOptimizedLineChart = new LineChart();
myXAxis = new AxisComponent.Builder(myViewXRange, new SingleUnitAxisFormatter(1, 5, 1, ""), AxisComponent.AxisOrientation.BOTTOM).build();
mySelection = new SelectionComponent(mySelectionXRange, myViewXRange);
myData = new DefaultDataSeries<>();
mySeries = new RangedContinuousSeries("Straight", myViewXRange, myYRange, myData);
myLineChart.addLine(mySeries, new LineConfig(JBColor.BLUE));
myOptimizedLineChart.addLine(mySeries, new LineConfig(JBColor.RED));
return Arrays.asList(myViewXRange, mySelectionXRange, myLineChart, myOptimizedLineChart, myXAxis, mySelection);
}
Aggregations