package de.gurkenlabs.utiliti.renderers;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Stroke;
import java.awt.geom.Rectangle2D;

import de.gurkenlabs.litiengine.Game;
import de.gurkenlabs.litiengine.environment.tilemap.IMapObject;
import de.gurkenlabs.utiliti.Style;
import de.gurkenlabs.utiliti.components.Editor;
import de.gurkenlabs.utiliti.components.MapComponent;
import de.gurkenlabs.utiliti.handlers.Transform;

public class FocusRenderer implements IEditorRenderer {

  @Override
  public String getName() {
    return "FOCUS";
  }

  @Override
  public void render(Graphics2D g) {
    // render the focus and the transform rects
    final Rectangle2D focus = Editor.instance().getMapComponent().getFocusBounds();
    final IMapObject focusedMapObject = Editor.instance().getMapComponent().getFocusedMapObject();
    if (focus != null && focusedMapObject != null) {
      Stroke stroke = new BasicStroke(1 / Game.world().camera().getRenderScale(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 4, new float[] { 1f, 1f }, Game.time().now() / 15f);

      g.setColor(Color.BLACK);

      Game.graphics().renderOutline(g, focus, stroke);

      Stroke whiteStroke = new BasicStroke(1 / Game.world().camera().getRenderScale(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 4, new float[] { 1f, 1f }, Game.time().now() / 15.0f - 1f);
      g.setColor(Color.WHITE);
      Game.graphics().renderOutline(g, focus, whiteStroke);

      // render transform rects
      if (Editor.instance().getMapComponent().getEditMode() != MapComponent.EDITMODE_MOVE) {
        Stroke transStroke = new BasicStroke(1 / Game.world().camera().getRenderScale());
        for (Rectangle2D trans : Transform.getAnchors()) {
          g.setColor(Style.COLOR_TRANSFORM_RECT_FILL);
          Game.graphics().renderShape(g, trans);
          g.setColor(Color.BLACK);
          Game.graphics().renderOutline(g, trans, transStroke);
        }
      }
    }
  }
}
@@ -929,82 +929,348 @@
     
-Stroke stroke = new BasicStroke(1 / Game.world().camera().getRenderScale()
+final float strokeSize = (float) Math.max(1, Math.log(Game.world().camera().getRenderScale()) * 4);%0A      final float dashPhaseBlack = (float) ((Game.time().now() / 15f) * Math.max(1, Math.sqrt(Game.world().camera().getRenderScale())));%0A      final float dashPhaseWhite = dashPhaseBlack + strokeSize;%0A      Stroke stroke = new BasicStroke(1
 , Ba
@@ -1306,33 +1306,42 @@
 oke.JOIN_MITER, 
-4
+strokeSize
 , new float%5B%5D %7B 
@@ -1344,41 +1344,48 @@
 %5D %7B 
-1f, 1f %7D, Game.time().now() / 15f
+strokeSize, strokeSize %7D, dashPhaseBlack
 );%0A%0A
@@ -1520,49 +1520,8 @@
 ke(1
- / Game.world().camera().getRenderScale()
 , Ba
@@ -1565,17 +1565,26 @@
 _MITER, 
-4
+strokeSize
 , new fl
@@ -1595,48 +1595,48 @@
 %5D %7B 
-1f, 1f %7D, Game.time().now() / 15.0f - 1f
+strokeSize, strokeSize %7D, dashPhaseWhite
 );%0A 
@@ -1901,49 +1901,8 @@
 ke(1
- / Game.world().camera().getRenderScale()
 );%0A 

Improve focus renderer after adjusting ShapeRenderer.