Package net.sf.myway.calibrator.da.entities

Examples of net.sf.myway.calibrator.da.entities.ScannedMap


  }

  public void save() {
    if (_calibrationObject == null)
      return;
    final ScannedMap upd = getDA().save(_calibrationObject.getMap());
    _calibrationObject.getMap().setId(upd.getId());
  }
View Full Code Here


   */
  public void setScannedFile(final String file) throws FileNotFoundException {
    final File f = new File(file);
    if (!f.exists())
      throw new FileNotFoundException(NLS.bind(Messages.CalibratorModel_FileNotFound, file));
    final ScannedMap map = new ScannedMap();
    // TODO map.setFile(file);
    setCalibratedMap(map);
  }
View Full Code Here

  /**
   * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
   */
  @Override
  protected IFigure createFigure() {
    final ScannedMap m = (ScannedMap) getModel();
    final Display display = Display.getDefault();
    final Image image = new Image(display, m.getFileName());
    final ImageData imageData = image.getImageData();

    final double north = m.getNorth().getVal();
    final double south = m.getSouth().getVal();
    final double west = m.getWest().getVal();
    final double east = m.getEast().getVal();
    final double dlat = north - south;
    final double dlon = east - west;
    final double latCenter = south + dlat / 2;
    final double lonCenter = west + dlon / 2;

    final Position center = new Position(latCenter, lonCenter);
    final Position nCenter = new Position(north, lonCenter);
    final Position eCenter = new Position(latCenter, east);

    final double latDist = center.distance(nCenter);
    final double lonDist = center.distance(eCenter);

    final int width = m.getUpperleft().distance(m.getUpperright());
    final int height = m.getUpperleft().distance(m.getLowerleft());

    final int w = width;
    final int h = (int) Math.min(2000, height * latDist / lonDist);

    final Vector2d p0 = new Vector2d(m.getUpperleft().getX(), m.getUpperleft().getY());
    final Vector2d vx = new Vector2d(m.getUpperright().getX(), m.getUpperright().getY()).minus(
      p0).div(w);
    final Vector2d vy = new Vector2d(m.getLowerleft().getX(), m.getLowerleft().getY())
      .minus(p0).div(h);

    _coordinateSystem = new CoordinateSystem();
    _coordinateSystem.setOrigin(new Position(m.getNorth(), m.getWest()));
    _coordinateSystem.setDx(new Vector2d(m.getEast().diff(m.getWest()) / w, 0));
    _coordinateSystem.setDy(new Vector2d(0, m.getSouth().diff(m.getNorth()) / h));

    ImageData id = (ImageData) imageData.clone();
    id = id.scaledTo(w, h);
    for (int y = 0; y < h; y++) {
      final Vector2d p = (Vector2d) p0.clone();
View Full Code Here

          if (obj instanceof Folder) {
            final Folder f = (Folder) obj;
            getBL().rename(f, newName);
          }
          else if (obj instanceof ScannedMap) {
            final ScannedMap m = (ScannedMap) obj;
            getBL().rename(m, newName);
          }
          _viewer.refresh();
        }
      }
    };
    _renameAction.setToolTipText(Messages.ScannedMapsView_RenameTooltip);
    _renameAction.setImageDescriptor(Activator.getImageDescriptor("/icons/pencil.png")); //$NON-NLS-1$

    _deleteAction = new Action(Messages.ScannedMapsView_Delete) {
      @Override
      public void run() {
        if (getViewer().getSelection() != null
          && getViewer().getSelection() instanceof IStructuredSelection) {
          final Object obj = ((IStructuredSelection) getViewer().getSelection())
            .getFirstElement();
          if (obj instanceof Folder) {
            final Folder f = (Folder) obj;
            if (showConfirm(getViewer().getControl().getShell(),
              Messages.ScannedMapsView_Delete, NLS.bind(
                Messages.ScannedMapsView_DeleteFolderConfirm, f.getName()),
              "/icons/folder_delete.png")) //$NON-NLS-1$
              CalibratorPlugin.getDA().delete(f);
          }
          else if (obj instanceof ScannedMap) {
            final ScannedMap m = (ScannedMap) obj;
            if (showConfirm(getViewer().getControl().getShell(),
              Messages.ScannedMapsView_Delete, NLS.bind(
                Messages.ScannedMapsView_DeleteMapConfirm, m.getName()),
              "/icons/map_delete.png")) { //$NON-NLS-1$
              m.getFolder().removeMap(m);
              CalibratorPlugin.getDA().delete(m);
            }
          }
        }
      }
View Full Code Here

   * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
   */
  @Override
  public void doSave(final IProgressMonitor monitor) {
    final ScannedMapEditorInput editorInput = (ScannedMapEditorInput) getEditorInput();
    final ScannedMap map = (ScannedMap) editorInput.getAdapter(ScannedMap.class);
    CalibratorPlugin.getDA().save(map);
    getCommandStack().markSaveLocation();
    _dirty = false;
    firePropertyChange(IEditorPart.PROP_DIRTY);
  }
View Full Code Here

  /**
   * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
   */
  @Override
  protected IFigure createFigure() {
    final ScannedMap m = (ScannedMap) getModel();
    final Image image = new Image(Display.getDefault(), m.getFileName());
    final ImageFigure fig = new ImageFigure(image);
    final Rectangle bounds = image.getBounds();
    fig.setBounds(new org.eclipse.draw2d.geometry.Rectangle(bounds));
    fig.setLayoutManager(new XYLayout());
    fig.setAlignment(PositionConstants.NORTH | PositionConstants.WEST);
    if (m.getUpperleft().equals(m.getUpperright()) && m.getUpperleft().equals(m.getLowerleft())) {
      m.setUpperleft(new Point(25, 25));
      m.setUpperright(new Point(bounds.width - 25, 25));
      m.setLowerleft(new Point(25, bounds.height - 25));
      m.setLowerright(new Point(bounds.width - 25, bounds.height - 25));
    }
    return fig;
  }
View Full Code Here

   * @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren()
   */
  @SuppressWarnings("rawtypes")
  @Override
  protected List getModelChildren() {
    final ScannedMap m = (ScannedMap) getModel();
    final List<Point> r = new ArrayList<Point>();
    r.add(m.getUpperleft());
    r.add(m.getUpperright());
    r.add(m.getLowerleft());
    r.add(m.getLowerright());
    return r;
  }
View Full Code Here

   * @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);
View Full Code Here

              _viewer.refresh();
              _viewer.refresh();
            }
          }
          else if (obj instanceof ScannedMap) {
            final ScannedMap f = (ScannedMap) obj;
            f.getName();
            // if (showConfirm(getViewer().getControl().getShell(), "Löschen",
            // "Region '"
            // + f.getRegion().getName() + "' und Inhalt wirklich löschen?",
            // "/icons/world_delete.png")) {
            // EditPlugin.getModel().delete(f);
View Full Code Here

        if (o instanceof Folder)
          folder = (Folder) o;
        else if (o instanceof ScannedMap)
          folder = ((ScannedMap) o).getFolder();
      }
      final ScannedMap map = new ScannedMap();
      map.setName(mapName.length() == 0 ? f.getName() : mapName);
      map.setFileName(f.getAbsolutePath());
      map.setFolder(folder);
      if (folder != null)
        folder.addMap(map);
      CalibratorPlugin.getModel().add(map);
      monitor.worked(2);
      // TODO ScannedMapView aktualisieren
View Full Code Here

TOP

Related Classes of net.sf.myway.calibrator.da.entities.ScannedMap

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.