GithubHelp home page GithubHelp logo

flowdalic / picnic-table-builder Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 18 KB

Create nice looking ASCII tables from Java and Scala. Other JVM languages and Unicode output is supported too.

License: Apache License 2.0

Java 100.00%
ascii-art ascii-table jvm-languages java android scala tables table-builder

picnic-table-builder's Introduction

Picnic Table Builder for Java & Co.

The Picnic Table Builder library provides a TableBuilder API for Java & Co. to create HTML-like tables that are nice looking when rendered as Unicode or ASCII. The provided TableBuilder is a Java-shim over Jake Wharton's great Picnic Tables (picnic) library. Unfortunately, picnic itself is not accessible from Scala (apparently due to its usage of Kotlin's @set:JvmSynthetic annotation). Picnic Table Builder, i.e., this library, solves this issue. It furthermore provides an IMHO more idiomatic and easier to use builder API than upstream does.

Originally submitted for upstream inclusion as Picnic PR #33, it is now released as standalone library.

Example

Table table = eu.geekplace.picnic.TableBuilder.create()
    .withTableStyle()
        .setBorderStyle(Hidden)
        .endTableStyle()
    .withCellStyle()
        .setAlignment(MiddleRight)
        .setPaddingLeft(1)
        .setPaddingRight(1)
        .setBorderLeft(true)
        .setBorderRight(true)
        .endCellStyle()
    .withHeader()
        .withCellStyle()
            .setBorder(true)
            .setAlignment(BottomLeft)
            .endCellStyle()
        .addRow()
            .addCell("APK")
                .setRowSpan(2)
                .endCell()
            .addCell("compressed")
                .setColumnSpan(3)
                .withCellStyle()
                    .setAlignment(BottomCenter)
                    .endCellStyle()
                .endCell()
            .addCell("uncompressed")
                .setColumnSpan(3)
                .withCellStyle()
                    .setAlignment(BottomCenter)
                    .endCellStyle()
                .endCell()
            .endRow()
        .addRow("old", "new", "diff", "old", "new", "diff")
        .endHeader()
    .withBody()
        .addRow("dex", "664.8 KiB", "664.8 KiB", "-25 B", "1.5 MiB", "1.5 MiB", "-112 B")
        .addRow("arsc", "201.7 KiB", "201.7 KiB", "0 B", "201.6 KiB", "201.6 KiB", "0 B")
        .addRow("manifest", "1.4 KiB", "1.4 KiB", "0 B", "4.2 KiB", "4.2 KiB", "0 B")
        .addRow("res", "418.2 KiB", "418.2 KiB", "-14 B", "488.3 KiB", "488.3 KiB", "0 B")
        .addRow("asset", "0 B", "0 B", "0 B", "0 B", "0 B", "0 B")
        .addRow("other", "37.1 KiB", "37.1 KiB", "0 B", "36.3 KiB", "36.3 KiB", "0 B")
        .endBody()
    .withFooter()
        .withCellStyle()
            .setBorder(true)
            .endCellStyle()
        .addRow("total", "1.3 MiB", "1.3 MiB", "-39 B", "2.2 MiB", "2.2 MiB", "-112 B")
        .endFooter()
    .build();

Where table.toString() yields:

          │          compressed           │          uncompressed
          ├───────────┬───────────┬───────┼───────────┬───────────┬────────
 APK      │ old       │ new       │ diff  │ old       │ new       │ diff
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼────────
      dex │ 664.8 KiB │ 664.8 KiB │ -25 B │   1.5 MiB │   1.5 MiB │ -112 B
     arsc │ 201.7 KiB │ 201.7 KiB │   0 B │ 201.6 KiB │ 201.6 KiB │    0 B
 manifest │   1.4 KiB │   1.4 KiB │   0 B │   4.2 KiB │   4.2 KiB │    0 B
      res │ 418.2 KiB │ 418.2 KiB │ -14 B │ 488.3 KiB │ 488.3 KiB │    0 B
    asset │       0 B │       0 B │   0 B │       0 B │       0 B │    0 B
    other │  37.1 KiB │  37.1 KiB │   0 B │  36.3 KiB │  36.3 KiB │    0 B
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼────────
    total │   1.3 MiB │   1.3 MiB │ -39 B │   2.2 MiB │   2.2 MiB │ -112 B

Maven Coordinates

This library is available on Maven Central.

Gradle

implementation 'eu.geekplace:picnic-table-builder:<version>'

License

This project is licensed under the Apache License 2.0.

picnic-table-builder's People

Contributors

flowdalic avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.