当前位置: 首页>>代码示例>>Java>>正文


Java SourceStringReader类代码示例

本文整理汇总了Java中net.sourceforge.plantuml.SourceStringReader的典型用法代码示例。如果您正苦于以下问题:Java SourceStringReader类的具体用法?Java SourceStringReader怎么用?Java SourceStringReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SourceStringReader类属于net.sourceforge.plantuml包,在下文中一共展示了SourceStringReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateUMLStateMachine

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
public void generateUMLStateMachine(File outputDir, StateMachineType stateMachine,
    STErrorListener errorListener) throws IOException {
  StringWriter stringWriter = new StringWriter();
  NoIndentWriter writer = new NoIndentWriter(stringWriter);

  ST stStates = stGroup.getInstanceOf("stateMachine");
  stStates.add("stateMachine", stateMachine);
  stStates.write(writer, errorListener);

  String umlString = stringWriter.toString();

  SourceStringReader reader = new SourceStringReader(umlString);
  File outputFile = new File(outputDir, String.format("%s.png", stateMachine.getName()));
  FileOutputStream png = new FileOutputStream(outputFile);
  String desc = reader.generateImage(png);
}
 
开发者ID:FIXTradingCommunity,项目名称:fix-orchestra,代码行数:17,代码来源:ImgGenerator.java

示例2: generateUMLSequence

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
public void generateUMLSequence(File outputDir, MessageType message, FlowType flow,
    List<ResponseType> responseList, STErrorListener errorListener) throws IOException {
  StringWriter stringWriter = new StringWriter();
  NoIndentWriter writer = new NoIndentWriter(stringWriter);

  ST stSequence = stGroup.getInstanceOf("sequence");
  stSequence.add("message", message);
  stSequence.add("flow", flow);
  stSequence.write(writer, errorListener);
  generateResponses(responseList, writer, errorListener);
  ST stEnd = stGroup.getInstanceOf("sequenceEnd");
  stEnd.add("message", message);
  stEnd.write(writer, errorListener);

  String umlString = stringWriter.toString();

  SourceStringReader reader = new SourceStringReader(umlString);
  File outputFile =
      new File(outputDir, String.format("%s-%s.png", message.getName(), message.getScenario()));
  FileOutputStream png = new FileOutputStream(outputFile);
  String desc = reader.generateImage(png);
}
 
开发者ID:FIXTradingCommunity,项目名称:fix-orchestra,代码行数:23,代码来源:ImgGenerator.java

示例3: serialize

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
@Override
public void serialize(VerbatimNode node, Printer printer) {
    Type type = Type.getByName(node.getType());

    String formatted = type.wrap(node.getText());
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SourceStringReader reader = new SourceStringReader(formatted);
    String desc;
    try {
        desc = reader.generateImage(baos, type.getFormatOption());
    } catch (IOException e) {
        throw new GeneratorException("Could not generate uml for node " + node, e);
    }
    final String rendered = type.render(baos.toByteArray(), desc);
    printer.print(rendered);
}
 
开发者ID:protostuff,项目名称:protostuff-compiler,代码行数:17,代码来源:PlantUmlVerbatimSerializer.java

示例4: create

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
public static MDADiagram create(String uml) {
	List<BlockUml> blocks = new SourceStringReader(uml).getBlocks();
	if (blocks.size() == 0) {
		uml = "@startuml\n" + uml + "\[email protected]";
		blocks = new SourceStringReader(uml).getBlocks();
		if (blocks.size() == 0) {
			return null;
		}
	}
	final BlockUml block = blocks.get(0);
	final Diagram diagram = block.getDiagram();
	if (diagram instanceof ClassDiagram) {
		return new MDADiagramImpl((ClassDiagram) diagram);
	}
	return null;
}
 
开发者ID:Banno,项目名称:sbt-plantuml-plugin,代码行数:17,代码来源:MDADiagramImpl.java

示例5: checkSyntaxFair

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
public static SyntaxResult checkSyntaxFair(String source) {
	final SyntaxResult result = new SyntaxResult();
	final SourceStringReader sourceStringReader = new SourceStringReader(new Defines(), source,
			Collections.<String> emptyList());

	final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram();
	result.setCmapData(system.hasUrl());
	if (system instanceof UmlDiagram) {
		result.setUmlDiagramType(((UmlDiagram) system).getUmlDiagramType());
		result.setDescription(system.getDescription().getDescription());
	} else if (system instanceof PSystemError) {
		result.setError(true);
		final PSystemError sys = (PSystemError) system;
		result.setErrorLinePosition(sys.getHigherErrorPosition());
		for (ErrorUml er : sys.getErrorsUml()) {
			result.addErrorText(er.getError());
		}
		result.setSystemError(sys);
		result.setSuggest(sys.getSuggest());
	} else {
		result.setDescription(system.getDescription().getDescription());
	}
	return result;
}
 
