Commit 28e5658c authored by Simon Barner's avatar Simon Barner
Browse files

- Reduce DIAGRAM_HORIZONTAL_SPACING to 2

- Ensure that minimum horizontal and vertical sizes are 1
refs 3371
parent 4ace00b7
AbstractObjectToDraw.java a1bbb2390af2b4485ec1dc7ad2fd316d305dbe5c GREEN
LabelToDraw.java 999a987f051ecf08965832c43c6164b20cb0431a GREEN
LineToDraw.java 96fb75373891873a51b557fece736f1c337069fc GREEN
ScheduleModelElementToDraw.java ec0d380a07267a61a3cb6be697e6d2b88aefcb5f GREEN
ScheduleModelElementToDraw.java 8d3da6f399fb33bfc243a5519345ee9d36953304 YELLOW
ScheduleView.java 3c0165545106c338f3a00449b09b4e219bf94a29 GREEN
ScheduleViewCanvas.java 7d0388840f39494728dd4cb385aa3809fd41fb97 GREEN
ScheduleViewCanvas.java c47deedbcc39fee8008ecad8ab0392f76b6ad4d8 YELLOW
ScheduleViewColors.java a5544e371ea55d1d6cec99cd119bdddfef3d1239 GREEN
ScheduleViewGraphModel.java 87262d9477f30db55c551e6096fcc6272c6e594f GREEN
ScheduleViewLayoutData.java f082ccd901fd2331a4d374c69afed12343f1aa72 GREEN
ScheduleViewGraphModel.java 218aadb5dd480a2a0f8ff72ced6bc8816181911d YELLOW
ScheduleViewLayoutData.java c192e6d12806bac9df98c7e25faa45607023bef0 YELLOW
ScheduleViewModel.java 5f6a9a99f00ee4bbc8b6e07b60e2cffc0e5ac9bb GREEN
......@@ -72,7 +72,8 @@ public class ScheduleModelElementToDraw extends AbstractObjectToDraw {
int x2 = x + width;
x = max(x, -1);
width = min(x2 - x, maxWidth);
// Ensure that width is in the range [1; maxWidth]
width = max(min(x2 - x, maxWidth), 1);
Rectangle rectangle = new Rectangle(x, y, width, height);
if(scheduleModelElement.hasBorder()) {
gc.setAlpha(190);
......
......@@ -17,6 +17,8 @@ package org.fortiss.af3.schedule.ui.ganttchartview;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static org.fortiss.af3.schedule.ui.ganttchartview.ScheduleViewLayoutData.DIAGRAM_HORIZONTAL_SPACING;
import static org.fortiss.af3.schedule.ui.ganttchartview.ScheduleViewLayoutData.DIAGRAM_OFFSET_Y;
import static org.fortiss.af3.schedule.ui.ganttchartview.ScheduleViewLayoutData.MATH_CONTEXT_DOUBLE_MAXIMUM_PRECISION;
import static org.fortiss.af3.schedule.ui.utils.ScheduleViewUtils.getDuration;
import static org.fortiss.af3.schedule.ui.utils.ScheduleViewUtils.getPhase;
......@@ -436,6 +438,11 @@ public class ScheduleViewCanvas extends Canvas {
}
}
/** Returns the Y coordinate of the i-th horizontal line. */
private int getHorizontalLineY(int i) {
return (int)(DIAGRAM_OFFSET_Y + i * scheduleLayoutData.getDiagramHeightOfSchedule() - DIAGRAM_HORIZONTAL_SPACING / 2.0);
}
/** Draws the coordinate system. */
private void drawCoordinateSystem(GC gc) {
Rectangle clientArea = getClientArea();
......@@ -447,7 +454,7 @@ public class ScheduleViewCanvas extends Canvas {
// Y axis
int diagramX = scheduleLayoutData.objectSpaceToDiagramSpaceX(BigDecimal.ZERO);
int diagramY = scheduleLayoutData.objectSpaceToDiagramSpaceY(BigDecimal.ZERO);
int diagramY = getHorizontalLineY(scheduleModel.getSchedules().size());
int diagramY2 = ScheduleViewLayoutData.DIAGRAM_OFFSET_Y;
gc.drawLine(diagramX, diagramY + 2 * DIAGRAM_COORDINATE_SYSTEM_EXTRA_LINE_LENGTH, diagramX,
diagramY2);
......@@ -472,9 +479,7 @@ public class ScheduleViewCanvas extends Canvas {
// Draw horizontal lines after every schedule
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
for(int i = 1; i < scheduleModel.getSchedules().size(); ++i) {
int diagramHorizotalLineY =
(int)(ScheduleViewLayoutData.DIAGRAM_OFFSET_Y + i *
scheduleLayoutData.getDiagramHeightOfSchedule() - ScheduleViewLayoutData.DIAGRAM_HORIZONTAL_SPACING / 2.0);
int diagramHorizotalLineY = getHorizontalLineY(i);
gc.drawLine(diagramX - DIAGRAM_COORDINATE_SYSTEM_EXTRA_LINE_LENGTH,
diagramHorizotalLineY, diagramX2 + DIAGRAM_COORDINATE_SYSTEM_EXTRA_LINE_LENGTH,
......@@ -513,12 +518,12 @@ public class ScheduleViewCanvas extends Canvas {
// interval line
int diagramLabelX = scheduleLayoutData.objectSpaceToDiagramSpaceX(i);
gc.drawLine(diagramLabelX, ScheduleViewLayoutData.DIAGRAM_OFFSET_Y -
DIAGRAM_COORDINATE_SYSTEM_EXTRA_LINE_LENGTH, diagramLabelX, diagramY +
DIAGRAM_COORDINATE_SYSTEM_EXTRA_LINE_LENGTH, diagramLabelX, diagramY + 3 *
DIAGRAM_COORDINATE_SYSTEM_EXTRA_LINE_LENGTH);
// draw x axis label
gc.drawText(
df.format(i.setScale(ScheduleViewLayoutData.MAXIMUM_PRECISION - 1,
BigDecimal.ROUND_DOWN)) + "", diagramLabelX, diagramY +
BigDecimal.ROUND_DOWN)) + "", diagramLabelX, diagramY + 3 *
DIAGRAM_COORDINATE_SYSTEM_EXTRA_LINE_LENGTH);
}
......
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.schedule.ui.ganttchartview;
import static java.lang.Math.max;
import static java.math.BigDecimal.valueOf;
import static java.math.RoundingMode.HALF_UP;
import static org.fortiss.af3.schedule.ui.ganttchartview.LabelToDraw.createLabel;
......@@ -23,6 +24,7 @@ import static org.fortiss.af3.schedule.ui.ganttchartview.LineToDraw.drawLine;
import static org.fortiss.af3.schedule.ui.ganttchartview.ScheduleModelElementToDraw.createScheduleModelElement;
import static org.fortiss.af3.schedule.ui.ganttchartview.ScheduleModelElementToDraw.drawScheduleModelElement;
import static org.fortiss.af3.schedule.ui.ganttchartview.ScheduleViewColors.getColor;
import static org.fortiss.af3.schedule.ui.ganttchartview.ScheduleViewLayoutData.DIAGRAM_HORIZONTAL_SPACING;
import static org.fortiss.af3.schedule.ui.ganttchartview.ScheduleViewLayoutData.DIAGRAM_OFFSET_Y;
import java.math.BigDecimal;
......@@ -199,7 +201,7 @@ public class ScheduleViewGraphModel {
BigDecimal multiply = valueOf(diagramHeight).multiply(startingPoint_Y);
int intValue = multiply.setScale(0, HALF_UP).intValue();
int y = DIAGRAM_OFFSET_Y + intValue;
int height = diagramHeight - ScheduleViewLayoutData.DIAGRAM_HORIZONTAL_SPACING;
int height = max(1, diagramHeight - DIAGRAM_HORIZONTAL_SPACING);
if(object instanceof LabelToDraw && period == 0) {
int x = scheduleLayoutData.getDiagramOrigin().x;
......
......@@ -61,7 +61,7 @@ public class ScheduleViewLayoutData {
public static final int DIAGRAM_OFFSET_LABEL = 100;
/** Absolute horizontal spacing between objects (in diagram space). */
public static final int DIAGRAM_HORIZONTAL_SPACING = 32;
public static final int DIAGRAM_HORIZONTAL_SPACING = 2;
/** Y offset of canvas (in diagram space). */
public static final int DIAGRAM_OFFSET_Y = 50;
......@@ -224,7 +224,7 @@ public class ScheduleViewLayoutData {
diagramWidthOfGraph =
scaleLengthObjectSpaceToDiagramSpaceX(objectWidthOfGraph) + marginWidth;
diagramHeightOfSchedule =
(int)((clientArea.height - 2 * DIAGRAM_OFFSET_Y) / (double)schedules.size());
max(1, (int)((clientArea.height - 2 * DIAGRAM_OFFSET_Y) / (double)schedules.size()));
}
/** Returns scalingUserX. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment