Пример #1
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);
  }
  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 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());
  }
 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;
 }
Пример #7
0
 private IEntityImage computeImage(final ILeaf leaf) {
   final IEntityImage image =
       CucaDiagramFileMakerSvek2.createEntityImageBlock(
           leaf, diagram.getSkinParam(), false, diagram, null, null, null);
   return image;
 }
 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);
 }