Nice TWiki > Dev > NiceCasts (r1.22 vs. r1.23) TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Dev . { Changes | Index | Search | Go }
 <<O>>  Difference Topic NiceCasts (r1.23 - 06 Jun 2003 - AlexGreif)

      Rectangle rect = this.getHandlesBoundsRect();
      int width = cast(rect.getWidth());
      int height = cast(rect.getHeight());
getters return double

You should use:

      Rectangle rect = this.getHandlesBoundsRect();
      int width = int(rect.getWidth());
      int height = int(rect.getHeight());

int(...) in Nice is equivalent to (int) ... in Java. See


   public class ConnectionHandle extends Handle
      implements ConnectorListener

   java.util.List<ConnectionHandle> connectionHandles = this.getHandles().filter(asConnectionHandle);
   ConnectionHandle connectionHandle = connectionHandles.get(connectionHandleIndex);
   ?java.util.List<ConnectorListener> connectorListeners = conn.getConnectorListeners();
   if (connectorListeners != null  &&  notNull(connectorListeners).contains(connectionHandle)) {...}
In the last line I check the existence of a ConnectorListener in a List of ConnectorListeners. The local instance connectionHandle implements ConnectorListener.

The notNull should not be necessary, since Nice 0.7.8! :-) -- DanielBonniot

I compile with 0.7.8.
Without notNull the following error is reported

   [nicec] src/nice/flow4j/designer/figure/Connection.nice: line 211, column 80:
    [nicec] No possible call for contains.
    [nicec] Arguments: (?java.util.List<flow4j.designer.figure.ConnectorListener>, <t1691, U' | U' < nice.lang.Maybe> U'<t1691>)
    [nicec] Possibilities:
    [nicec] nice.lang.boolean contains(java.nio.charset.Charset, ?java.nio.charset.Charset)
    [nicec] nice.lang.boolean contains(flow4j.designer.figure.Handle this, Point)
    [nicec] nice.lang.boolean contains(flow4j.designer.figure.Figure this, Point)
    [nicec] nice.lang.boolean contains(flow4j.designer.figure.Connector this, Point)
    [nicec] nice.lang.boolean contains(java.awt.Component, ?java.awt.Point)
    [nicec] nice.lang.boolean contains(javax.accessibility.AccessibleRelationSet, ?java.lang.String)
    [nicec] nice.lang.boolean contains(javax.accessibility.AccessibleStateSet, ?javax.accessibility.AccessibleState)
    [nicec] nice.lang.boolean contains(javax.accessibility.AccessibleComponent, ?java.awt.Point)
    [nicec] nice.lang.boolean contains(java.awt.Polygon, ?java.awt.Point)
    [nicec] nice.lang.boolean contains(java.awt.Rectangle, ?java.awt.Rectangle)
    [nicec] nice.lang.boolean contains(java.awt.Rectangle, ?java.awt.Point)
    [nicec] nice.lang.boolean contains(java.awt.Shape, ?java.awt.geom.Point2D)
    [nicec] nice.lang.boolean contains(java.awt.Shape, ?java.awt.geom.Rectangle2D)
    [nicec] <Any K, Any V> nice.lang.boolean contains(java.util.Hashtable<K, V>, V)
    [nicec] <Any E> nice.lang.boolean contains(java.util.Collection<E>, E)
-- AlexGreif

With 0.7.8 I dont need the cast but need the notNull. If I leave the notNull off then the above problem is reported.

I'm surprised. You should not need notNull, because you test a local variable here. Can I have a self-contained testcase, please?

Topic NiceCasts . { View | Diffs | r1.24 | > | r1.23 | > | r1.22 | More }
Revision r1.22 - 06 Jun 2003 - 19:41 GMT - AlexGreif
Revision r1.23 - 06 Jun 2003 - 20:02 GMT - AlexGreif
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.