Package roadnetwork

Examples of roadnetwork.RoadNetworkElement


      }

      return;
    case Flow:
      // Get the map element below the mouse
      RoadNetworkElement elementBelowMouse = roadNetwork.PointHitTest(transformedPoint);

      // If we are in the middle of creating a new flow and the user right
      // clicks or clicks somewhere that is not an edge cancel the
      // operation
      if ((creatingNewElement) && ((e.getButton() == MouseEvent.BUTTON3) || (elementBelowMouse == null) || !(elementBelowMouse instanceof Edge))) {
        creatingNewElement = false;
        newElement = null;
        repaint();

        return;
      }

      if ((elementBelowMouse != null) && (elementBelowMouse instanceof Edge)) {
        // Set the flow's ending point and add it to the traffic layer
        if (creatingNewElement) {
          ((Flow) newElement).setTo(new Point2D.Double(elementBelowMouse.getBounds().getCenterX(), elementBelowMouse.getBounds().getCenterY()));

          ((Flow) newElement).setEnd((Edge) elementBelowMouse);

          ((Flow) newElement).SetDependencies();

          currentTrafficLayer.AddTrafficElement(newElement);

          creatingNewElement = false;
          newElement = null;

          repaint();
        }
        // Start creating the flow
        else {
          newElement = new Flow();
          ((Flow) newElement).setStart((Edge) elementBelowMouse);
          ((Flow) newElement).setFrom(new Point2D.Float((float) elementBelowMouse.getBounds().getCenterX(), (float) elementBelowMouse.getBounds().getCenterY()));

          creatingNewElement = true;
        }
      }

      return;
    case Accident:
      // Get the map element below the mouse
      RoadNetworkElement elementBelowMouse2 = roadNetwork.PointHitTest(transformedPoint);

      if ((elementBelowMouse2 != null) && (elementBelowMouse2 instanceof Edge) && (e.getButton() == MouseEvent.BUTTON1)) {
        currentTrafficLayer.AddTrafficElement(new Accident((Edge) elementBelowMouse2, transformedPoint));
      }
View Full Code Here


      return;
    }

    // Find if an element is below the mouse location to show its tooltip
    TrafficDefinitionElement trafficElementBelowMouse = null;
    RoadNetworkElement roadElementBelowMouse = roadNetwork.PointHitTest(transformedPoint);

    if (currentTrafficLayer != null) {
      trafficElementBelowMouse = currentTrafficLayer.PointHitTest(transformedPoint);
    }

    // Set the tooltip of the element below the mouse
    if (trafficElementBelowMouse != null) {
      setToolTipText(trafficElementBelowMouse.getToolTip());
    } else if (roadElementBelowMouse != null) {
      setToolTipText(roadElementBelowMouse.getToolTip());
    } else {
      setToolTipText(null);
    }

    switch (tool) {
View Full Code Here

TOP

Related Classes of roadnetwork.RoadNetworkElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.