示例#1
0
  public void drawU(
      UGraphic ug,
      double xTheoricalPosition,
      double yTheoricalPosition,
      double marginWidth,
      double marginHeight) {
    final Dimension2D dim = getDimension(ug.getStringBounder());

    final double widthTotal = dim.getWidth() + 2 * marginWidth;
    final double heightTotal = dim.getHeight() + 2 * marginHeight;
    final URectangle rect = new URectangle(widthTotal, heightTotal);

    // if (entity.getParent() == null) {
    if (entity.getType() != EntityType.GROUP) {
      ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBackground));
      ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder));
      ug.draw(xTheoricalPosition - marginWidth, yTheoricalPosition - marginHeight, rect);
      // name.drawU(ug, xTheoricalPosition + margin, yTheoricalPosition + margin);
      name.drawU(ug, xTheoricalPosition + 0, yTheoricalPosition + 0);
    } else {
      // final Frame frame = new Frame(StringUtils.getWithNewlines(entity.getDisplay()),
      // Color.BLACK, param
      // .getFont(FontParam.CLASS), rose.getHtmlColor(param, ColorParam.classBorder).getColor());
      final Frame frame = new Frame(entity.getDisplay2(), param);

      ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.background));
      ug.getParam().setColor(null);
      ug.draw(xTheoricalPosition - marginWidth, yTheoricalPosition - marginWidth, rect);

      final double oldX = ug.getTranslateX();
      final double oldY = ug.getTranslateY();
      ug.translate(xTheoricalPosition - marginWidth, yTheoricalPosition - marginHeight);
      frame.drawU(ug, new Area(new Dimension2DDouble(widthTotal, heightTotal)), null);
      // ug.translate(-xTheoricalPosition + marginWidth,
      // -yTheoricalPosition + marginHeight);
      ug.setTranslate(oldX, oldY);

      // playField.drawInternal(UGraphicUtils.translate(ug, xTheoricalPosition + margin,
      // yTheoricalPosition +
      // margin
      // + frame.getPreferredHeight(ug.getStringBounder())));
      playField.drawInternal(
          UGraphicUtils.translate(
              ug,
              xTheoricalPosition + 0,
              yTheoricalPosition + 0 + frame.getPreferredHeight(ug.getStringBounder())));
    }
  }
示例#2
0
  private void initPlayField(StringBounder stringBounder) {
    if (playField != null || entity.getParent() == null || entity.getType() != EntityType.GROUP) {
      return;
    }
    this.playField = new PlayField(param);
    final Collection<IEntity> entities = new ArrayList<IEntity>();
    for (IEntity ent : entity.getParent().entities().values()) {
      // entities.add(EntityUtils.withNoParent(ent));
      entities.add(ent);
    }
    playField.initInternal(entities, links, stringBounder);

    // this.frame = new Frame(StringUtils.getWithNewlines(entity.getDisplay()), Color.BLACK, param
    // .getFont(FontParam.CLASS), rose.getHtmlColor(param, ColorParam.classBorder).getColor());
    this.frame = new Frame(entity.getDisplay2(), param);
  }
示例#3
0
 private Dimension2D getDimensionSlow(StringBounder stringBounder) {
   initPlayField(stringBounder);
   Dimension2D dim;
   if (playField == null) {
     dim = name.calculateDimension(stringBounder);
   } else {
     try {
       dim = playField.solve();
       // final double frameWidth =
       // frame.getPreferredWidth(stringBounder);
       final double frameHeight = frame.getPreferredHeight(stringBounder);
       dim = Dimension2DDouble.delta(dim, 0, frameHeight);
     } catch (IOException e) {
       e.printStackTrace();
       throw new RuntimeException();
     } catch (InterruptedException e) {
       e.printStackTrace();
       throw new RuntimeException();
     }
   }
   return dim;
   // return Dimension2DDouble.delta(dim, margin * 2);
 }