Package org.stathissideris.ascii2image.text

Examples of org.stathissideris.ascii2image.text.TextGrid$Cell


    assertEquals(expectedBoundaries, boundaries);
  }

 
  @Test public void testFindBoundariesExpandingFromUOutside() throws FileNotFoundException, IOException {
    TextGrid grid;
    grid = new TextGrid();
    grid.loadFrom("tests/text/simple_U01.txt");

    CellSet wholeGridSet = new CellSet();
    addSquareToCellSet(grid, wholeGridSet, 0,0, grid.getWidth(),grid.getHeight());
   
    TextGrid copyGrid = new AbstractionGrid(grid, wholeGridSet).getCopyOfInternalBuffer();
    CellSet boundaries = copyGrid.findBoundariesExpandingFrom(copyGrid.new Cell(0, 0));
    int size = boundaries.size();

    assertEquals(154, size);

    System.out.println(boundaries.getCellsAsString());
View Full Code Here


    assertEquals(expectedBoundaries, boundaries);
  }

 
  @Test public void testCellSetFromCellsString(){
    TextGrid grid;
    grid = new TextGrid();
   
    String str = "(9,7)/(0, 2)/(3 ,2)/(5,3)";
    CellSet cellSet = cellSetFromCellsString(str, grid);
   
    CellSet expectedCellSet = new CellSet();
View Full Code Here

   
    long startTime = System.currentTimeMillis();
   
    ConversionOptions options = new ConversionOptions();
   
    TextGrid grid = new TextGrid();
   
    String filename = "bug18.txt";
   
    grid.loadFrom("tests/text/"+filename);
   
    Diagram diagram = new Diagram(grid, options);
    new BitmapRenderer().renderToPNG(diagram, "tests/images/"+filename+".png", options.renderingOptions);
    long endTime = System.currentTimeMillis();
    long totalTime  = (endTime - startTime) / 1000;
View Full Code Here

    private void renderInternal(final ConversionOptions options, final String gridText,
                                int timeoutSeconds, HttpServletResponse response)
            throws IOException, TimeoutException
    {
        final TextGrid grid = new TextGrid();

        // initialize thread pool on first use, to avoid unnecessary allocation
        synchronized (INTERNAL_SETUP_SYNC) {
            if (RENDER_EXECUTOR == null)
                RENDER_EXECUTOR = Executors.newFixedThreadPool(12);
        }

        Future<RenderedImage> future = RENDER_EXECUTOR.submit(new Callable<RenderedImage>() {
            public RenderedImage call() throws Exception {
                grid.initialiseWithText(gridText, options.processingOptions);
                grid.printDebug();

                Diagram diagram = new Diagram(grid, options);
                return new BitmapRenderer().renderToImage(diagram, options.renderingOptions);
            }
        });
View Full Code Here

        used = true;
        start = System.currentTimeMillis();
        debug("External renderer: allowing " + timeoutMillis + " ms to complete.");

        {
            TextGrid grid = new TextGrid();
            grid.initialiseWithText(gridText, options.processingOptions);
            grid.printDebug();
            debug("Printed grid in " + (System.currentTimeMillis() - start) + " ms");
        }

        File workingDir = new File("/tmp");
        String classPath = Config.getExternalRenderClasspath(context);
View Full Code Here

public class DitaaTest {
    public static void main(String[] args) throws UnsupportedEncodingException {
        ConversionOptions options = new ConversionOptions();

        TextGrid grid = new TextGrid();

        boolean noAntiAlias = false;
        boolean noShadows = false;
        boolean roundCorners = false;
        boolean noSeparation = false;
        float scale = 1f;
        String gridText = null;
        for (int i = 0; i < args.length; ++i) {
            String a = args[i];
            if ("-A".equals(a) || "-no-antialias".equals(a)) noAntiAlias = true;
            if ("-S".equals(a) || "-no-shadows".equals(a)) noShadows = true;
            if ("-E".equals(a) || "-no-separation".equals(a)) noSeparation = true;
            if ("-r".equals(a) || "-round-corners".equals(a)) roundCorners = true;
            if ("-scale".equals(a)) scale = Float.parseFloat(args[++i]);
            if ("-grid".equals(a)) gridText = args[++i];
        }
        options.renderingOptions.setAntialias(!noAntiAlias);
        options.renderingOptions.setDropShadows(!noShadows);
        options.renderingOptions.setScale(scale);
        options.processingOptions.setAllCornersAreRound(roundCorners);
        options.processingOptions.setPerformSeparationOfCommonEdges(!noSeparation);
//        options.renderingOptions.setRenderDebugLines(false);
//        options.processingOptions.setColorCodesProcessingMode(ProcessingOptions.USE_COLOR_CODES);
//        options.processingOptions.setPrintDebugOutput(true);
//        options.processingOptions.setVerbose(true);

        if (gridText == null) {
            try {
                InputStream is = DitaaTest.class.getResourceAsStream("complex-ditaa.properties");
                LineNumberReader reader = new LineNumberReader(new InputStreamReader(is));
                ArrayList<StringBuilder> lines = new ArrayList<StringBuilder>();
                while (true) {
                    String line = reader.readLine();
                    if (line == null) break;
                    else lines.add(new StringBuilder(line));
                }
                grid.initialiseWithLines(lines, options.processingOptions);
            } catch(IOException e) {
                e.printStackTrace();
                grid.initialiseWithText("/-+\n| |\n+-/", options.processingOptions);
            }
        }
        else grid.initialiseWithText(gridText, options.processingOptions);

        grid.printDebug();

        long start = System.currentTimeMillis();
        Diagram diagram = new Diagram(grid, options);
        final RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);
        System.out.println("0. Rendered in " + (System.currentTimeMillis() - start) + " ms");
View Full Code Here

            options.processingOptions.setAllCornersAreRound(roundedCorners);
            options.processingOptions.setPerformSeparationOfCommonEdges(separation);
            options.renderingOptions.setAntialias(antialias);


            TextGrid grid = new TextGrid();
            if(options.processingOptions.getCustomShapes() != null){
                grid.addToMarkupTags(options.processingOptions.getCustomShapes().keySet());
            }

            XdmNode doc = source.read();
            String text = doc.getStringValue();

            ArrayList<StringBuffer> lines = new ArrayList<StringBuffer>();
            String[] linesArray = text.split("\n");
            for (int i = 0; i  < linesArray.length; i++) {
                lines.add(new StringBuffer(linesArray[i]));
            }
            grid.initialiseWithLines(lines, options.processingOptions);
            Diagram diagram = new Diagram(grid, options);
            RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ImageIO.write(image, "png", baos);
View Full Code Here

TOP

Related Classes of org.stathissideris.ascii2image.text.TextGrid$Cell

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.