From a9e12f6c508810604c8c91ee15451776b08ce1a1 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 22 Apr 2019 07:41:56 -0400
Subject: [PATCH] Camera capslock fix

---
 timeflow/vis/timeline/AxisRenderer.java |  154 ++++++++++++++++++++++++++------------------------
 1 files changed, 80 insertions(+), 74 deletions(-)

diff --git a/timeflow/vis/timeline/AxisRenderer.java b/timeflow/vis/timeline/AxisRenderer.java
index 7d020cb..7c16246 100755
--- a/timeflow/vis/timeline/AxisRenderer.java
+++ b/timeflow/vis/timeline/AxisRenderer.java
@@ -9,80 +9,86 @@
 import timeflow.vis.Mouseover;
 import timeflow.vis.TimeScale;
 
-public class AxisRenderer {
-	
-	TimelineVisuals visuals;
-	
-	public AxisRenderer(TimelineVisuals visuals)
-	{
-		this.visuals=visuals;
-	}
-	
-	public void render(Graphics2D g, Collection<Mouseover> objectLocations)
-	{		
-		TFModel model=visuals.getModel();
-		g.setColor(model.getDisplay().getColor("chart.background"));
-		Rectangle bounds=visuals.getBounds();
-		
-		TimeScale scale=visuals.getTimeScale();
-		java.util.List<AxisTicMarks> t=AxisTicMarks.allRelevant(scale.getInterval());
-		
-		int dateLabelH=model.getDisplay().getInt("timeline.datelabel.height");
-		int y=bounds.y+bounds.height-dateLabelH;	
-		
-		// draw in reverse order so bigger granularity at top.
-		int n=t.size();
-		for (int i=0; i<n; i++)
-		{
-			render(t.get(i), g, bounds.x, y, dateLabelH-1, bounds.y, i==0, objectLocations);
-			y-=dateLabelH;
-		}
-	}
-	
-	void render(AxisTicMarks t, Graphics2D g, int x, int y, int h, int top, boolean full, Collection<Mouseover> objectLocations)
-	{
-		TFModel model=visuals.getModel();
+public class AxisRenderer
+{
+        TimelineVisuals visuals;
 
-		int n=t.tics.size();
-		for (int i=0; i<n-1; i++)
-		{
-			
-			long start=t.tics.get(i);
-			long end=t.tics.get(i+1);
-			
-			int x0=Math.max(x,visuals.getTimeScale().toInt(start));			
-			int x1=visuals.getTimeScale().toInt(end);
-			
-			int dayOfWeek=TimeUtils.cal(start).get(Calendar.DAY_OF_WEEK);
-			
-			g.setColor(t.unit.isDayOrLess() && (dayOfWeek==1 || dayOfWeek==7) ? 
-					new Color(245,245,245) : new Color(240,240,240));
+        public AxisRenderer(TimelineVisuals visuals)
+        {
+                this.visuals = visuals;
+        }
 
-			g.fillRect(x0, y, x1-x0-1, h);
-			g.setColor(Color.white);
-			g.drawLine(x1-1, y, x1-1, y+h);
-			g.drawLine(x0,y+h,x1,y+h);
-			objectLocations.add(new Mouseover(new Interval(start,end), x0, y, x1-x0-1, h));
-			
-			g.setFont(model.getDisplay().timeLabel());
-			String label=full? t.unit.formatFull(start) : t.unit.format(new Date(start));
-			int tx=x0+3;
-			int ty=y+h-5;
-			g.setColor(full ? Color.darkGray : Color.gray);
-			int sw=model.getDisplay().timeLabelFontMetrics().stringWidth(label);
-			if (sw<x1-tx-3)
-				g.drawString(label, tx,ty);
-			else
-			{
-				int c=label.indexOf(':');
-				if (c>0)
-				{
-					label=label.substring(0,c);
-					sw=model.getDisplay().timeLabelFontMetrics().stringWidth(label);
-					if (sw<x1-tx-3)
-						g.drawString(label, tx,ty);
-				}
-			}
-		}
-	}
+        public void render(Graphics2D g, Collection<Mouseover> objectLocations)
+        {
+                TimeflowModel model = visuals.getModel();
+                g.setColor(model.getDisplay().getColor("chart.background"));
+                Rectangle bounds = visuals.getBounds();
+
+                TimeScale scale = visuals.getTimeScale();
+                java.util.List<AxisTicMarks> t = AxisTicMarks.allRelevant(scale.getInterval());
+
+                int dateLabelH = model.getDisplay().getInt("timeline.datelabel.height");
+                int y = bounds.y + bounds.height - dateLabelH;
+
+                // draw in reverse order so bigger granularity at top.
+                int n = t.size();
+                for (int i = 0; i < n; i++)
+                {
+                        render(t.get(i), g, bounds.x, y, dateLabelH - 1, bounds.y, i == 0, objectLocations);
+                        y -= dateLabelH;
+                }
+        }
+
+        void render(AxisTicMarks t, Graphics2D g, int x, int y, int h, int top, boolean full, Collection<Mouseover> objectLocations)
+        {
+                TimeflowModel model = visuals.getModel();
+
+                int n = t.tics.size();
+                for (int i = 0; i < n - 1; i++)
+                {
+                        long start = t.tics.get(i);
+                        long end = t.tics.get(i + 1);
+
+                        int x0 = Math.max(x, visuals.getTimeScale().toInt(start));
+                        int x1 = visuals.getTimeScale().toInt(end);
+
+                        int dayOfWeek = TimeUtils.cal(start).get(Calendar.DAY_OF_WEEK);
+
+                        g.setColor(t.unit.isDayOrLess() && (dayOfWeek == 1 || dayOfWeek == 7)
+                                ? new Color(245, 245, 245) : new Color(240, 240, 240));
+
+                        g.fillRect(x0, y, x1 - x0, h);
+                        g.setColor(Color.white);
+                        g.drawLine(x1, y, x1, y + h);
+                        g.drawLine(x0, y + h, x1, y + h);
+                        objectLocations.add(new Mouseover(new Interval(start, end), x0, y, x1 - x0, h));
+
+                        g.setFont(model.getDisplay().timeLabel());
+                        String label = full ? t.unit.formatFull(start) : t.unit.format(new Date(start));
+                        
+                        if (!full)
+                                full = false;
+                        
+                        int tx = x0;
+                        int ty = y + h;
+                        g.setColor(full ? Color.darkGray : Color.gray);
+                        int sw = model.getDisplay().timeLabelFontMetrics().stringWidth(label);
+                        if (true) // sw < x1 - tx)
+                        {
+                                g.drawString(label, tx, ty);
+                        } else
+                        {
+                                int c = label.indexOf(':');
+                                if (c > 0)
+                                {
+                                        label = label.substring(0, c);
+                                        sw = model.getDisplay().timeLabelFontMetrics().stringWidth(label);
+                                        //if (sw < x1 - tx)
+                                        {
+                                                g.drawString(label, tx, ty);
+                                        }
+                                }
+                        }
+                }
+        }
 }

--
Gitblit v1.6.2