Closed SprocketNYC closed 9 years ago
I am testing the bounding box. One problem found is: For text shape, getBoundingBox() will result in an error, due to the height being returned is "undefined" (instead of a double).
Here is the stripped-down code to reproduce the bug. Thank you.
package com.company.consumer.examples.client; import java.awt.Color; import java.util.logging.Logger; import com.ait.lienzo.client.core.shape.Layer; import com.ait.lienzo.client.core.shape.Text; import com.ait.lienzo.client.core.types.BoundingBox; import com.ait.lienzo.client.core.types.Point2D; import com.ait.lienzo.client.widget.LienzoPanel; import com.ait.lienzo.shared.core.types.ColorName; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel;
public class MyText implements EntryPoint { private LienzoPanel panel; private Layer layer; Logger logger = Logger.getLogger("MyText");
@Override
public void onModuleLoad() {
panel = new LienzoPanel(800, 1000);
layer = new Layer();
panel.add(layer);
RootPanel.get().add(panel);
Text text = new Text("Hello Lienzo");
text.setLocation(new Point2D(100, 200));
text.setDraggable(true).setFillColor(ColorName.CORNFLOWERBLUE.getValue());
layer.add(text);
BoundingBox bBox = text.getBoundingBox();
layer.draw();
}
}
Error messages are as follows:
13:39:05.385 [ERROR] [com.helpswitch.consumer.examples.MyText] Unable to load module entry point class com.helpswitch.consumer.examples.client.MyText (see associated exception for details)
com.google.gwt.dev.shell.HostedModeException: Something other than a double was returned from JSNI method '@com.ait.lienzo.client.core.types.TextMetrics::getHeight()': JS value of type undefined, expected double at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:112) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeDouble(ModuleSpace.java:238) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeDouble(JavaScriptHost.java:59) at com.ait.lienzo.client.core.types.TextMetrics$.getHeight$(TextMetrics.java) at com.ait.lienzo.client.core.shape.Text.getBoundingBox(Text.java:142) at com.ait.lienzo.client.core.shape.Text.getBoundingBox(Text.java:133) at com.helpswitch.consumer.examples.client.MyText.onModuleLoad(MyText.java:34) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:411) at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364) at java.lang.Thread.run(Thread.java:744)
I'll look into it....
Thank you.
The following are some issues that I am sure you are aware of already:) 1) getBoundingBox for a SVGPath always returns BoundingBox(0, 0, 10, 10) 2) bounding box for shapes with transformations (such as scaling, rotation etc.) are not yet supported 3) the (x, y) location of the bounding box is not tied with the location of its shape
I would be pleased to help with testing when these are ready. Thanks again.
I know, many shapes are not done, which is why this ticket is not closed ;-)
2) BoundingBox is a raw BoundingBox, no transform, x, y, etc. Minimal Rectangle. 3) Shape you can call BoundingPoints points = s.getBoundingPoints(), this is basically the 4 (x,y) points of the BoundingBox.
You can then transform the points, points = points.transform(t), where t is s.getNodeTransform() or s.getAbsoluteTransform(), note this may not be "square" anymore, so you can further derive a minimal BoundingBox from points.getBoundingBox()
Thanks for the info.
On Nov 14, 2014, at 12:52 AM, Dean Jones notifications@github.com wrote:
2) BoundingBox is a raw BoundingBox, no transform, x, y, etc. Minimal Rectangle. 3) Shape you can call BoundingPoints points = s.getBoundingPoints(), this is basically the 4 (x,y) points of the BoundingBox.
You can then transform the points, points = points.transform(t), where t is s.getNodeTransform() or s.getAbsoluteTransform(), note this may not be "square" anymore, so you can further derive a minimal BoundingBox from points.getBoundingBox()
http://www.lienzo-core.com/lienzo-ks/#BEZIER_BOUNDING http://www.lienzo-core.com/lienzo-ks/#BEZIER_BOUNDING — Reply to this email directly or view it on GitHub https://github.com/ahome-it/lienzo-core/issues/16#issuecomment-63013912.
Any target date that we might be able to get raw bounding boxes for most if not all shapes (e.g. SVGPath, Text, ...)?? Thank you:)
Thanks. Will take a look very soon.
Great site to help with calculating bounding boxes of cubic and quadratic curves and Catmull-Rom splines
http://pomax.github.io/bezierinfo/