(Class cz, Vec2 at, Box... parents)
| 239 | b1 = (Box) cz.getConstructor() |
| 240 | .newInstance(); |
| 241 | } catch (NoSuchMethodException e) { |
| 242 | try { |
| 243 | b1 = (Box) cz.getConstructor(Box.class) |
| 244 | .newInstance(parents[0]); |
| 245 | } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { |
| 246 | e1.printStackTrace(); |
| 247 | } |
| 248 | |
| 249 | } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { |
| 250 | e.printStackTrace(); |
| 251 | } |
| 252 | if (b1 == null) return null; |
| 253 | |
| 254 | for (Box p : parents) |
| 255 | p.connect(b1); |
| 256 | float w = 50; |
| 257 | b1.properties.put(frame, new Rect(at.x - w, at.y - w, w * 2, w * 2)); |
| 258 | b1.properties.put(Box.name, "Untitled"); |
| 259 | b1.properties.put(wasNew, true); |
| 260 | Drawing.dirty(b1); |
| 261 | return b1; |
| 262 | } |
| 263 | |
| 264 | public Vec2 convertCoordinateSystem(Window.MouseState event) { |
| 265 | Optional<Drawing> drawing = this.find(Drawing.drawing, both()) |
| 266 | .findFirst(); |
| 267 | return drawing.map(x -> x.windowSystemToDrawingSystem(new Vec2(event.x, event.y))) |
| 268 | .orElseThrow(() -> new IllegalArgumentException(" cant mouse around something without drawing support (to provide coordinate system)")); |
| 269 | } |
| 270 | |
| 271 | static public void save(Box root, String filename) { |
no test coverage detected