In my application, the lines may change their zIndex when the user clicks on them.
Here is a simple example: https://dev.3dmathpuzzles.com/3dmp/D...therlink3.html
In this example, red lines have a zIndex of 1, green lines have a zIndex of 2, and blue lines have a zIndex of 3.
Therefore, blue lines should be on top, green lines in the middle, and red lines at the bottom.
When I change the color of a line, I also change it's zIndex, but the UI does not show the line
in the correct zOrder. When I change the vertical line to blue, it should be on top, but the
horizontal green line is still overlaying it.
Here is my EntryPoint:
Here is the draw handler:
Here is the click handler:
Here is a simple example: https://dev.3dmathpuzzles.com/3dmp/D...therlink3.html
In this example, red lines have a zIndex of 1, green lines have a zIndex of 2, and blue lines have a zIndex of 3.
Therefore, blue lines should be on top, green lines in the middle, and red lines at the bottom.
When I change the color of a line, I also change it's zIndex, but the UI does not show the line
in the correct zOrder. When I change the vertical line to blue, it should be on top, but the
horizontal green line is still overlaying it.
Here is my EntryPoint:
Code:
package com._3dmathpuzzles.gwt.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.widgets.drawing.DrawPane; public class DiagonalSlitherlink3 implements EntryPoint { private DrawPane drawPane; public void onModuleLoad() { drawPane = new DrawPane(); DiagonalSlitherlinkDrawHandler3 drawHandler = new DiagonalSlitherlinkDrawHandler3(drawPane); drawPane.addDrawHandler(drawHandler); drawPane.setCanDragScroll(true); drawPane.setHtmlElement("gwt"); drawPane.setMatchElement(true); drawPane.draw(); } }
Code:
package com._3dmathpuzzles.gwt.client; import com.smartgwt.client.widgets.drawing.DrawLine; import com.smartgwt.client.widgets.drawing.DrawPane; import com.smartgwt.client.widgets.drawing.Point; import com.smartgwt.client.widgets.events.DrawEvent; import com.smartgwt.client.widgets.events.DrawHandler; public class DiagonalSlitherlinkDrawHandler3 implements DrawHandler { private DrawPane drawPane; public DiagonalSlitherlinkDrawHandler3(DrawPane drawPane) { this.drawPane = drawPane; } public void onDraw(DrawEvent event) { DrawLine drawLine = new DrawLine(); drawLine.addClickHandler(new LineClickHandler3(drawPane,drawLine)); drawLine.setDrawPane(drawPane); drawLine.setStartPoint(new Point(250,0)); drawLine.setEndPoint(new Point(250,500)); drawLine.setLineColor("#ff0000"); drawLine.setLineWidth(20); setLineZindex(drawLine); drawLine.draw(); drawLine = new DrawLine(); drawLine.addClickHandler(new LineClickHandler3(drawPane,drawLine)); drawLine.setDrawPane(drawPane); drawLine.setStartPoint(new Point(0,250)); drawLine.setEndPoint(new Point(500,250)); drawLine.setLineColor("#00ff00"); drawLine.setLineWidth(20); setLineZindex(drawLine); drawLine.draw(); } public static void setLineZindex(DrawLine drawLine) { if( "#ff0000".equals(drawLine.getLineColor()) ) drawLine.setZIndex(1); else if( "#00ff00".equals(drawLine.getLineColor()) ) drawLine.setZIndex(2); else if( "#0000ff".equals(drawLine.getLineColor()) ) drawLine.setZIndex(3); } }
Code:
package com._3dmathpuzzles.gwt.client; import com.smartgwt.client.widgets.drawing.DrawLine; import com.smartgwt.client.widgets.drawing.DrawPane; import com.smartgwt.client.widgets.drawing.events.ClickEvent; import com.smartgwt.client.widgets.drawing.events.ClickHandler; public class LineClickHandler3 implements ClickHandler { private DrawPane drawPane; private DrawLine drawLine; public LineClickHandler3(DrawPane drawPane, DrawLine drawLine) { this.drawPane = drawPane; this.drawLine = drawLine; } public void onClick(ClickEvent event) { if( "#ff0000".equals(drawLine.getLineColor()) ) drawLine.setLineColor("#00ff00"); else if( "#00ff00".equals(drawLine.getLineColor()) ) drawLine.setLineColor("#0000ff"); else if( "#0000ff".equals(drawLine.getLineColor()) ) drawLine.setLineColor("#ff0000"); DiagonalSlitherlinkDrawHandler3.setLineZindex(drawLine); drawPane.markForRedraw(); } }
Comment