1 /*
2 * File: PPSInterval.java
3 * Copyright (c) 2004-2007 Peter Kliem (Peter.Kliem@jaret.de)
4 * A commercial license is available, see http://www.jaret.de.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 package de.jaret.util.ui.timebars.model;
21
22 import de.jaret.util.date.IntervalImpl;
23
24 /**
25 * Special interval for holding a pps value in the xScalePPSInterval row.
26 *
27 * @author kliem
28 * @version $Id: PPSInterval.java 836 2009-02-14 21:24:39Z kliem $
29 */
30 public class PPSInterval extends IntervalImpl {
31 /** default value. */
32 private static final double DEFAULT_PIXEL_PER_SECOND = 0.05;
33 /** the carried pps value. */
34 private double _pps = DEFAULT_PIXEL_PER_SECOND;
35
36 /** true if this pps interval marks a break in the time scale. */
37 private boolean _isBreak = false;
38
39 /** number of pixels that should be used to display a break if it is break. */
40 private int _breakDisplayWidth = 10;
41
42 /**
43 * Construct.
44 *
45 * @param pps pps value
46 */
47 public PPSInterval(double pps) {
48 _pps = pps;
49 }
50
51 /**
52 * Retrieve the pps value.
53 *
54 * @return pps value
55 */
56 public double getPps() {
57 return _pps;
58 }
59
60 /**
61 * Set the pps value.
62 *
63 * @param pps pps value
64 */
65 public void setPps(double pps) {
66 if (_pps != pps) {
67 double oldval = _pps;
68 _pps = pps;
69 firePropertyChange("Pps", oldval, pps);
70 }
71 }
72
73 /**
74 * {@inheritDoc} Simply output the pps value for displaying purposes.
75 */
76 public String toString() {
77 return (_isBreak ? "break" : "") + "pps: " + _pps;
78 }
79
80 /**
81 * Check whether the pps interval should cause a break in the timeline.
82 *
83 * @return <code>true</code> if this pps interval denotes a break in the timeline
84 */
85 public boolean isBreak() {
86 return _isBreak;
87 }
88
89 /**
90 * Set whether the pps interval will be rendered as a break in the timeline.
91 *
92 * @param isBreak <code>true</code> for rendering as a break in the timeline
93 */
94 public void setBreak(boolean isBreak) {
95 if (isBreak != _isBreak) {
96 boolean oldVal = _isBreak;
97 _isBreak = isBreak;
98 firePropertyChange("break", oldVal, isBreak);
99 }
100 }
101
102 /**
103 * Retrieve the width that should be used if this pps interval denotes a break in the timeline.
104 *
105 * @return the width in pixel
106 */
107 public int getBreakDisplayWidth() {
108 return _breakDisplayWidth;
109 }
110
111 /**
112 * Set the width that should be used if the pps interval denotes a break in the timescale.
113 *
114 * @param breakDisplayWidth width in pixel
115 */
116 public void setBreakDisplayWidth(int breakDisplayWidth) {
117 if (_breakDisplayWidth != breakDisplayWidth) {
118 int oldVal = _breakDisplayWidth;
119 _breakDisplayWidth = breakDisplayWidth;
120 firePropertyChange("breakWidth", oldVal, breakDisplayWidth);
121 }
122 }
123
124 }