public CucaDiagramSimplifierActivity(CucaDiagram diagram, List<String> dotStrings)
      throws IOException, InterruptedException {
    this.diagram = diagram;
    boolean changed;
    do {
      changed = false;
      final Collection<IGroup> groups = new ArrayList<IGroup>(diagram.getGroups(false));
      for (IGroup g : groups) {
        if (diagram.isAutarkic(g)) {
          //					final EntityType type;
          //					if (g.zgetGroupType() == GroupType.INNER_ACTIVITY) {
          //						type = EntityType.ACTIVITY;
          //					} else if (g.zgetGroupType() == GroupType.CONCURRENT_ACTIVITY) {
          //						type = EntityType.ACTIVITY_CONCURRENT;
          //					} else {
          //						throw new IllegalStateException();
          //					}

          final IEntityImage img = computeImage(g);
          g.overideImage(img, LeafType.ACTIVITY);

          changed = true;
        }
      }
    } while (changed);
  }
  public CucaDiagramSimplifier2(CucaDiagram diagram, List<String> dotStrings)
      throws IOException, InterruptedException {
    this.diagram = diagram;
    boolean changed;
    do {
      changed = false;
      final Collection<Group> groups = new ArrayList<Group>(diagram.getGroups(false));
      for (Group g : groups) {
        if (diagram.isAutarkic(g)) {
          final EntityType type;
          if (g.getType() == GroupType.CONCURRENT_STATE) {
            type = EntityType.STATE_CONCURRENT;
          } else if (g.getType() == GroupType.STATE) {
            type = EntityType.STATE;
          } else if (g.getType() == GroupType.INNER_ACTIVITY) {
            type = EntityType.ACTIVITY;
          } else if (g.getType() == GroupType.CONCURRENT_ACTIVITY) {
            type = EntityType.ACTIVITY_CONCURRENT;
          } else {
            throw new IllegalStateException();
          }
          final Entity proxy =
              new Entity(
                  "#" + g.getCode(), g.getDisplay(), type, g.getParent(), diagram.getHides());
          // if (type == EntityType.STATE) {
          // manageBackColorForState(diagram, g, proxy);
          // }
          for (Member field : g.getEntityCluster().getFieldsToDisplay()) {
            proxy.addField(field);
          }
          computeImageGroup(g, proxy, dotStrings);
          diagram.overideGroup(g, proxy);
          if (proxy.getImageFile() != null) {
            diagram.ensureDelete(proxy.getImageFile());
          }

          // final IEntity entityCluster = g.getEntityCluster();
          // if (entityCluster != null && entityCluster.getImageFile()
          // != null) {
          // proxy.addSubImage(entityCluster.getImageFile());
          // }
          // if (entityCluster != null) {
          // proxy.addSubImage((Entity) entityCluster);
          // }

          for (IEntity sub : g.entities().values()) {
            final DrawFile subImage = sub.getImageFile();
            if (subImage != null) {
              proxy.addSubImage(subImage);
            }
          }

          changed = true;
        }
      }
    } while (changed);
  }
 private double getScale(FileFormatOption fileFormatOption, final Dimension2D dim) {
   final double scale;
   final Scale diagScale = diagram.getScale();
   if (diagScale == null) {
     scale = diagram.getDpiFactor(fileFormatOption);
   } else {
     scale = diagScale.getScale(dim.getWidth(), dim.getHeight());
   }
   return scale;
 }
  private TextBlockBackcolored addLegend(TextBlockBackcolored original) {
    final Display legend = diagram.getLegend();
    if (Display.isNull(legend)) {
      return original;
    }
    final TextBlock text = EntityImageLegend.create(legend, diagram.getSkinParam());

    return DecorateEntityImage.add(
        original, text, diagram.getLegendAlignment(), diagram.getLegendVerticalAlignment());
  }
 private List<Link> getOrderedLinks() {
   final List<Link> result = new ArrayList<Link>();
   for (Link l : diagram.getLinks()) {
     addLinkNew(result, l);
   }
   return result;
 }
