• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SVGGraphics2D类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: renderToSvg

import org.jfree.graphics2d.svg.SVGGraphics2D; //导入依赖的package包/类
private void renderToSvg(JFreeChart chart) {
//        int width = 1200, height = 1800; // høy
//        int width = 2400, height = 1800; // lang
//        int width = 1200, height = 800; // brukt før

        // 535 small, 630 legend
//        int width = 1200, height = 535;
//        int width = 1200, height = 630;

//        int width = 400, height = 535; // box


        int width = 600, height = 540; // objectives


        SVGGraphics2D svgGraphics2D = new SVGGraphics2D(width, height);
        chart.draw(svgGraphics2D, new Rectangle(width, height));

        String svgElement = svgGraphics2D.getSVGElement();
        try {
            SVGUtils.writeToSVG(new File("latestChart.svg"), svgElement);
            System.out.println("made chart");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:Matsemann,项目名称:eamaster,代码行数:27,代码来源:PlotSaver.java


示例2: writeSVG

import org.jfree.graphics2d.svg.SVGGraphics2D; //导入依赖的package包/类
public static void writeSVG(TrackPoint points[], int width, int height,
        File file) throws IOException {
    JFreeChart chart = createChart(points);
    SVGGraphics2D g = new SVGGraphics2D(width, height);
    chart.draw(g, new Rectangle(0, 0, width, height));
    OutputStream stream = new FileOutputStream(file);
    try {
        Writer out = new OutputStreamWriter(stream, "UTF-8");
        try {
            out.write(g.getSVGDocument());
        } finally {
            out.close();
        }
    } finally {
        stream.close();
    }
}
 
开发者ID:robbyn,项目名称:hiketools,代码行数:18,代码来源:Profile.java


示例3: save

import org.jfree.graphics2d.svg.SVGGraphics2D; //导入依赖的package包/类
public static void save(JFreeChart plot, String path, int width, int height) throws IOException {		
	SVGGraphics2D svg = new SVGGraphics2D(width, height);
	Rectangle area = new Rectangle(0, 0, width, height);
	File file = new File(path);
	
	plot.draw(svg, area);			
	SVGUtils.writeToSVG(file,  svg.getSVGElement());		
}
 
开发者ID:gmarciani,项目名称:opmap,代码行数:9,代码来源:Plotter.java


示例4: Runnable

import org.jfree.graphics2d.svg.SVGGraphics2D; //导入依赖的package包/类
static void renderSvg_idTE4nIlnV$W(@NotNull final org.jetbrains.mps.openapi.model.SNode __thisNode__, final org.jetbrains.mps.openapi.model.SNode node, final SVGWriter writer, final SRepository repository) {
  repository.getModelAccess().runReadAction(new Runnable() {
    public void run() {
      try {
        HeadlessEditorComponent editorComponent = new HeadlessEditorComponent(null, repository);
        editorComponent.setFont(new Font("Courier New", Font.PLAIN, 10));
        editorComponent.editNode(node);
        editorComponent.doLayout();
        jetbrains.mps.nodeEditor.cells.EditorCell editorCell = editorComponent.findNodeCell(node);
        int width = editorCell.getWidth() + editorCell.getX();
        int height = editorCell.getHeight() + editorCell.getY();
        StringBuilder builder = new StringBuilder();
        SVGGraphics2D g2d = new SVGGraphics2D(editorCell.getWidth(), editorCell.getHeight());
        ParentSettings settings = new ParentSettings();
        g2d.setTransform(AffineTransform.getTranslateInstance(-editorCell.getX(), -editorCell.getY()));
        g2d.setFont(Font.getFont("Courier New"));
        EditorAnnotation__BehaviorDescriptor.visit_id7OORWOlZVvH.invoke(__thisNode__, editorCell, g2d, settings, null, ((boolean) true));
        g2d.dispose();
        String svg = g2d.getSVGElement();
        writer.write(svg);
        writer.close();
      } catch (Exception e) {
        LoggingRuntime.logMsgView(Level.ERROR, "Failed to render: " + e.getMessage(), EditorAnnotation__BehaviorDescriptor.class, e, null);
      }

    }
  });

}
 
开发者ID:CampagneLaboratory,项目名称:Editor2PDF,代码行数:30,代码来源:EditorAnnotation__BehaviorDescriptor.java


示例5: File

import org.jfree.graphics2d.svg.SVGGraphics2D; //导入依赖的package包/类
static void renderNodeEditorToSVG_id46q0f$BiLBY(@NotNull org.jetbrains.mps.openapi.model.SNode __thisNode__, org.jetbrains.mps.openapi.model.SNode annotation, EditorCell editorCell) {
  // jetbrains.mps.nodeEditor.cells.EditorCell 

  String dir = ((SLinkOperations.getTarget(annotation, MetaAdapterFactory.getReferenceLink(0x93bc01ac08ca4f11L, 0x9c7d614d04055dfbL, 0x79754067868533ecL, 0xc65f8233c99545fL, "outputTo")) == null) ? "." : SPropertyOperations.getString(SLinkOperations.getTarget(annotation, MetaAdapterFactory.getReferenceLink(0x93bc01ac08ca4f11L, 0x9c7d614d04055dfbL, 0x79754067868533ecL, 0xc65f8233c99545fL, "outputTo")), MetaAdapterFactory.getProperty(0x93bc01ac08ca4f11L, 0x9c7d614d04055dfbL, 0xc65f8233c993928L, 0xc65f8233c993964L, "path")));
  try {
    File svgFile = new File(dir + "/" + SPropertyOperations.getString(annotation, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")) + ".svg");
    FileWriter writer = new FileWriter(svgFile);
    editorCell.relayout();

    int width = editorCell.getWidth() + editorCell.getX();
    int height = editorCell.getHeight() + editorCell.getY();
    StringBuilder builder = new StringBuilder();
    SVGGraphics2D g2d = new SVGGraphics2D(editorCell.getWidth(), editorCell.getHeight());
    ParentSettings settings = new ParentSettings();
    g2d.setTransform(AffineTransform.getTranslateInstance(-editorCell.getX(), -editorCell.getY()));
    g2d.setFont(Font.getFont("Courier New"));
    if (LOG.isInfoEnabled()) {
      LoggingRuntime.legacyLog(Level.INFO, "About to render the node", EditorAnnotation__BehaviorDescriptor.class, null);
    }
    EditorAnnotation__BehaviorDescriptor.visit_id7OORWOlZVvH.invoke(__thisNode__, editorCell, g2d, settings, null, ((boolean) true));
    g2d.dispose();
    writer.write(g2d.getSVGElement());
    writer.close();
    if (LOG.isInfoEnabled()) {
      LoggingRuntime.legacyLog(Level.INFO, "Editor SVG rendered to " + svgFile.getAbsolutePath(), EditorAnnotation__BehaviorDescriptor.class, null);
    }
  } catch (Exception e) {
    if (LOG.isEnabledFor(Level.ERROR)) {
      LoggingRuntime.legacyLog(Level.ERROR, "Exception", EditorAnnotation__BehaviorDescriptor.class, e);
    }
    e.printStackTrace();
  }


}
 
开发者ID:CampagneLaboratory,项目名称:Editor2PDF,代码行数:36,代码来源:EditorAnnotation__BehaviorDescriptor.java


示例6: measureText

import org.jfree.graphics2d.svg.SVGGraphics2D; //导入依赖的package包/类
private int measureText(String text) {
    SVGGraphics2D g = new SVGGraphics2D(0, 0);
    FontMetrics metrics = g.getFontMetrics(getFont());
    return metrics.stringWidth(text);
}
 
开发者ID:cicomponents,项目名称:cicomponents,代码行数:6,代码来源:ShieldStyleFlatBadgeMaker.java


示例7: writeToFile

import org.jfree.graphics2d.svg.SVGGraphics2D; //导入依赖的package包/类
public void writeToFile(String outName) throws FileNotFoundException, UnsupportedEncodingException, IOException
{
    calcMeans();
    calcAvgRulesBySeed();
    
    // Create JFreeChart Dataset
    DefaultCategoryDataset dataset = new DefaultCategoryDataset( );
    
    
    HashMap<String, Double> measuresFirst = algorithmMeasures.entrySet().iterator().next().getValue();
    for (Map.Entry<String, Double> measure : measuresFirst.entrySet())
    {
        String measureName = measure.getKey();
        //Double measureValue = measure.getValue();
        dataset.clear();
        
        for (Map.Entry<String, HashMap<String, Double>> entry : algorithmMeasures.entrySet())
        {
            String alg = entry.getKey();
            Double measureValue = entry.getValue().get(measureName);
            
            // Parse algorithm name to show it correctly
            String aName = alg.substring(0, alg.length()-1);
            int startAlgName = aName.lastIndexOf("/");
            aName = aName.substring(startAlgName + 1);
            
            dataset.addValue(measureValue, aName, measureName);
            
            ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
            JFreeChart barChart = ChartFactory.createBarChart("Assotiation Rules Measures", measureName, measureName, dataset, PlotOrientation.VERTICAL, true, true, false);
            StandardChartTheme.createLegacyTheme().apply(barChart);
            
            CategoryItemRenderer renderer = barChart.getCategoryPlot().getRenderer();
            
            // Black and White
            int numItems = algorithmMeasures.size();
            for(int i=0;i<numItems;i++)
            {
                Color color = Color.DARK_GRAY;
                if(i%2 == 1)
                {
                    color = Color.LIGHT_GRAY;
                }
                renderer.setSeriesPaint(i, color);
                renderer.setSeriesOutlinePaint(i, Color.BLACK);
            }
            
            
            int width = 640 * 2; /* Width of the image */
            int height = 480 * 2; /* Height of the image */ 
            
            // JPEG
            File BarChart = new File( outName + "_" + measureName + "_barchart.jpg" );
            ChartUtilities.saveChartAsJPEG( BarChart , barChart , width , height );
            
            // SVG
            SVGGraphics2D g2 = new SVGGraphics2D(width, height);
            Rectangle r = new Rectangle(0, 0, width, height);
            barChart.draw(g2, r);
            File BarChartSVG = new File( outName + "_" + measureName + "_barchart.svg" );
            SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
        }
    }
    /*
    for (Map.Entry<String, HashMap<String, Double>> entry : algorithmMeasures.entrySet())
    {
        String alg = entry.getKey();
        HashMap<String, Double> measures = entry.getValue();
        
        for (Map.Entry<String, Double> entry1 : measures.entrySet())
        {
            String measureName = entry1.getKey();
            Double measureValue = entry1.getValue();
            
            dataset.addValue(measureValue, alg, measureName);
        }
    }
            */
    
}
 
开发者ID:SCI2SUGR,项目名称:KEEL,代码行数:81,代码来源:ResultsProccessor.java


示例8: writeToFile

import org.jfree.graphics2d.svg.SVGGraphics2D; //导入依赖的package包/类
public void writeToFile(String outName) throws FileNotFoundException, UnsupportedEncodingException, IOException
{
    //calcMeans();
    
    // Create JFreeChart Dataset
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset( );
    
    
    HashMap<String, ArrayList<Double> > measuresFirst = algorithmMeasures.entrySet().iterator().next().getValue();
    for (Map.Entry<String, ArrayList<Double> > measure : measuresFirst.entrySet())
    {
        String measureName = measure.getKey();
        //Double measureValue = measure.getValue();
        dataset.clear();
        
        for (Map.Entry<String, HashMap<String, ArrayList<Double> >> entry : algorithmMeasures.entrySet())
        {
            String alg = entry.getKey();
            ArrayList<Double> measureValues = entry.getValue().get(measureName);
            
            // Parse algorithm name to show it correctly
            String aName = alg.substring(0, alg.length()-1);
            int startAlgName = aName.lastIndexOf("/");
            aName = aName.substring(startAlgName + 1);
            
            dataset.add(measureValues, aName, measureName);
        }
        
        // Tutorial: http://www.java2s.com/Code/Java/Chart/JFreeChartBoxAndWhiskerDemo.htm
        final CategoryAxis xAxis = new CategoryAxis("Algorithm");
        final NumberAxis yAxis = new NumberAxis("Value");
        yAxis.setAutoRangeIncludesZero(false);
        final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
        
        // Black and White
        int numItems = algorithmMeasures.size();
        for(int i=0;i<numItems;i++)
        {
            Color color = Color.DARK_GRAY;
            if(i%2 == 1)
            {
                color = Color.LIGHT_GRAY;
            }
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesOutlinePaint(i, Color.BLACK);
        }
        
        renderer.setMeanVisible(false);
        renderer.setFillBox(false);
        renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
        final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

        Font font = new Font("SansSerif", Font.BOLD, 10);
        //ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
        JFreeChart jchart = new JFreeChart("Assotiation Rules Measures - BoxPlot", font, plot, true);
        //StandardChartTheme.createLegacyTheme().apply(jchart);
     
        int width = 640 * 2; /* Width of the image */
        int height = 480 * 2; /* Height of the image */ 

        // JPEG
        File chart = new File( outName + "_" + measureName + "_boxplot.jpg" );
        ChartUtilities.saveChartAsJPEG( chart , jchart , width , height );

        // SVG
        SVGGraphics2D g2 = new SVGGraphics2D(width, height);
        Rectangle r = new Rectangle(0, 0, width, height);
        jchart.draw(g2, r);
        File BarChartSVG = new File( outName + "_" + measureName + "_boxplot.svg" );
        SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
    }
    
}
 
开发者ID:SCI2SUGR,项目名称:KEEL,代码行数:74,代码来源:ResultsProccessor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LanguageSet类代码示例发布时间:2022-05-22
下一篇:
Java BoostedQuery类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap