/dimmingplan

Realize timetable based dimming with interpolation in Java.

Primary LanguageJavaApache License 2.0Apache-2.0

Release Quality Gate Status codebeat badge Known Vulnerabilities FOSSA Status Hits-of-Code

dimmingplan | dimming timetable for Java

Realize timetable based dimming with interpolation in Java.

PROJECT INFORMATION

Project website: https://github.com/albahrani/dimmingplan
Project issues list: https://github.com/albahrani/dimmingplan/issues

Release builds are available from Maven Central

  <dependency>
    <groupId>com.github.albahrani</groupId>
    <artifactId>dimmingplan</artifactId>
    <version>0.0.3</version>
  </dependency>

Snapshot builds are available via

  <dependency>
    <groupId>com.github.albahrani</groupId>
    <artifactId>dimmingplan</artifactId>
    <version>0.0.4-SNAPSHOT</version>
  </dependency>

Don't forget to enable snapshots in your repsitory config

  <repository>
    <id>sonatype-snapshots-repo</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    <releases><enabled>false</enabled></releases>
    <snapshots><enabled>true</enabled></snapshots>
  </repository>

LICENSE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

FOSSA Status

USAGE

Create a dimming plan

  DimmingPlan plan = DimmingPlan.create();

Create a Channel

  DimmingPlan plan = DimmingPlan.create();
  DimmingPlanChannel channel = plan.channel("ch1");

Define a Timetable entry

  channel.define(LocalTime.of(6, 0), 0.0d);		

Interpolate the plan / channel

  plan.interpolate();
  channel.interpolate();

Use fluent API

  DimmingPlan.create()
      .channel("ch1")
          .define(LocalTime.of(6, 0), 0.0d)
          .define(LocalTime.of(12, 0), 100.0d)
          .define(LocalTime.of(21, 0), 0.0d)
      .channel("ch2")
          .define(LocalTime.of(0, 0), 33.0d)
      .interpolate();

Retrieve the percentage for a certain time

  OptionalDouble percentage = plan.channel("ch1").getPercentage(LocalTime.of(6, 0));