Package net.sf.myway.map.da.entities

Examples of net.sf.myway.map.da.entities.MapNode


  private EditMapEditPart _target;

  @Override
  public void execute() {
    final CoordinateSystem cs = _target.getCoordinateSystem();
    final MapNode center = _object.getCenter().getNode();
    final Point pos = new Point(newPos);
    if (_relative) {
      final Point point = cs.toPoint(center.getPosition());
      pos.x += point.x;
      pos.y += point.y;
    }
    final Position position = cs.toPosition(pos);
    MapNode n = getBL().findNode(position);
    if (getBL().hasSingleReference(center)) {
      // there is only one reference to the current center node
      if (n == null)
        // at the move destination there is no node, so we can move it
        center.setPosition(position);
      else {
        // there is already a node, so we change the ref and delete the old center
        getBL().delete(center);
        _object.getCenter().setNode(n);
      }
      center.setPosition(position);
    }
    // we have multiple references to the old center
    else if (n == null) {
      // at the move destination there is no node, so we have to create a new one
      n = new MapNode();
      n.setPosition(position);
      _object.getCenter().setNode(n);
    }
    else
      // there is a node at the destination, so just change the ref
      _object.getCenter().setNode(n);
View Full Code Here


   * @see org.eclipse.gef.commands.Command#execute()
   */
  @Override
  public void execute() {
    final Position position = _coordSys.toPosition(_location);
    MapNode n = EditPlugin.getBL().findNode(position);
    if (n == null) {
      n = _node;
      n.setPosition(position);
    }
    final MapNodeRef ref = new MapNodeRef(n);
    _target.addNode(ref);
  }
View Full Code Here

  protected void refreshFigure() {
    final Polyline polyline = (Polyline) getFigure();
    polyline.removeAllPoints();
    for (final MapNodeRef ref : ((MapObjectNodes) getModel()).getObject().getNodes()) {
      final MapNode node = ref.getNode();
      final Point p = getCoordinateSystem().toPoint(node.getPosition());
      polyline.addPoint(p);
    }
    polyline.setPreferredSize(polyline.getBounds().width, polyline.getBounds().height);
  }
View Full Code Here

      final Query q2 = session
        .createQuery("from net.sf.myway.map.db.MapNode node where node.latitude.val=:lat and node.longitude.val = :lon");
      q1.setParameter("key", system);
      final Map<String, MapNode> cache = new HashMap<String, MapNode>();
      for (final MapNode mapNode : nodes) {
        MapNode old = null;
        // Schritt 1: Suche die externe Referenz
        q1.setParameter("val", mapNode.getExtRef().get(system));
        List<MapNode> l = q1.list();
        if (l.isEmpty()) { // nicht gefunden
          // Schritt 2: Suche Node mit den Koordinaten
          q2.setParameter("lat", mapNode.getLatitude().getVal());
          q2.setParameter("lon", mapNode.getLongitude().getVal());
          l = q2.list();
          if (!l.isEmpty()) // immer noch nicht gefunden
            old = l.iterator().next();
        }
        else
          old = l.iterator().next();
        // Schritt 3: Anlegen oder aktualisieren
        if (old == null)
          session.persist(mapNode);
        else {
          if (mapNode.getTimestamp().after(old.getTimestamp())) {
            old.setTimestamp(mapNode.getTimestamp());
            old.setLatitude(mapNode.getLatitude());
            old.setLongitude(mapNode.getLongitude());
            old.setUser(mapNode.getUser());
            old.setTags(mapNode.getTags());
            old.addExtRef(system, mapNode.getExtRef(system));
          }
          cache.put(old.getExtRef(system), old);
        }
        trans.commit();
      }
      return cache;
    }
View Full Code Here

  /**
   * @see org.eclipse.gef.requests.CreationFactory#getNewObject()
   */
  @Override
  public Object getNewObject() {
    return new MapNode();
  }
View Full Code Here

   */
  @Override
  public void execute() {
    final CoordinateSystem cs = _target.getCoordinateSystem();
    final Position position = cs.toPosition(_location);
    MapNode n = EditPlugin.getBL().findNode(position);
    if (n == null) {
      n = new MapNode();
      n.setPosition(position);
    }
    final MapNodeRef ref = new MapNodeRef(n);
    _object.setCenter(ref);
    _target.addChild(_object);
  }
View Full Code Here

   * @return
   * @throws ParseException
   */
  private MapNode extractNode(final Element node, final Map<String, MapNode> lookup)
    throws ParseException {
    final MapNode n = new MapNode();
    final String osmId = node.attributeValue("id");
    lookup.put(osmId, n);
    n.addExtRef(SYSTEM_ID, osmId);
    n.setLatitude(new Angle(Double.parseDouble(node.attributeValue("lat"))));
    n.setLongitude(new Angle(Double.parseDouble(node.attributeValue("lon"))));
    n.setUser(node.attributeValue("user"));
    final String t = node.attributeValue("timestamp");
    final Date ts = parseTimestamp(t);
    final Calendar cal = Calendar.getInstance();
    cal.setTime(ts);
    n.setTimestamp(cal);
    final List<Element> tags = node.elements("tag");
    for (final Element tag : tags)
      n.addTag(tag.attributeValue("k"), tag.attributeValue("v"));
    return n;
  }
View Full Code Here

    polyline.setForegroundColor(Display.getDefault().getSystemColor(SWT.COLOR_CYAN));
    polyline.setLineWidth(5);
    polyline.setLineStyle(SWT.LINE_SOLID);
    polyline.setBackgroundColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
    for (final MapNodeRef ref : ((MapObjectNodes) getModel()).getObject().getNodes()) {
      final MapNode node = ref.getNode();
      final Point p = getCoordinateSystem().toPoint(node.getPosition());
      polyline.addPoint(p);
    }
    polyline.setPreferredSize(polyline.getBounds().width, polyline.getBounds().height);
    return polyline;
  }
View Full Code Here

TOP

Related Classes of net.sf.myway.map.da.entities.MapNode

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.