Finished catching up to 1.7 functionality.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
package com.jdbernard.timestamper
|
||||
package com.jdbernard
|
||||
|
||||
import java.awt.Point
|
||||
import java.awt.Rectangle
|
@ -214,14 +214,16 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
||||
}
|
||||
|
||||
|
||||
public TimelineDayDisplay() {
|
||||
this(null, Calendar.getInstance());
|
||||
}
|
||||
|
||||
public TimelineDayDisplay(Timeline t) {
|
||||
super();
|
||||
setDay(new Date(), false);
|
||||
this.timeline = t;
|
||||
addMouseListener(this);
|
||||
this(t, Calendar.getInstance());
|
||||
}
|
||||
|
||||
public TimelineDayDisplay(Timeline t, Calendar day) {
|
||||
super();
|
||||
setDay(day.getTime(), false);
|
||||
addMouseListener(this);
|
||||
this.timeline = t;
|
||||
@ -232,16 +234,31 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
||||
pcs.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(String propertyName,
|
||||
PropertyChangeListener l) {
|
||||
pcs.addPropertyChangeListener(propertyName, l);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
pcs.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public Timeline getTimeline() { return timeline; }
|
||||
|
||||
public void setTimeline(Timeline t) {
|
||||
if (timeline == t) return;
|
||||
pcs.firePropertyChange("timeline", timeline, timeline = t);
|
||||
updateMarkers(getGraphics());
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the range for the visible timeline segment.
|
||||
* @param start The beginning of the desired timeline segment.
|
||||
* @param end The end of the desired timeline segment.
|
||||
*/
|
||||
public void setDisplayInterval(Date start, Date end) {
|
||||
if (start == rangeStartDate && end == rangeEndDate) return;
|
||||
pcs.firePropertyChange("rangeStart", rangeStartDate, rangeStartDate = start);
|
||||
pcs.firePropertyChange("rangeEnd", rangeEndDate, rangeEndDate = end);
|
||||
}
|
||||
@ -299,31 +316,39 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
||||
* @param f The font to use.
|
||||
*/
|
||||
public void setMarkFont(Font f) {
|
||||
if (markFont == f) return;
|
||||
pcs.firePropertyChange("markFont", markFont, markFont = f);
|
||||
repaint();
|
||||
}
|
||||
|
||||
public Font getMarkFont() { return markFont; }
|
||||
|
||||
public void setNotesFont(Font f) {
|
||||
if (notesFont == f) return;
|
||||
pcs.firePropertyChange("notesFont", notesFont, notesFont = f);
|
||||
repaint();
|
||||
}
|
||||
|
||||
public Font getNotesFont() { return notesFont; }
|
||||
|
||||
public void setFontColor(Color f) {
|
||||
if (fontColor == f) return;
|
||||
pcs.firePropertyChange("fontColor", fontColor,
|
||||
fontColor = new Color(f.getRGB()));
|
||||
repaint();
|
||||
}
|
||||
|
||||
public Color getFontColor() { return fontColor; }
|
||||
|
||||
public void setEvenColor(Color c) {
|
||||
if (evenOpaque == c) return;
|
||||
evenTrans = new Color((float) c.getRed() / 255f,
|
||||
(float) c.getGreen() / 255f,
|
||||
(float) c.getBlue() / 255f, 0.4f);
|
||||
|
||||
pcs.firePropertyChange("evenColor", evenOpaque,
|
||||
evenOpaque = new Color(c.getRGB()));
|
||||
repaint();
|
||||
}
|
||||
|
||||
public Color getEvenColor() {
|
||||
@ -331,13 +356,14 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
||||
}
|
||||
|
||||
public void setOddColor(Color c) {
|
||||
oddOpaque = new Color(c.getRGB());
|
||||
if (oddOpaque == c) return;
|
||||
oddTrans = new Color((float) c.getRed() / 255f,
|
||||
(float) c.getGreen() / 255f,
|
||||
(float) c.getBlue() / 255f, 0.4f);
|
||||
|
||||
pcs.firePropertyChange("oddColor", oddOpaque,
|
||||
oddOpaque = new Color(c.getRGB()));
|
||||
repaint();
|
||||
}
|
||||
|
||||
public Color getOddColor() {
|
||||
@ -345,12 +371,13 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
||||
}
|
||||
|
||||
public void setSelectedColor(Color c) {
|
||||
selectedOpaque = new Color(c.getRGB());
|
||||
if (selectedOpaque == c) return;
|
||||
selectedTrans = new Color((float) c.getRed() / 255f,
|
||||
(float) c.getGreen() / 255f,
|
||||
(float) c.getBlue() / 255f, 0.4f);
|
||||
pcs.firePropertyChange("selectedColor", selectedOpaque,
|
||||
selectedOpaque = new Color(c.getRGB()));
|
||||
repaint();
|
||||
}
|
||||
|
||||
public Color getSelectedColor() {
|
||||
@ -375,6 +402,8 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
||||
*/
|
||||
private void updateMarkers(Graphics g) {
|
||||
|
||||
if (timeline == null) return;
|
||||
|
||||
Insets insets = this.getInsets();
|
||||
Rectangle bounds = this.getBounds();
|
||||
Rectangle canvasBounds = new Rectangle(insets.left, insets.top,
|
||||
@ -498,6 +527,8 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
||||
public void paintComponent(Graphics g) {
|
||||
removeAll();
|
||||
|
||||
if (timeline == null) return;
|
||||
|
||||
if (markerEntries == null) updateMarkers(g);
|
||||
|
||||
Insets insets = this.getInsets();
|
||||
@ -614,7 +645,8 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
||||
|
||||
// should only match one entry
|
||||
if (absBounds.contains(e.getLocationOnScreen())) {
|
||||
currentMarker = markerEntry.marker;
|
||||
pcs.firePropertyChange("selectedTimelineMarker",
|
||||
currentMarker, currentMarker = markerEntry.marker);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -678,4 +710,8 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void setStateChanged(Object o) {
|
||||
stateChanged(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user