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


Java SVGGraphics2D.translate方法代码示例

本文整理汇总了Java中org.apache.batik.svggen.SVGGraphics2D.translate方法的典型用法代码示例。如果您正苦于以下问题:Java SVGGraphics2D.translate方法的具体用法?Java SVGGraphics2D.translate怎么用?Java SVGGraphics2D.translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.batik.svggen.SVGGraphics2D的用法示例。


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

示例1: export

import org.apache.batik.svggen.SVGGraphics2D; //导入方法依赖的package包/类
@Override
public void export(Model model, OutputStream out) throws IOException, SerialisationException {
    if (!(model instanceof VisualModel)) {
        throw new SerialisationException("Non-visual model cannot be exported as SVG file.");
    }
    VisualModel visualModel = (VisualModel) model;
    try {
        Document doc = XmlUtils.createDocument();
        SVGGraphics2D g2d = new SVGGraphics2D(doc);
        g2d.setUnsupportedAttributes(null);
        g2d.scale(SCALE_FACTOR, SCALE_FACTOR);
        VisualGroup visualGroup = (VisualGroup) model.getRoot();
        Rectangle2D bounds = visualGroup.getBoundingBoxInLocalSpace();
        g2d.translate(-bounds.getMinX(), -bounds.getMinY());
        int canvasWidth = (int) (bounds.getWidth() * SCALE_FACTOR);
        int canvasHeight = (int) (bounds.getHeight() * SCALE_FACTOR);
        g2d.setSVGCanvasSize(new Dimension(canvasWidth, canvasHeight));
        visualModel.draw(g2d, Decorator.Empty.INSTANCE);
        g2d.stream(new OutputStreamWriter(out));
    } catch (ParserConfigurationException e) {
        throw new SerialisationException(e);
    }
}
 
开发者ID:workcraft,项目名称:workcraft,代码行数:24,代码来源:SvgExporter.java

示例2: fullExportToStream

import org.apache.batik.svggen.SVGGraphics2D; //导入方法依赖的package包/类
@Override
public void fullExportToStream(ERDesignerGraph aGraph, OutputStream aStream) throws IOException {
    Object[] cells = aGraph.getRoots();
    Rectangle2D bounds = aGraph.toScreen(aGraph.getCellBounds(cells));
    if (bounds != null) {
        DOMImplementation theDomImpl = SVGDOMImplementation.getDOMImplementation();
        String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
        Document theDocument = theDomImpl.createDocument(svgNS, "svg", null);
        SVGGraphics2D theSvgGenerator = new SVGGraphics2D(theDocument);
        theSvgGenerator.translate(-bounds.getX() + 10, -bounds.getY() + 0);
        RepaintManager theRepaintManager = RepaintManager.currentManager(aGraph);
        theRepaintManager.setDoubleBufferingEnabled(false);
        boolean theDoubleBuffered = aGraph.isDoubleBuffered();
        // Disable double buffering to allow Batik to render svg elements
        // instead of images
        aGraph.setDoubleBuffered(false);
        aGraph.paint(theSvgGenerator);
        aGraph.setDoubleBuffered(theDoubleBuffered);
        Writer theWriter = new OutputStreamWriter(aStream, PlatformConfig.getXMLEncoding());
        theSvgGenerator.stream(theWriter, false);
        theRepaintManager.setDoubleBufferingEnabled(true);

        theWriter.flush();
        theWriter.close();
    }
}
 
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:27,代码来源:SVGExporter.java

示例3: fillSVGGraphics2D

import org.apache.batik.svggen.SVGGraphics2D; //导入方法依赖的package包/类
/**
 */