开发者ID:mar9000,项目名称:plantuml,代码行数:25,代码来源:SyntaxChecker.java

示例6: processImage

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
public void processImage(String fileName) throws IOException {
	if (fileName.startsWith("/")) {
		throw new IllegalArgumentException();
	}
	final SourceStringReader sourceStringReader = new SourceStringReader(incoming.get(fileName));
	final ByteArrayOutputStream baos = new ByteArrayOutputStream();
	final FileFormat format = FileFormat.PNG;
	final DiagramDescription desc = sourceStringReader.generateDiagramDescription(baos,
			new FileFormatOption(format));
	final String pngFileName = format.changeName(fileName, 0);
	final String errorFileName = pngFileName.substring(0, pngFileName.length() - 4) + ".err";
	synchronized (this) {
		outgoing.remove(pngFileName);
		outgoing.remove(errorFileName);
		if (desc != null && desc.getDescription() != null) {
			outgoing.put(pngFileName, baos.toByteArray());
			if (desc.getDescription().startsWith("(Error)")) {
				final ByteArrayOutputStream errBaos = new ByteArrayOutputStream();
				sourceStringReader.generateImage(errBaos, new FileFormatOption(FileFormat.ATXT));
				errBaos.close();
				outgoing.put(errorFileName, errBaos.toByteArray());
			}
		}
	}
}
 
开发者ID:mar9000,项目名称:plantuml,代码行数:26,代码来源:FtpConnexion.java

