本文整理汇总了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();
}
示例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));
}
示例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));
}
示例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());
}
示例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());
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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());
}
示例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))));
}
示例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));
}
示例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;
}
示例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());
}
示例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);
}
示例15: StateChangeGroupingFilter
import de.erichseifert.vectorgraphics2d.intermediate.CommandSequence; //导入依赖的package包/类
public StateChangeGroupingFilter(CommandSequence stream) {
super(stream);
}