use of com.codename1.ui.geom.Shape in project CodenameOne by codenameone.
the class ChartComponent method chartToScreenShape.
/**
* Converts a screen coordinate spaced shape to the same shape in the chart coordinate space
* @param s shape in chart coordinates
* @return same shape using screen coordinate space
*/
public Shape chartToScreenShape(Shape s) {
GeneralPath p = new GeneralPath();
Transform inverse = Transform.makeTranslation(getAbsoluteX(), getAbsoluteY());
if (currentTransform != null) {
inverse.concatenate(currentTransform);
}
p.append(s.getPathIterator(inverse), false);
return p;
}
use of com.codename1.ui.geom.Shape in project CodenameOne by codenameone.
the class ChartComponent method screenToChartShape.
/**
* Converts a chart coordinate spaced shape to the same shape in the screen coordinate space
* @param s shape in screen coordinates
* @return same shape using chart space coordinates
*/
public Shape screenToChartShape(Shape s) {
GeneralPath p = new GeneralPath();
Transform t = Transform.makeIdentity();
if (currentTransform != null) {
t.concatenate(currentTransform.getInverse());
}
t.translate(-getAbsoluteX(), -getAbsoluteY());
p.append(s.getPathIterator(t), false);
return p;
}
use of com.codename1.ui.geom.Shape in project CodenameOne by codenameone.
the class ChartComponent method zoomToShapeInChartCoords.
/**
* Zooms the view port to show a specified shape. The shape should be
* expressed in chart coordinates (not screen coordinates).
* @param s The shape that should be shown.
* @param duration The duration of the transition.
* @see #zoomTo(double, double, double, double, int)
*/
public void zoomToShapeInChartCoords(Shape s, int duration) {
Rectangle r = s.getBounds();
zoomTransition(r.getX(), r.getX() + r.getWidth(), r.getY(), r.getY() + r.getHeight(), duration);
}
Aggregations