示例7: applyOnFixtures

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
@Override
public String applyOnFixtures(List<FixtureCallResult> fixtureCallResults, String... parameters) {
    String plantUml = plantUmlSequenceDiagramGenerator.getPlantUmlScript(fixtureCallResults);

    SourceStringReader reader = new SourceStringReader(plantUml);
    final ByteArrayOutputStream os = new ByteArrayOutputStream();


    try {
        reader.generateImage(os, new FileFormatOption(FileFormat.SVG));
        os.close();
        return new String(os.toByteArray());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:slezier,项目名称:SimpleFunctionalTest,代码行数:17,代码来源:HtmlSequenceDiagram.java

示例8: close

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
/**
 * Closes the delegate writer and tries to generate an image file for each configured image format.
 * The default file extension from the image format is used, together with the specified <code>directory</code>
 * and <code>baseName</code>.
 *
 * @throws IOException In case of I/O errors while closing the delegate writer or writing to an image file.
 */
@Override
public void close() throws IOException {
    super.close();
    for (FileFormat imageFormat : imageFormats) {
        File imageFile = new File(directory, baseName + imageFormat.getFileSuffix());
        LogSupport.info("Generating {0}...", imageFile);
        try (OutputStream imageOutput = new BufferedOutputStream(new FileOutputStream(imageFile))) {
            new SourceStringReader(getBuffer().toString()).generateImage(imageOutput, new FileFormatOption(imageFormat));
            LogSupport.debug("Finished image {0}.", imageFile);
        }
    }
}
 
开发者ID:talsma-ict,项目名称:umldoclet,代码行数:20,代码来源:PlantumlImageWriter.java

示例9: createSvg

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
private String createSvg(String plantUmlMarkup) {
    SourceStringReader reader = new SourceStringReader(plantUmlMarkup);
    final ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        reader.generateImage(os, new FileFormatOption(SVG));
        os.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return new String(os.toByteArray());
}
 
开发者ID:bodar,项目名称:yatspec,代码行数:13,代码来源:SequenceDiagramGenerator.java

示例10: unitConversionSkill

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
@Test
public void unitConversionSkill() throws IOException {
    reset(factService);
    final Skill skill = skillRepo.get("unitConversion");
    final String uml = skill.renderUml();
    log.info("UML:\n{}", uml);

    final SourceStringReader reader = new SourceStringReader(uml);
    final File tempFile = new File(FileUtils.getTempDirectory(), "lumen_skill_unitConversion.png");
    final String generated = reader.generateImage(tempFile);
    log.info("Generated UML Activity Diagram {} to {}", generated, tempFile);
}
 
开发者ID:lumenrobot,项目名称:lumen,代码行数:13,代码来源:SkillUmlTest.java

示例11: storeDiagram

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
private void storeDiagram(String source, String fileName) throws IOException, FileNotFoundException {
    SourceStringReader reader = new SourceStringReader(source);
    final ByteArrayOutputStream os = new ByteArrayOutputStream();
    // Write the first image to "os"
    reader.generateImage(os, new FileFormatOption(FileFormat.SVG));
    os.close();
    FileOutputStream fos = new FileOutputStream(fileName);

    reader.generateImage(fos, new FileFormatOption(FileFormat.PNG));
    fos.close();
}
 
开发者ID:PayU-Tech,项目名称:Ratel,代码行数:12,代码来源:DiagramGenerator.java

示例12: checkSyntaxFair

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
public static SyntaxResult checkSyntaxFair(String source) {
	final SyntaxResult result = new SyntaxResult();
	final SourceStringReader sourceStringReader = new SourceStringReader(new Defines(), source,
			Collections.<String> emptyList());

	final List<BlockUml> blocks = sourceStringReader.getBlocks();
	if (blocks.size() == 0) {
		result.setError(true);
		result.setErrorLinePosition(lastLineNumber(source));
		result.addErrorText("No @enduml found");
		result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
		return result;
	}

	final Diagram system = blocks.get(0).getDiagram();
	result.setCmapData(system.hasUrl());
	if (system instanceof UmlDiagram) {
		result.setUmlDiagramType(((UmlDiagram) system).getUmlDiagramType());
		result.setDescription(system.getDescription().getDescription());
	} else if (system instanceof PSystemError) {
		result.setError(true);
		final PSystemError sys = (PSystemError) system;
		result.setErrorLinePosition(sys.getHigherErrorPosition());
		result.setLineLocation(sys.getLineLocation());
		for (ErrorUml er : sys.getErrorsUml()) {
			result.addErrorText(er.getError());
		}
		result.setSystemError(sys);
		result.setSuggest(sys.getSuggest());
	} else {
		result.setDescription(system.getDescription().getDescription());
	}
	return result;
}
 
开发者ID:Banno,项目名称:sbt-plantuml-plugin,代码行数:35,代码来源:SyntaxChecker.java

示例13: hasCMapData

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
public static boolean hasCMapData(String uml) {
	List<BlockUml> blocks = new SourceStringReader(uml).getBlocks();
	if (blocks.size() == 0) {
		uml = "@startuml\n" + uml + "\[email protected]";
		blocks = new SourceStringReader(uml).getBlocks();
		if (blocks.size() == 0) {
			return false;
		}
	}
	final BlockUml block = blocks.get(0);
	final Diagram diagram = block.getDiagram();
	return diagram.hasUrl();
}
 
开发者ID:Banno,项目名称:sbt-plantuml-plugin,代码行数:14,代码来源:PlantumlUtils.java

示例14: processImage

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
public void processImage(String fileName) throws IOException {
	if (fileName.startsWith("/")) {
		throw new IllegalArgumentException();
	}
	final String pngFileName = getFutureFileName(fileName);
	boolean done = false;
	try {
		final SourceStringReader sourceStringReader = new SourceStringReader(incoming.get(fileName));
		final ByteArrayOutputStream baos = new ByteArrayOutputStream();
		final FileFormat format = getFileFormat();
		final DiagramDescription desc = sourceStringReader.generateDiagramDescription(baos, new FileFormatOption(
				format));
		final String errorFileName = pngFileName.substring(0, pngFileName.length() - 4) + ".err";
		synchronized (this) {
			outgoing.remove(pngFileName);
			futureOutgoing.remove(pngFileName);
			outgoing.remove(errorFileName);
			if (desc != null && desc.getDescription() != null) {
				outgoing.put(pngFileName, baos.toByteArray());
				done = true;
				if (desc.getDescription().startsWith("(Error)")) {
					final ByteArrayOutputStream errBaos = new ByteArrayOutputStream();
					sourceStringReader.generateImage(errBaos, new FileFormatOption(FileFormat.ATXT));
					errBaos.close();
					outgoing.put(errorFileName, errBaos.toByteArray());
				}
			}
		}
	} finally {
		if (done == false) {
			outgoing.put(pngFileName, new byte[0]);
		}
	}
}
 
开发者ID:Banno,项目名称:sbt-plantuml-plugin,代码行数:35,代码来源:FtpConnexion.java

示例15: run

import net.sourceforge.plantuml.SourceStringReader; //导入依赖的package包/类
public void run() {
	try {
		final String uml = runInternal();
		Log.println("UML=" + uml);
		final SourceStringReader s = new SourceStringReader(uml);
		s.generateImage(os, new FileFormatOption(FileFormat.ATXT));
		os.close();
		br.close();
	} catch (IOException e) {
		e.printStackTrace();
	}

}
 
开发者ID:Banno,项目名称:sbt-plantuml-plugin,代码行数:14,代码来源:AcceptTelnetClient.java


注:本文中的net.sourceforge.plantuml.SourceStringReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。