Beispiel #6
0
 @Override
 protected CommandExecutionResult executeArg(CucaDiagram diagram, List<String> arg) {
   final String s = StringUtils.goUpperCase(arg.get(0)).replace(' ', '_');
   ((SkinParam) diagram.getSkinParam()).setRankdir(Rankdir.valueOf(s));
   // diagram.setRankdir(Rankdir.valueOf(s));
   return CommandExecutionResult.ok();
 }
  private TextBlockBackcolored addTitle(TextBlockBackcolored original) {
    final Display title = diagram.getTitle();
    if (Display.isNull(title)) {
      return original;
    }
    final TextBlock text =
        title.create(
            new FontConfiguration(
                getFont(FontParam.TITLE),
                getFontColor(FontParam.TITLE, null),
                diagram.getSkinParam().getHyperlinkColor(),
                diagram.getSkinParam().useUnderlineForHyperlink()),
            HorizontalAlignment.CENTER,
            diagram.getSkinParam());

    return DecorateEntityImage.addTop(original, text, HorizontalAlignment.CENTER);
  }
  public CucaDiagramSimplifierState(CucaDiagram diagram, List<String> dotStrings)
      throws IOException, InterruptedException {
    this.diagram = diagram;
    boolean changed;
    do {
      changed = false;
      final Collection<IGroup> groups = putConcurrentStateAtEnd(diagram.getGroups(false));
      for (IGroup g : groups) {
        if (diagram.isAutarkic(g)) {
          final IEntityImage img = computeImage(g);
          g.overideImage(
              img,
              g.getGroupType() == GroupType.CONCURRENT_STATE
                  ? LeafType.STATE_CONCURRENT
                  : LeafType.STATE);

          changed = true;
        }
      }
    } while (changed);
  }
  private ImageData createFileInternal(
      OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
      throws IOException, InterruptedException {
    if (diagram.getUmlDiagramType() == UmlDiagramType.ACTIVITY) {
      new CucaDiagramSimplifierActivity(diagram, dotStrings);
    } else if (diagram.getUmlDiagramType() == UmlDiagramType.STATE) {
      new CucaDiagramSimplifierState(diagram, dotStrings);
    }

    CucaDiagramFileMakerSvek2 svek2 = buildCucaDiagramFileMakerSvek2(DotMode.NORMAL);
    TextBlockBackcolored result = svek2.createFile(diagram.getDotStringSkek());
    if (result instanceof GraphvizCrash) {
      svek2 = buildCucaDiagramFileMakerSvek2(DotMode.NO_LEFT_RIGHT);
      result = svek2.createFile(diagram.getDotStringSkek());
    }
    result = addLegend(result);
    result = addTitle(result);
    result = addHeaderAndFooter(result);

    final String widthwarning = diagram.getSkinParam().getValue("widthwarning");
    if (widthwarning != null && widthwarning.matches("\\d+")) {
      this.warningOrError =
          svek2.getBibliotekon().getWarningOrError(Integer.parseInt(widthwarning));
    } else {
      this.warningOrError = null;
    }
    final Dimension2D dim = result.calculateDimension(stringBounder);
    final double scale = getScale(fileFormatOption, dim);

    final ImageBuilder imageBuilder =
        new ImageBuilder(
            diagram.getSkinParam().getColorMapper(),
            scale,
            result.getBackcolor(),
            fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null,
            warningOrError,
            0,
            10,
            diagram.getAnimation(),
            diagram.getSkinParam().handwritten());
    imageBuilder.addUDrawable(result);
    return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
  }
  private TextBlockBackcolored addHeaderAndFooter(TextBlockBackcolored original) {
    final Display footer = diagram.getFooter();
    final Display header = diagram.getHeader();
    if (Display.isNull(footer) && Display.isNull(header)) {
      return original;
    }
    final TextBlock textFooter =
        Display.isNull(footer)
            ? null
            : footer.create(
                new FontConfiguration(
                    getFont(FontParam.FOOTER),
                    getFontColor(FontParam.FOOTER, null),
                    diagram.getSkinParam().getHyperlinkColor(),
                    diagram.getSkinParam().useUnderlineForHyperlink()),
                diagram.getFooterAlignment(),
                diagram.getSkinParam());
    final TextBlock textHeader =
        Display.isNull(header)
            ? null
            : header.create(
                new FontConfiguration(
                    getFont(FontParam.HEADER),
                    getFontColor(FontParam.HEADER, null),
                    diagram.getSkinParam().getHyperlinkColor(),
                    diagram.getSkinParam().useUnderlineForHyperlink()),
                diagram.getHeaderAlignment(),
                diagram.getSkinParam());

    return new DecorateEntityImage(
        original,
        textHeader,
        diagram.getHeaderAlignment(),
        textFooter,
        diagram.getFooterAlignment());
  }
Beispiel #11
0
 private IEntityImage computeImage(final ILeaf leaf) {
   final IEntityImage image =
       CucaDiagramFileMakerSvek2.createEntityImageBlock(
           leaf, diagram.getSkinParam(), false, diagram, null, null, null);
   return image;
 }
 private CucaDiagramFileMakerSvek2 buildCucaDiagramFileMakerSvek2(DotMode dotMode) {
   final DotData dotData =
       new DotData(
           diagram.getEntityFactory().getRootGroup(),
           getOrderedLinks(),
           diagram.getLeafsvalues(),
           diagram.getUmlDiagramType(),
           diagram.getSkinParam(),
           diagram,
           diagram,
           diagram.getColorMapper(),
           diagram.getEntityFactory(),
           diagram.isHideEmptyDescriptionForState(),
           dotMode,
           diagram.getNamespaceSeparator(),
           diagram.getPragma());
   final CucaDiagramFileMakerSvek2 svek2 =
       new CucaDiagramFileMakerSvek2(
           dotData, diagram.getEntityFactory(), diagram.getSource(), diagram.getPragma());
   return svek2;
 }
 private final HtmlColor getFontColor(FontParam fontParam, Stereotype stereo) {
   final ISkinParam skinParam = diagram.getSkinParam();
   return skinParam.getFontHtmlColor(fontParam, stereo);
 }
 private final UFont getFont(FontParam fontParam) {
   final ISkinParam skinParam = diagram.getSkinParam();
   return skinParam.getFont(fontParam, null, false);
 }