当前位置: 首页>>代码示例>>Java>>正文


Java TimeSection类代码示例

本文整理汇总了Java中eu.hansolo.medusa.TimeSection的典型用法代码示例。如果您正苦于以下问题:Java TimeSection类的具体用法?Java TimeSection怎么用?Java TimeSection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TimeSection类属于eu.hansolo.medusa包,在下文中一共展示了TimeSection类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawTimeSections

import eu.hansolo.medusa.TimeSection; //导入依赖的package包/类
public static void drawTimeSections(final Clock CLOCK, final GraphicsContext CTX, final List<TimeSection> SECTIONS, final double SIZE,
                                    final double XY_INSIDE, final double XY_OUTSIDE, final double WH_INSIDE, final double WH_OUTSIDE,
                                    final double LINE_WIDTH) {
    if (SECTIONS.isEmpty()) return;
    TickLabelLocation tickLabelLocation = CLOCK.getTickLabelLocation();
    ZonedDateTime     time              = CLOCK.getTime();
    boolean           isAM              = time.get(ChronoField.AMPM_OF_DAY) == 0;
    double            xy                = TickLabelLocation.INSIDE == tickLabelLocation ? XY_INSIDE * SIZE : XY_OUTSIDE * SIZE;
    double            wh                = TickLabelLocation.INSIDE == tickLabelLocation ? WH_INSIDE * SIZE : WH_OUTSIDE * SIZE;
    double            offset            = 90;
    int               listSize          = SECTIONS.size();
    double            angleStep         = 360.0 / 60.0;
    boolean           highlightSections = CLOCK.isHighlightSections();
    for (int i = 0 ; i < listSize ; i++) {
        TimeSection section   = SECTIONS.get(i);
        LocalTime   start     = section.getStart();
        LocalTime   stop      = section.getStop();
        boolean     isStartAM = start.get(ChronoField.AMPM_OF_DAY) == 0;
        boolean     isStopAM  = stop.get(ChronoField.AMPM_OF_DAY) == 0;
        boolean     draw      = isAM ? (isStartAM || isStopAM) :(!isStartAM || !isStopAM);
        if (draw) {
            double sectionStartAngle = (start.getHour() % 12 * 5.0 + start.getMinute() / 12.0 + start.getSecond() / 300.0) * angleStep + 180;
            double sectionAngleExtend = ((stop.getHour() - start.getHour()) % 12 * 5.0 + (stop.getMinute() - start.getMinute()) / 12.0 + (stop.getSecond() - start.getSecond()) / 300.0) * angleStep;
            //TODO: Add an indicator to the section like -1 or similar
            // check if start was already yesterday
            if (start.getHour() > stop.getHour()) { sectionAngleExtend = (360.0 - Math.abs(sectionAngleExtend)); }
            CTX.save();
            if (highlightSections) {
                CTX.setStroke(section.contains(time.toLocalTime()) ? section.getHighlightColor() : section.getColor());
            } else {
                CTX.setStroke(section.getColor());
            }
            CTX.setLineWidth(SIZE * LINE_WIDTH);
            CTX.setLineCap(StrokeLineCap.BUTT);
            CTX.strokeArc(xy, xy, wh, wh, -(offset + sectionStartAngle), -sectionAngleExtend, ArcType.OPEN);
            CTX.restore();
        }
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:40,代码来源:Helper.java

示例2: drawTimeAreas

import eu.hansolo.medusa.TimeSection; //导入依赖的package包/类
public static void drawTimeAreas(final Clock CLOCK, final GraphicsContext CTX, final List<TimeSection> AREAS, final double SIZE,
                                 final double XY_INSIDE, final double XY_OUTSIDE, final double WH_INSIDE, final double WH_OUTSIDE) {
    if (AREAS.isEmpty()) return;
    TickLabelLocation tickLabelLocation = CLOCK.getTickLabelLocation();
    ZonedDateTime     time              = CLOCK.getTime();
    boolean           isAM              = time.get(ChronoField.AMPM_OF_DAY) == 0;
    double            xy                = TickLabelLocation.OUTSIDE == tickLabelLocation ? XY_OUTSIDE * SIZE : XY_INSIDE * SIZE;
    double            wh                = TickLabelLocation.OUTSIDE == tickLabelLocation ? WH_OUTSIDE * SIZE : WH_INSIDE * SIZE;
    double            offset            = 90;
    double            angleStep         = 360.0 / 60.0;
    int               listSize          = AREAS.size();
    boolean           highlightAreas    = CLOCK.isHighlightAreas();
    for (int i = 0; i < listSize ; i++) {
        TimeSection area      = AREAS.get(i);
        LocalTime   start     = area.getStart();
        LocalTime   stop      = area.getStop();
        boolean     isStartAM = start.get(ChronoField.AMPM_OF_DAY) == 0;
        boolean     isStopAM  = stop.get(ChronoField.AMPM_OF_DAY) == 0;
        boolean     draw      = isAM ? (isStartAM || isStopAM) :(!isStartAM || !isStopAM);
        if (draw) {
            double areaStartAngle  = (start.getHour() % 12 * 5.0 + start.getMinute() / 12.0 + start.getSecond() / 300.0) * angleStep + 180;;
            double areaAngleExtend = ((stop.getHour() - start.getHour()) % 12 * 5.0 + (stop.getMinute() - start.getMinute()) / 12.0 + (stop.getSecond() - start.getSecond()) / 300.0) * angleStep;
            //TODO: Add an indicator to the area like -1 or similar
            // check if start was already yesterday
            if (start.getHour() > stop.getHour()) { areaAngleExtend = (360.0 - Math.abs(areaAngleExtend)); }
            CTX.save();
            if (highlightAreas) {
                CTX.setFill(area.contains(time.toLocalTime()) ? area.getHighlightColor() : area.getColor());
            } else {
                CTX.setFill(area.getColor());
            }
            CTX.fillArc(xy, xy, wh, wh, -(offset + areaStartAngle), -areaAngleExtend, ArcType.ROUND);
            CTX.restore();
        }
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:37,代码来源:Helper.java

示例3: init

import eu.hansolo.medusa.TimeSection; //导入依赖的package包/类
@Override public void init() {
    TimeSection gardenLightOn = TimeSectionBuilder.create()
                                                  .start(LocalTime.now().plusHours(1))
                                                  .stop(LocalTime.now().plusHours(3))
                                                  .color(Color.rgb(200, 100, 0, 0.1))
                                                  .highlightColor(Color.rgb(222, 111, 0, 0.75))
                                                  .onTimeSectionEntered(event -> System.out.println("Garden light on"))
                                                  .onTimeSectionLeft(event -> System.out.println("Garden light off"))
                                                  .build();

    TimeSection lunchBreak = TimeSectionBuilder.create()
                                               .start(LocalTime.now().plusMinutes(1))
                                               .stop(LocalTime.now().plusHours(1))
                                               .color(Color.rgb(200, 0, 0, 0.1))
                                               .highlightColor(Color.rgb(222, 0, 0, 0.75))
                                               .onTimeSectionEntered(event -> System.out.println("Lunch break started"))
                                               .onTimeSectionLeft(event -> System.out.println("Lunch break ended"))
                                               .build();


    clock1 = ClockBuilder.create()
                         .titleVisible(true)
                         .title("Sections")
                         .sectionsVisible(true)
                         .highlightSections(true)
                         .sections(gardenLightOn)
                         .checkSectionsForValue(true)
                         .areasVisible(true)
                         .highlightAreas(true)
                         .areas(lunchBreak)
                         .secondsVisible(true)
                         .running(true)
                         .build();


    LightOn  lightOn  = new LightOn();
    LightOff lightOff = new LightOff();

    Alarm alarmLightOn =
        AlarmBuilder.create()
                    .time(ZonedDateTime.now().plusMinutes(1))
                    .repetition(Repetition.ONCE)
                    .text("Light On")
                    .command(lightOn)
                    .color(Color.LIME)
                    .onAlarmMarkerPressed(e -> System.out.println("Light On marker pressed"))
                    .build();

    Alarm alarmLightOff =
        AlarmBuilder.create()
                    .time(ZonedDateTime.now().plusMinutes(10))
                    .repetition(Repetition.ONCE)
                    .text("Light off")
                    .command(lightOff)
                    .color(Color.RED)
                    .onAlarmMarkerPressed(e -> System.out.println("Light Off marker pressed"))
                    .build();

    clock2 = ClockBuilder.create()
                         .titleVisible(true)
                         .title("Alarms")
                         .alarmsEnabled(true)
                         .alarmsVisible(true)
                         .alarms(alarmLightOn, alarmLightOff)
                         .onAlarm(event -> System.out.println("Alarm: " + LocalTime.now() + " : " + event.ALARM.getText()))
                         .secondsVisible(true)
                         .running(true)
                         .build();
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:70,代码来源:ClockControl.java

示例4: compare

import eu.hansolo.medusa.TimeSection; //导入依赖的package包/类
@Override public int compare(final TimeSection SECTION_1, final TimeSection SECTION_2) {
    return SECTION_1.compareTo(SECTION_2);
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:4,代码来源:TimeSectionComparator.java


注:本文中的eu.hansolo.medusa.TimeSection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。