项目作者: beryx

项目描述 :
AWT Color Factory
高级语言: Java
项目地址: git://github.com/beryx/awt-color-factory.git
创建时间: 2018-06-29T21:33:09Z
项目社区:https://github.com/beryx/awt-color-factory

开源协议:Other

下载


PRs Welcome
License
Build Status
Javadocs

AWT Color Factory

:bulb: You can use this library regardless of the license under which your software is distributed.

In JavaFX you can easily create a javafx.scene.paint.Color object from a string representation such as
“lightblue”, “#aa38e0”, or “0x40A8CC” by using
Color.web(String colorString)),
Color.web(String colorString, double opacity)),
or Color.valueOf(String value)).

This one-class project provides equivalent methods for creating java.awt.Color objects.

Example usage

  1. Color c1 = ColorFactory.valueOf("firebrick");
  2. Color c2 = ColorFactory.valueOf("#aa38e0");
  3. Color c3 = ColorFactory.valueOf("0x40A8CC");
  4. Color c4 = ColorFactory.valueOf("rgba(112,36,228,0.9)");
  5. Color c5 = ColorFactory.web("forestgreen", 0.7);
  6. Color c6 = ColorFactory.web("hsl(270,90%,70%)", 0.8);

See the javadoc
for more details.

Why should you use this library? Can’t you just call the JavaFX methods and convert the returned javafx.scene.paint.Color into a java.awt.Color?
Of course you can. But you may find this little library useful if you don’t want your code to depend on JavaFX.
And remember, starting with JDK 11, JavaFX is no longer part of the JDK.

AWT Color Factory is available in JCenter and Maven Central.

Maven

  1. <dependency>
  2. <groupId>org.beryx</groupId>
  3. <artifactId>awt-color-factory</artifactId>
  4. <version>1.0.1</version>
  5. </dependency>

Gradle

  1. compile 'org.beryx:awt-color-factory:1.0.1'

AWT Color Factory contains code that is almost identical to that found in javafx.scene.paint.Color,
therefore the library is distributed under the same license as OpenJFX: the GPL 2 with Classpath exception.
The Classpath exception clause gives you permission to include this library in your executable code,
regardless of the license under which your software is distributed.

This library requires Java 7 or newer.
The jar artifact is modularized under the name org.beryx.awt.color.