Began work on PunchcardDisplayDialog to display timestamps on various timelines.
Modified build file to clean additional files (logs, etc) committer: Jonathan Bernard <jdbernard@gmail.com>
This commit is contained in:
parent
0914ea5b6c
commit
789e708f69
10
build.xml
10
build.xml
@ -82,4 +82,14 @@
|
||||
<tar destfile="release/TimeStamper_v${application.version}.tar.gz" basedir="${dist.dir}" compression="gzip" />
|
||||
|
||||
</target>
|
||||
|
||||
<target name="-post-clean" >
|
||||
<delete>
|
||||
<fileset dir="${basedir}">
|
||||
<include name="*.log" />
|
||||
<include name="*.log.lck" />
|
||||
<include name="timestamper.config" />
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
</project>
|
||||
|
@ -4,3 +4,4 @@ javac.debug=true
|
||||
javadoc.preview=true
|
||||
jaxws.endorsed.dir=C:\\Program Files\\NetBeans 6.1\\java2\\modules\\ext\\jaxws21\\api
|
||||
user.properties.file=C:\\Documents and Settings\\jbernard\\.netbeans\\6.1\\build.properties
|
||||
axis2.deploy.war=C:\\Program Files\\glassfish-v2ur2\\domains\\domain1\\autodeploy\\axis2.war
|
||||
|
@ -1,8 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
|
||||
<file>file:/C:/Documents%20and%20Settings/jbernard/My%20Documents/Development/TimeStamper/src/jdbernard/timestamper/TimeStamperApp.java</file>
|
||||
<file>file:/C:/Documents%20and%20Settings/jbernard/My%20Documents/Development/TimeStamper/src/jdbernard/timestamper/TimeStamperView.java</file>
|
||||
</open-files>
|
||||
</project-private>
|
||||
|
65
src/jdbernard/timestamper/PunchcardDisplayDialog.form
Executable file
65
src/jdbernard/timestamper/PunchcardDisplayDialog.form
Executable file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="name" type="java.lang.String" value="Form" noResource="true"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="timelineDayDisplay1" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="timelineDayDisplay1" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="jdbernard.timestamper.TimelineDayDisplay" name="timelineDayDisplay1">
|
||||
<Properties>
|
||||
<Property name="name" type="java.lang.String" value="timelineDayDisplay1" noResource="true"/>
|
||||
<Property name="timeline" type="jdbernard.timestamper.Timeline" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="timeline" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="380" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="278" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
100
src/jdbernard/timestamper/PunchcardDisplayDialog.java
Executable file
100
src/jdbernard/timestamper/PunchcardDisplayDialog.java
Executable file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* PunchcardDisplayDialog.java
|
||||
*
|
||||
* Created on October 16, 2008, 4:37 PM
|
||||
*/
|
||||
|
||||
package jdbernard.timestamper;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jbernard
|
||||
*/
|
||||
public class PunchcardDisplayDialog extends javax.swing.JDialog {
|
||||
|
||||
/** Creates new form PunchcardDisplayDialog */
|
||||
public PunchcardDisplayDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
timelineDayDisplay1.setDay(Calendar.getInstance());
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
timelineDayDisplay1 = new jdbernard.timestamper.TimelineDayDisplay();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setName("Form"); // NOI18N
|
||||
|
||||
timelineDayDisplay1.setName("timelineDayDisplay1"); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout timelineDayDisplay1Layout = new javax.swing.GroupLayout(timelineDayDisplay1);
|
||||
timelineDayDisplay1.setLayout(timelineDayDisplay1Layout);
|
||||
timelineDayDisplay1Layout.setHorizontalGroup(
|
||||
timelineDayDisplay1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 380, Short.MAX_VALUE)
|
||||
);
|
||||
timelineDayDisplay1Layout.setVerticalGroup(
|
||||
timelineDayDisplay1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 278, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(timelineDayDisplay1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(timelineDayDisplay1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) throws Exception {
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
PunchcardDisplayDialog dialog = new PunchcardDisplayDialog(new javax.swing.JFrame(), true);
|
||||
try { dialog.timelineDayDisplay1.setTimeline(Timeline.readFromFile("test-timeline.txt")); }
|
||||
catch (Exception e) {
|
||||
System.err.println("Could not open timeline text.");
|
||||
try { new File("PLACE_HERE").createNewFile(); }
|
||||
catch (Exception e1) {}
|
||||
}
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private jdbernard.timestamper.TimelineDayDisplay timelineDayDisplay1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private Timeline timeline;
|
||||
}
|
136
src/jdbernard/timestamper/TimelineDayDisplay.java
Executable file
136
src/jdbernard/timestamper/TimelineDayDisplay.java
Executable file
@ -0,0 +1,136 @@
|
||||
/* TimelineDayDisplay.java
|
||||
* Author: Jonathan Bernard - jonathan.bernard@gemalto.com
|
||||
*/
|
||||
|
||||
package jdbernard.timestamper;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jbernard
|
||||
*/
|
||||
public class TimelineDayDisplay extends JComponent {
|
||||
|
||||
private Timeline timeline;
|
||||
private Calendar day;
|
||||
|
||||
private final Color evenTrans = new Color(0.75f, 0.75f, 0.75f, 0.4f);
|
||||
private final Color evenOpaque = new Color(0.75f, 0.75f, 0.75f, 1f);
|
||||
private final Color oddTrans = new Color(0.5f, 0.5f, 0.5f, 0.4f);
|
||||
private final Color oddOpaque = new Color(0.5f, 0.5f, 0.5f, 1f);
|
||||
|
||||
public TimelineDayDisplay() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TimelineDayDisplay(Timeline timeline, Calendar day) {
|
||||
super();
|
||||
this.timeline = timeline;
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
public void setTimeline(Timeline t) {
|
||||
timeline = t;
|
||||
}
|
||||
|
||||
public Timeline getTimeline() {
|
||||
return timeline;
|
||||
}
|
||||
|
||||
public void setDay(Calendar d) {
|
||||
day = d;
|
||||
day.set(Calendar.HOUR_OF_DAY, 0);
|
||||
day.set(Calendar.MINUTE, 0);
|
||||
day.set(Calendar.SECOND, 0);
|
||||
}
|
||||
|
||||
public Calendar getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Insets insets = this.getInsets();
|
||||
Rectangle bounds = this.getBounds();
|
||||
Rectangle canvasBounds = new Rectangle(insets.left, insets.top,
|
||||
bounds.width - insets.left - insets.right - 1,
|
||||
bounds.height - insets.top - insets.bottom - 1);
|
||||
|
||||
Calendar nextDay = Calendar.getInstance();
|
||||
nextDay.setTime(day.getTime());
|
||||
nextDay.add(Calendar.DAY_OF_YEAR, 1);
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
double hourHeight = canvasBounds.getHeight() / 24.0;
|
||||
long oneDayInMilli = (24 * 60 * 60 * 1000);
|
||||
Rectangle2D stringBounds = getFontMetrics(getFont()).getStringBounds("00:00 ", g);
|
||||
for (int i = 1; i < 24; i++) {
|
||||
int lineY = (int) Math.round(hourHeight * (double) i);
|
||||
g.drawLine(canvasBounds.x + (int) stringBounds.getWidth(), canvasBounds.y + lineY,
|
||||
canvasBounds.x + canvasBounds.width,
|
||||
canvasBounds.y + lineY);
|
||||
|
||||
if ((hourHeight > (stringBounds.getHeight()) || ((i % 2) == 0))) {
|
||||
g.drawString(String.format("%1$02d:00", i),
|
||||
canvasBounds.x + 2, lineY + (int) (stringBounds.getHeight() / 2));
|
||||
}
|
||||
}
|
||||
|
||||
Timeline.TimelineMarker tm = timeline.getLastMarker(day.getTime());
|
||||
Iterator<Timeline.TimelineMarker> itr = timeline.iterator();
|
||||
|
||||
while (!itr.next().equals(tm));
|
||||
|
||||
ArrayList<Timeline.TimelineMarker> markers = new ArrayList<Timeline.TimelineMarker>();
|
||||
while (nextDay.getTime().after(tm.getTimestamp())) {
|
||||
markers.add(tm);
|
||||
if (itr.hasNext()) tm = itr.next();
|
||||
else break;
|
||||
}
|
||||
|
||||
markers.add(tm);
|
||||
|
||||
for (int i = 0; i < markers.size(); i++) {
|
||||
int boxY = 0;
|
||||
int boxHeight = 1;
|
||||
if (i != 0) {
|
||||
double relTime = markers.get(i).getTimestamp().getTime() - day.getTimeInMillis();
|
||||
boxY = (int) Math.round((relTime / oneDayInMilli)
|
||||
* canvasBounds.getHeight()) + canvasBounds.y;
|
||||
}
|
||||
if (i == markers.size() - 1) {
|
||||
double relTime = nextDay.getTime().getTime()
|
||||
- markers.get(i).getTimestamp().getTime();
|
||||
boxHeight = (int) Math.round(relTime / oneDayInMilli
|
||||
* canvasBounds.getHeight());
|
||||
} else {
|
||||
double relTime = markers.get(i + 1).getTimestamp().getTime()
|
||||
- markers.get(i).getTimestamp().getTime();
|
||||
boxHeight = (int) Math.round(relTime / oneDayInMilli
|
||||
* canvasBounds.getHeight());
|
||||
}
|
||||
g.setColor((i % 2 == 0 ? evenTrans : oddTrans));
|
||||
g.fillRect(canvasBounds.x + (int) stringBounds.getWidth() + 5, boxY,
|
||||
canvasBounds.x + canvasBounds.width, boxHeight);
|
||||
g2d.setColor((i % 2 == 0 ? evenOpaque : oddOpaque));
|
||||
g2d.setStroke(new BasicStroke(3f));
|
||||
g2d.drawRect(canvasBounds.x + (int) stringBounds.getWidth() + 5, boxY,
|
||||
canvasBounds.x + canvasBounds.width, boxHeight);
|
||||
}
|
||||
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect(canvasBounds.x, canvasBounds.y, canvasBounds.width, canvasBounds.height);
|
||||
}
|
||||
}
|
BIN
test-timeline.txt
Executable file
BIN
test-timeline.txt
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user