protected SVGGraphics2D fillSVGGraphics2D(MapView view) {
	// NodeAdapter root = (NodeAdapter) getController().getMap().getRoot();
	SVGGraphics2D g2d = createSvgGraphics2D();
	try {
		view.preparePrinting();
		Rectangle innerBounds = view.getInnerBounds();
		g2d.setSVGCanvasSize(new Dimension(innerBounds.width,
				innerBounds.height));
		g2d.translate(-innerBounds.x, -innerBounds.y);
		//
		// Generate SVG content
		//
		view.print(g2d);
	} finally {
		view.endPrinting();
	}
	// g2d.setColor(Color.BLACK);
	// g2d.setStroke(new BasicStroke(3));
	// g2d.drawRect(innerBounds.x, innerBounds.y, innerBounds.width - 2,
	// innerBounds.height - 2);
	return g2d;
}
 
开发者ID:iwabuchiken,项目名称:freemind_1.0.0_20140624_214725,代码行数:25,代码来源:ExportVectorGraphic.java

示例4: screenshotSVG

import org.apache.batik.svggen.SVGGraphics2D; //导入方法依赖的package包/类
public void screenshotSVG(final String outFile) {
    DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
    Document document = domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null);
    SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
    Point2D.Double min = getMinPoint();
    svgGenerator.translate(-min.getX(), -min.getY());
    paintModel(svgGenerator, false, true, false);
    
    try(FileWriter fw = new FileWriter(new File(outFile))){
   	    svgGenerator.stream(fw, false);
    }catch(Exception ex){
    	ex.printStackTrace();
    }
}
 
开发者ID:arnobl,项目名称:kompren,代码行数:15,代码来源:MetamodelView.java

示例5: render

import org.apache.batik.svggen.SVGGraphics2D; //导入方法依赖的package包/类
/**
 * Renders provided list of signatures as SVG document.
 * @param signatures    list of signatures
 * @return {@link SVGGraphics2D} of SVG document
 */
public SVGGraphics2D render(List<RandomSignature> signatures) {

  /* Create SVG path */
  Document document = domImpl.createDocument(
          BatikConfig.SVG_NAMESPACE_URI, "svg", null);

  SVGGraphics2D graphics = new SVGGraphics2D(document);

  Font font = graphics.getFont();

  for (int i = 0; i < signatures.size(); i++) {
      RandomSignature signature = signatures.get(i);
      int baseY = i * 70;
      String dateFormat = randomDateFormat();
      final DateTimeFormatter formatter = DateTimeFormat
              .forPattern(dateFormat);

      /* Chose the font */
      if (randomizer.nextBoolean()) {

          /* Keep the normal font */

      } else if (randomizer.nextBoolean()) {

          /* Make font italic */
          graphics.setFont(font.deriveFont(Font.ITALIC));
      } else {

          /* Make font bold */
          graphics.setFont(font.deriveFont(Font.BOLD));
      }

      /* Draw person's name */
      graphics.drawString(getFullName(signature), 10, baseY + 35);

      /* Draw person's birth date */
      graphics.drawString(
              formatter.print(signature.getPerson().dateOfBirth()),
              210,
              baseY + 35);

      /* Draw person's address */
      String[] brokenAddress = getAddress(signature);
      graphics.drawString(brokenAddress[0], 345, baseY + 35);
      graphics.drawString(brokenAddress[1], 345, baseY + 50);

      /* Draw person's ID number */
      graphics.drawString(
              signature.getPerson().nationalIdentityCardNumber(),
              690,
              baseY + 35);

      /* Draw signature date */
      graphics.drawString(
              formatter.print(signature.getSignatureDate()),
              800,
              baseY + 35);

      /* Draw sign */
      SVGGraphics2D gg = (SVGGraphics2D) graphics.create();
      gg.translate(920, baseY);
      gg.draw(signature.getSign());

      /* Separator line */
      graphics.drawLine(0, baseY + 70, 1000, baseY + 70);

      /* Reset ordinary font */
      graphics.setFont(font);
  }

  return graphics;
}
 
开发者ID:hosuaby,项目名称:signature-processing,代码行数:78,代码来源:SignaturesListSvgRender.java


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