Repository: dialex/JColor Branch: main Commit: 9c311f01c87f Files: 60 Total size: 359.3 KB Directory structure: gitextract_ni9ofp4h/ ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ └── bug_report.md │ ├── RUNBOOK.md │ ├── img/ │ │ └── JColor-logo.pxm │ └── update-javadoc.sh ├── .gitignore ├── .java-version ├── .travis.yml ├── LICENSE ├── README.md ├── changelog.md ├── docs/ │ ├── allclasses-index.html │ ├── allpackages-index.html │ ├── com/ │ │ └── diogonunes/ │ │ └── jcolor/ │ │ ├── Ansi.html │ │ ├── AnsiFormat.html │ │ ├── Attribute.html │ │ ├── Command.html │ │ ├── class-use/ │ │ │ ├── Ansi.html │ │ │ ├── AnsiFormat.html │ │ │ ├── Attribute.html │ │ │ └── Command.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ ├── constant-values.html │ ├── element-list │ ├── help-doc.html │ ├── index-all.html │ ├── index.html │ ├── jquery-ui.overrides.css │ ├── legal/ │ │ ├── ADDITIONAL_LICENSE_INFO │ │ ├── ASSEMBLY_EXCEPTION │ │ ├── LICENSE │ │ ├── jquery.md │ │ └── jqueryUI.md │ ├── member-search-index.js │ ├── module-search-index.js │ ├── overview-tree.html │ ├── package-search-index.js │ ├── script.js │ ├── search.js │ ├── stylesheet.css │ ├── tag-search-index.js │ └── type-search-index.js ├── pom.xml └── src/ ├── main/ │ └── java/ │ └── com/ │ └── diogonunes/ │ └── jcolor/ │ ├── Ansi.java │ ├── AnsiFormat.java │ ├── Attribute.java │ ├── BackColorAttribute.java │ ├── ColorAttribute.java │ ├── Command.java │ ├── SimpleAttribute.java │ └── TextColorAttribute.java └── test/ └── java/ └── com/ └── diogonunes/ └── jcolor/ └── tests/ ├── acceptance/ │ └── TestHumanEye.java └── unit/ ├── DataGenerator.java ├── TestAnsi.java ├── TestAttribute.java ├── TestCommand.java ├── TestDataGenerator.java └── TestUsage.java ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: dialex tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with a single custom sponsorship URL ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: Bug report about: Something that doesn't work as documented or expected title: '' labels: '' assignees: '' --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: 1. ... **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. **Environment** - OS: [e.g. Windows/Linux] - Version [e.g. 1.0.2] ================================================ FILE: .github/RUNBOOK.md ================================================ # Runbook How to do stuff ## Release a new version - On GitHub, - Create PR - Wait for CI results - Merge PR - Locally, - Checkout `main` - (See [Generate Javadoc](#Generate-Javadoc) - Run `mvn release:clean release:prepare` - Breaking changes, increase major (`X.*.*`) - New features or upgraded dependencies, increase minor (`*.Y.*`) - Fixing issues, increase patch (`*.*.Z`) - Run `mvn release:perform` - Run `git push` - On GitHub, - Create new release - Select tag created by maven - Describe changes ## Generate Javadoc ```sh jenv shell 18 ./.github/update-javadoc.sh jenv shell 1.8 git add . git commit -m "doc: update javadoc to latest version" ``` - Locally, - If after you prepared a new release... - Copy the contents of folder `target/apidocs` - If not... - Run `mvn javadoc:javadoc` to generate docs - Copy the contents of folder `target/site/apidocs/` - Delete the contents of folder `docs` - Paste your clipboard inside that folder - Run `git add .; git commit -m "doc: update to version X.Y.Z"` ## Update dependencies - Check what is outdated: `mvn versions:display-dependency-updates` - Update all of them: `mvn versions:use-latest-releases` - Check that tests still pass: `mvn test` ## Generate GPG - `gpg --gen-key` - `gpg --list-keys` - `gpg -ab README.md` (you can delete the generated file, it's just to test the key) - `gpg --keyserver keyserver.ubuntu.com --send-keys ` ================================================ FILE: .github/update-javadoc.sh ================================================ #!/usr/bin/env bash mvn javadoc:javadoc rm -r docs cp -R target/site/apidocs docs open docs/index.html ================================================ FILE: .gitignore ================================================ .DS_Store ## ============================================================================ ## project secrets ## ============================================================================ ## gitignore for JAVA *.class # Mobile Tools for Java (J2ME) .mtj.tmp/ # Package Files # *.jar *.war *.ear # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* ## ============================================================================ ## gitignore for MAVEN target/ .classpath .project .settings dependency-reduced-pom.xml release.properties *.releaseBackup ## ============================================================================ ## gitignore for JetBrains: IntelliJ, Android Studio, ... .idea_modules/ .idea/ *.iml *.iws atlassian-ide-plugin.xml out/ ## ============================================================================ ## gitignore for generated files test_output/ ================================================ FILE: .java-version ================================================ 1.8 ================================================ FILE: .travis.yml ================================================ language: java jdk: - openjdk9 install: - mvn install -Dgpg.skip=true script: - mvn test branches: only: - main notifications: email: on_success: never on_failure: always ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2011 Diogo Nunes Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # [![Maven Central](https://img.shields.io/maven-central/v/com.diogonunes/JColor)](https://mvnrepository.com/artifact/com.diogonunes/JColor) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/faaed58a577d4c3099cf8d6d4d572fb8)](https://www.codacy.com/manual/dialex-nunes/JColor?utm_source=github.com&utm_medium=referral&utm_content=dialex/JColor&utm_campaign=Badge_Grade) [![License](https://img.shields.io/github/license/dialex/JColor.svg)](https://github.com/dialex/JColor/blob/main/LICENSE) [![Donate](https://img.shields.io/badge/donate-%E2%99%A5%20-E91E63.svg)](https://www.paypal.me/dialexnunes/) **JColor** offers you an easy syntax to print messages with a colored font or background on a terminal. ### Screenshots ![JColor running on iTerm (macOS)](https://raw.githubusercontent.com/dialex/JColor/main/.github/img/example-mac-iterm-fancy.png) How it looks on different platforms: [macOS iTerm](https://raw.githubusercontent.com/dialex/JColor/main/.github/img/example-mac-iterm-fancy.png), [Windows Terminal](https://raw.githubusercontent.com/dialex/JColor/main/.github/img/example-win-console.png), [IntelliJ](https://raw.githubusercontent.com/dialex/JColor/main/.github/img/example-IntelliJ.png) ### Usage The screenshot was the result of running this [demo code](./src/test/java/com/diogonunes/jcolor/tests/acceptance/TestHumanEye.java): ```java // Use Case 1: use Ansi.colorize() to format inline System.out.println(colorize("This text will be yellow on magenta", YELLOW_TEXT(), MAGENTA_BACK())); System.out.println("\n"); // Use Case 2: compose Attributes to create your desired format Attribute[] myFormat = new Attribute[]{RED_TEXT(), YELLOW_BACK(), BOLD()}; System.out.println(colorize("This text will be red on yellow", myFormat)); System.out.println("\n"); // Use Case 3: AnsiFormat is syntactic sugar for an array of Attributes AnsiFormat fWarning = new AnsiFormat(GREEN_TEXT(), BLUE_BACK(), BOLD()); System.out.println(colorize("AnsiFormat is just a pretty way to declare formats", fWarning)); System.out.println(fWarning.format("...and use those formats without calling colorize() directly")); System.out.println("\n"); // Use Case 4: you can define your formats and use them throughout your code AnsiFormat fInfo = new AnsiFormat(CYAN_TEXT()); AnsiFormat fError = new AnsiFormat(YELLOW_TEXT(), RED_BACK()); System.out.println(fInfo.format("This info message will be cyan")); System.out.println("This normal message will not be formatted"); System.out.println(fError.format("This error message will be yellow on red")); System.out.println("\n"); // Use Case 5: we support bright colors AnsiFormat fNormal = new AnsiFormat(MAGENTA_BACK(), YELLOW_TEXT()); AnsiFormat fBright = new AnsiFormat(BRIGHT_MAGENTA_BACK(), BRIGHT_YELLOW_TEXT()); System.out.println(fNormal.format("You can use normal colors ") + fBright.format(" and bright colors too")); // Use Case 6: we support 8-bit colors System.out.println("Any 8-bit color (0-255), as long as your terminal supports it:"); for (int i = 0; i <= 255; i++) { Attribute txtColor = TEXT_COLOR(i); System.out.print(colorize(String.format("%4d", i), txtColor)); } System.out.println("\n"); // Use Case 7: we support true colors (RGB) System.out.println("Any TrueColor (RGB), as long as your terminal supports it:"); for (int i = 0; i <= 300; i++) { Attribute bkgColor = BACK_COLOR(randomInt(255), randomInt(255), randomInt(255)); System.out.print(colorize(" ", bkgColor)); } System.out.println("\n"); // Credits System.out.print("This example used JColor 5.0.0 "); System.out.print(colorize("\tMADE ", BOLD(), BRIGHT_YELLOW_TEXT(), GREEN_BACK())); System.out.println(colorize("IN PORTUGAL\t", BOLD(), BRIGHT_YELLOW_TEXT(), RED_BACK())); System.out.println("I hope you find it useful ;)"); ``` #### Installation You can import this dependency through Maven or Gradle: - [JColor](https://mvnrepository.com/artifact/com.diogonunes/JColor) `v5.*` supports Java 8+, Linux, macOS, Windows* 10+ - [JCDP](https://mvnrepository.com/artifact/com.diogonunes/JCDP) `v4.*` supports Java 8+, Linux, macOS, Windows* 10+ - JCDP `v3.*` supports Java 8+, Linux, macOS, Windows - JCDP `v2.*` supports Java 6+, Linux, macOS, Windows ##### Troubleshoot > ⚠️ *Windows users, attention! > > Even though Windows 10 has support for ANSI escape sequences, it is [disabled by default](https://stackoverflow.com/questions/51680709/colored-text-output-in-powershell-console-using-ansi-vt100-codes/51681675#51681675). The easiest way to fix this is to use [Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701), otherwise pick one of these [workarounds](https://github.com/dialex/JColor/issues/62#issuecomment-967010670). #### Useful links - [Javadoc](https://dialex.github.io/JColor/) - [Changelog](https://github.com/dialex/JColor/releases/) ### License JColor, former JCDP Copyright (C) 2011-\* [Diogo Nunes](https://www.diogonunes.com/) This program is licensed under the terms of the MIT License and it comes with ABSOLUTELY NO WARRANTY. For more details check LICENSE. ### Credits A big thanks to all [contributors](https://github.com/dialex/JColor/graphs/contributors), namely [@xafero](https://github.com/xafero) who _maven-ized_ this project. ================================================ FILE: changelog.md ================================================ # Release Changelog [See GitHub releases](https://github.com/dialex/JColor/releases) ================================================ FILE: docs/allclasses-index.html ================================================ All Classes and Interfaces (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

All Classes and Interfaces

Classes
Class
Description
Provides a fluent API to generate ANSI escape sequences by specifying Attributes of your format.
Abstracts an Array of Attributes.
Abstracts ANSI codes with intuitive names.
Abstracts ANSI codes with intuitive names.

