[Swift-commit] r5826 - trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Thu Jul 12 12:34:24 CDT 2012


Author: hategan
Date: 2012-07-12 12:34:24 -0500 (Thu, 12 Jul 2012)
New Revision: 5826

Modified:
   trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ANSI.java
   trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/HLine.java
   trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/Table.java
   trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/TableColumn.java
   trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/VLine.java
Log:
nicer tables and fixed last column size rounding issue

Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ANSI.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ANSI.java	2012-07-12 16:20:48 UTC (rev 5825)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/ANSI.java	2012-07-12 17:34:24 UTC (rev 5826)
@@ -35,6 +35,11 @@
 	public static final int WHITE = 7;
 	public static final int DEFAULT = 9;
 
+	/*
+	 * UL UM UR
+	 * ML CR MR
+	 * LL LM LR
+	 */
 	public static final int GCH_LR_CORNER = 106;
 	public static final int GCH_UR_CORNER = 107;
 	public static final int GCH_UL_CORNER = 108;

Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/HLine.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/HLine.java	2012-07-12 16:20:48 UTC (rev 5825)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/HLine.java	2012-07-12 17:34:24 UTC (rev 5826)
@@ -23,6 +23,21 @@
 import java.io.IOException;
 
 public class HLine extends Component {
+    
+    private boolean leftEndCap, rightEndCap;
+    
+    public HLine(boolean leftEndCap, boolean rightEndCap) {
+        this.leftEndCap = leftEndCap;
+        this.rightEndCap = rightEndCap;
+    }
+    
+    public HLine(boolean endCaps) {
+        this(endCaps, endCaps);
+    }
+    
+    public HLine() {
+        this(false);
+    }
 
 	protected void draw(ANSIContext context) throws IOException {
 		context.lock();
@@ -34,6 +49,14 @@
 			for (int i = 0; i < width; i++) {
 				context.putChar(ANSI.GCH_H_LINE);
 			}
+			if (leftEndCap) {
+			    context.moveTo(sx - 1, sy);
+			    context.putChar(ANSI.GCH_ML_CORNER);
+			}
+			if (rightEndCap) {
+			    context.moveTo(sx + width, sy);
+			    context.putChar(ANSI.GCH_MR_CORNER);
+			}
 			context.lineArt(false);
 		}
 		finally {

Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/Table.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/Table.java	2012-07-12 16:20:48 UTC (rev 5825)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/Table.java	2012-07-12 17:34:24 UTC (rev 5826)
@@ -21,7 +21,6 @@
 package org.griphyn.vdl.karajan.monitor.monitors.ansi.tui;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import javax.swing.event.TableModelEvent;
@@ -47,7 +46,6 @@
 		this.model = model;
 		colWidths = new HashMap<Integer, Integer>();
 		sb = new VScrollbar();
-		sb.setBackgroundChar(ANSI.GCH_V_LINE);
 		sb.setThumbChar(ANSI.GCH_BULLET);
 		cellRenderer = new DefaultTableCellRenderer();
 	}
@@ -84,8 +82,8 @@
 			return;
 		}
 		removeAll();
-		sb.setLocation(width, 0);
-		sb.setSize(1, height);
+		sb.setLocation(width, 2);
+		sb.setSize(1, height - 2);
 		sb.setBgColor(bgColor);
 		sb.setFgColor(fgColor);
 		int cc = model.getColumnCount();
@@ -117,11 +115,16 @@
 			c.setBgColor(bgColor);
 			c.setFgColor(fgColor);
 			c.setLocation((int) cx, 0);
-			c.setSize(colWidth - 1, height);
+			if (last) {
+			    c.setSize(width - (int) cx, height);
+			}
+			else {
+			    c.setSize(colWidth - 1, height);
+			}
 			add(c);
 
 			if (!last) {
-				VLine l = new VLine();
+				VLine l = new VLine(true);
 				l.setBgColor(bgColor);
 				l.setFgColor(fgColor);
 				l.setLocation((int) (cx + colWidth) - 1, 0);
@@ -217,7 +220,7 @@
 			return super.keyboardEvent(key);
 		}
 	}
-
+	
     public TableCellRenderer getCellRenderer() {
         return cellRenderer;
     }

Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/TableColumn.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/TableColumn.java	2012-07-12 16:20:48 UTC (rev 5825)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/TableColumn.java	2012-07-12 17:34:24 UTC (rev 5826)
@@ -76,7 +76,7 @@
         text.setSize(width, 1);
         add(text);
 
-        HLine l = new HLine();
+        HLine l = new HLine(index == 0, index == model.getColumnCount() - 1);
         l.setBgColor(bgColor);
         l.setFgColor(fgColor);
         l.setLocation(0, 1);

Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/VLine.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/VLine.java	2012-07-12 16:20:48 UTC (rev 5825)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/VLine.java	2012-07-12 17:34:24 UTC (rev 5826)
@@ -23,6 +23,21 @@
 import java.io.IOException;
 
 public class VLine extends Component {
+    
+    private boolean topEndCap, bottomEndCap;
+    
+    public VLine(boolean topEndCap, boolean bottomEndCap) {
+        this.topEndCap = topEndCap;
+        this.bottomEndCap = bottomEndCap;
+    }
+    
+    public VLine(boolean endCaps) {
+        this(endCaps, endCaps);
+    }
+    
+    public VLine() {
+        this(false);
+    }
 
 	protected void draw(ANSIContext context) throws IOException {
 		context.bgColor(bgColor);
@@ -32,6 +47,14 @@
 			context.moveTo(sx, sy + i);
 			context.putChar(ANSI.GCH_V_LINE);
 		}
+		if (topEndCap) {
+            context.moveTo(sx, sy - 1);
+            context.putChar(ANSI.GCH_UM_CORNER);
+        }
+        if (bottomEndCap) {
+            context.moveTo(sx, sy + height);
+            context.putChar(ANSI.GCH_LM_CORNER);
+        }
 		context.lineArt(false);
 	}
 }




More information about the Swift-commit mailing list