Hi,

> -----Original Message-----
> From: Konstantin Kolinko [mailto:knst.koli...@gmail.com]
> Sent: Wednesday, August 19, 2015 12:10 AM
> /tomcat/trunk/webapps/examples/WEB-
> INF/classes/websocket/drawboard/DrawMessage.java
> 
> 2015-08-18 15:39 GMT+03:00 Mark Thomas <ma...@apache.org>:
> > On 18/08/2015 12:58, Konstantin Kolinko wrote:
> >> 2015-08-18 14:44 GMT+03:00  <ma...@apache.org>:
(...)
> >>> -            last = !"0".equals(elements[10]);
> >>> -
> >>
> >> I think the above condition can have either value. It is not always
> >> false.   As such,  I think removing the "last" flag below is wrong.
> >>
> >> You can remove getter/setter in DrawMessage, but DrawMessage
> >> constructor argument (as passed below) is used.
> >>
> >> The value of that property is used (directly, without calling a
> >> getter) in the following fragment above:
> >
> > It is only ever used to construct the wire representation from a
> > DrawMessage and when constructing a DrawMessage from the wire
> > representation.
> >
> > I don't see it being used outside of those two uses so I see no
> > requirement to keep it.
> >
> 
> 1. It is used at client side (by javascript code), and that javascript
> code has not been updated.
> 
> It must be aligned with java.
> 
> 2. At the same time you are right in your diagnosis and I do not see
> that value being used when performing actual drawing in javascript
> code. It is when serializing / deserializing, but I do not see any
> other use.
> 
> \webapps\examples\websocket\drawboard.xhtml
> 
> Line 378 is event handling function:
> [[[
>                     // Handles an incoming Websocket message.
>                     var handleOnMessage = function(message) {
> ]]]
> 
> skipping to line 478 there is the branch that processes the DrawMessage
> [[[
>                                     } else if (type == "1") {
>                                         // We received a new DrawMessage.
>                                         var maxLastHandledId = -1;
>                                         var drawMessages =
> msg.substring(1).split("|");
>                                         for (var i = 0; i <
> drawMessages.length; i++) {
>                                             var elements =
> drawMessages[i].split(",");
>                                             var lastHandledId =
> parseInt(elements[0]);
>                                                maxLastHandledId =
> Math.max(maxLastHandledId,
>                                                        lastHandledId);
> 
>                                             var path = new Path(
>                                                     parseInt(elements[1]),
>                                                     [parseInt(elements[2]),
>                                                     parseInt(elements[3]),
>                                                     parseInt(elements[4]),
> 
> parseInt(elements[5]) / 255.0],
>                                                     parseFloat(elements[6]),
>                                                     parseFloat(elements[7]),
>                                                     parseFloat(elements[8]),
>                                                     parseFloat(elements[9]),
>                                                     parseFloat(elements[10]),
>                                                     elements[11] != "0");
> 
>                                             // Draw the path onto the
> last canvas.
>                                             path.draw(canvasServerImageCtx);
>                                         }
> ]]]
> 
> The "elements[11] != "0""  line matches the "lastInChain" flag in java code.
> 
> The Path class is starting with line 270.
> It has "lastInChain" property that is not used by its draw() method,
> .but is used when serializing the message (function pushPath(path) -
> line 798)

You are right that the "lastInChain" flag of DrawMessage (Java) and Path 
(Javascript) was not used. The Javadoc of DrawMessage.isLastInChain() says:
    /**
     * Specifies if this DrawMessage is the last one in a chain
     * (e.g. a chain of brush paths).<br>
     * Currently it is unused.
     */

The Javascript code generates the "lastInChain" flag to indicate when a series 
of Paths/DrawMessages that has been constructed by pressing down the mouse 
button, moving the mouse and releasing the mouse button, is complete. However, 
because every Path/DrawMessage instance contains both the start and end point 
(instead of only containing one point which would mean the drawing code would 
need to keep the last Path element until the lastInChain flag is set to true), 
it is not used.

I do not know why I kept the flag when committing the drawboard example, but I 
think the flag can be removed at Javascript side as well. I will look into it.


Thanks,
Konstantin Preißer



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to