Skip to content

Commit

Permalink
Added rouneded UI impl
Browse files Browse the repository at this point in the history
  • Loading branch information
serjiokov committed May 12, 2020
1 parent 46e1055 commit cbb3d4d
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 31 deletions.
Expand Up @@ -77,6 +77,7 @@ public final class ChronographStageImpl extends Canvas implements ChronographSta
private ScrollBar scrollBarHorizontal;
private StageLabelProvider labelProvider;
private ContainerProvider dataProvider;
private int zoom = 1;

private static ChronographManagerRenderers INSTANCE = ChronographManagerRenderers.getInstance();

Expand Down Expand Up @@ -330,7 +331,7 @@ private void calculateSectionBounds(Area area, Collection<Section> sections, int
}
}
int height = 10 + Math.max(lenghtOfGroups, strHeight);
Area sectionArea = new AreaImpl(area.x(), y, area.width(), height);
Area sectionArea = new AreaImpl(area.x(), y, area.width() * zoom, height * zoom);
groupsAreas.put(section.id(), sectionArea);
y += height + sectionSpace;
}
Expand Down Expand Up @@ -390,7 +391,7 @@ private void drawSceneObjects(final GC gc, Area area, final Collection<? extends
if (area == null) {
return;
}
bricks.stream().forEach(new Consumer<Brick>() {
bricks.stream().forEach(new Consumer<Brick>() {
public void accept(Brick brick) {
calculateObjectPosition(brick, area, pXhint, pYhint, pxlHint);
Area brickArea = getDrawingArea(brick);
Expand Down Expand Up @@ -570,4 +571,19 @@ public void setProvider(ContainerProvider provider) {
this.calculateObjectBounds();
this.redraw();
}

@Override
public void setZoomLevelDown() {
this.zoom++;
this.calculateObjectBounds();
this.redraw();

}

@Override
public void setZoomLevelUp() {
this.zoom--;
this.calculateObjectBounds();
this.redraw();
}
}
Expand Up @@ -28,12 +28,18 @@ public ChronographStageMouseWheelListener(T stage) {

@Override
public void handleEvent(Event event) {
if (event.stateMask == SWT.MOD1) {
if (event.stateMask == SWT.CTRL) {
if (event.count > 0) {
stage.scaleDown();
} else {
stage.scaleUp();
}
} else if (event.stateMask == SWT.ALT) {
if (event.count > 0) {
stage.setZoomLevelDown();
} else {
stage.setZoomLevelUp();
}
} else {
stage.verticalScroll(event);
}
Expand Down
Expand Up @@ -43,13 +43,13 @@ public class BrickStyler implements Styler {
public void initClassicTheme() {
COLOR_TOP = new Color(DISPLAY, new RGB(195, 245, 180));
COLOR_BOTTOM = new Color(DISPLAY, new RGB(100, 150, 90));
SELECTED_COLOR_TOP = new Color(DISPLAY, new RGB(100, 200, 110));
SELECTED_COLOR_BOTTOM = new Color(DISPLAY, new RGB(100, 130, 152));
ACTIVE_COLOR_TOP = new Color(DISPLAY, new RGB(80, 250, 82));
SELECTED_COLOR_TOP = new Color(DISPLAY, new RGB(110, 190, 82));
SELECTED_COLOR_BOTTOM = new Color(DISPLAY, new RGB(80, 140, 82));
ACTIVE_COLOR_TOP = new Color(DISPLAY, new RGB(110, 190, 82));
ACTIVE_COLOR_BOTTOM = new Color(DISPLAY, new RGB(80, 140, 82));
COLOR_BORDER = new Color(DISPLAY, new RGB(95, 95, 95));
COLOR_TEXT = new Color(DISPLAY, new RGB(220, 220, 220));
COLOR_CALL_OUT = new Color(DISPLAY, new RGB(20, 20, 20));
COLOR_CALL_OUT = new Color(DISPLAY, new RGB(100, 100, 100));
BRICK_HEIGHT_DEFAULT = 26;
}

Expand All @@ -59,7 +59,7 @@ public void initDarkTheme() {
COLOR_BOTTOM = new Color(DISPLAY, new RGB(64, 36, 89));
SELECTED_COLOR_TOP = new Color(DISPLAY, new RGB(136, 105, 184));
SELECTED_COLOR_BOTTOM = new Color(DISPLAY, new RGB(64, 36, 89));
ACTIVE_COLOR_TOP = new Color(DISPLAY, new RGB(236, 50, 184));
ACTIVE_COLOR_TOP = new Color(DISPLAY, new RGB(149, 140, 184));
ACTIVE_COLOR_BOTTOM = new Color(DISPLAY, new RGB(104, 136, 89));
COLOR_BORDER = new Color(DISPLAY, new RGB(190, 155, 184));
COLOR_TEXT = new Color(DISPLAY, new RGB(220, 220, 220));
Expand Down
Expand Up @@ -53,10 +53,10 @@ public void initClassicTheme() {
public void initDarkTheme() {
RULER_TOP_COLOR = new Color(DISPLAY, new RGB(106, 155, 164));
RULER_BTM_COLOR = new Color(DISPLAY, new RGB(55, 99, 124));
RULER_BRD_COLOR = new Color(DISPLAY, new RGB(220, 220, 220));
RULER_BRD_COLOR = new Color(DISPLAY, new RGB(0, 100, 117));
RULER_TEXT_COLOR = new Color(DISPLAY, new RGB(220, 220, 220));
RULER_CUREENT_DAY_COLOR_TOP = new Color(DISPLAY, new RGB(82, 148, 226));
RULER_CUREENT_DAY_COLOR_BTM = new Color(DISPLAY, new RGB(64, 69, 82));
RULER_CUREENT_DAY_COLOR_TOP = new Color(DISPLAY, new RGB(255, 148, 0));
RULER_CUREENT_DAY_COLOR_BTM = new Color(DISPLAY, new RGB(55,99,120)) ;//new RGB(64, 69, 82));

}
}
Expand Up @@ -14,9 +14,9 @@
package org.eclipse.chronograph.internal.swt.renderers.impl;

import org.eclipse.chronograph.internal.api.Group;
import org.eclipse.chronograph.internal.swt.BrickStyler;
import org.eclipse.chronograph.internal.swt.GroupStyler;
import org.eclipse.chronograph.internal.swt.renderers.api.ChronographGroupRenderer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
Expand All @@ -36,13 +36,18 @@ public void draw(GC gc, String label, Rectangle groupBound, Display display, int

final Rectangle groupNameRectangle = new Rectangle(groupBound.x, groupBound.y - hintY, width,
groupBound.height);
gc.setBackground(GroupStyler.GROUP_BTM_COLOR);
gc.setForeground(GroupStyler.GROUP_TOP_COLOR);
gc.fillGradientRectangle(groupNameRectangle.x, groupNameRectangle.y, groupNameRectangle.width,
groupNameRectangle.height, false);
gc.setForeground(BrickStyler.getColorBorder());
gc.drawRectangle(groupNameRectangle);
gc.drawRectangle(groupBound.x, groupBound.y - hintY, groupBound.width, groupBound.height);
gc.setBackground(GroupStyler.GROUP_BTM_COLOR);
gc.setAntialias(SWT.ON);
gc.setForeground(GroupStyler.GROUP_BTM_COLOR);
gc.setBackground(GroupStyler.GROUP_TOP_COLOR);
gc.fillRoundRectangle(groupNameRectangle.x, groupNameRectangle.y, groupNameRectangle.width,
groupNameRectangle.height, 30, 30);
gc.drawRoundRectangle(groupNameRectangle.x, groupNameRectangle.y, groupNameRectangle.width,
groupNameRectangle.height, 30, 30);
gc.setForeground(GroupStyler.GROUP_BTM_COLOR);
gc.drawRoundRectangle(groupBound.x, groupBound.y - hintY, groupBound.width, groupBound.height,30,30);

Point stringExtent = gc.stringExtent(label);
Transform tr = new Transform(display);
tr.translate(groupNameRectangle.x, groupNameRectangle.y);
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.chronograph.internal.base.UnitConverter;
import org.eclipse.chronograph.internal.swt.BrickStyler;
import org.eclipse.chronograph.internal.swt.renderers.api.ChronographObjectContentRenderer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;

Expand All @@ -35,15 +36,20 @@ public void draw(Brick object, GC gc, Rectangle bounds, int vOffset) {
LocalDate now = LocalDate.now();
LocalDate start = UnitConverter.unitsToLocalDate((int) object.position().start());
LocalDate end = UnitConverter.unitsToLocalDate((int) object.position().end());
gc.setAntialias(SWT.ON);
gc.setBackground(BrickStyler.getColorBottom());

if (now.isAfter(start) && now.isBefore(end)) {
gc.setForeground(BrickStyler.getActiveColorTop());
gc.setBackground(BrickStyler.getActiveColorBottom());
gc.setBackground(BrickStyler.getActiveColorTop());
} else {
gc.setForeground(BrickStyler.getColorTop());
gc.setForeground(BrickStyler.getColorTop());
gc.setBackground(BrickStyler.getColorBottom());
}
gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width, bounds.height, true);

gc.fillRoundRectangle(bounds.x, bounds.y, bounds.width, bounds.height, 30,30);
gc.setForeground(BrickStyler.getColorBorder());
gc.drawRectangle(bounds);
gc.setBackground(BrickStyler.getColorBottom());
gc.fillOval(bounds.x-bounds.height/10, bounds.y, bounds.height, bounds.height);
}
}
Expand Up @@ -37,7 +37,7 @@ public void drawLabel(String label, Position brickPosition, GC gc, Rectangle obj
gc.drawString(label, objectBounds.x + 5, objectBounds.y - 15, true);

String msg = String.valueOf(UnitConverter.unitsToLocalDate((int) brickPosition.start()));
gc.drawString(msg, objectBounds.x + 5, objectBounds.y + objectBounds.height + 5, true);
gc.drawString(msg, objectBounds.x + 30, objectBounds.y + objectBounds.height / 5, true);

msg = String.valueOf(UnitConverter.unitsToLocalDate((int) brickPosition.end()));
gc.drawString(msg, objectBounds.x + objectBounds.width - msg.length() - 55,
Expand All @@ -46,7 +46,6 @@ public void drawLabel(String label, Position brickPosition, GC gc, Rectangle obj
gc.setForeground(StageStyler.STAGE_TOP_COLOR);
gc.drawLine(objectBounds.x, 0, objectBounds.x, 20);
gc.setForeground(BrickStyler.getColorBorder());
gc.drawLine(objectBounds.x, objectBounds.y - 20, objectBounds.x, objectBounds.y + objectBounds.height + 20);
gc.drawLine(objectBounds.x + objectBounds.width, objectBounds.y + objectBounds.height,
objectBounds.x + objectBounds.width, objectBounds.y + objectBounds.height);
gc.setLineStyle(SWT.LINE_SOLID);
Expand Down
Expand Up @@ -30,8 +30,8 @@ public class ObjectSelectedRendererImpl implements ChronographObjectContentRende
public void draw(Brick object, GC gc, Rectangle bounds, int vOffset) {
gc.setForeground(BrickStyler.getColorTopSelected());
gc.setBackground(BrickStyler.getColorBottomSelected());
gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width, bounds.height, true);
gc.setForeground(BrickStyler.getColorBorder());
gc.drawRectangle(bounds);
gc.fillRoundRectangle(bounds.x, bounds.y, bounds.width, bounds.height, 30,30);
gc.setBackground(BrickStyler.getColorTopSelected());
gc.fillOval(bounds.x-bounds.height/10, bounds.y, bounds.height, bounds.height);
}
}
Expand Up @@ -19,6 +19,7 @@

import org.eclipse.chronograph.internal.swt.RulerStyler;
import org.eclipse.chronograph.internal.swt.renderers.api.ChronographStageRulerRenderer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;

Expand All @@ -38,6 +39,7 @@ public void draw(GC gc, Rectangle bounds, int scale, int width, int tiksOffset,
int yBottomPosition = bounds.y + bounds.height - RulerStyler.RULER_DAY_HEIGHT - RulerStyler.RULER_MOUNTH_HEIGHT
- RulerStyler.RULER_YEAR_HEIGHT;
int xPosition = 0;
gc.setAntialias(SWT.ON);
calendar.clear();
calendar.set(Calendar.YEAR, 2019);
calendar.set(Calendar.MONTH, 0);
Expand All @@ -57,6 +59,11 @@ public void draw(GC gc, Rectangle bounds, int scale, int width, int tiksOffset,
gc.setForeground(RulerStyler.RULER_BRD_COLOR);
gc.drawLine(xPosition, yBottomPosition + RulerStyler.RULER_DAY_HEIGHT, xPosition, yBottomPosition);

if(scale > 4) {
gc.setForeground(RulerStyler.RULER_BTM_COLOR);
gc.drawLine(xPosition, bounds.y, xPosition, yBottomPosition);
}

// Keep here to show in ticks
// int currentTick = (xPosition / width) + (xAxis / (width * scale));
gc.setForeground(RulerStyler.RULER_TEXT_COLOR);
Expand Down
Expand Up @@ -31,11 +31,10 @@ public class SectionRendererImpl implements ChronographSectionRenderer<Section>

@Override
public void draw(GC gc, String label, Rectangle bounds, Display display, int width, int hintY) {
gc.setForeground(SectionStyler.SECTION_TOP_COLOR);
gc.setBackground(SectionStyler.SECTION_BTM_COLOR);
gc.fillGradientRectangle(1, bounds.y - hintY, width, bounds.height + 1, false);
gc.setForeground(SectionStyler.SECTION_BTM_COLOR);
gc.drawRectangle(0, bounds.y - hintY, bounds.width + width, bounds.height);
gc.setBackground(SectionStyler.SECTION_TOP_COLOR);
gc.fillRoundRectangle(0, bounds.y - hintY, width, bounds.height + 1, 30, 30);
gc.drawRoundRectangle(0, bounds.y - hintY, width, bounds.height + 1, 30, 30);
gc.setForeground(SectionStyler.SECTION_TOP_COLOR);
Point lblPoint = gc.stringExtent(label);
Transform tr = new Transform(display);
Expand Down
Expand Up @@ -73,4 +73,8 @@ public interface ChronographStage extends Drawable {

public void setProvider(ContainerProvider provider);

public void setZoomLevelDown();

public void setZoomLevelUp();

}

0 comments on commit cbb3d4d

Please sign in to comment.