當前位置: 首頁>>代碼示例>>Java>>正文


Java CommandSequence類代碼示例

本文整理匯總了Java中de.erichseifert.vectorgraphics2d.intermediate.CommandSequence的典型用法代碼示例。如果您正苦於以下問題:Java CommandSequence類的具體用法?Java CommandSequence怎麽用?Java CommandSequence使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CommandSequence類屬於de.erichseifert.vectorgraphics2d.intermediate包,在下文中一共展示了CommandSequence類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PDFDocument

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
PDFDocument(CommandSequence commands, PageSize pageSize, boolean compressed) {
	super(pageSize, compressed);

	states = new Stack<>();
	states.push(new GraphicsState());

	objects = new LinkedList<>();
	crossReferences = new HashMap<>();
	images = new HashMap<>();

	contents = initPage();
	for (Command<?> command : commands) {
		try {
			byte[] pdfStatement = toBytes(command);
			contents.write(pdfStatement);
			contents.write(EOL.getBytes(CHARSET));
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	close();
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:23,代碼來源:PDFDocument.java

示例2: testTranslateCorrect

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
@Test
public void testTranslateCorrect() {
	AffineTransform absoluteTransform = new AffineTransform();
	absoluteTransform.scale(2.0, 2.0);
	absoluteTransform.translate(4.2, 4.2); // (8.4, 8.4)
	CommandSequence commands = wrapCommands(
		new TranslateCommand(4.0, 2.0),
		new SetTransformCommand(absoluteTransform)
	);

	AbsoluteToRelativeTransformsFilter filter = new AbsoluteToRelativeTransformsFilter(commands);

	TransformCommand transformCommand = null;
	while (filter.hasNext()) {
		Command<?> filteredCommand = filter.next();
		if (filteredCommand instanceof TransformCommand) {
			transformCommand = (TransformCommand) filteredCommand;
		}
	}
	AffineTransform relativeTransform = transformCommand.getValue();
	assertThat(relativeTransform.getTranslateX(), is(4.4));
	assertThat(relativeTransform.getTranslateY(), is(6.4));
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:24,代碼來源:AbsoluteToRelativeTransformsFilterTest.java

示例3: testRelativeTransformAfterDispose

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
@Test
public void testRelativeTransformAfterDispose() {
	AffineTransform absoluteTransform = new AffineTransform();
	absoluteTransform.rotate(42.0);
	absoluteTransform.translate(4.0, 2.0);
	CommandSequence commands = wrapCommands(
		new CreateCommand(null),
		new TransformCommand(absoluteTransform),
		new DisposeCommand(null),
		new SetTransformCommand(absoluteTransform)
	);

	AbsoluteToRelativeTransformsFilter filter = new AbsoluteToRelativeTransformsFilter(commands);
	TransformCommand lastTransformCommand = null;
	for (Command<?> filteredCommand : filter) {
		if (filteredCommand instanceof TransformCommand) {
			lastTransformCommand = (TransformCommand) filteredCommand;
		}
	}
	assertThat(lastTransformCommand.getValue(), is(absoluteTransform));
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:22,代碼來源:AbsoluteToRelativeTransformsFilterTest.java

示例4: testCreateEmitsCreateCommand

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
@Test
public void testCreateEmitsCreateCommand() {
	VectorGraphics2D g = new VectorGraphics2D();
	CommandSequence gCommands = g.getCommands();
	Iterator<Command<?>> gCommandIterator = gCommands.iterator();
	CreateCommand gCreateCommand = (CreateCommand) gCommandIterator.next();

	VectorGraphics2D g2 = (VectorGraphics2D) g.create();
	CreateCommand g2CreateCommand = null;
	for (Command<?> g2Command : g2.getCommands()) {
		if (g2Command instanceof CreateCommand) {
			g2CreateCommand = (CreateCommand) g2Command;
		}
	}
	assertNotEquals(gCreateCommand, g2CreateCommand);
	assertEquals(g2, g2CreateCommand.getValue());
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:18,代碼來源:VectorGraphics2DTest.java

示例5: testDisposeCommandEmitted

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
@Test
public void testDisposeCommandEmitted() {
	VectorGraphics2D g = new VectorGraphics2D();
	g.setColor(Color.RED);

	VectorGraphics2D g2 = (VectorGraphics2D) g.create();
	g2.setColor(Color.BLUE);
	g2.dispose();

	CommandSequence commands = g.getCommands();
	Command<?> lastCommand = null;
	for (Command<?> command : commands) {
		lastCommand = command;
	}

	assertTrue(lastCommand instanceof DisposeCommand);
	assertEquals(Color.BLUE, ((DisposeCommand) lastCommand).getValue().getColor());
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:19,代碼來源:VectorGraphics2DTest.java

示例6: SVGDocument

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
public SVGDocument(CommandSequence commands, PageSize pageSize) {
	super(pageSize, true);

	states = new Stack<>();
	states.push(new GraphicsState());
	clippingPathElements = new HashMap<>();

	// Prepare DOM
	DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
	docFactory.setValidating(false);
	DocumentBuilder docBuilder;
	try {
		docBuilder = docFactory.newDocumentBuilder();
	} catch (ParserConfigurationException e) {
		throw new IllegalStateException("Could not create XML builder.");
	}

	// Create XML document with DOCTYPE
	DOMImplementation domImpl = docBuilder.getDOMImplementation();
	DocumentType docType = domImpl.createDocumentType(SVG_DOCTYPE_QNAME, SVG_DOCTYPE_PUBLIC_ID, SVG_DOCTYPE_SYSTEM_ID);
	doc = domImpl.createDocument(SVG_NAMESPACE_URI, "svg", docType);
	doc.setXmlStandalone(false);

	root = doc.getDocumentElement();
	initRoot();

	group = root;
	for (Command<?> command : commands) {
		handle(command);
	}
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:32,代碼來源:SVGDocument.java

示例7: getDocument

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
@Override
public Document getDocument(CommandSequence commands, PageSize pageSize) {
	// TODO Apply rotate(theta,x,y) => translate-rotate-translate filter
	// TODO Apply image transparency => image mask filter
	// TODO Apply optimization filter
	FillPaintedShapeAsImageFilter paintedShapeAsImageFilter = new FillPaintedShapeAsImageFilter(commands);
	return new EPSDocument(paintedShapeAsImageFilter, pageSize);
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:9,代碼來源:EPSProcessor.java

示例8: EPSDocument

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
public EPSDocument(CommandSequence commands, PageSize pageSize) {
	super(pageSize, true);
	elements = new LinkedList<>();
	addHeader();
	for (Command<?> command : commands) {
		handle(command);
	}
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:9,代碼來源:EPSDocument.java

示例9: getDocument

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
@Override
public Document getDocument(CommandSequence commands, PageSize pageSize) {
	AbsoluteToRelativeTransformsFilter absoluteToRelativeTransformsFilter = new AbsoluteToRelativeTransformsFilter(commands);
	FillPaintedShapeAsImageFilter paintedShapeAsImageFilter = new FillPaintedShapeAsImageFilter(absoluteToRelativeTransformsFilter);
	CommandSequence filtered = new StateChangeGroupingFilter(paintedShapeAsImageFilter);
	return new PDFDocument(filtered, pageSize, isCompressed());
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:8,代碼來源:PDFProcessor.java

示例10: testSetTransformCommandReplaced

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
@Test
public void testSetTransformCommandReplaced() {
	AffineTransform absoluteTransform = new AffineTransform();
	absoluteTransform.rotate(42.0);
	absoluteTransform.translate(4.0, 2.0);
	CommandSequence commands = wrapCommands(
		new SetTransformCommand(absoluteTransform)
	);

	AbsoluteToRelativeTransformsFilter filter = new AbsoluteToRelativeTransformsFilter(commands);
	assertThat(filter, not(hasItem(any(SetTransformCommand.class))));
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:13,代碼來源:AbsoluteToRelativeTransformsFilterTest.java

示例11: testAbsoluteAndRelativeTransformsIdentical

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
@Test
public void testAbsoluteAndRelativeTransformsIdentical() {
	AffineTransform absoluteTransform = new AffineTransform();
	absoluteTransform.rotate(42.0);
	absoluteTransform.translate(4.0, 2.0);
	CommandSequence commands = wrapCommands(
		new SetTransformCommand(absoluteTransform)
	);

	AbsoluteToRelativeTransformsFilter filter = new AbsoluteToRelativeTransformsFilter(commands);

	filter.next();
	AffineTransform relativeTransform = ((TransformCommand) filter.next()).getValue();
	assertThat(relativeTransform, is(absoluteTransform));
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:16,代碼來源:AbsoluteToRelativeTransformsFilterTest.java

示例12: wrapCommands

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
private CommandSequence wrapCommands(Command<?>... commands) {
	MutableCommandSequence commandSequence = new MutableCommandSequence();
	commandSequence.add(new CreateCommand(null));
	for (Command<?> command : commands) {
		commandSequence.add(command);
	}
	commandSequence.add(new DisposeCommand(null));
	return commandSequence;
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:10,代碼來源:AbsoluteToRelativeTransformsFilterTest.java

示例13: testVectorGraphics2DEmitsCreateCommand

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
@Test
public void testVectorGraphics2DEmitsCreateCommand() {
	VectorGraphics2D g = new VectorGraphics2D();

	CommandSequence commands = g.getCommands();
	Iterator<Command<?>> commandIterator = commands.iterator();
	assertTrue(commandIterator.hasNext());

	Command<?> firstCommand = commandIterator.next();
	assertThat(firstCommand, instanceOf(CreateCommand.class));
	// TODO: Move this assertion into a separate test case
	assertEquals(g, ((CreateCommand) firstCommand).getValue());
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:14,代碼來源:VectorGraphics2DTest.java

示例14: getDocument

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
@Override
public Document getDocument(CommandSequence commands, PageSize pageSize) {
	FillPaintedShapeAsImageFilter shapesAsImages = new FillPaintedShapeAsImageFilter(commands);
	CommandSequence filtered = new StateChangeGroupingFilter(shapesAsImages);
	return new SVGDocument(filtered, pageSize);
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:7,代碼來源:SVGProcessor.java

示例15: StateChangeGroupingFilter

import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //導入依賴的package包/類
public StateChangeGroupingFilter(CommandSequence stream) {
	super(stream);
}
 
開發者ID:eseifert,項目名稱:vectorgraphics2d,代碼行數:4,代碼來源:StateChangeGroupingFilter.java


注:本文中的de.erichseifert.vectorgraphics2d.intermediate.CommandSequence類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。