Added PropertyChangeSupport to TimelineDayDisplay and decoupled it from the GUI
Added log4j lib
This commit is contained in:
parent
bff340e910
commit
5b19542355
BIN
lib/log4j-1.2.15.jar
Normal file
BIN
lib/log4j-1.2.15.jar
Normal file
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
* Author: Jonathan Bernard - jonathan.bernard@gemalto.com
|
* Author: Jonathan Bernard - jonathan.bernard@gemalto.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package jdbernard.timestamper.gui;
|
package com.jdbernard.timestamper.gui;
|
||||||
|
|
||||||
import com.jdbernard.timestamper.core.TimelineMarker;
|
import com.jdbernard.timestamper.core.TimelineMarker;
|
||||||
import com.jdbernard.timestamper.core.Timeline;
|
import com.jdbernard.timestamper.core.Timeline;
|
||||||
@ -17,6 +17,8 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.beans.PropertyChangeSupport;
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -32,6 +34,31 @@ import javax.swing.event.ChangeListener;
|
|||||||
public class TimelineDayDisplay extends JComponent implements MouseListener,
|
public class TimelineDayDisplay extends JComponent implements MouseListener,
|
||||||
ChangeListener {
|
ChangeListener {
|
||||||
|
|
||||||
|
private ArrayList<MarkerDisplayEntry> markerEntries;
|
||||||
|
private ArrayList<TimeLegendEntry> timeLegendLocations;
|
||||||
|
private ArrayList<ChangeListener> changeListeners = new ArrayList<ChangeListener>();
|
||||||
|
|
||||||
|
private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||||
|
|
||||||
|
private Timeline timeline;
|
||||||
|
private TimelineMarker currentMarker;
|
||||||
|
|
||||||
|
private Point lastMousePress;
|
||||||
|
|
||||||
|
private Font markFont;// = getFont().deriveFont(Font.BOLD);
|
||||||
|
private Font notesFont;// = getFont();
|
||||||
|
|
||||||
|
private Color evenTrans = new Color(0.75f, 0.75f, 0.75f, 0.4f);
|
||||||
|
private Color evenOpaque = new Color(0.75f, 0.75f, 0.75f, 1f);
|
||||||
|
private Color oddTrans = new Color(0.5f, 0.5f, 0.5f, 0.4f);
|
||||||
|
private Color oddOpaque = new Color(0.5f, 0.5f, 0.5f, 1f);
|
||||||
|
private Color selectedTrans = new Color(0.5f, 0.75f, 0.5f, 0.4f);
|
||||||
|
private Color selectedOpaque = new Color(0.5f, 0.75f, 0.5f, 1f);
|
||||||
|
private Color fontColor = new Color(0.1f, 0.1f, 0.1f, 1f);
|
||||||
|
|
||||||
|
private Date rangeStartDate = new Date();
|
||||||
|
private Date rangeEndDate = new Date();
|
||||||
|
|
||||||
private class MarkerDisplayEntry {
|
private class MarkerDisplayEntry {
|
||||||
public TimelineMarker marker;
|
public TimelineMarker marker;
|
||||||
public float relY;
|
public float relY;
|
||||||
@ -186,47 +213,37 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
|||||||
public abstract String formatCalendar(Calendar c); { }
|
public abstract String formatCalendar(Calendar c); { }
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<MarkerDisplayEntry> markerEntries;
|
|
||||||
private ArrayList<TimeLegendEntry> timeLegendLocations;
|
|
||||||
private TimelineMarker currentMarker;
|
|
||||||
private ArrayList<ChangeListener> changeListeners = new ArrayList<ChangeListener>();
|
|
||||||
|
|
||||||
private Point lastMousePress;
|
public TimelineDayDisplay(Timeline t) {
|
||||||
|
|
||||||
private Font markFont;// = getFont().deriveFont(Font.BOLD);
|
|
||||||
private Font notesFont;// = getFont();
|
|
||||||
|
|
||||||
private Color evenTrans = new Color(0.75f, 0.75f, 0.75f, 0.4f);
|
|
||||||
private Color evenOpaque = new Color(0.75f, 0.75f, 0.75f, 1f);
|
|
||||||
private Color oddTrans = new Color(0.5f, 0.5f, 0.5f, 0.4f);
|
|
||||||
private Color oddOpaque = new Color(0.5f, 0.5f, 0.5f, 1f);
|
|
||||||
private Color selectedTrans = new Color(0.5f, 0.75f, 0.5f, 0.4f);
|
|
||||||
private Color selectedOpaque = new Color(0.5f, 0.75f, 0.5f, 1f);
|
|
||||||
private Color fontColor = new Color(0.1f, 0.1f, 0.1f, 1f);
|
|
||||||
|
|
||||||
private Date rangeStartDate = new Date();
|
|
||||||
private Date rangeEndDate = new Date();
|
|
||||||
|
|
||||||
public TimelineDayDisplay() {
|
|
||||||
super();
|
super();
|
||||||
setDay(new Date(), false);
|
setDay(new Date(), false);
|
||||||
|
this.timeline = t;
|
||||||
addMouseListener(this);
|
addMouseListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineDayDisplay(Calendar day) {
|
public TimelineDayDisplay(Timeline t, Calendar day) {
|
||||||
setDay(day.getTime(), false);
|
setDay(day.getTime(), false);
|
||||||
addMouseListener(this);
|
addMouseListener(this);
|
||||||
|
this.timeline = t;
|
||||||
updateMarkers(getGraphics());
|
updateMarkers(getGraphics());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||||
|
pcs.addPropertyChangeListener(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||||
|
pcs.removePropertyChangeListener(l);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the range for the visible timeline segment.
|
* Set the range for the visible timeline segment.
|
||||||
* @param start The beginning of the desired timeline segment.
|
* @param start The beginning of the desired timeline segment.
|
||||||
* @param end The end of the desired timeline segment.
|
* @param end The end of the desired timeline segment.
|
||||||
*/
|
*/
|
||||||
public void setDisplayInterval(Date start, Date end) {
|
public void setDisplayInterval(Date start, Date end) {
|
||||||
rangeStartDate = start;
|
pcs.firePropertyChange("rangeStart", rangeStartDate, rangeStartDate = start);
|
||||||
rangeEndDate = end;
|
pcs.firePropertyChange("rangeEnd", rangeEndDate, rangeEndDate = end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -256,42 +273,57 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
|||||||
day.set(Calendar.HOUR_OF_DAY, 0);
|
day.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
day.set(Calendar.MINUTE, 0);
|
day.set(Calendar.MINUTE, 0);
|
||||||
day.set(Calendar.SECOND, 0);
|
day.set(Calendar.SECOND, 0);
|
||||||
rangeStartDate = day.getTime();
|
pcs.firePropertyChange("rangeStart", rangeStartDate, rangeStartDate = day.getTime());
|
||||||
|
|
||||||
day.add(Calendar.DAY_OF_YEAR, 1);
|
day.add(Calendar.DAY_OF_YEAR, 1);
|
||||||
rangeEndDate = day.getTime();
|
pcs.firePropertyChange("rangeEnd", rangeEndDate, rangeEndDate = day.getTime());
|
||||||
|
|
||||||
if (update) updateMarkers(getGraphics());
|
if (update) updateMarkers(getGraphics());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMarkFont(Font f) {
|
/**
|
||||||
markFont = f;
|
* Get the starting point for the display range.
|
||||||
|
* @return The starting {@link java.util.Date} for the display range.
|
||||||
|
*/
|
||||||
|
public Date getRangeStart() { return rangeStartDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ending point for the display range.
|
||||||
|
* @return The ending {@link java.util.Date} for the display range.
|
||||||
|
*/
|
||||||
|
public Date getRangeEnd() { return rangeEndDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the font used for displaying the name of the entry (more precisely:
|
||||||
|
* {@link com.jdbernard.timestamper.core.TimelineMarker#mark}).
|
||||||
|
* @param f The font to use.
|
||||||
|
*/
|
||||||
|
public void setMarkFont(Font f) {
|
||||||
|
pcs.firePropertyChange("markFont", markFont, markFont = f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Font getMarkFont() {
|
public Font getMarkFont() { return markFont; }
|
||||||
return markFont;
|
|
||||||
|
public void setNotesFont(Font f) {
|
||||||
|
pcs.firePropertyChange("notesFont", notesFont, notesFont = f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotesFont(Font f) {
|
public Font getNotesFont() { return notesFont; }
|
||||||
notesFont = f;
|
|
||||||
|
public void setFontColor(Color f) {
|
||||||
|
pcs.firePropertyChange("fontColor", fontColor,
|
||||||
|
fontColor = new Color(f.getRGB()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Font getNotesFont() {
|
public Color getFontColor() { return fontColor; }
|
||||||
return notesFont;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFontColor(Color f) {
|
|
||||||
fontColor = new Color(f.getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color getFontColor() {
|
|
||||||
return fontColor;
|
|
||||||
}
|
|
||||||
public void setEvenColor(Color c) {
|
public void setEvenColor(Color c) {
|
||||||
evenOpaque = new Color(c.getRGB());
|
|
||||||
evenTrans = new Color((float) c.getRed() / 255f,
|
evenTrans = new Color((float) c.getRed() / 255f,
|
||||||
(float) c.getGreen() / 255f,
|
(float) c.getGreen() / 255f,
|
||||||
(float) c.getBlue() / 255f, 0.4f);
|
(float) c.getBlue() / 255f, 0.4f);
|
||||||
|
|
||||||
|
pcs.firePropertyChange("evenColor", evenOpaque,
|
||||||
|
evenOpaque = new Color(c.getRGB()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getEvenColor() {
|
public Color getEvenColor() {
|
||||||
@ -303,6 +335,9 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
|||||||
oddTrans = new Color((float) c.getRed() / 255f,
|
oddTrans = new Color((float) c.getRed() / 255f,
|
||||||
(float) c.getGreen() / 255f,
|
(float) c.getGreen() / 255f,
|
||||||
(float) c.getBlue() / 255f, 0.4f);
|
(float) c.getBlue() / 255f, 0.4f);
|
||||||
|
|
||||||
|
pcs.firePropertyChange("oddColor", oddOpaque,
|
||||||
|
oddOpaque = new Color(c.getRGB()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getOddColor() {
|
public Color getOddColor() {
|
||||||
@ -314,6 +349,8 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
|||||||
selectedTrans = new Color((float) c.getRed() / 255f,
|
selectedTrans = new Color((float) c.getRed() / 255f,
|
||||||
(float) c.getGreen() / 255f,
|
(float) c.getGreen() / 255f,
|
||||||
(float) c.getBlue() / 255f, 0.4f);
|
(float) c.getBlue() / 255f, 0.4f);
|
||||||
|
pcs.firePropertyChange("selectedColor", selectedOpaque,
|
||||||
|
selectedOpaque = new Color(c.getRGB()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getSelectedColor() {
|
public Color getSelectedColor() {
|
||||||
@ -324,20 +361,6 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
|||||||
return currentMarker;
|
return currentMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMarker(Date timestamp, String mark, String notes) {
|
|
||||||
/*Timeline timeline = TimeStamperApp.getApplication()
|
|
||||||
.getTimelineProperties().getTimeline();
|
|
||||||
timeline.addMarker(timestamp, mark, notes);
|
|
||||||
updateMarkers(getGraphics());*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteSelectedMarker() {
|
|
||||||
/*Timeline timeline = TimeStamperApp.getApplication()
|
|
||||||
.getTimelineProperties().getTimeline();
|
|
||||||
timeline.removeMarker(currentMarker);
|
|
||||||
updateMarkers(getGraphics());*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateSelectedMarker(String notes) {
|
public void updateSelectedMarker(String notes) {
|
||||||
currentMarker.setNotes(notes);
|
currentMarker.setNotes(notes);
|
||||||
updateMarkers(getGraphics());
|
updateMarkers(getGraphics());
|
||||||
@ -352,8 +375,6 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
|||||||
*/
|
*/
|
||||||
private void updateMarkers(Graphics g) {
|
private void updateMarkers(Graphics g) {
|
||||||
|
|
||||||
/*Timeline timeline = TimeStamperApp.getApplication()
|
|
||||||
.getTimelineProperties().getTimeline();
|
|
||||||
Insets insets = this.getInsets();
|
Insets insets = this.getInsets();
|
||||||
Rectangle bounds = this.getBounds();
|
Rectangle bounds = this.getBounds();
|
||||||
Rectangle canvasBounds = new Rectangle(insets.left, insets.top,
|
Rectangle canvasBounds = new Rectangle(insets.left, insets.top,
|
||||||
@ -470,7 +491,7 @@ public class TimelineDayDisplay extends JComponent implements MouseListener,
|
|||||||
|
|
||||||
markerEntries.add(markerEntry);
|
markerEntries.add(markerEntry);
|
||||||
}
|
}
|
||||||
repaint();*/
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user