================================================ FILE: docs/allpackages-index.html ================================================ All Packages (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

All Packages

Package Summary
Package
Description
 

================================================ FILE: docs/com/diogonunes/jcolor/Ansi.html ================================================ Ansi (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Class Ansi

java.lang.Object
com.diogonunes.jcolor.Ansi

public class Ansi extends Object
Provides a fluent API to generate ANSI escape sequences by specifying Attributes of your format.
  • Field Details

    • PREFIX

      public static final String PREFIX
      Every Ansi escape code begins with this PREFIX.
      See Also:
    • SEPARATOR

      public static final String SEPARATOR
      Two options must be separated by this SEPARATOR.
      See Also:
    • POSTFIX

      public static final String POSTFIX
      Every Ansi escape code must end with this POSTFIX.
      See Also:
    • RESET

      public static final String RESET
      Shorthand for the Ansi code that resets to the terminal's default format.
  • Constructor Details

    • Ansi

      public Ansi()
  • Method Details

    • generateCode

      public static String generateCode(Attribute... attributes)
      Parameters:
      attributes - ANSI attributes to format a text.
      Returns:
      The ANSI code that describes all those attributes together.
    • generateCode

      public static String generateCode(AnsiFormat attributes)
      Parameters:
      attributes - Object containing format attributes.
      Returns:
      The ANSI code that describes all those attributes together.
    • generateCode

      public static String generateCode(Command command)
      Parameters:
      command - ANSI command to apply to terminal.
      Returns:
      The ANSI code that describes that command.
    • colorize

      public static String colorize(Command command)
      Parameters:
      command - Ansi command to apply to terminal.
      Returns:
      The formatted string, ready to be printed.
    • colorize

      public static String colorize(String text, String ansiCode)
      Parameters:
      text - String to format.
      ansiCode - Ansi code to format each message's lines.
      Returns:
      The formatted string, ready to be printed.
    • colorize

      public static String colorize(String text, Attribute... attributes)
      Parameters:
      text - String to format.
      attributes - ANSI attributes to format a text.
      Returns:
      The formatted string, ready to be printed.
    • colorize

      public static String colorize(String text, AnsiFormat attributes)
      Parameters:
      text - String to format.
      attributes - Object containing format attributes.
      Returns:
      The formatted string, ready to be printed.
    • makeItFabulous

      public static String makeItFabulous(String text, Attribute... attributes)
      Easter egg. Just an alias of method "colorize".
      Parameters:
      text - String to format.
      attributes - ANSI attributes to format a text.
      Returns:
      The formatted string, ready to be printed.

================================================ FILE: docs/com/diogonunes/jcolor/AnsiFormat.html ================================================ AnsiFormat (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Class AnsiFormat

java.lang.Object
com.diogonunes.jcolor.AnsiFormat

public class AnsiFormat extends Object
Abstracts an Array of Attributes. Use it if you find this more readable than Attribute[].
  • Constructor Details

    • AnsiFormat

      public AnsiFormat(Attribute... attributes)
      Parameters:
      attributes - All ANSI attributes to format a text.
  • Method Details

    • format

      public String format(String text)
      Parameters:
      text - String to format.
      Returns:
      The formatted string, ready to be printed.
    • toArray

      protected Attribute[] toArray()

================================================ FILE: docs/com/diogonunes/jcolor/Attribute.html ================================================ Attribute (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Class Attribute

java.lang.Object
com.diogonunes.jcolor.Attribute

public abstract class Attribute extends Object
Abstracts ANSI codes with intuitive names. It maps a description (e.g. RED_TEXT) with a code (e.g. 31).
See Also:
  • Constructor Details

    • Attribute

      public Attribute()
  • Method Details

    • toString

      public abstract String toString()
      Overrides:
      toString in class Object
      Returns:
      The Attribute's ansi escape code.
    • NONE

      public static Attribute NONE()
    • CLEAR

      public static Attribute CLEAR()
      Returns:
      Clears any format. Restores the terminal's default format.
    • BOLD

      public static Attribute BOLD()
    • SATURATED

      public static Attribute SATURATED()
      Returns:
      Alias of BOLD().
    • DIM

      public static Attribute DIM()
    • DESATURATED

      public static Attribute DESATURATED()
      Returns:
      Alias of DIM().
    • ITALIC

      public static Attribute ITALIC()
    • UNDERLINE

      public static Attribute UNDERLINE()
    • SLOW_BLINK

      public static Attribute SLOW_BLINK()
    • RAPID_BLINK

      public static Attribute RAPID_BLINK()
    • REVERSE

      public static Attribute REVERSE()
    • HIDDEN

      public static Attribute HIDDEN()
    • STRIKETHROUGH

      public static Attribute STRIKETHROUGH()
    • FRAMED

      public static Attribute FRAMED()
    • ENCIRCLED

      public static Attribute ENCIRCLED()
    • OVERLINED

      public static Attribute OVERLINED()
    • BLACK_TEXT

      public static Attribute BLACK_TEXT()
    • RED_TEXT

      public static Attribute RED_TEXT()
    • GREEN_TEXT

      public static Attribute GREEN_TEXT()
    • YELLOW_TEXT

      public static Attribute YELLOW_TEXT()
    • BLUE_TEXT

      public static Attribute BLUE_TEXT()
    • MAGENTA_TEXT

      public static Attribute MAGENTA_TEXT()
    • CYAN_TEXT

      public static Attribute CYAN_TEXT()
    • WHITE_TEXT

      public static Attribute WHITE_TEXT()
    • BLACK_BACK

      public static Attribute BLACK_BACK()
    • RED_BACK

      public static Attribute RED_BACK()
    • GREEN_BACK

      public static Attribute GREEN_BACK()
    • YELLOW_BACK

      public static Attribute YELLOW_BACK()
    • BLUE_BACK

      public static Attribute BLUE_BACK()
    • MAGENTA_BACK

      public static Attribute MAGENTA_BACK()
    • CYAN_BACK

      public static Attribute CYAN_BACK()
    • WHITE_BACK

      public static Attribute WHITE_BACK()
    • BRIGHT_BLACK_TEXT

      public static Attribute BRIGHT_BLACK_TEXT()
    • BRIGHT_RED_TEXT

      public static Attribute BRIGHT_RED_TEXT()
    • BRIGHT_GREEN_TEXT

      public static Attribute BRIGHT_GREEN_TEXT()
    • BRIGHT_YELLOW_TEXT

      public static Attribute BRIGHT_YELLOW_TEXT()
    • BRIGHT_BLUE_TEXT

      public static Attribute BRIGHT_BLUE_TEXT()
    • BRIGHT_MAGENTA_TEXT

      public static Attribute BRIGHT_MAGENTA_TEXT()
    • BRIGHT_CYAN_TEXT

      public static Attribute BRIGHT_CYAN_TEXT()
    • BRIGHT_WHITE_TEXT

      public static Attribute BRIGHT_WHITE_TEXT()
    • BRIGHT_BLACK_BACK

      public static Attribute BRIGHT_BLACK_BACK()
    • BRIGHT_RED_BACK

      public static Attribute BRIGHT_RED_BACK()
    • BRIGHT_GREEN_BACK

      public static Attribute BRIGHT_GREEN_BACK()
    • BRIGHT_YELLOW_BACK

      public static Attribute BRIGHT_YELLOW_BACK()
    • BRIGHT_BLUE_BACK

      public static Attribute BRIGHT_BLUE_BACK()
    • BRIGHT_MAGENTA_BACK

      public static Attribute BRIGHT_MAGENTA_BACK()
    • BRIGHT_CYAN_BACK

      public static Attribute BRIGHT_CYAN_BACK()
    • BRIGHT_WHITE_BACK

      public static Attribute BRIGHT_WHITE_BACK()
    • TEXT_COLOR

      public static Attribute TEXT_COLOR(int colorNumber)
      Parameters:
      colorNumber - A number (0-255) that represents an 8-bit color.
      Returns:
      An Attribute that represents a foreground with an 8-bit color.
    • TEXT_COLOR

      public static Attribute TEXT_COLOR(int r, int g, int b)
      Parameters:
      r - A number (0-255) that represents the red component.
      g - A number (0-255) that represents the green component.
      b - A number (0-255) that represents the blue component.
      Returns:
      An Attribute that represents a foreground with a true color.
    • BACK_COLOR

      public static Attribute BACK_COLOR(int colorNumber)
      Parameters:
      colorNumber - A number (0-255) that represents an 8-bit color.
      Returns:
      An Attribute that represents a background with an 8-bit color.
    • BACK_COLOR

      public static Attribute BACK_COLOR(int r, int g, int b)
      Parameters:
      r - A number (0-255) that represents the red component.
      g - A number (0-255) that represents the green component.
      b - A number (0-255) that represents the blue component.
      Returns:
      An Attribute that represents a background with a true color.

================================================ FILE: docs/com/diogonunes/jcolor/Command.html ================================================ Command (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Class Command

java.lang.Object
com.diogonunes.jcolor.Command

public class Command extends Object
Abstracts ANSI codes with intuitive names. It maps a command (e.g. CLEAR_SCREEN) with a code.
  • Method Details

    • CLEAR_SCREEN

      public static Command CLEAR_SCREEN()
      Returns:
      Clears the terminal's text, e.g. just like the command-line `clear`.
    • toString

      public String toString()
      Overrides:
      toString in class Object

================================================ FILE: docs/com/diogonunes/jcolor/class-use/Ansi.html ================================================ Uses of Class com.diogonunes.jcolor.Ansi (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Uses of Class
com.diogonunes.jcolor.Ansi

No usage of com.diogonunes.jcolor.Ansi

================================================ FILE: docs/com/diogonunes/jcolor/class-use/AnsiFormat.html ================================================ Uses of Class com.diogonunes.jcolor.AnsiFormat (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Uses of Class
com.diogonunes.jcolor.AnsiFormat


================================================ FILE: docs/com/diogonunes/jcolor/class-use/Attribute.html ================================================ Uses of Class com.diogonunes.jcolor.Attribute (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Uses of Class
com.diogonunes.jcolor.Attribute


================================================ FILE: docs/com/diogonunes/jcolor/class-use/Command.html ================================================ Uses of Class com.diogonunes.jcolor.Command (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Uses of Class
com.diogonunes.jcolor.Command


================================================ FILE: docs/com/diogonunes/jcolor/package-summary.html ================================================ com.diogonunes.jcolor (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Package com.diogonunes.jcolor


package com.diogonunes.jcolor

================================================ FILE: docs/com/diogonunes/jcolor/package-tree.html ================================================ com.diogonunes.jcolor Class Hierarchy (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Hierarchy For Package com.diogonunes.jcolor

Class Hierarchy


================================================ FILE: docs/com/diogonunes/jcolor/package-use.html ================================================ Uses of Package com.diogonunes.jcolor (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Uses of Package
com.diogonunes.jcolor


================================================ FILE: docs/constant-values.html ================================================ Constant Field Values (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Constant Field Values

Contents

com.diogonunes.*


================================================ FILE: docs/element-list ================================================ com.diogonunes.jcolor ================================================ FILE: docs/help-doc.html ================================================ API Help (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

JavaDoc Help


Navigation

Starting from the Overview page, you can browse the documentation using the links in each page, and in the navigation bar at the top of each page. The Index and Search box allow you to navigate to specific declarations and summary pages, including: All Packages, All Classes and Interfaces

Kinds of Pages

The following sections describe the different kinds of pages in this collection.

Package

Each package has a page that contains a list of its classes and interfaces, with a summary for each. These pages may contain the following categories:

  • Interfaces
  • Classes
  • Enums
  • Exception Classes
  • Annotation Types

Class or Interface

Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a declaration and description, member summary tables, and detailed member descriptions. Entries in each of these sections are omitted if they are empty or not applicable.

  • Class Inheritance Diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class or Interface Declaration
  • Class or Interface Description

  • Nested Class Summary
  • Enum Constant Summary
  • Field Summary
  • Property Summary
  • Constructor Summary
  • Method Summary
  • Required Element Summary
  • Optional Element Summary

  • Enum Constant Details
  • Field Details
  • Property Details
  • Constructor Details
  • Method Details
  • Element Details

Note: Annotation interfaces have required and optional elements, but not methods. Only enum classes have enum constants. The components of a record class are displayed as part of the declaration of the record class. Properties are a feature of JavaFX.

The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

Other Files

Packages and modules may contain pages with additional information related to the declarations nearby.

Use

Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the USE link in the navigation bar.

Tree (Class Hierarchy)

There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. Classes are organized by inheritance structure starting with java.lang.Object. Interfaces do not inherit from java.lang.Object.

  • When viewing the Overview page, clicking on TREE displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking on TREE displays the hierarchy for only that package.

Constant Field Values

The Constant Field Values page lists the static final fields and their values.

All Packages

The All Packages page contains an alphabetic index of all packages contained in the documentation.

All Classes and Interfaces

The All Classes and Interfaces page contains an alphabetic index of all classes and interfaces contained in the documentation, including annotation interfaces, enum classes, and record classes.

Index

The Index contains an alphabetic index of all classes, interfaces, constructors, methods, and fields in the documentation, as well as summary pages such as All Packages, All Classes and Interfaces.


This help file applies to API documentation generated by the standard doclet.

================================================ FILE: docs/index-all.html ================================================ Index (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Index

A B C D E F G H I M N O P R S T U W Y 
All Classes and Interfaces|All Packages|Constant Field Values

A

Ansi - Class in com.diogonunes.jcolor
Provides a fluent API to generate ANSI escape sequences by specifying Attributes of your format.
Ansi() - Constructor for class com.diogonunes.jcolor.Ansi
 
AnsiFormat - Class in com.diogonunes.jcolor
Abstracts an Array of Attributes.
AnsiFormat(Attribute...) - Constructor for class com.diogonunes.jcolor.AnsiFormat
 
Attribute - Class in com.diogonunes.jcolor
Abstracts ANSI codes with intuitive names.
Attribute() - Constructor for class com.diogonunes.jcolor.Attribute
 

B

BACK_COLOR(int) - Static method in class com.diogonunes.jcolor.Attribute
 
BACK_COLOR(int, int, int) - Static method in class com.diogonunes.jcolor.Attribute
 
BLACK_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
BLACK_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
BLUE_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
BLUE_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
BOLD() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_BLACK_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_BLACK_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_BLUE_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_BLUE_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_CYAN_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_CYAN_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_GREEN_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_GREEN_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_MAGENTA_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_MAGENTA_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_RED_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_RED_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_WHITE_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_WHITE_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_YELLOW_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
BRIGHT_YELLOW_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 

C

CLEAR() - Static method in class com.diogonunes.jcolor.Attribute
 
CLEAR_SCREEN() - Static method in class com.diogonunes.jcolor.Command
 
colorize(Command) - Static method in class com.diogonunes.jcolor.Ansi
 
colorize(String, AnsiFormat) - Static method in class com.diogonunes.jcolor.Ansi
 
colorize(String, Attribute...) - Static method in class com.diogonunes.jcolor.Ansi
 
colorize(String, String) - Static method in class com.diogonunes.jcolor.Ansi
 
com.diogonunes.jcolor - package com.diogonunes.jcolor
 
Command - Class in com.diogonunes.jcolor
Abstracts ANSI codes with intuitive names.
CYAN_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
CYAN_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 

D

DESATURATED() - Static method in class com.diogonunes.jcolor.Attribute
 
DIM() - Static method in class com.diogonunes.jcolor.Attribute
 

E

ENCIRCLED() - Static method in class com.diogonunes.jcolor.Attribute
 

F

format(String) - Method in class com.diogonunes.jcolor.AnsiFormat
 
FRAMED() - Static method in class com.diogonunes.jcolor.Attribute
 

G

generateCode(AnsiFormat) - Static method in class com.diogonunes.jcolor.Ansi
 
generateCode(Attribute...) - Static method in class com.diogonunes.jcolor.Ansi
 
generateCode(Command) - Static method in class com.diogonunes.jcolor.Ansi
 
GREEN_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
GREEN_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 

H

HIDDEN() - Static method in class com.diogonunes.jcolor.Attribute
 

I

ITALIC() - Static method in class com.diogonunes.jcolor.Attribute
 

M

MAGENTA_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
MAGENTA_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
makeItFabulous(String, Attribute...) - Static method in class com.diogonunes.jcolor.Ansi
Easter egg.

N

NONE() - Static method in class com.diogonunes.jcolor.Attribute
 

O

OVERLINED() - Static method in class com.diogonunes.jcolor.Attribute
 

P

POSTFIX - Static variable in class com.diogonunes.jcolor.Ansi
Every Ansi escape code must end with this POSTFIX.
PREFIX - Static variable in class com.diogonunes.jcolor.Ansi
Every Ansi escape code begins with this PREFIX.

R

RAPID_BLINK() - Static method in class com.diogonunes.jcolor.Attribute
 
RED_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
RED_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
RESET - Static variable in class com.diogonunes.jcolor.Ansi
Shorthand for the Ansi code that resets to the terminal's default format.
REVERSE() - Static method in class com.diogonunes.jcolor.Attribute
 

S

SATURATED() - Static method in class com.diogonunes.jcolor.Attribute
 
SEPARATOR - Static variable in class com.diogonunes.jcolor.Ansi
Two options must be separated by this SEPARATOR.
SLOW_BLINK() - Static method in class com.diogonunes.jcolor.Attribute
 
STRIKETHROUGH() - Static method in class com.diogonunes.jcolor.Attribute
 

T

TEXT_COLOR(int) - Static method in class com.diogonunes.jcolor.Attribute
 
TEXT_COLOR(int, int, int) - Static method in class com.diogonunes.jcolor.Attribute
 
toArray() - Method in class com.diogonunes.jcolor.AnsiFormat
 
toString() - Method in class com.diogonunes.jcolor.Attribute
 
toString() - Method in class com.diogonunes.jcolor.Command
 

U

UNDERLINE() - Static method in class com.diogonunes.jcolor.Attribute
 

W

WHITE_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
WHITE_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 

Y

YELLOW_BACK() - Static method in class com.diogonunes.jcolor.Attribute
 
YELLOW_TEXT() - Static method in class com.diogonunes.jcolor.Attribute
 
A B C D E F G H I M N O P R S T U W Y 
All Classes and Interfaces|All Packages|Constant Field Values

================================================ FILE: docs/index.html ================================================ com.diogonunes:JColor 5.5.2-SNAPSHOT API

com/diogonunes/jcolor/package-summary.html

================================================ FILE: docs/jquery-ui.overrides.css ================================================ /* * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active, a.ui-button:active, .ui-button:active, .ui-button.ui-state-active:hover { /* Overrides the color of selection used in jQuery UI */ background: #F8981D; } ================================================ FILE: docs/legal/ADDITIONAL_LICENSE_INFO ================================================ ADDITIONAL INFORMATION ABOUT LICENSING Certain files distributed by Oracle America, Inc. and/or its affiliates are subject to the following clarification and special exception to the GPLv2, based on the GNU Project exception for its Classpath libraries, known as the GNU Classpath Exception. Note that Oracle includes multiple, independent programs in this software package. Some of those programs are provided under licenses deemed incompatible with the GPLv2 by the Free Software Foundation and others. For example, the package includes programs licensed under the Apache License, Version 2.0 and may include FreeType. Such programs are licensed to you under their original licenses. Oracle facilitates your further distribution of this package by adding the Classpath Exception to the necessary parts of its GPLv2 code, which permits you to use that code in combination with other independent modules not licensed under the GPLv2. However, note that this would not permit you to commingle code under an incompatible license with Oracle's GPLv2 licensed code by, for example, cutting and pasting such code into a file also containing Oracle's GPLv2 licensed code and then distributing the result. Additionally, if you were to remove the Classpath Exception from any of the files to which it applies and distribute the result, you would likely be required to license some or all of the other code in that distribution under the GPLv2 as well, and since the GPLv2 is incompatible with the license terms of some items included in the distribution by Oracle, removing the Classpath Exception could therefore effectively compromise your ability to further distribute the package. Failing to distribute notices associated with some files may also create unexpected legal consequences. Proceed with caution and we recommend that you obtain the advice of a lawyer skilled in open source matters before removing the Classpath Exception or making modifications to this package which may subsequently be redistributed and/or involve the use of third party software. ================================================ FILE: docs/legal/ASSEMBLY_EXCEPTION ================================================ OPENJDK ASSEMBLY EXCEPTION The OpenJDK source code made available by Oracle America, Inc. (Oracle) at openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU General Public License version 2 only ("GPL2"), with the following clarification and special exception. Linking this OpenJDK Code statically or dynamically with other code is making a combined work based on this library. Thus, the terms and conditions of GPL2 cover the whole combination. As a special exception, Oracle gives you permission to link this OpenJDK Code with certain code licensed by Oracle as indicated at http://openjdk.java.net/legal/exception-modules-2007-05-08.html ("Designated Exception Modules") to produce an executable, regardless of the license terms of the Designated Exception Modules, and to copy and distribute the resulting executable under GPL2, provided that the Designated Exception Modules continue to be governed by the licenses under which they were offered by Oracle. As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code to build an executable that includes those portions of necessary code that Oracle could not provide under GPL2 (or that Oracle has provided under GPL2 with the Classpath exception). If you modify or add to the OpenJDK code, that new GPL2 code may still be combined with Designated Exception Modules if the new code is made subject to this exception by its copyright holder. ================================================ FILE: docs/legal/LICENSE ================================================ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. ================================================ FILE: docs/legal/jquery.md ================================================ ## jQuery v3.5.1 ### jQuery License ``` jQuery v 3.5.1 Copyright JS Foundation and other contributors, https://js.foundation/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************** The jQuery JavaScript Library v3.5.1 also includes Sizzle.js Sizzle.js includes the following license: Copyright JS Foundation and other contributors, https://js.foundation/ This software consists of voluntary contributions made by many individuals. For exact contribution history, see the revision history available at https://github.com/jquery/sizzle The following license applies to all parts of this software except as documented below: ==== Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ==== All files located in the node_modules and external directories are externally maintained libraries used by this software which have their own licenses; we recommend you read them, as their terms may differ from the terms above. ********************* ``` ================================================ FILE: docs/legal/jqueryUI.md ================================================ ## jQuery UI v1.12.1 ### jQuery UI License ``` Copyright jQuery Foundation and other contributors, https://jquery.org/ This software consists of voluntary contributions made by many individuals. For exact contribution history, see the revision history available at https://github.com/jquery/jquery-ui The following license applies to all parts of this software except as documented below: ==== Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ==== Copyright and related rights for sample code are waived via CC0. Sample code is defined as all source code contained within the demos directory. CC0: http://creativecommons.org/publicdomain/zero/1.0/ ==== All files located in the node_modules and external directories are externally maintained libraries used by this software which have their own licenses; we recommend you read them, as their terms may differ from the terms above. ``` ================================================ FILE: docs/member-search-index.js ================================================ memberSearchIndex = [{"p":"com.diogonunes.jcolor","c":"Ansi","l":"Ansi()","u":"%3Cinit%3E()"},{"p":"com.diogonunes.jcolor","c":"AnsiFormat","l":"AnsiFormat(Attribute...)","u":"%3Cinit%3E(com.diogonunes.jcolor.Attribute...)"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"Attribute()","u":"%3Cinit%3E()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BACK_COLOR(int)"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BACK_COLOR(int, int, int)","u":"BACK_COLOR(int,int,int)"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BLACK_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BLACK_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BLUE_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BLUE_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BOLD()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_BLACK_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_BLACK_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_BLUE_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_BLUE_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_CYAN_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_CYAN_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_GREEN_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_GREEN_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_MAGENTA_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_MAGENTA_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_RED_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_RED_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_WHITE_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_WHITE_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_YELLOW_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"BRIGHT_YELLOW_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Command","l":"CLEAR_SCREEN()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"CLEAR()"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"colorize(Command)","u":"colorize(com.diogonunes.jcolor.Command)"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"colorize(String, AnsiFormat)","u":"colorize(java.lang.String,com.diogonunes.jcolor.AnsiFormat)"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"colorize(String, Attribute...)","u":"colorize(java.lang.String,com.diogonunes.jcolor.Attribute...)"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"colorize(String, String)","u":"colorize(java.lang.String,java.lang.String)"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"CYAN_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"CYAN_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"DESATURATED()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"DIM()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"ENCIRCLED()"},{"p":"com.diogonunes.jcolor","c":"AnsiFormat","l":"format(String)","u":"format(java.lang.String)"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"FRAMED()"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"generateCode(AnsiFormat)","u":"generateCode(com.diogonunes.jcolor.AnsiFormat)"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"generateCode(Attribute...)","u":"generateCode(com.diogonunes.jcolor.Attribute...)"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"generateCode(Command)","u":"generateCode(com.diogonunes.jcolor.Command)"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"GREEN_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"GREEN_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"HIDDEN()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"ITALIC()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"MAGENTA_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"MAGENTA_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"makeItFabulous(String, Attribute...)","u":"makeItFabulous(java.lang.String,com.diogonunes.jcolor.Attribute...)"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"NONE()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"OVERLINED()"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"POSTFIX"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"PREFIX"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"RAPID_BLINK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"RED_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"RED_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"RESET"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"REVERSE()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"SATURATED()"},{"p":"com.diogonunes.jcolor","c":"Ansi","l":"SEPARATOR"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"SLOW_BLINK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"STRIKETHROUGH()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"TEXT_COLOR(int)"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"TEXT_COLOR(int, int, int)","u":"TEXT_COLOR(int,int,int)"},{"p":"com.diogonunes.jcolor","c":"AnsiFormat","l":"toArray()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"toString()"},{"p":"com.diogonunes.jcolor","c":"Command","l":"toString()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"UNDERLINE()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"WHITE_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"WHITE_TEXT()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"YELLOW_BACK()"},{"p":"com.diogonunes.jcolor","c":"Attribute","l":"YELLOW_TEXT()"}];updateSearchResults(); ================================================ FILE: docs/module-search-index.js ================================================ moduleSearchIndex = [];updateSearchResults(); ================================================ FILE: docs/overview-tree.html ================================================ Class Hierarchy (com.diogonunes:JColor 5.5.2-SNAPSHOT API)

Hierarchy For All Packages

Package Hierarchies:

Class Hierarchy


================================================ FILE: docs/package-search-index.js ================================================ packageSearchIndex = [{"l":"All Packages","u":"allpackages-index.html"},{"l":"com.diogonunes.jcolor"}];updateSearchResults(); ================================================ FILE: docs/script.js ================================================ /* * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ var moduleSearchIndex; var packageSearchIndex; var typeSearchIndex; var memberSearchIndex; var tagSearchIndex; function loadScripts(doc, tag) { createElem(doc, tag, 'search.js'); createElem(doc, tag, 'module-search-index.js'); createElem(doc, tag, 'package-search-index.js'); createElem(doc, tag, 'type-search-index.js'); createElem(doc, tag, 'member-search-index.js'); createElem(doc, tag, 'tag-search-index.js'); } function createElem(doc, tag, path) { var script = doc.createElement(tag); var scriptElement = doc.getElementsByTagName(tag)[0]; script.src = pathtoroot + path; scriptElement.parentNode.insertBefore(script, scriptElement); } function show(tableId, selected, columns) { if (tableId !== selected) { document.querySelectorAll('div.' + tableId + ':not(.' + selected + ')') .forEach(function(elem) { elem.style.display = 'none'; }); } document.querySelectorAll('div.' + selected) .forEach(function(elem, index) { elem.style.display = ''; var isEvenRow = index % (columns * 2) < columns; elem.classList.remove(isEvenRow ? oddRowColor : evenRowColor); elem.classList.add(isEvenRow ? evenRowColor : oddRowColor); }); updateTabs(tableId, selected); } function updateTabs(tableId, selected) { document.querySelector('div#' + tableId +' .summary-table') .setAttribute('aria-labelledby', selected); document.querySelectorAll('button[id^="' + tableId + '"]') .forEach(function(tab, index) { if (selected === tab.id || (tableId === selected && index === 0)) { tab.className = activeTableTab; tab.setAttribute('aria-selected', true); tab.setAttribute('tabindex',0); } else { tab.className = tableTab; tab.setAttribute('aria-selected', false); tab.setAttribute('tabindex',-1); } }); } function switchTab(e) { var selected = document.querySelector('[aria-selected=true]'); if (selected) { if ((e.keyCode === 37 || e.keyCode === 38) && selected.previousSibling) { // left or up arrow key pressed: move focus to previous tab selected.previousSibling.click(); selected.previousSibling.focus(); e.preventDefault(); } else if ((e.keyCode === 39 || e.keyCode === 40) && selected.nextSibling) { // right or down arrow key pressed: move focus to next tab selected.nextSibling.click(); selected.nextSibling.focus(); e.preventDefault(); } } } var updateSearchResults = function() {}; function indexFilesLoaded() { return moduleSearchIndex && packageSearchIndex && typeSearchIndex && memberSearchIndex && tagSearchIndex; } function copySnippet(button) { var textarea = document.createElement("textarea"); textarea.style.height = 0; document.body.appendChild(textarea); textarea.value = button.nextElementSibling.innerText; textarea.select(); document.execCommand("copy"); document.body.removeChild(textarea); var span = button.firstElementChild; var copied = span.getAttribute("data-copied"); if (span.innerHTML !== copied) { var initialLabel = span.innerHTML; span.innerHTML = copied; var parent = button.parentElement; parent.onmouseleave = parent.ontouchend = function() { span.innerHTML = initialLabel; }; } } // Workaround for scroll position not being included in browser history (8249133) document.addEventListener("DOMContentLoaded", function(e) { var contentDiv = document.querySelector("div.flex-content"); window.addEventListener("popstate", function(e) { if (e.state !== null) { contentDiv.scrollTop = e.state; } }); window.addEventListener("hashchange", function(e) { history.replaceState(contentDiv.scrollTop, document.title); }); contentDiv.addEventListener("scroll", function(e) { var timeoutID; if (!timeoutID) { timeoutID = setTimeout(function() { history.replaceState(contentDiv.scrollTop, document.title); timeoutID = null; }, 100); } }); if (!location.hash) { history.replaceState(contentDiv.scrollTop, document.title); } }); ================================================ FILE: docs/search.js ================================================ /* * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ var noResult = {l: "No results found"}; var loading = {l: "Loading search index..."}; var catModules = "Modules"; var catPackages = "Packages"; var catTypes = "Types"; var catMembers = "Members"; var catSearchTags = "Search Tags"; var highlight = "$&"; var searchPattern = ""; var fallbackPattern = ""; var RANKING_THRESHOLD = 2; var NO_MATCH = 0xffff; var MIN_RESULTS = 3; var MAX_RESULTS = 500; var UNNAMED = ""; function escapeHtml(str) { return str.replace(//g, ">"); } function getHighlightedText(item, matcher, fallbackMatcher) { var escapedItem = escapeHtml(item); var highlighted = escapedItem.replace(matcher, highlight); if (highlighted === escapedItem) { highlighted = escapedItem.replace(fallbackMatcher, highlight) } return highlighted; } function getURLPrefix(ui) { var urlPrefix=""; var slash = "/"; if (ui.item.category === catModules) { return ui.item.l + slash; } else if (ui.item.category === catPackages && ui.item.m) { return ui.item.m + slash; } else if (ui.item.category === catTypes || ui.item.category === catMembers) { if (ui.item.m) { urlPrefix = ui.item.m + slash; } else { $.each(packageSearchIndex, function(index, item) { if (item.m && ui.item.p === item.l) { urlPrefix = item.m + slash; } }); } } return urlPrefix; } function createSearchPattern(term) { var pattern = ""; var isWordToken = false; term.replace(/,\s*/g, ", ").trim().split(/\s+/).forEach(function(w, index) { if (index > 0) { // whitespace between identifiers is significant pattern += (isWordToken && /^\w/.test(w)) ? "\\s+" : "\\s*"; } var tokens = w.split(/(?=[A-Z,.()<>[\/])/); for (var i = 0; i < tokens.length; i++) { var s = tokens[i]; if (s === "") { continue; } pattern += $.ui.autocomplete.escapeRegex(s); isWordToken = /\w$/.test(s); if (isWordToken) { pattern += "([a-z0-9_$<>\\[\\]]*?)"; } } }); return pattern; } function createMatcher(pattern, flags) { var isCamelCase = /[A-Z]/.test(pattern); return new RegExp(pattern, flags + (isCamelCase ? "" : "i")); } $(function() { var search = $("#search-input"); var reset = $("#reset-button"); search.val(''); search.prop("disabled", false); reset.prop("disabled", false); reset.click(function() { search.val('').focus(); }); search.focus(); }); $.widget("custom.catcomplete", $.ui.autocomplete, { _create: function() { this._super(); this.widget().menu("option", "items", "> :not(.ui-autocomplete-category)"); }, _renderMenu: function(ul, items) { var rMenu = this; var currentCategory = ""; rMenu.menu.bindings = $(); $.each(items, function(index, item) { var li; if (item.category && item.category !== currentCategory) { ul.append("
  • " + item.category + "
  • "); currentCategory = item.category; } li = rMenu._renderItemData(ul, item); if (item.category) { li.attr("aria-label", item.category + " : " + item.l); li.attr("class", "result-item"); } else { li.attr("aria-label", item.l); li.attr("class", "result-item"); } }); }, _renderItem: function(ul, item) { var label = ""; var matcher = createMatcher(escapeHtml(searchPattern), "g"); var fallbackMatcher = new RegExp(fallbackPattern, "gi") if (item.category === catModules) { label = getHighlightedText(item.l, matcher, fallbackMatcher); } else if (item.category === catPackages) { label = getHighlightedText(item.l, matcher, fallbackMatcher); } else if (item.category === catTypes) { label = (item.p && item.p !== UNNAMED) ? getHighlightedText(item.p + "." + item.l, matcher, fallbackMatcher) : getHighlightedText(item.l, matcher, fallbackMatcher); } else if (item.category === catMembers) { label = (item.p && item.p !== UNNAMED) ? getHighlightedText(item.p + "." + item.c + "." + item.l, matcher, fallbackMatcher) : getHighlightedText(item.c + "." + item.l, matcher, fallbackMatcher); } else if (item.category === catSearchTags) { label = getHighlightedText(item.l, matcher, fallbackMatcher); } else { label = item.l; } var li = $("
  • ").appendTo(ul); var div = $("
    ").appendTo(li); if (item.category === catSearchTags && item.h) { if (item.d) { div.html(label + " (" + item.h + ")
    " + item.d + "
    "); } else { div.html(label + " (" + item.h + ")"); } } else { if (item.m) { div.html(item.m + "/" + label); } else { div.html(label); } } return li; } }); function rankMatch(match, category) { if (!match) { return NO_MATCH; } var index = match.index; var input = match.input; var leftBoundaryMatch = 2; var periferalMatch = 0; // make sure match is anchored on a left word boundary if (index === 0 || /\W/.test(input[index - 1]) || "_" === input[index]) { leftBoundaryMatch = 0; } else if ("_" === input[index - 1] || (input[index] === input[index].toUpperCase() && !/^[A-Z0-9_$]+$/.test(input))) { leftBoundaryMatch = 1; } var matchEnd = index + match[0].length; var leftParen = input.indexOf("("); var endOfName = leftParen > -1 ? leftParen : input.length; // exclude peripheral matches if (category !== catModules && category !== catSearchTags) { var delim = category === catPackages ? "/" : "."; if (leftParen > -1 && leftParen < index) { periferalMatch += 2; } else if (input.lastIndexOf(delim, endOfName) >= matchEnd) { periferalMatch += 2; } } var delta = match[0].length === endOfName ? 0 : 1; // rank full match higher than partial match for (var i = 1; i < match.length; i++) { // lower ranking if parts of the name are missing if (match[i]) delta += match[i].length; } if (category === catTypes) { // lower ranking if a type name contains unmatched camel-case parts if (/[A-Z]/.test(input.substring(matchEnd))) delta += 5; if (/[A-Z]/.test(input.substring(0, index))) delta += 5; } return leftBoundaryMatch + periferalMatch + (delta / 200); } function doSearch(request, response) { var result = []; searchPattern = createSearchPattern(request.term); fallbackPattern = createSearchPattern(request.term.toLowerCase()); if (searchPattern === "") { return this.close(); } var camelCaseMatcher = createMatcher(searchPattern, ""); var fallbackMatcher = new RegExp(fallbackPattern, "i"); function searchIndexWithMatcher(indexArray, matcher, category, nameFunc) { if (indexArray) { var newResults = []; $.each(indexArray, function (i, item) { item.category = category; var ranking = rankMatch(matcher.exec(nameFunc(item)), category); if (ranking < RANKING_THRESHOLD) { newResults.push({ranking: ranking, item: item}); } return newResults.length <= MAX_RESULTS; }); return newResults.sort(function(e1, e2) { return e1.ranking - e2.ranking; }).map(function(e) { return e.item; }); } return []; } function searchIndex(indexArray, category, nameFunc) { var primaryResults = searchIndexWithMatcher(indexArray, camelCaseMatcher, category, nameFunc); result = result.concat(primaryResults); if (primaryResults.length <= MIN_RESULTS && !camelCaseMatcher.ignoreCase) { var secondaryResults = searchIndexWithMatcher(indexArray, fallbackMatcher, category, nameFunc); result = result.concat(secondaryResults.filter(function (item) { return primaryResults.indexOf(item) === -1; })); } } searchIndex(moduleSearchIndex, catModules, function(item) { return item.l; }); searchIndex(packageSearchIndex, catPackages, function(item) { return (item.m && request.term.indexOf("/") > -1) ? (item.m + "/" + item.l) : item.l; }); searchIndex(typeSearchIndex, catTypes, function(item) { return request.term.indexOf(".") > -1 ? item.p + "." + item.l : item.l; }); searchIndex(memberSearchIndex, catMembers, function(item) { return request.term.indexOf(".") > -1 ? item.p + "." + item.c + "." + item.l : item.l; }); searchIndex(tagSearchIndex, catSearchTags, function(item) { return item.l; }); if (!indexFilesLoaded()) { updateSearchResults = function() { doSearch(request, response); } result.unshift(loading); } else { updateSearchResults = function() {}; } response(result); } $(function() { var expanded = false; var windowWidth; function collapse() { if (expanded) { $("div#navbar-top").removeAttr("style"); $("button#navbar-toggle-button") .removeClass("expanded") .attr("aria-expanded", "false"); expanded = false; } } $("button#navbar-toggle-button").click(function (e) { if (expanded) { collapse(); } else { $("div#navbar-top").height($("#navbar-top").prop("scrollHeight")); $("button#navbar-toggle-button") .addClass("expanded") .attr("aria-expanded", "true"); expanded = true; windowWidth = window.innerWidth; } }); $("ul.sub-nav-list-small li a").click(collapse); $("input#search-input").focus(collapse); $("main").click(collapse); $(window).on("orientationchange", collapse).on("resize", function(e) { if (expanded && windowWidth !== window.innerWidth) collapse(); }); $("#search-input").catcomplete({ minLength: 1, delay: 300, source: doSearch, response: function(event, ui) { if (!ui.content.length) { ui.content.push(noResult); } else { $("#search-input").empty(); } }, autoFocus: true, focus: function(event, ui) { return false; }, position: { collision: "flip" }, select: function(event, ui) { if (ui.item.category) { var url = getURLPrefix(ui); if (ui.item.category === catModules) { url += "module-summary.html"; } else if (ui.item.category === catPackages) { if (ui.item.u) { url = ui.item.u; } else { url += ui.item.l.replace(/\./g, '/') + "/package-summary.html"; } } else if (ui.item.category === catTypes) { if (ui.item.u) { url = ui.item.u; } else if (ui.item.p === UNNAMED) { url += ui.item.l + ".html"; } else { url += ui.item.p.replace(/\./g, '/') + "/" + ui.item.l + ".html"; } } else if (ui.item.category === catMembers) { if (ui.item.p === UNNAMED) { url += ui.item.c + ".html" + "#"; } else { url += ui.item.p.replace(/\./g, '/') + "/" + ui.item.c + ".html" + "#"; } if (ui.item.u) { url += ui.item.u; } else { url += ui.item.l; } } else if (ui.item.category === catSearchTags) { url += ui.item.u; } if (top !== window) { parent.classFrame.location = pathtoroot + url; } else { window.location.href = pathtoroot + url; } $("#search-input").focus(); } } }); }); ================================================ FILE: docs/stylesheet.css ================================================ /* * Javadoc style sheet */ @import url('resources/fonts/dejavu.css'); /* * Styles for individual HTML elements. * * These are styles that are specific to individual HTML elements. Changing them affects the style of a particular * HTML element throughout the page. */ body { background-color:#ffffff; color:#353833; font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; font-size:14px; margin:0; padding:0; height:100%; width:100%; } iframe { margin:0; padding:0; height:100%; width:100%; overflow-y:scroll; border:none; } a:link, a:visited { text-decoration:none; color:#4A6782; } a[href]:hover, a[href]:focus { text-decoration:none; color:#bb7a2a; } a[name] { color:#353833; } pre { font-family:'DejaVu Sans Mono', monospace; font-size:14px; } h1 { font-size:20px; } h2 { font-size:18px; } h3 { font-size:16px; } h4 { font-size:15px; } h5 { font-size:14px; } h6 { font-size:13px; } ul { list-style-type:disc; } code, tt { font-family:'DejaVu Sans Mono', monospace; } :not(h1, h2, h3, h4, h5, h6) > code, :not(h1, h2, h3, h4, h5, h6) > tt { font-size:14px; padding-top:4px; margin-top:8px; line-height:1.4em; } dt code { font-family:'DejaVu Sans Mono', monospace; font-size:14px; padding-top:4px; } .summary-table dt code { font-family:'DejaVu Sans Mono', monospace; font-size:14px; vertical-align:top; padding-top:4px; } sup { font-size:8px; } button { font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; font-size: 14px; } /* * Styles for HTML generated by javadoc. * * These are style classes that are used by the standard doclet to generate HTML documentation. */ /* * Styles for document title and copyright. */ .about-language { float:right; padding:0 21px 8px 8px; font-size:11px; margin-top:-9px; height:2.9em; } .legal-copy { margin-left:.5em; } /* * Styles for navigation bar. */ @media screen { div.flex-box { position:fixed; display:flex; flex-direction:column; height: 100%; width: 100%; } header.flex-header { flex: 0 0 auto; } div.flex-content { flex: 1 1 auto; overflow-y: auto; } } .top-nav { background-color:#4D7A97; color:#FFFFFF; float:left; padding:0; width:100%; clear:right; min-height:2.8em; padding-top:10px; overflow:hidden; font-size:12px; } button#navbar-toggle-button { display:none; } ul.sub-nav-list-small { display: none; } .sub-nav { background-color:#dee3e9; float:left; width:100%; overflow:hidden; font-size:12px; } .sub-nav div { clear:left; float:left; padding:6px; text-transform:uppercase; } .sub-nav .sub-nav-list { padding-top:4px; } ul.nav-list { display:block; margin:0 25px 0 0; padding:0; } ul.sub-nav-list { float:left; margin:0 25px 0 0; padding:0; } ul.nav-list li { list-style:none; float:left; padding: 5px 6px; text-transform:uppercase; } .sub-nav .nav-list-search { float:right; margin:0; padding:6px; clear:none; text-align:right; position:relative; } ul.sub-nav-list li { list-style:none; float:left; } .top-nav a:link, .top-nav a:active, .top-nav a:visited { color:#ffffff; text-decoration:none; text-transform:uppercase; } .top-nav a:hover { color:#bb7a2a; } .nav-bar-cell1-rev { background-color:#F8981D; color:#253441; margin: auto 5px; } .skip-nav { position:absolute; top:auto; left:-9999px; overflow:hidden; } /* * Hide navigation links and search box in print layout */ @media print { ul.nav-list, div.sub-nav { display:none; } } /* * Styles for page header. */ .title { color:#2c4557; margin:10px 0; } .sub-title { margin:5px 0 0 0; } .header ul { margin:0 0 15px 0; padding:0; } .header ul li { list-style:none; font-size:13px; } /* * Styles for headings. */ body.class-declaration-page .summary h2, body.class-declaration-page .details h2, body.class-use-page h2, body.module-declaration-page .block-list h2 { font-style: italic; padding:0; margin:15px 0; } body.class-declaration-page .summary h3, body.class-declaration-page .details h3, body.class-declaration-page .summary .inherited-list h2 { background-color:#dee3e9; border:1px solid #d0d9e0; margin:0 0 6px -8px; padding:7px 5px; } /* * Styles for page layout containers. */ main { clear:both; padding:10px 20px; position:relative; } dl.notes > dt { font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; margin:10px 0 0 0; color:#4E4E4E; } dl.notes > dd { margin:5px 10px 10px 0; font-size:14px; font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; } dl.name-value > dt { margin-left:1px; font-size:1.1em; display:inline; font-weight:bold; } dl.name-value > dd { margin:0 0 0 1px; font-size:1.1em; display:inline; } /* * Styles for lists. */ li.circle { list-style:circle; } ul.horizontal li { display:inline; font-size:0.9em; } div.inheritance { margin:0; padding:0; } div.inheritance div.inheritance { margin-left:2em; } ul.block-list, ul.details-list, ul.member-list, ul.summary-list { margin:10px 0 10px 0; padding:0; } ul.block-list > li, ul.details-list > li, ul.member-list > li, ul.summary-list > li { list-style:none; margin-bottom:15px; line-height:1.4; } .summary-table dl, .summary-table dl dt, .summary-table dl dd { margin-top:0; margin-bottom:1px; } ul.see-list, ul.see-list-long { padding-left: 0; list-style: none; } ul.see-list li { display: inline; } ul.see-list li:not(:last-child):after, ul.see-list-long li:not(:last-child):after { content: ", "; white-space: pre-wrap; } /* * Styles for tables. */ .summary-table, .details-table { width:100%; border-spacing:0; border-left:1px solid #EEE; border-right:1px solid #EEE; border-bottom:1px solid #EEE; padding:0; } .caption { position:relative; text-align:left; background-repeat:no-repeat; color:#253441; font-weight:bold; clear:none; overflow:hidden; padding:0; padding-top:10px; padding-left:1px; margin:0; white-space:pre; } .caption a:link, .caption a:visited { color:#1f389c; } .caption a:hover, .caption a:active { color:#FFFFFF; } .caption span { white-space:nowrap; padding-top:5px; padding-left:12px; padding-right:12px; padding-bottom:7px; display:inline-block; float:left; background-color:#F8981D; border: none; height:16px; } div.table-tabs { padding:10px 0 0 1px; margin:0; } div.table-tabs > button { border: none; cursor: pointer; padding: 5px 12px 7px 12px; font-weight: bold; margin-right: 3px; } div.table-tabs > button.active-table-tab { background: #F8981D; color: #253441; } div.table-tabs > button.table-tab { background: #4D7A97; color: #FFFFFF; } .two-column-summary { display: grid; grid-template-columns: minmax(15%, max-content) minmax(15%, auto); } .three-column-summary { display: grid; grid-template-columns: minmax(10%, max-content) minmax(15%, max-content) minmax(15%, auto); } .four-column-summary { display: grid; grid-template-columns: minmax(10%, max-content) minmax(10%, max-content) minmax(10%, max-content) minmax(10%, auto); } @media screen and (max-width: 600px) { .two-column-summary { display: grid; grid-template-columns: 1fr; } } @media screen and (max-width: 800px) { .three-column-summary { display: grid; grid-template-columns: minmax(10%, max-content) minmax(25%, auto); } .three-column-summary .col-last { grid-column-end: span 2; } } @media screen and (max-width: 1000px) { .four-column-summary { display: grid; grid-template-columns: minmax(15%, max-content) minmax(15%, auto); } } .summary-table > div, .details-table > div { text-align:left; padding: 8px 3px 3px 7px; } .col-first, .col-second, .col-last, .col-constructor-name, .col-summary-item-name { vertical-align:top; padding-right:0; padding-top:8px; padding-bottom:3px; } .table-header { background:#dee3e9; font-weight: bold; } .col-first, .col-first { font-size:13px; } .col-second, .col-second, .col-last, .col-constructor-name, .col-summary-item-name, .col-last { font-size:13px; } .col-first, .col-second, .col-constructor-name { vertical-align:top; overflow: auto; } .col-last { white-space:normal; } .col-first a:link, .col-first a:visited, .col-second a:link, .col-second a:visited, .col-first a:link, .col-first a:visited, .col-second a:link, .col-second a:visited, .col-constructor-name a:link, .col-constructor-name a:visited, .col-summary-item-name a:link, .col-summary-item-name a:visited { font-weight:bold; } .even-row-color, .even-row-color .table-header { background-color:#FFFFFF; } .odd-row-color, .odd-row-color .table-header { background-color:#EEEEEF; } /* * Styles for contents. */ div.block { font-size:14px; font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; } .col-last div { padding-top:0; } .col-last a { padding-bottom:3px; } .module-signature, .package-signature, .type-signature, .member-signature { font-family:'DejaVu Sans Mono', monospace; font-size:14px; margin:14px 0; white-space: pre-wrap; } .module-signature, .package-signature, .type-signature { margin-top: 0; } .member-signature .type-parameters-long, .member-signature .parameters, .member-signature .exceptions { display: inline-block; vertical-align: top; white-space: pre; } .member-signature .type-parameters { white-space: normal; } /* * Styles for formatting effect. */ .source-line-no { color:green; padding:0 30px 0 0; } .block { display:block; margin:0 10px 5px 0; color:#474747; } .deprecated-label, .description-from-type-label, .implementation-label, .member-name-link, .module-label-in-package, .module-label-in-type, .package-label-in-type, .package-hierarchy-label, .type-name-label, .type-name-link, .search-tag-link, .preview-label { font-weight:bold; } .deprecation-comment, .help-footnote, .preview-comment { font-style:italic; } .deprecation-block { font-size:14px; font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; border-style:solid; border-width:thin; border-radius:10px; padding:10px; margin-bottom:10px; margin-right:10px; display:inline-block; } .preview-block { font-size:14px; font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; border-style:solid; border-width:thin; border-radius:10px; padding:10px; margin-bottom:10px; margin-right:10px; display:inline-block; } div.block div.deprecation-comment { font-style:normal; } details.invalid-tag, span.invalid-tag { font-size:14px; font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; background: #ffe6e6; border: thin solid #000000; border-radius:2px; padding: 2px 4px; display:inline-block; } details.invalid-tag summary { cursor: pointer; } /* * Styles specific to HTML5 elements. */ main, nav, header, footer, section { display:block; } /* * Styles for javadoc search. */ .ui-autocomplete-category { font-weight:bold; font-size:15px; padding:7px 0 7px 3px; background-color:#4D7A97; color:#FFFFFF; } .result-item { font-size:13px; } .ui-autocomplete { max-height:85%; max-width:65%; overflow-y:scroll; overflow-x:scroll; white-space:nowrap; box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); } ul.ui-autocomplete { position:fixed; z-index:999999; } ul.ui-autocomplete li { float:left; clear:both; min-width:100%; } .result-highlight { font-weight:bold; } #search-input { background-image:url('resources/glass.png'); background-size:13px; background-repeat:no-repeat; background-position:2px 3px; padding-left:20px; width: 250px; margin: 0; } #reset-button { background-color: transparent; background-image:url('resources/x.png'); background-repeat:no-repeat; background-size:contain; border:0; border-radius:0; width:12px; height:12px; position:absolute; right:12px; top:10px; font-size:0; } ::placeholder { color:#909090; opacity: 1; } .search-tag-desc-result { font-style:italic; font-size:11px; } .search-tag-holder-result { font-style:italic; font-size:12px; } .search-tag-result:target { background-color:yellow; } .module-graph span { display:none; position:absolute; } .module-graph:hover span { display:block; margin: -100px 0 0 100px; z-index: 1; } .inherited-list { margin: 10px 0 10px 0; } section.class-description { line-height: 1.4; } .summary section[class$="-summary"], .details section[class$="-details"], .class-uses .detail, .serialized-class-details { padding: 0px 20px 5px 10px; border: 1px solid #ededed; background-color: #f8f8f8; } .inherited-list, section[class$="-details"] .detail { padding:0 0 5px 8px; background-color:#ffffff; border:none; } .vertical-separator { padding: 0 5px; } ul.help-section-list { margin: 0; } ul.help-subtoc > li { display: inline-block; padding-right: 5px; font-size: smaller; } ul.help-subtoc > li::before { content: "\2022" ; padding-right:2px; } span.help-note { font-style: italic; } /* * Indicator icon for external links. */ main a[href*="://"]::after { content:""; display:inline-block; background-image:url('data:image/svg+xml; utf8, \ \ \ '); background-size:100% 100%; width:7px; height:7px; margin-left:2px; margin-bottom:4px; } main a[href*="://"]:hover::after, main a[href*="://"]:focus::after { background-image:url('data:image/svg+xml; utf8, \ \ \ '); } /* * Styles for user-provided tables. * * borderless: * No borders, vertical margins, styled caption. * This style is provided for use with existing doc comments. * In general, borderless tables should not be used for layout purposes. * * plain: * Plain borders around table and cells, vertical margins, styled caption. * Best for small tables or for complex tables for tables with cells that span * rows and columns, when the "striped" style does not work well. * * striped: * Borders around the table and vertical borders between cells, striped rows, * vertical margins, styled caption. * Best for tables that have a header row, and a body containing a series of simple rows. */ table.borderless, table.plain, table.striped { margin-top: 10px; margin-bottom: 10px; } table.borderless > caption, table.plain > caption, table.striped > caption { font-weight: bold; font-size: smaller; } table.borderless th, table.borderless td, table.plain th, table.plain td, table.striped th, table.striped td { padding: 2px 5px; } table.borderless, table.borderless > thead > tr > th, table.borderless > tbody > tr > th, table.borderless > tr > th, table.borderless > thead > tr > td, table.borderless > tbody > tr > td, table.borderless > tr > td { border: none; } table.borderless > thead > tr, table.borderless > tbody > tr, table.borderless > tr { background-color: transparent; } table.plain { border-collapse: collapse; border: 1px solid black; } table.plain > thead > tr, table.plain > tbody tr, table.plain > tr { background-color: transparent; } table.plain > thead > tr > th, table.plain > tbody > tr > th, table.plain > tr > th, table.plain > thead > tr > td, table.plain > tbody > tr > td, table.plain > tr > td { border: 1px solid black; } table.striped { border-collapse: collapse; border: 1px solid black; } table.striped > thead { background-color: #E3E3E3; } table.striped > thead > tr > th, table.striped > thead > tr > td { border: 1px solid black; } table.striped > tbody > tr:nth-child(even) { background-color: #EEE } table.striped > tbody > tr:nth-child(odd) { background-color: #FFF } table.striped > tbody > tr > th, table.striped > tbody > tr > td { border-left: 1px solid black; border-right: 1px solid black; } table.striped > tbody > tr > th { font-weight: normal; } /** * Tweak style for small screens. */ @media screen and (max-width: 920px) { header.flex-header { max-height: 100vh; overflow-y: auto; } div#navbar-top { height: 2.8em; transition: height 0.35s ease; } ul.nav-list { display: block; width: 40%; float:left; clear: left; margin: 10px 0 0 0; padding: 0; } ul.nav-list li { float: none; padding: 6px; margin-left: 10px; margin-top: 2px; } ul.sub-nav-list-small { display:block; height: 100%; width: 50%; float: right; clear: right; background-color: #dee3e9; color: #353833; margin: 6px 0 0 0; padding: 0; } ul.sub-nav-list-small ul { padding-left: 20px; } ul.sub-nav-list-small a:link, ul.sub-nav-list-small a:visited { color:#4A6782; } ul.sub-nav-list-small a:hover { color:#bb7a2a; } ul.sub-nav-list-small li { list-style:none; float:none; padding: 6px; margin-top: 1px; text-transform:uppercase; } ul.sub-nav-list-small > li { margin-left: 10px; } ul.sub-nav-list-small li p { margin: 5px 0; } div#navbar-sub-list { display: none; } .top-nav a:link, .top-nav a:active, .top-nav a:visited { display: block; } button#navbar-toggle-button { width: 3.4em; height: 2.8em; background-color: transparent; display: block; float: left; border: 0; margin: 0 10px; cursor: pointer; font-size: 10px; } button#navbar-toggle-button .nav-bar-toggle-icon { display: block; width: 24px; height: 3px; margin: 1px 0 4px 0; border-radius: 2px; transition: all 0.1s; background-color: #ffffff; } button#navbar-toggle-button.expanded span.nav-bar-toggle-icon:nth-child(1) { transform: rotate(45deg); transform-origin: 10% 10%; width: 26px; } button#navbar-toggle-button.expanded span.nav-bar-toggle-icon:nth-child(2) { opacity: 0; } button#navbar-toggle-button.expanded span.nav-bar-toggle-icon:nth-child(3) { transform: rotate(-45deg); transform-origin: 10% 90%; width: 26px; } } @media screen and (max-width: 800px) { .about-language { padding-right: 16px; } ul.nav-list li { margin-left: 5px; } ul.sub-nav-list-small > li { margin-left: 5px; } main { padding: 10px; } .summary section[class$="-summary"], .details section[class$="-details"], .class-uses .detail, .serialized-class-details { padding: 0 8px 5px 8px; } body { -webkit-text-size-adjust: none; } } @media screen and (max-width: 400px) { .about-language { font-size: 10px; padding-right: 12px; } } @media screen and (max-width: 400px) { .nav-list-search { width: 94%; } #search-input { width: 70%; } } @media screen and (max-width: 320px) { .nav-list-search > label { display: none; } .nav-list-search { width: 90%; } #search-input { width: 80%; } } pre.snippet { background-color: #ebecee; padding: 10px; margin: 12px 0; overflow: auto; white-space: pre; } div.snippet-container { position: relative; } button.snippet-copy { position: absolute; top: 6px; right: 6px; height: 1.7em; opacity: 50%; transition: opacity 0.2s; padding: 2px; border: none; cursor: pointer; background: none; } button.snippet-copy img { width: 18px; height: 18px; padding: 0.05em 0; background: none; } div.snippet-container:hover button.snippet-copy { opacity: 80%; } div.snippet-container button.snippet-copy:hover { opacity: 100%; } button.snippet-copy span { color: #3d3d3d; content: attr(aria-label); font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; font-size: 85%; line-height: 1.2em; padding: 0.2em; position: relative; white-space: nowrap; top: -0.5em; display: none; } div.snippet-container:hover button.snippet-copy span { display: inline; } button.snippet-copy:active { background: #d3d3d3; opacity: 100%; } @media screen and (max-width: 800px) { pre.snippet { padding-top: 26px; } button.snippet-copy { top: 4px; right: 4px; } } pre.snippet .italic { font-style: italic; } pre.snippet .bold { font-weight: bold; } pre.snippet .highlighted { background-color: #f7c590; border-radius: 10%; } ================================================ FILE: docs/tag-search-index.js ================================================ tagSearchIndex = [{"l":"Constant Field Values","h":"","u":"constant-values.html"}];updateSearchResults(); ================================================ FILE: docs/type-search-index.js ================================================ typeSearchIndex = [{"l":"All Classes and Interfaces","u":"allclasses-index.html"},{"p":"com.diogonunes.jcolor","l":"Ansi"},{"p":"com.diogonunes.jcolor","l":"AnsiFormat"},{"p":"com.diogonunes.jcolor","l":"Attribute"},{"p":"com.diogonunes.jcolor","l":"Command"}];updateSearchResults(); ================================================ FILE: pom.xml ================================================ 4.0.0 com.diogonunes JColor 5.5.2-SNAPSHOT bundle ${project.groupId}:${project.artifactId} An easy syntax to format your strings with colored fonts and backgrounds. https://github.com/dialex/JColor 2011 UTF-8 1.8 1.8 MIT License https://opensource.org/licenses/MIT repo Diogo Nunes email@diogonunes.com https://www.diogonunes.com scm:git:git@github.com/dialex/jcolor.git scm:git:git@github.com:dialex/jcolor.git git@github.com/dialex/jcolor/tree/main v5.2.0 ossrh https://oss.sonatype.org/content/repositories/snapshots ossrh https://oss.sonatype.org/service/local/staging/deploy/maven2/ org.apache.maven.plugins maven-compiler-plugin 3.10.1 ${maven.compiler.source} ${maven.compiler.target} org.apache.felix maven-bundle-plugin 5.1.5 true com.diogonunes*;version=${project.version} org.sonatype.plugins nexus-staging-maven-plugin 1.6.13 true ossrh https://oss.sonatype.org/ true org.apache.maven.plugins maven-source-plugin 3.2.1 attach-sources jar-no-fork org.apache.maven.plugins maven-javadoc-plugin 3.1.1 8 attach-javadocs jar org.apache.maven.plugins maven-gpg-plugin 1.6 sign-artifacts verify sign 70AC2DCF410F446BD81C82D603AEFF59C2E5C034 --pinentry-mode loopback org.apache.maven.plugins maven-release-plugin 2.5.3 true false release deploy v@{version} org.apache.maven.plugins maven-enforcer-plugin 3.0.0-M2 enforce-maven enforce 3.2.5 org.apache.maven.plugins maven-surefire-plugin 2.22.2 org.apache.felix maven-bundle-plugin 5.1.6 maven-plugin test org.hamcrest hamcrest-library 2.2 test org.junit.jupiter junit-jupiter-api 5.8.2 test org.junit.jupiter junit-jupiter-engine 5.8.2 test ================================================ FILE: src/main/java/com/diogonunes/jcolor/Ansi.java ================================================ package com.diogonunes.jcolor; /** * Provides a fluent API to generate * ANSI escape sequences * by specifying {@link Attribute}s of your format. */ public class Ansi { private static final char ESC = 27; // Escape character used to start an ANSI code private static final String NEWLINE = System.getProperty("line.separator"); /** * Every Ansi escape code begins with this PREFIX. */ public static final String PREFIX = ESC + "["; /** * Two options must be separated by this SEPARATOR. */ public static final String SEPARATOR = ";"; /** * Every Ansi escape code must end with this POSTFIX. */ public static final String POSTFIX = "m"; /** * Shorthand for the Ansi code that resets to the terminal's default format. */ public static final String RESET = PREFIX + Attribute.CLEAR() + POSTFIX; /** * @param attributes ANSI attributes to format a text. * @return The ANSI code that describes all those attributes together. */ public static String generateCode(Attribute... attributes) { StringBuilder builder = new StringBuilder(); builder.append(PREFIX); for (Object option : attributes) { String code = option.toString(); if (code.equals("")) continue; builder.append(code); builder.append(SEPARATOR); } builder.append(POSTFIX); // because code must not end with SEPARATOR return builder.toString().replace(SEPARATOR + POSTFIX, POSTFIX); } /** * @param attributes Object containing format attributes. * @return The ANSI code that describes all those attributes together. */ public static String generateCode(AnsiFormat attributes) { return generateCode(attributes.toArray()); } /** * @param command ANSI command to apply to terminal. * @return The ANSI code that describes that command. */ public static String generateCode(Command command) { return PREFIX + command; } /** * @param command Ansi command to apply to terminal. * @return The formatted string, ready to be printed. */ public static String colorize(Command command) { return generateCode(command); } /** * @param text String to format. * @param ansiCode Ansi code to format each message's lines. * @return The formatted string, ready to be printed. */ public static String colorize(String text, String ansiCode) { StringBuilder output = new StringBuilder(); /* * Every formatted line should: * 1) start with a code that sets the format * 2) end with a code that resets the format * This prevents "spilling" the format to other independent prints, which * is noticeable when the background is colored. */ output.append(ansiCode); // Each line needs to end the current format (RESET) and start it on the next line. // This avoids spilling, ie. a long line without text but formatted background String enclosedFormatting = text.replace(NEWLINE, RESET + NEWLINE + ansiCode); output.append(enclosedFormatting); output.append(RESET); return output.toString(); } /** * @param text String to format. * @param attributes ANSI attributes to format a text. * @return The formatted string, ready to be printed. */ public static String colorize(String text, Attribute... attributes) { String ansiCode = generateCode(attributes); return colorize(text, ansiCode); } /** * @param text String to format. * @param attributes Object containing format attributes. * @return The formatted string, ready to be printed. */ public static String colorize(String text, AnsiFormat attributes) { return colorize(text, attributes.toArray()); } /** * Easter egg. Just an alias of method "colorize". * * @param text String to format. * @param attributes ANSI attributes to format a text. * @return The formatted string, ready to be printed. */ public static String makeItFabulous(String text, Attribute... attributes) { return colorize(text, attributes); } } ================================================ FILE: src/main/java/com/diogonunes/jcolor/AnsiFormat.java ================================================ package com.diogonunes.jcolor; import java.util.ArrayList; import java.util.Arrays; /** * Abstracts an Array of {@link Attribute}s. * Use it if you find this more readable than Attribute[]. */ public class AnsiFormat { // Starts with capacity=2 because that's how many attributes are used on average private final ArrayList _attributes = new ArrayList<>(2); /** * @param attributes All ANSI attributes to format a text. */ public AnsiFormat(Attribute... attributes) { _attributes.addAll(Arrays.asList(attributes)); } /** * @param text String to format. * @return The formatted string, ready to be printed. */ public String format(String text) { return Ansi.colorize(text, this.toArray()); } protected Attribute[] toArray() { return _attributes.toArray(new Attribute[0]); } } ================================================ FILE: src/main/java/com/diogonunes/jcolor/Attribute.java ================================================ package com.diogonunes.jcolor; /** * Abstracts ANSI codes with intuitive names. It maps a description (e.g. RED_TEXT) with a code (e.g. 31). * @see Wikipedia, for a list of all codes available * @see StackOverflow, for a list of codes with examples */ public abstract class Attribute { /** * @return The Attribute's ansi escape code. */ @Override public abstract String toString(); // Effects public static Attribute NONE() { return new SimpleAttribute(""); } /** * @return Clears any format. Restores the terminal's default format. */ public static Attribute CLEAR() { return new SimpleAttribute("0"); } public static Attribute BOLD() { return new SimpleAttribute("1"); } /** * @return Alias of BOLD(). */ public static Attribute SATURATED() { return new SimpleAttribute("1"); } public static Attribute DIM() { return new SimpleAttribute("2"); } /** * @return Alias of DIM(). */ public static Attribute DESATURATED() { return new SimpleAttribute("2"); } public static Attribute ITALIC() { return new SimpleAttribute("3"); } public static Attribute UNDERLINE() { return new SimpleAttribute("4"); } public static Attribute SLOW_BLINK() { return new SimpleAttribute("5"); } public static Attribute RAPID_BLINK() { return new SimpleAttribute("6"); } public static Attribute REVERSE() { return new SimpleAttribute("7"); } public static Attribute HIDDEN() { return new SimpleAttribute("8"); } public static Attribute STRIKETHROUGH() { return new SimpleAttribute("9"); } public static Attribute FRAMED() { return new SimpleAttribute("51"); } public static Attribute ENCIRCLED() { return new SimpleAttribute("52"); } public static Attribute OVERLINED() { return new SimpleAttribute("53"); } // Colors (foreground) public static Attribute BLACK_TEXT() { return new SimpleAttribute("30"); } public static Attribute RED_TEXT() { return new SimpleAttribute("31"); } public static Attribute GREEN_TEXT() { return new SimpleAttribute("32"); } public static Attribute YELLOW_TEXT() { return new SimpleAttribute("33"); } public static Attribute BLUE_TEXT() { return new SimpleAttribute("34"); } public static Attribute MAGENTA_TEXT() { return new SimpleAttribute("35"); } public static Attribute CYAN_TEXT() { return new SimpleAttribute("36"); } public static Attribute WHITE_TEXT() { return new SimpleAttribute("37"); } // Colors (background) public static Attribute BLACK_BACK() { return new SimpleAttribute("40"); } public static Attribute RED_BACK() { return new SimpleAttribute("41"); } public static Attribute GREEN_BACK() { return new SimpleAttribute("42"); } public static Attribute YELLOW_BACK() { return new SimpleAttribute("43"); } public static Attribute BLUE_BACK() { return new SimpleAttribute("44"); } public static Attribute MAGENTA_BACK() { return new SimpleAttribute("45"); } public static Attribute CYAN_BACK() { return new SimpleAttribute("46"); } public static Attribute WHITE_BACK() { return new SimpleAttribute("47"); } // Bright colors (foreground) public static Attribute BRIGHT_BLACK_TEXT() { return new SimpleAttribute("90"); } public static Attribute BRIGHT_RED_TEXT() { return new SimpleAttribute("91"); } public static Attribute BRIGHT_GREEN_TEXT() { return new SimpleAttribute("92"); } public static Attribute BRIGHT_YELLOW_TEXT() { return new SimpleAttribute("93"); } public static Attribute BRIGHT_BLUE_TEXT() { return new SimpleAttribute("94"); } public static Attribute BRIGHT_MAGENTA_TEXT() { return new SimpleAttribute("95"); } public static Attribute BRIGHT_CYAN_TEXT() { return new SimpleAttribute("96"); } public static Attribute BRIGHT_WHITE_TEXT() { return new SimpleAttribute("97"); } // Bright colors (background) public static Attribute BRIGHT_BLACK_BACK() { return new SimpleAttribute("100"); } public static Attribute BRIGHT_RED_BACK() { return new SimpleAttribute("101"); } public static Attribute BRIGHT_GREEN_BACK() { return new SimpleAttribute("102"); } public static Attribute BRIGHT_YELLOW_BACK() { return new SimpleAttribute("103"); } public static Attribute BRIGHT_BLUE_BACK() { return new SimpleAttribute("104"); } public static Attribute BRIGHT_MAGENTA_BACK() { return new SimpleAttribute("105"); } public static Attribute BRIGHT_CYAN_BACK() { return new SimpleAttribute("106"); } public static Attribute BRIGHT_WHITE_BACK() { return new SimpleAttribute("107"); } // Complex colors /** * * @param colorNumber A number (0-255) that represents an 8-bit color. * @return An Attribute that represents a foreground with an 8-bit color. */ public static Attribute TEXT_COLOR(int colorNumber) { return new TextColorAttribute(colorNumber); } /** * * @param r A number (0-255) that represents the red component. * @param g A number (0-255) that represents the green component. * @param b A number (0-255) that represents the blue component. * @return An Attribute that represents a foreground with a true color. */ public static Attribute TEXT_COLOR(int r, int g, int b) { return new TextColorAttribute(r, g, b); } /** * * @param colorNumber A number (0-255) that represents an 8-bit color. * @return An Attribute that represents a background with an 8-bit color. */ public static Attribute BACK_COLOR(int colorNumber) { return new BackColorAttribute(colorNumber); } /** * * @param r A number (0-255) that represents the red component. * @param g A number (0-255) that represents the green component. * @param b A number (0-255) that represents the blue component. * @return An Attribute that represents a background with a true color. */ public static Attribute BACK_COLOR(int r, int g, int b) { return new BackColorAttribute(r, g, b); } } ================================================ FILE: src/main/java/com/diogonunes/jcolor/BackColorAttribute.java ================================================ package com.diogonunes.jcolor; class BackColorAttribute extends ColorAttribute { /** * {@inheritDoc} */ BackColorAttribute(int colorNumber) { super(colorNumber); } /** * {@inheritDoc} */ BackColorAttribute(int r, int g, int b) { super(r, g, b); } @Override protected String getColorAnsiPrefix() { String ANSI_8BIT_COLOR_PREFIX = "48;5;"; String ANSI_TRUE_COLOR_PREFIX = "48;2;"; return isTrueColor() ? ANSI_TRUE_COLOR_PREFIX : ANSI_8BIT_COLOR_PREFIX; } } ================================================ FILE: src/main/java/com/diogonunes/jcolor/ColorAttribute.java ================================================ package com.diogonunes.jcolor; import static java.lang.String.valueOf; abstract class ColorAttribute extends Attribute { protected final String[] _color; /** * Constructor (8-bit color). * * @param colorNumber A number (0-255) that represents an 8-bit color. */ ColorAttribute(int colorNumber) { if (0 <= colorNumber && colorNumber <= 255) { _color = new String[]{valueOf(colorNumber)}; } else throw new IllegalArgumentException("Color must be a number inside range [0-255]. Received: " + colorNumber); } /** * Constructor (true-color). * * @param r A number (0-255) that represents the red component. * @param g A number (0-255) that represents the green component. * @param b A number (0-255) that represents the blue component. */ ColorAttribute(int r, int g, int b) { if ((0 <= r && r <= 255) && (0 <= g && g <= 255) && (0 <= b && b <= 255)) { _color = new String[]{valueOf(r), valueOf(g), valueOf(b)}; } else throw new IllegalArgumentException( String.format("Color components must be a number inside range [0-255]. Received: %d, %d, %d", r, g, b)); } protected boolean isTrueColor() { return (_color.length == 3 ); } protected abstract String getColorAnsiPrefix(); protected String getColorAnsiCode() { if (isTrueColor()) return _color[0] + Ansi.SEPARATOR + _color[1] + Ansi.SEPARATOR + _color[2]; else return _color[0]; } @Override public String toString() { return getColorAnsiPrefix() + getColorAnsiCode(); } } ================================================ FILE: src/main/java/com/diogonunes/jcolor/Command.java ================================================ package com.diogonunes.jcolor; /** * Abstracts ANSI codes with intuitive names. It maps a command (e.g. CLEAR_SCREEN) with a code. */ public class Command { private final String _code; /** * Constructor. Maps a command to an Ansi code. * * @param code Ansi code that represents the command. */ Command(String code) { _code = code; } /** * @return Clears the terminal's text, e.g. just like the command-line `clear`. */ public static Command CLEAR_SCREEN() { // Covers https://github.com/dialex/JColor/issues/68 return new Command("H\\033[2J\""); } @Override public String toString() { return _code; } } ================================================ FILE: src/main/java/com/diogonunes/jcolor/SimpleAttribute.java ================================================ package com.diogonunes.jcolor; class SimpleAttribute extends Attribute { private final String _code; /** * Constructor. Maps an attribute to an Ansi code. * * @param code Ansi code that represents the attribute. */ SimpleAttribute(String code) { _code = code; } @Override public String toString() { return _code; } } ================================================ FILE: src/main/java/com/diogonunes/jcolor/TextColorAttribute.java ================================================ package com.diogonunes.jcolor; class TextColorAttribute extends ColorAttribute { /** * {@inheritDoc} */ TextColorAttribute(int colorNumber) { super(colorNumber); } /** * {@inheritDoc} */ TextColorAttribute(int r, int g, int b) { super(r, g, b); } @Override protected String getColorAnsiPrefix() { String ANSI_8BIT_COLOR_PREFIX = "38;5;"; String ANSI_TRUE_COLOR_PREFIX = "38;2;"; return isTrueColor() ? ANSI_TRUE_COLOR_PREFIX : ANSI_8BIT_COLOR_PREFIX; } } ================================================ FILE: src/test/java/com/diogonunes/jcolor/tests/acceptance/TestHumanEye.java ================================================ package com.diogonunes.jcolor.tests.acceptance; import com.diogonunes.jcolor.AnsiFormat; import com.diogonunes.jcolor.Attribute; import org.junit.jupiter.api.Disabled; import static com.diogonunes.jcolor.Ansi.colorize; import static com.diogonunes.jcolor.Attribute.*; import static com.diogonunes.jcolor.tests.unit.DataGenerator.randomInt; public class TestHumanEye { @Disabled public void ShouldLookGood() { /* ============== Usage examples ============== */ // Use Case 1: use Ansi.colorize() to format inline System.out.println(colorize("This text will be yellow on magenta", YELLOW_TEXT(), MAGENTA_BACK())); System.out.println("\n"); // Use Case 2: compose Attributes to create your desired format Attribute[] myFormat = new Attribute[]{RED_TEXT(), YELLOW_BACK(), BOLD()}; System.out.println(colorize("This text will be red on yellow", myFormat)); System.out.println("\n"); // Use Case 3: AnsiFormat is syntactic sugar for an array of Attributes AnsiFormat fWarning = new AnsiFormat(GREEN_TEXT(), BLUE_BACK(), BOLD()); System.out.println(colorize("AnsiFormat is just a pretty way to declare formats", fWarning)); System.out.println(fWarning.format("...and use those formats without calling colorize() directly")); System.out.println("\n"); // Use Case 4: you can define your formats and use them throughout your code AnsiFormat fInfo = new AnsiFormat(CYAN_TEXT()); AnsiFormat fError = new AnsiFormat(YELLOW_TEXT(), RED_BACK()); System.out.println(fInfo.format("This info message will be cyan")); System.out.println("This normal message will not be formatted"); System.out.println(fError.format("This error message will be yellow on red")); System.out.println("\n"); // Use Case 5: we support bright colors AnsiFormat fNormal = new AnsiFormat(MAGENTA_BACK(), YELLOW_TEXT()); AnsiFormat fBright = new AnsiFormat(BRIGHT_MAGENTA_BACK(), BRIGHT_YELLOW_TEXT()); System.out.println(fNormal.format("You can use normal colors ") + fBright.format(" and bright colors too")); // Use Case 6: we support 8-bit colors System.out.println("Any 8-bit color (0-255), as long as your terminal supports it:"); for (int i = 0; i <= 255; i++) { Attribute textColor = TEXT_COLOR(i); System.out.print(colorize(String.format("%4d", i), textColor)); } System.out.println("\n"); // Use Case 7: we support true colors (RGB) System.out.println("Any TrueColor (RGB), as long as your terminal supports it:"); for (int i = 0; i <= 300; i++) { Attribute bkgColor = BACK_COLOR(randomInt(255), randomInt(255), randomInt(255)); System.out.print(colorize(" ", bkgColor)); } System.out.println("\n"); // Credits System.out.print("This example used JColor 5.1.0 "); System.out.print(colorize("\tMADE ", BOLD(), BRIGHT_YELLOW_TEXT(), GREEN_BACK())); System.out.println(colorize("IN PORTUGAL\t", BOLD(), BRIGHT_YELLOW_TEXT(), RED_BACK())); System.out.println("I hope you find it useful ;)"); } } ================================================ FILE: src/test/java/com/diogonunes/jcolor/tests/unit/DataGenerator.java ================================================ package com.diogonunes.jcolor.tests.unit; import java.util.Random; import java.util.regex.Matcher; import java.util.regex.Pattern; public class DataGenerator { public static final String NEWLINE = System.getProperty("line.separator"); private static final Random _rand = new Random(); public static String createText() { return "Message"; } public static String createTextWithId(int n) { return "Message" + n; } public static String createTextLine() { return "This is a line" + NEWLINE; } public static int randomInt(int upperLimit) { return _rand.nextInt(upperLimit); } // Adapted from https://stackoverflow.com/a/2850495/675577 public static int countLines(String text) { Matcher m = Pattern.compile(NEWLINE).matcher(text); int lines = 0; while (m.find()) lines++; return lines; } } ================================================ FILE: src/test/java/com/diogonunes/jcolor/tests/unit/TestAnsi.java ================================================ package com.diogonunes.jcolor.tests.unit; import com.diogonunes.jcolor.Ansi; import com.diogonunes.jcolor.AnsiFormat; import com.diogonunes.jcolor.Attribute; import com.diogonunes.jcolor.Command; import org.junit.jupiter.api.Test; import java.util.regex.Matcher; import java.util.regex.Pattern; import static com.diogonunes.jcolor.Ansi.*; import static com.diogonunes.jcolor.Attribute.*; import static com.diogonunes.jcolor.tests.unit.DataGenerator.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** * Tests for Ansi class. */ public class TestAnsi { public static final String NEWLINE = System.getProperty("line.separator"); @Test public void Configuration_EscapeCodes() { // ARRANGE // ACT // ASSERT char escapeChar = 27; // according to spec: https://en.wikipedia.org/wiki/ANSI_escape_code#Escape_sequences assertThat(PREFIX, equalTo(escapeChar + "[")); assertThat(POSTFIX, equalTo("m")); assertThat(SEPARATOR, equalTo(";")); } @Test public void GenerateCode_ZeroAttributes() { // ARRANGE Attribute[] attributes = new Attribute[]{}; // ACT String code = Ansi.generateCode(attributes); // ASSERT String expectedCode = PREFIX + POSTFIX; assertThat(code, equalTo(expectedCode)); } @Test // Covers https://github.com/dialex/JColor/issues/56 public void GenerateCode_OneCommand() { // ARRANGE Command command = Command.CLEAR_SCREEN(); // ACT String code = Ansi.generateCode(command); // ASSERT String expectedCode = PREFIX + command; assertThat(code, equalTo(expectedCode)); } @Test // Covers https://github.com/dialex/JColor/issues/68 public void GenerateCode_ComplexCommand() { // ARRANGE int totalCommands = 0; Command command = Command.CLEAR_SCREEN(); // ACT String code = generateCode(command); // ASSERT Matcher prefix = (Pattern.compile("\\[")).matcher(code); while (prefix.find()) totalCommands++; assertThat(totalCommands, equalTo(2)); } @Test // Covers https://github.com/dialex/JColor/issues/6 public void GenerateCode_OneAttribute_Simple() { // ARRANGE Attribute[] attributes = new Attribute[]{STRIKETHROUGH()}; // ACT String code = Ansi.generateCode(attributes); // ASSERT String expectedCode = PREFIX + attributes[0] + POSTFIX; assertThat(code, equalTo(expectedCode)); } @Test public void GenerateCode_OneAttribute_Color() { // ARRANGE Attribute[] attributes = new Attribute[]{TEXT_COLOR(225)}; // ACT String code = Ansi.generateCode(attributes); // ASSERT String expectedCode = PREFIX + attributes[0] + POSTFIX; assertThat(code, equalTo(expectedCode)); } @Test public void GenerateCode_MultipleAttributes_HandlesArray() { // ARRANGE Attribute[] attributes = new Attribute[]{DIM(), CYAN_TEXT()}; // ACT String code = Ansi.generateCode(attributes); // ASSERT String expectedCode = PREFIX + attributes[0] + SEPARATOR + attributes[1] + POSTFIX; assertThat(code, equalTo(expectedCode)); } @Test public void GenerateCode_MultipleAttributes_HandlesAnsiFormat() { // ARRANGE AnsiFormat attributes = new AnsiFormat(DIM(), CYAN_TEXT()); // ACT String code = Ansi.generateCode(attributes); // ASSERT String expectedCode = PREFIX + DIM() + SEPARATOR + CYAN_TEXT() + POSTFIX; assertThat(code, equalTo(expectedCode)); } @Test public void GenerateCode_MultipleAttributes_HandlesMultipleParams() { // ARRANGE Attribute firstAttribute = UNDERLINE(); Attribute secondAttribute = GREEN_TEXT(); // ACT String code = Ansi.generateCode(firstAttribute, secondAttribute); // ASSERT String expectedCode = PREFIX + firstAttribute + SEPARATOR + secondAttribute + POSTFIX; assertThat(code, equalTo(expectedCode)); } @Test public void GenerateCode_MultipleAttributes_HandlesAttributesWithoutCode() { // ARRANGE Attribute[] attributes = new Attribute[]{NONE(), NONE(), NONE()}; // ACT String code = Ansi.generateCode(attributes); // ASSERT String expectedCode = PREFIX + POSTFIX; assertThat(code, equalTo(expectedCode)); } @Test // Covers https://github.com/dialex/JColor/issues/6 public void GenerateCode_MultiplesAttributes_HandlesAttributesMixedWithNone() { // ARRANGE Attribute[] attributes = new Attribute[]{NONE(), BLUE_TEXT(), NONE()}; // ACT String code = Ansi.generateCode(attributes); // ASSERT String expectedCode = PREFIX + attributes[1] + POSTFIX; assertThat(code, equalTo(expectedCode)); int suffixIndex = code.lastIndexOf(POSTFIX); assertThat("Code ending in semicolon does not show color", code.charAt(suffixIndex - 1), is(not(';'))); } @Test public void Colorize_TextWithoutLines() { // ARRANGE Attribute[] attributes = new Attribute[]{YELLOW_BACK()}; String text = createText(); // ACT String formattedText = Ansi.colorize(text, attributes); //System.out.println(formattedText); // ASSERT String expectedCode = Ansi.generateCode(attributes); assertThat(formattedText, startsWith(expectedCode)); assertThat("Message should clear its format", formattedText, endsWith(Ansi.RESET)); } @Test // Covers https://github.com/dialex/JColor/issues/56 public void Colorize_SingleCommand() { // ARRANGE Command command = Command.CLEAR_SCREEN(); String text = createTextLine(); // ACT String formattedCommand = Ansi.colorize(command); //System.out.println(formattedText); // ASSERT String expectedCode = Ansi.generateCode(command); assertThat(formattedCommand, equalTo(expectedCode)); } @Test // Covers https://github.com/dialex/JColor/issues/38 public void Colorize_TextWithSingleLine() { // ARRANGE Attribute[] attributes = new Attribute[]{GREEN_BACK()}; String text = createTextLine(); // ACT String formattedText = Ansi.colorize(text, attributes); //System.out.println(formattedText); // ASSERT String expectedCode = Ansi.generateCode(attributes); assertThat("Format must be cleared before changing line, to avoid format spillage", formattedText, endsWith(Ansi.RESET)); } @Test // Covers https://github.com/dialex/JColor/issues/38 public void Colorize_TextWithMultiplesLines() { // ARRANGE Attribute[] attributes = new Attribute[]{RED_BACK()}; String text1 = createTextWithId(1), text2 = createTextWithId(2); String fullText = text1 + NEWLINE + text2 + NEWLINE; // ACT String formattedText = Ansi.colorize(fullText, attributes); //System.out.println(formattedText); // ASSERT String expectedCode = Ansi.generateCode(attributes); assertThat("Middle lines preserve format", formattedText, containsString(expectedCode + text2 + Ansi.RESET)); assertThat(formattedText, endsWith(Ansi.RESET)); } @Test // Covers https://github.com/dialex/JColor/issues/51 public void Colorize_TextWithMultipleEmptyLines() { // ARRANGE Attribute[] attributes = new Attribute[]{(CYAN_BACK())}; String emptyLines = NEWLINE + NEWLINE + NEWLINE; String fullText = createText() + emptyLines; // ACT String formattedText = Ansi.colorize(fullText, attributes); //System.out.println(formattedText); // ASSERT assertThat("Empty lines are not deleted", countLines(formattedText), equalTo(countLines(emptyLines))); assertThat(formattedText, endsWith(Ansi.RESET)); } @Test // Covers https://github.com/dialex/JColor/issues/51 public void Colorize_TextWithMiddleEmptyLines() { // ARRANGE Attribute[] attributes = new Attribute[]{(CYAN_BACK())}; String text1 = createTextWithId(1), text2 = createTextWithId(2); String fullText = text1 + NEWLINE + NEWLINE + text2; // ACT String formattedText = Ansi.colorize(fullText, attributes); System.out.println(formattedText); // ASSERT assertThat("Middle empty lines are not deleted", countLines(formattedText), equalTo(countLines(fullText))); assertThat(formattedText, endsWith(Ansi.RESET)); } @Test public void Colorize_ConflictingAttributes_UsesTheLast() { // ARRANGE Attribute[] attributes = new Attribute[]{BLACK_BACK(), WHITE_BACK(), BLUE_BACK()}; String text = "This text will have a blue back"; // ACT String formattedText = Ansi.colorize(text, attributes); //System.out.println(formattedText); // ASSERT String expectedCode = Ansi.generateCode(attributes); assertThat(formattedText, startsWith(expectedCode)); assertThat("Message should clear its format", formattedText, endsWith(Ansi.RESET)); } } ================================================ FILE: src/test/java/com/diogonunes/jcolor/tests/unit/TestAttribute.java ================================================ package com.diogonunes.jcolor.tests.unit; import com.diogonunes.jcolor.Attribute; import org.junit.jupiter.api.Test; import static com.diogonunes.jcolor.Ansi.SEPARATOR; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** * Assert that each Attribute outputs the correct Ansi code. */ public class TestAttribute { // Effects @Test public void Attribute_AnsiCode_None() { // ARRANGE Attribute attribute = Attribute.NONE(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = ""; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Clear() { // ARRANGE Attribute attribute = Attribute.CLEAR(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "0"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Bold() { // ARRANGE Attribute attribute = Attribute.BOLD(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "1"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Saturated() { // ARRANGE Attribute attribute = Attribute.SATURATED(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "1"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Dim() { // ARRANGE Attribute attribute = Attribute.DIM(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "2"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Desaturated() { // ARRANGE Attribute attribute = Attribute.DESATURATED(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "2"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Italic() { // ARRANGE Attribute attribute = Attribute.ITALIC(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "3"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Underline() { // ARRANGE Attribute attribute = Attribute.UNDERLINE(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "4"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Slow_blink() { // ARRANGE Attribute attribute = Attribute.SLOW_BLINK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "5"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Rapid_blink() { // ARRANGE Attribute attribute = Attribute.RAPID_BLINK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "6"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Reverse() { // ARRANGE Attribute attribute = Attribute.REVERSE(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "7"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Hidden() { // ARRANGE Attribute attribute = Attribute.HIDDEN(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "8"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Strikethrough() { // ARRANGE Attribute attribute = Attribute.STRIKETHROUGH(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "9"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Framed() { // ARRANGE Attribute attribute = Attribute.FRAMED(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "51"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Encircled() { // ARRANGE Attribute attribute = Attribute.ENCIRCLED(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "52"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_Overlined() { // ARRANGE Attribute attribute = Attribute.OVERLINED(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "53"; assertThat(code, equalTo(expectedAnsiCode)); } // Colors (foreground) @Test public void Attribute_AnsiCode_BlackText() { // ARRANGE Attribute attribute = Attribute.BLACK_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "30"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_RedText() { // ARRANGE Attribute attribute = Attribute.RED_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "31"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_GreenText() { // ARRANGE Attribute attribute = Attribute.GREEN_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "32"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_YellowText() { // ARRANGE Attribute attribute = Attribute.YELLOW_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "33"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BlueText() { // ARRANGE Attribute attribute = Attribute.BLUE_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "34"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_MagentaText() { // ARRANGE Attribute attribute = Attribute.MAGENTA_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "35"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_CyanText() { // ARRANGE Attribute attribute = Attribute.CYAN_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "36"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_WhiteText() { // ARRANGE Attribute attribute = Attribute.WHITE_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "37"; assertThat(code, equalTo(expectedAnsiCode)); } // Colors (background) @Test public void Attribute_AnsiCode_BlackBack() { // ARRANGE Attribute attribute = Attribute.BLACK_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "40"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_RedBack() { // ARRANGE Attribute attribute = Attribute.RED_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "41"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_GreenBack() { // ARRANGE Attribute attribute = Attribute.GREEN_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "42"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_YellowBack() { // ARRANGE Attribute attribute = Attribute.YELLOW_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "43"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BlueBack() { // ARRANGE Attribute attribute = Attribute.BLUE_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "44"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_MagentaBack() { // ARRANGE Attribute attribute = Attribute.MAGENTA_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "45"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_CyanBack() { // ARRANGE Attribute attribute = Attribute.CYAN_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "46"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_WhiteBack() { // ARRANGE Attribute attribute = Attribute.WHITE_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "47"; assertThat(code, equalTo(expectedAnsiCode)); } // Bright colors (foreground) @Test public void Attribute_AnsiCode_BrightBlackText() { // ARRANGE Attribute attribute = Attribute.BRIGHT_BLACK_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "90"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightRedText() { // ARRANGE Attribute attribute = Attribute.BRIGHT_RED_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "91"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightGreenText() { // ARRANGE Attribute attribute = Attribute.BRIGHT_GREEN_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "92"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightYellowText() { // ARRANGE Attribute attribute = Attribute.BRIGHT_YELLOW_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "93"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightBlueText() { // ARRANGE Attribute attribute = Attribute.BRIGHT_BLUE_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "94"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightMagentaText() { // ARRANGE Attribute attribute = Attribute.BRIGHT_MAGENTA_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "95"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightCyanText() { // ARRANGE Attribute attribute = Attribute.BRIGHT_CYAN_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "96"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightWhiteText() { // ARRANGE Attribute attribute = Attribute.BRIGHT_WHITE_TEXT(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "97"; assertThat(code, equalTo(expectedAnsiCode)); } // Bright colors (background) @Test public void Attribute_AnsiCode_BrightBlackBack() { // ARRANGE Attribute attribute = Attribute.BRIGHT_BLACK_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "100"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightRedBack() { // ARRANGE Attribute attribute = Attribute.BRIGHT_RED_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "101"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightGreenBack() { // ARRANGE Attribute attribute = Attribute.BRIGHT_GREEN_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "102"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightYellowBack() { // ARRANGE Attribute attribute = Attribute.BRIGHT_YELLOW_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "103"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightBlueBack() { // ARRANGE Attribute attribute = Attribute.BRIGHT_BLUE_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "104"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightMagentaBack() { // ARRANGE Attribute attribute = Attribute.BRIGHT_MAGENTA_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "105"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightCyanBack() { // ARRANGE Attribute attribute = Attribute.BRIGHT_CYAN_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "106"; assertThat(code, equalTo(expectedAnsiCode)); } @Test public void Attribute_AnsiCode_BrightWhiteBack() { // ARRANGE Attribute attribute = Attribute.BRIGHT_WHITE_BACK(); // ACT String code = attribute.toString(); // ASSERT String expectedAnsiCode = "107"; assertThat(code, equalTo(expectedAnsiCode)); } // Complex colors @Test public void Attribute_AnsiCode_Text8bitColor() { // ARRANGE int colorNumber = 225; Attribute attribute = Attribute.TEXT_COLOR(colorNumber); String ansiCodeFor8bitForeColor = "38;5;"; // ACT String code = attribute.toString(); // ASSERT String expectedCode = ansiCodeFor8bitForeColor + colorNumber; assertThat(code, equalTo(expectedCode)); } @Test public void Attribute_AnsiCode_TextTrueColor() { // ARRANGE int r = 255, g = 160, b = 122; Attribute attribute = Attribute.TEXT_COLOR(r, g, b); String ansiCodeForRGBForeColor = "38;2;"; // ACT String code = attribute.toString(); // ASSERT String expectedCode = ansiCodeForRGBForeColor + r + SEPARATOR + g + SEPARATOR + b; assertThat(code, equalTo(expectedCode)); } @Test public void Attribute_AnsiCode_Back8bitColor() { // ARRANGE int colorNumber = 225; Attribute attribute = Attribute.BACK_COLOR(colorNumber); String ansiCodeFor8bitBackColor = "48;5;"; // ACT String code = attribute.toString(); // ASSERT String expectedCode = ansiCodeFor8bitBackColor + colorNumber; assertThat(code, equalTo(expectedCode)); } @Test public void Attribute_AnsiCode_BackTrueColor() { // ARRANGE int r = 160, g = 122, b = 255; Attribute attribute = Attribute.BACK_COLOR(r, g, b); String ansiCodeForRGBBackColor = "48;2;"; // ACT String code = attribute.toString(); // ASSERT String expectedCode = ansiCodeForRGBBackColor + r + SEPARATOR + g + SEPARATOR + b; assertThat(code, equalTo(expectedCode)); } } ================================================ FILE: src/test/java/com/diogonunes/jcolor/tests/unit/TestCommand.java ================================================ package com.diogonunes.jcolor.tests.unit; import com.diogonunes.jcolor.Command; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** * Assert that each Command outputs the correct Ansi code. */ public class TestCommand { @Test public void Attribute_AnsiCode_ClearScreen() { // ARRANGE Command command = Command.CLEAR_SCREEN(); // ACT String code = command.toString(); // ASSERT String expectedAnsiCode = "H\\033[2J\""; assertThat(code, equalTo(expectedAnsiCode)); } } ================================================ FILE: src/test/java/com/diogonunes/jcolor/tests/unit/TestDataGenerator.java ================================================ package com.diogonunes.jcolor.tests.unit; import org.junit.jupiter.api.Test; import static com.diogonunes.jcolor.tests.unit.DataGenerator.NEWLINE; import static com.diogonunes.jcolor.tests.unit.DataGenerator.countLines; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; public class TestDataGenerator { @Test public void CountLines_NoText() { String text = ""; assertThat(countLines(text), equalTo(0)); } @Test public void CountLines_Inline() { String text = "A sentence without a newline"; assertThat(countLines(text), equalTo(0)); } @Test public void CountLines_OneLine() { String text = "A single line" + NEWLINE; assertThat(countLines(text), equalTo(1)); } @Test public void CountLines_MultipleEmptyLines() { String text = "A single line" + NEWLINE + NEWLINE + NEWLINE; assertThat(countLines(text), equalTo(3)); } @Test public void CountLines_MultipleMiddleLines() { String text = "Preface" + NEWLINE + NEWLINE + "Body" + NEWLINE + "Ending"; assertThat(countLines(text), equalTo(3)); } } ================================================ FILE: src/test/java/com/diogonunes/jcolor/tests/unit/TestUsage.java ================================================ package com.diogonunes.jcolor.tests.unit; import com.diogonunes.jcolor.Ansi; import com.diogonunes.jcolor.AnsiFormat; import com.diogonunes.jcolor.Attribute; import org.junit.jupiter.api.Test; import static com.diogonunes.jcolor.Ansi.*; import static com.diogonunes.jcolor.Attribute.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; public class TestUsage { @Test public void CanFormatWithOneAttribute() { // ARRANGE AnsiFormat fInfo = new AnsiFormat(CYAN_BACK()); // ACT String formattedText = fInfo.format("This text will have a cyan back"); //System.out.println(formattedText); // ASSERT String expectedCode = Ansi.generateCode(fInfo); assertThat(formattedText, startsWith(expectedCode)); assertThat("Message should clear its format", formattedText, endsWith(Ansi.RESET)); } @Test public void CanFormatWithMultipleAttributes() { // ARRANGE AnsiFormat fWarning = new AnsiFormat(RED_TEXT(), YELLOW_BACK(), BOLD()); // ACT String formattedText = fWarning.format("This bold text will be red on yellow"); //System.out.println(formattedText); // ASSERT String expectedCode = Ansi.generateCode(fWarning); assertThat(formattedText, startsWith(expectedCode)); assertThat("Message should clear its format", formattedText, endsWith(Ansi.RESET)); } @Test public void CanFormatWithTrueColorAttributes() { // ARRANGE AnsiFormat fWarning = new AnsiFormat(TEXT_COLOR(202), BACK_COLOR(225, 255, 47), BOLD()); // ACT String formattedText = fWarning.format("This bold text will be kinda-orange on greenish-yellow"); //System.out.println(formattedText); // ASSERT String expectedCode = Ansi.generateCode(fWarning); assertThat(formattedText, startsWith(expectedCode)); assertThat("Message should clear its format", formattedText, endsWith(Ansi.RESET)); } @Test public void CanFormatInline() { // ARRANGE // ACT String formattedText = colorize("This text will be yellow on magenta", YELLOW_TEXT(), MAGENTA_BACK()); //System.out.println(formattedText); // ASSERT String expectedCode = Ansi.generateCode(YELLOW_TEXT(), MAGENTA_BACK()); assertThat(formattedText, startsWith(expectedCode)); assertThat("Message should clear its format", formattedText, endsWith(Ansi.RESET)); } @Test public void CanMakeItFabulous() { // ARRANGE String text = "This text will be magenta"; // ACT String formattedText = makeItFabulous(text, MAGENTA_TEXT()); // ASSERT assertThat(formattedText, equalTo(colorize(text, MAGENTA_TEXT()))); } @Test public void CanUseAnsiFormatOrArray() { // ARRANGE AnsiFormat formatNotation = new AnsiFormat(BLACK_TEXT(), BLACK_BACK()); Attribute[] arrayNotation = new Attribute[]{BLACK_TEXT(), BLACK_BACK()}; String text = "This text will be black on black"; // ACT String formatNotationOutput = formatNotation.format(text); String arrayNotationOutput = Ansi.colorize(text, arrayNotation); // ASSERT assertThat(formatNotationOutput, equalTo(arrayNotationOutput)); assertThat(formatNotationOutput.compareTo(arrayNotationOutput), equalTo(0)); } }