Search in sources :

Example 11 with Shape

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;
}
Also used : GeneralPath(com.codename1.ui.geom.GeneralPath) Transform(com.codename1.ui.Transform)

Example 12 with Shape

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;
}
Also used : GeneralPath(com.codename1.ui.geom.GeneralPath) Transform(com.codename1.ui.Transform)

Example 13 with Shape

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);
}
Also used : Rectangle(com.codename1.ui.geom.Rectangle)

Aggregations

GeneralPath (com.codename1.ui.geom.GeneralPath)6 Rectangle (com.codename1.ui.geom.Rectangle)5 Transform (com.codename1.ui.Transform)2 GradientDrawable (com.codename1.charts.compat.GradientDrawable)1 XYChart (com.codename1.charts.views.XYChart)1 Image (com.codename1.ui.Image)1 PathIterator (com.codename1.ui.geom.PathIterator)1 Shape (com.codename1.ui.geom.Shape)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1