Skip to content

Commit fc01868

Browse files
committed
contrib/android: rework the drawing of lines
Just use small boxes since we only draw horizontal/vertical lines. Extend these boxes a little to make sure they touch neighbor boxes and lines. Signed-off-by: Brice Goglin <[email protected]>
1 parent b4a99ae commit fc01868

File tree

1 file changed

+19
-2
lines changed
  • contrib/android/AndroidApp/lstopo/src/main/java/com/hwloc/lstopo

1 file changed

+19
-2
lines changed

contrib/android/AndroidApp/lstopo/src/main/java/com/hwloc/lstopo/Lstopo.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,25 @@ public void text(String text, int x, int y, int fontsize, int bold, int outside,
184184
* Draw topology line
185185
*/
186186
public void line(int x1, int y1, int x2, int y2){
187-
MyCanvas canvas = new MyCanvas(activity,x1 * xscale,x2 * xscale,y1 * yscale,y2 * yscale);
188-
layout.addView(canvas);
187+
int width = x2-x1;
188+
int height = y2-y1;
189+
if (width != 0 && height != 0)
190+
return; /* not supported yet */
191+
LinearLayout view = new LinearLayout(activity);
192+
view.setOrientation(LinearLayout.VERTICAL);
193+
layout.addView(view);
194+
if (width == 0)
195+
width = 2;
196+
if (height == 0)
197+
height = 2;
198+
view.setX((int)(xscale * x1)-1);
199+
view.setY((int)(yscale * y1)-1);
200+
GradientDrawable shape = new GradientDrawable();
201+
shape.setShape(GradientDrawable.RECTANGLE);
202+
shape.setColor(Color.rgb(0, 0, 0));
203+
view.setBackground(shape);
204+
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int)(xscale * width)+2, (int)(yscale * height)+2);
205+
view.setLayoutParams(params);
189206
}
190207

191208
public void setScreenSize(){

0 commit comments

Comments
 (0)