Erste Zeichnung von Objekten

thobaben_diagram
Harald Wolff 2015-06-25 01:38:22 +02:00
parent b5e498c3e4
commit 2b3fc57150
3 changed files with 21 additions and 12 deletions

View File

@ -3,6 +3,5 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo"/>
<classpathentry kind="lib" path="miglayout15-swing.jar" sourcepath="miglayout-src.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -118,7 +118,7 @@ public class JNetPlan extends JComponent {
@Override
public void paint(Graphics _g) {
Graphics2D g = (Graphics2D)_g;
Graphics2D g = (Graphics2D)_g;
int n;
@ -149,12 +149,19 @@ public class JNetPlan extends JComponent {
}
for (INetPlanObject object: netPlanObjects){
int pos = 2 + (object.getStartTime().getDate().daysAfter(firstDate) * dayColumnWidth);
int width = (object.getEndTime().getDate().daysAfter(object.getStartTime().getDate()) * dayColumnWidth) + dayColumnWidth - 4;
g.setColor(Color.RED);
//g.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
for (INetPlanResource res: object.getResources()){
int vpos = 6 + (netPlanResources.indexOf(res) * lineHeight);
g.setColor(Color.RED);
g.fillRoundRect(pos, vpos, width, lineHeight - 4, 8, 8);
g.drawRoundRect(pos, vpos, width, lineHeight - 4, 8, 8);
g.setColor(Color.WHITE);
g.drawString(object.getShortLabel(), pos + 4, vpos + lineHeight - 8);
//System.err.println(String.format("[%d/%d] [%d/%d]",pos,vpos,width,lineHeight - 4));
}
}
@ -169,7 +176,7 @@ public class JNetPlan extends JComponent {
FontMetrics fm = getFontMetrics(getFont());
//lineHeight = (int)(getFont().getSize2D()*72) + 4;
lineHeight = getFont().getSize() + 4;
lineHeight = getFont().getSize() + 8;
resourceBaseHeight = lineHeight * 3;

View File

@ -61,7 +61,7 @@ public class JNetPlanTestDialog extends JDialog {
{
netPlan = new JNetPlan();
netPlan.setDays(45);
netPlan.setFont(new Font("Courier 10 Pitch", Font.PLAIN, 12));
netPlan.setFont(new Font("DejaVu Sans", Font.PLAIN, 16));
netPlan.setBackground(Color.WHITE);
scrollPane.setViewportView(netPlan);
}
@ -95,8 +95,6 @@ public class JNetPlanTestDialog extends JDialog {
private void initialize(){
for (int i=0;i<10;i++){
BaseNetPlanResource res = new BaseNetPlanResource(String.format("Resource %d",i), "-");
if (i == 3)
res.setMaxParallelUsage(2);
netPlan.addNetPlanResource(res);
}
@ -104,12 +102,17 @@ public class JNetPlanTestDialog extends JDialog {
d.addDays(3);
Date d2 = new Date(d);
d2.addDays(4);
BaseNetPlanObject o = new BaseNetPlanObject();
o.setStartTime(new DateTime(d, new TimeOfDay()));
o.setEndTime(new DateTime(d, TimeOfDay.beforeMidnight()));
o.setEndTime(new DateTime(d2, TimeOfDay.beforeMidnight()));
o.setShortLabel("Eine Aufgabe");
o.addResource(netPlan.getNetPlanResources()[0]);
o.addResource(netPlan.getNetPlanResources()[3]);
o.addResource(netPlan.getNetPlanResources()[7]);
netPlan.addNetPlanObject(o);