コード例 #1
0
  @Override
  public void drawShadow(
      IBNAView view, ICoordinateMapper cm, GL2 gl, Rectangle clip, IResources r) {
    Rectangle lbb = BNAUtils.getLocalBoundingBox(cm, t);
    if (!clip.intersects(lbb)) {
      return;
    }

    Shape localShape = new Ellipse2D.Float(lbb.x, lbb.y, lbb.width, lbb.height);

    r.setColor(new RGB(0, 0, 0), 1f);
    BNAUtils.renderShapeFill(view, cm, gl, clip, r, localShape);
  }
コード例 #2
0
  @Override
  public void dispose() {
    BNAUtils.checkLock();

    instances.remove(this);
    super.dispose();
  }
コード例 #3
0
  @Override
  public void fillMenu(
      final IBNAView view, List<IThing> things, final ICoordinate location, IMenuManager m) {
    IThing editThing = null;
    if (Iterables.size(BNAUtils.getSelectedThings(view.getBNAWorld().getBNAModel())) <= 1) {
      MAIN:
      for (IThing thing : things) {
        for (IThing assemblyPartThing :
            Assemblies.getRelatedParts(view.getBNAWorld().getBNAModel(), thing)) {
          if (assemblyPartThing instanceof IHasMutableText
              && UserEditableUtils.isEditableForAnyQualities(
                  assemblyPartThing,
                  IHasMutableText.USER_MAY_EDIT_TEXT,
                  IHasToolTip.USER_MAY_EDIT_TOOL_TIP)) {
            editThing = assemblyPartThing;
            break MAIN;
          }
        }
      }
    }
    final IThing finalThing = editThing;
    if (finalThing != null) {
      m.add(
          new Action("Edit Description...") {

            @Override
            public void run() {
              initEdit(finalThing);
            }
          });
    }
  }
コード例 #4
0
  @Override
  public void draw(IBNAView view, ICoordinateMapper cm, GL2 gl, Rectangle clip, IResources r) {
    Rectangle lbb = BNAUtils.getLocalBoundingBox(cm, t);
    if (!clip.intersects(lbb)) {
      return;
    }

    Shape localShape = new Ellipse2D.Float(lbb.x, lbb.y, lbb.width, lbb.height);

    BNAUtils.renderShapeFill(t, view, cm, gl, clip, r, localShape);
    for (int count = 0; count < t.getCount(); count++) {
      int offset = count * 2 * t.getLineWidth();
      Shape edgeShape =
          new Ellipse2D.Float(
              lbb.x + offset, lbb.y + offset, lbb.width - 2 * offset, lbb.height - 2 * offset);
      BNAUtils.renderShapeEdge(t, view, cm, gl, clip, r, edgeShape);
    }
    BNAUtils.renderShapeSelected(t, view, cm, gl, clip, r, localShape);
  }
コード例 #5
0
 @Override
 public void keyReleased(IBNAView view, KeyEvent e) {
   if (SWT.F2 == e.keyCode) {
     IThing editThing = null;
     if (Iterables.size(BNAUtils.getSelectedThings(view.getBNAWorld().getBNAModel())) == 1) {
       MAIN:
       for (IThing thing : BNAUtils.getSelectedThings(view.getBNAWorld().getBNAModel())) {
         for (IThing assemblyPartThing :
             Assemblies.getRelatedParts(view.getBNAWorld().getBNAModel(), thing)) {
           if (UserEditableUtils.isEditableForAnyQualities(
               assemblyPartThing,
               IHasMutableText.USER_MAY_EDIT_TEXT,
               IHasToolTip.USER_MAY_EDIT_TOOL_TIP)) {
             editThing = assemblyPartThing;
             break MAIN;
           }
         }
       }
     }
     if (editThing != null) {
       initEdit(editThing);
     }
   }
 }
コード例 #6
0
  private void initEdit(IThing forThing) {
    checkNotNull(forThing);

    IBNAModel model = getBNAModel();
    if (model != null) {
      Point p = checkNotNull(BNAUtils.getCentralPoint(forThing));

      SWTTextThing tt = model.addThing(new SWTTextThing(null), forThing);
      tt.set(DATA_KEY, new EditTextLogicData(forThing.getID()));
      String text = "";
      if (forThing instanceof IHasText) {
        text = ((IHasText) forThing).getText();
      } else {
        text = ToolTipLogic.getToolTip(forThing);
      }
      tt.setText(text);
      tt.setBoundingBox(new Rectangle(p.x, p.y, 0, 0));
    }
  }
コード例 #7
0
  @Override
  public void draw(IBNAView view, ICoordinateMapper cm, GL2 gl, Rectangle clip, IResources r) {
    if (Boolean.TRUE.equals(t.get(IHasSelected.SELECTED_KEY))) {
      List<Point> localPoints = BNAUtils.worldToLocal(cm, t.getPoints());

      gl.glLineWidth(1f);

      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL2.GL_LINE_STRIP);
      for (Point p : localPoints) {
        gl.glVertex2f(p.x + 0.5f, p.y + 0.5f);
      }
      gl.glEnd();

      gl.glColor3f(0f, 0f, 0f);
      gl.glLineStipple(1, (short) (0x0f0f0f0f >> t.getRotatingOffset() % 8));
      gl.glBegin(GL2.GL_LINE_STRIP);
      for (Point p : localPoints) {
        gl.glVertex2f(p.x + 0.5f, p.y + 0.5f);
      }
      gl.glEnd();
    }
  }