track board area while dragging

This commit is contained in:
Branislav Stojkovic
2019-01-20 10:47:27 +01:00
parent 32b2713732
commit 58aa0ab5be
@@ -68,15 +68,17 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
IDrawingObserver drawingObserver) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
if (componentState != ComponentState.DRAGGING) {
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
}
g2d.setColor(boardColor);
g2d.fillRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
g2d.setComposite(oldComposite);
Composite oldComposite = g2d.getComposite();
// render as transparent when dragging
int alpha = componentState == ComponentState.DRAGGING ? 0 : this.alpha;
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
}
g2d.setColor(boardColor);
g2d.fillRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
g2d.setComposite(oldComposite);
// Do not track any changes that follow because the whole board has been
// tracked so far.
drawingObserver.stopTracking();