1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-05-31 23:50:49 +00:00
plantuml/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java

73 lines
2.2 KiB
Java
Raw Normal View History

2011-01-09 19:00:05 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2023-02-22 18:43:48 +00:00
* (C) Copyright 2009-2024, Arnaud Roques
2011-01-09 19:00:05 +00:00
*
2023-02-22 18:43:48 +00:00
* Project Info: https://plantuml.com
2011-01-09 19:00:05 +00:00
*
2017-03-15 19:13:31 +00:00
* If you like this project or if you find it useful, you can support us at:
*
2023-02-22 18:43:48 +00:00
* https://plantuml.com/patreon (only 1$ per month!)
* https://plantuml.com/paypal
2017-03-15 19:13:31 +00:00
*
2011-01-09 19:00:05 +00:00
* This file is part of PlantUML.
*
* PlantUML 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 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2013-12-10 19:36:50 +00:00
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2011-01-09 19:00:05 +00:00
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
2017-03-12 17:22:02 +00:00
*
2011-01-09 19:00:05 +00:00
*
*/
2020-02-18 21:24:31 +00:00
package net.sourceforge.plantuml.project.timescale;
2013-12-10 19:36:50 +00:00
2022-03-07 19:33:46 +00:00
import net.sourceforge.plantuml.project.core.PrintScale;
2020-09-30 20:57:58 +00:00
import net.sourceforge.plantuml.project.time.Day;
2020-02-18 21:24:31 +00:00
public class TimeScaleWink implements TimeScale {
2011-01-09 19:00:05 +00:00
2023-11-27 17:41:15 +00:00
private final double cellWidth;
2022-03-07 19:33:46 +00:00
private final PrintScale printScale;
2021-05-06 21:23:05 +00:00
2023-11-27 17:41:15 +00:00
public TimeScaleWink(double size, double scale, PrintScale printScale) {
this.cellWidth = size * scale;
2022-03-07 19:33:46 +00:00
this.printScale = printScale;
2021-05-06 21:23:05 +00:00
}
2011-01-29 15:09:35 +00:00
2020-09-30 20:57:58 +00:00
public double getStartingPosition(Day instant) {
final long wink = instant.getMillis();
2023-11-27 17:41:15 +00:00
return wink * cellWidth / Day.MILLISECONDS_PER_DAY;
2011-01-09 19:00:05 +00:00
}
2020-09-30 20:57:58 +00:00
public double getEndingPosition(Day instant) {
2018-04-06 20:36:30 +00:00
return getStartingPosition(instant) + getWidth(instant);
}
2020-09-30 20:57:58 +00:00
public double getWidth(Day instant) {
2023-11-27 17:41:15 +00:00
return cellWidth;
2011-04-19 16:50:40 +00:00
}
2020-09-30 20:57:58 +00:00
public boolean isBreaking(Day instant) {
2022-03-07 19:33:46 +00:00
if (printScale == PrintScale.WEEKLY) {
final long num = instant.getMillis() / Day.MILLISECONDS_PER_DAY;
return num % 7 == 6;
}
2020-08-25 17:24:17 +00:00
return true;
}
2011-01-09 19:00:05 +00:00
}