Examples of MapObject


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

      copyBackground(gc);
      final List<MapObject> obj = cm.getAllObjects();
      _log.info("cell " + _id + " has " + obj.size() + " objects");

      final IStructuredSelection sel = UIActivator.getDefault().getSelection();
      MapObject selO = null;
      if (sel != null && !sel.isEmpty()) {
        final Object f = sel.getFirstElement();
        if (f instanceof MapObject)
          selO = (MapObject) f;
      }
View Full Code Here

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

  /**
   * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
   */
  @Override
  protected IFigure createFigure() {
    final MapObject obj = (MapObject) getModel();
    final ScannedMap map = (ScannedMap) getParent().getModel();
    final String symbol = EditPlugin.getBL().getProfile(map).getIcon(obj.getType());
    final ImageDescriptor desc = EditUIPlugin.getImageDescriptor("/icons/" + symbol + ".png"); //$NON-NLS-1$ //$NON-NLS-2$
    if (desc == null)
      throw new IllegalArgumentException("Icon for " + obj.getType() + " not found! " //$NON-NLS-1$ //$NON-NLS-2$
        + symbol);
    final Image img = desc.createImage();
    final ImageFigure fig = new ImageFigure(img);
    final Rectangle bounds = img.getBounds();
    final CoordinateSystem cs = getCoordinateSystem();
    final Point p = cs.toPoint(obj.getCenter().getNode().getPosition());
    bounds.x = p.x - bounds.width / 2;
    bounds.y = p.y - bounds.height / 2;
    fig.setBounds(new org.eclipse.draw2d.geometry.Rectangle(bounds));
    fig.setLayoutManager(new XYLayout());
    return fig;
View Full Code Here

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

  /**
   * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
   */
  @Override
  protected void refreshVisuals() {
    final MapObject p = (MapObject) getModel();
    final CoordinateSystem cs = getCoordinateSystem();
    final Point loc = cs.toPoint(p.getCenter().getNode().getPosition());
    final Dimension size = getFigure().getSize();
    loc.x -= size.width / 2;
    loc.y -= size.height / 2;
    final org.eclipse.draw2d.geometry.Rectangle r = new org.eclipse.draw2d.geometry.Rectangle(
      loc, size);
View Full Code Here

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

          return ""; //$NON-NLS-1$
      }
    if (element instanceof MapObject)
      switch (columnIndex) {
        case 0:
          final MapObject mo = (MapObject) element;
          String name = mo.getName();
          if (name == null)
            name = mo.getTags().get("name"); //$NON-NLS-1$
          return name == null ? mo.getId() : name;
        default:
          return ""; //$NON-NLS-1$
      }
    return element.toString();
  }
View Full Code Here

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

            return;
          final Object data = sel[0].getData();
          if (data instanceof MapObjectType) {
            final MapObjectType type = (MapObjectType) data;
            System.out.println("create " + type.name()); //$NON-NLS-1$
            final MapObject obj = new MapObject();
            final Position p = new Position();
            // p.setLatitude(new Angle(_centerLatitude.getVal()));
            // p.setLongitude(new Angle(_centerLongitude.getVal()));
            // obj.setCenter(p);
            // BoundingBox b = new BoundingBox();
View Full Code Here

Examples of tiled.core.MapObject

        final int x = getAttribute(t, "x", 0);
        final int y = getAttribute(t, "y", 0);
        final int width = getAttribute(t, "width", 0);
        final int height = getAttribute(t, "height", 0);

        MapObject obj = new MapObject(x, y, width, height);
        obj.setShape(obj.getBounds());
        if (name != null)
            obj.setName(name);
        if (type != null)
            obj.setType(type);

        NodeList children = t.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            if ("image".equalsIgnoreCase(child.getNodeName())) {
                String source = getAttributeValue(child, "source");
                if (source != null) {
                    if (! new File(source).isAbsolute()) {
                        source = xmlPath + source;
                    }
                    obj.setImageSource(source);
                }
                break;
            } else if ("ellipse".equalsIgnoreCase(child.getNodeName())) {
                obj.setShape(new Ellipse2D.Double(x, y, width, height));
            } else if ("polygon".equalsIgnoreCase(child.getNodeName()) || "polyline".equalsIgnoreCase(child.getNodeName())) {
                Polygon shape = new Polygon();
                final String pointsAttribute = getAttributeValue(child, "points");
                StringTokenizer st = new StringTokenizer(pointsAttribute, ", ");
                while (st.hasMoreElements()) {
                    shape.addPoint(x + Integer.parseInt(st.nextToken()), y + Integer.parseInt(st.nextToken()));
                }
                obj.setShape(shape);
                obj.setBounds(shape.getBounds());
            }
        }

        Properties props = new Properties();
        readProperties(children, props);

        obj.setProperties(props);
        return obj;
    }
