Ejemplo n.º 1
0
  @Override
  protected PolygonAssembly addAssembly(
      IBNAModel model, ObjRef objRef, ObjRef[] relativeAncestorRefs) {

    PolygonAssembly assembly =
        new PolygonAssembly(
            model,
            parentThing,
            kind,
            new IPolygonGenerator() {

              public Point[] calculatePoints(Rectangle r) {
                int x1 = r.x;
                int y1 = r.y;
                int x2 = r.x + r.width;
                int y2 = r.y + r.height;

                int foldSize = 11;

                return new Point[] {
                  new Point(x1, y1),
                  new Point(x2, y1),
                  new Point(x2, y2 - foldSize),
                  new Point(x2 - foldSize, y2),
                  new Point(x2 - foldSize, y2 - foldSize),
                  new Point(x2, y2 - foldSize),
                  new Point(x2 - foldSize, y2),
                  new Point(x1, y2),
                  new Point(x1, y1)
                };
              }
            });
    assembly.getPolygonThing().setColor(new RGB(255, 255, 128));
    assembly.getPolygonBorderThing().setColor(new RGB(0, 0, 0));
    assembly
        .getPolygonGlassThing()
        .setBoundingBox(ArchipelagoUtils.findOpenSpotForNewThing(model, 200, 75));

    BoxedLabelThing boxedLabelThing = new BoxedLabelThing();
    model.addThing(boxedLabelThing, assembly.getPolygonThing());

    MirrorBoundingBoxLogic.mirrorBoundingBox(
        assembly.getPolygonGlassThing(), new Rectangle(5, 5, -10, -10), boxedLabelThing);

    UserEditableUtils.addEditableQuality(
        assembly.getPolygonGlassThing(),
        IHasMutableSelected.USER_MAY_SELECT,
        IHasMutableBoundingBox.USER_MAY_RESIZE,
        IRelativeMovable.USER_MAY_MOVE);
    UserEditableUtils.addEditableQuality(boxedLabelThing, IHasMutableText.USER_MAY_EDIT_TEXT);

    assembly.markPart("label", boxedLabelThing);

    return assembly;
  }
Ejemplo n.º 2
0
  @Override
  protected BoxAssembly addAssembly(IBNAModel model, ObjRef objRef, ObjRef[] relativeAncestorRefs) {

    BoxAssembly assembly = new BoxAssembly(model, parentThing, kind);
    assembly
        .getBoxGlassThing()
        .setBoundingBox(ArchipelagoUtils.findOpenSpotForNewThing(model, 125, 100));
    assembly.getBoxGlassThing().setCornerWidth(45);
    assembly.getBoxGlassThing().setCornerHeight(45);
    assembly.getBoxThing().setColor(new RGB(245, 245, 245));

    UserEditableUtils.addEditableQuality(
        assembly.getBoxGlassThing(),
        IHasMutableSelected.USER_MAY_SELECT,
        IHasMutableBoundingBox.USER_MAY_RESIZE,
        IRelativeMovable.USER_MAY_MOVE);
    UserEditableUtils.addEditableQuality(
        assembly.getBoxedLabelThing(), IHasMutableText.USER_MAY_EDIT_TEXT);

    return assembly;
  }