use of com.codename1.ui.geom.GeneralPath in project CodenameOne by codenameone.
the class BubbleTransition method paint.
@Override
public void paint(Graphics g) {
Component source = getSource();
Component dest = getDestination();
Component srcCmp = source;
Component destCmp = dest;
if ((source instanceof Dialog && dest instanceof Form) || originDest != null) {
srcCmp = dest;
destCmp = source;
}
paint(g, srcCmp, -srcCmp.getAbsoluteX(), -srcCmp.getAbsoluteY(), true);
int[] clip = g.getClip();
if (destCmp instanceof Dialog) {
destCmp = getDialogParent(destCmp);
}
if (roundBubble && g.isShapeClipSupported()) {
GeneralPath p = getBubbleShape();
p.reset();
p.arc(x + destCmp.getWidth() / 2 - clipSize / 2, y + destCmp.getHeight() / 2 - clipSize / 2, clipSize, clipSize, 0, Math.toRadians(360));
g.setClip(p);
} else {
g.setClip(x + destCmp.getWidth() / 2 - clipSize / 2, y + destCmp.getHeight() / 2 - clipSize / 2, clipSize, clipSize);
}
g.drawImage(destBuffer, x, y);
g.setClip(clip);
}
use of com.codename1.ui.geom.GeneralPath in project CodenameOne by codenameone.
the class Graphics method setClip.
/**
* Clips the Graphics context to the Shape.
* <p>This is not supported on all platforms and contexts currently.
* Use {@link #isShapeClipSupported} to check if the current
* context supports clipping shapes.</p>
*
* <script src="https://gist.github.com/codenameone/65f531adae2e8c22afc8.js"></script>
* <img src="https://www.codenameone.com/img/blog/shaped-clipping.png" alt="Shaped clipping in action" />
*
* @param shape The shape to clip.
* @see #isShapeClipSupported
*/
public void setClip(Shape shape) {
if (xTranslate != 0 || yTranslate != 0) {
GeneralPath p = tmpClipShape();
p.setShape(shape, translation());
shape = p;
}
impl.setClip(nativeGraphics, shape);
}
use of com.codename1.ui.geom.GeneralPath in project CodenameOne by codenameone.
the class Graphics method drawShape.
// --------------------------------------------------------------------------
// START SHAPE DRAWING STUFF
// --------------------------------------------------------------------------
/**
* Draws a outline shape inside the specified bounding box. The bounding box will resize the shape to fit in its dimensions.
* <p>This is not supported on
* all platforms and contexts currently. Use {@link #isShapeSupported} to check if the current
* context supports drawing shapes.</p>
*
* <script src="https://gist.github.com/codenameone/3f2f8cdaabb7780eae6f.js"></script>
* <img src="https://www.codenameone.com/img/developer-guide/graphics-shape-fill.png" alt="Fill a shape general path" />
*
* @param shape The shape to be drawn.
* @param stroke the stroke to use
*
* @see #setStroke
* @see #isShapeSupported
*/
public void drawShape(Shape shape, Stroke stroke) {
if (isShapeSupported()) {
if (xTranslate != 0 || yTranslate != 0) {
GeneralPath p = tmpClipShape();
p.setShape(shape, translation());
shape = p;
}
impl.drawShape(nativeGraphics, shape, stroke);
}
}
use of com.codename1.ui.geom.GeneralPath in project CodenameOne by codenameone.
the class Graphics method fillShape.
/**
* Fills the given shape using the current alpha and color settings.
* <p>This is not supported on
* all platforms and contexts currently. Use {@link #isShapeSupported} to check if the current
* context supports drawing shapes.</p>
*
* <script src="https://gist.github.com/codenameone/3f2f8cdaabb7780eae6f.js"></script>
* <img src="https://www.codenameone.com/img/developer-guide/graphics-shape-fill.png" alt="Fill a shape general path" />
*
* @param shape The shape to be filled.
*
* @see #isShapeSupported
*/
public void fillShape(Shape shape) {
if (isShapeSupported()) {
if (xTranslate != 0 || yTranslate != 0) {
GeneralPath p = tmpClipShape();
p.setShape(shape, translation());
shape = p;
}
impl.fillShape(nativeGraphics, shape);
}
}
use of com.codename1.ui.geom.GeneralPath 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;
}
Aggregations