View Full Code Here

Examples of tiled.core.MapObject

//        gc.translate(
//                bounds.x * tsize.x,
//                bounds.y * tsize.y);

        while (itr.hasNext()) {
            MapObject mo = itr.next();
            double ox = mo.getX() * zoom;
            double oy = mo.getY() * zoom;

            Image objectImage = mo.getImage(zoom);
            if (objectImage != null) {
                gc.drawImage(objectImage, (int) ox, (int) oy);
            }

            int objWidth = mo.getWidth();
      int objHeight = mo.getHeight();
      if (objWidth == 0 || objHeight == 0) {
                gc.setAntialias(SWT.ON);
                gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
                gc.fillOval((int) ox + 1, (int) oy + 1,
                        (int) (10 * zoom), (int) (10 * zoom));
                gc.setBackground(getDisplay().getSystemColor(OBJECT_FOREGROUND));
                gc.fillOval((int) ox, (int) oy,
                        (int) (10 * zoom), (int) (10 * zoom));
                gc.setAntialias(SWT.OFF);
            } else {
                gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
                gc.drawRectangle((int) ox + 1, (int) oy + 1,
                    (int) (objWidth * zoom),
                    (int) (objHeight * zoom));
                gc.setForeground(getDisplay().getSystemColor(OBJECT_FOREGROUND));
                gc.drawRectangle((int) ox, (int) oy,
                    (int) (objWidth * zoom),
                    (int) (objHeight * zoom));
            }
            if (zoom > 0.0625) {
              if (drawResizeAnchors) {
                drawAnchors(gc, ox, oy, objWidth, objHeight);
              }
                final String s = mo.getName() != null ? mo.getName() : "(null)";
                gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
                gc.drawString(s, (int) (ox - 5) + 1, (int) (oy - 5) + 1);
                gc.setForeground(getDisplay().getSystemColor(OBJECT_FOREGROUND));
                gc.drawString(s, (int) (ox - 5), (int) (oy - 5));
               
View Full Code Here

Examples of tiled.core.MapObject

      return;
    MapLayer layer = map.getLayer(mapView.getCurrentLayer());
    mapView.setCursor(Display.getDefault()
        .getSystemCursor(SWT.CURSOR_ARROW));
    if (layer instanceof ObjectGroup) {
      MapObject targetObject = ((ObjectGroup) layer)
          .getObjectAt(e.x, e.y);
      if (targetObject != null) {
        Rectangle bounds = ((ObjectGroup) layer)
            .getActualObjectRectangle(targetObject);
        Rectangle[] anchorRects = AnchoringUtil.getAnchorRects(bounds);
View Full Code Here

Examples of tiled.core.MapObject

  public boolean canStartDrag(MouseEvent e) {
    if (mapEditor.getCurrentPointerState() != MapEditor.PS_RESIZEOBJ)
      return false;
    MapLayer layer = map.getLayer(mapView.getCurrentLayer());
    if (layer instanceof ObjectGroup) {
      MapObject targetObject = ((ObjectGroup) layer)
          .getObjectAt(e.x, e.y);
      if (targetObject != null) {
        Rectangle bounds = ((ObjectGroup) layer)
            .getActualObjectRectangle(targetObject);
        Rectangle[] anchorRects = AnchoringUtil.getAnchorRects(bounds);
View Full Code Here

Examples of tiled.core.MapObject

    if (currentMode == SELECT_MODE) {
      setSelectionBounds(e);
      selectionLayer.maskedCopyFrom(editor.getCurrentLayer(), selectionLayer.getPixelBounds());
      Iterator<MapObject> objects = selectionLayer.getObjects();
      if (!objects.hasNext()) {
        MapObject object = ((ObjectGroup)editor.getCurrentLayer()).getObjectAt(e.x,e.y);
        if (object == null) {
          editor.getMap().removeLayerSpecial(selectionLayer);
          return;
        } else {
          selectionLayer.addObject(object);
          selectionLayer.setPixelBounds(object.getBounds());
          objects = selectionLayer.getObjects(); //To avoid concurrent modification
        }
       
      }
      Rectangle origBounds = selectionLayer.getPixelBounds();
      int left = origBounds.x + origBounds.width;
      int right = origBounds.x;
      int top = origBounds.y + origBounds.height;
      int bottom = origBounds.y;
      for (; objects.hasNext();) {
        MapObject object = objects.next();
        Rectangle rect = object.getBounds();
        if (rect.x < left)
          left = rect.x;
        if (rect.y < top)
          top = rect.y;
        if (rect.x + rect.width > right)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.