Ejemplo n.º 1
0
  @SuppressWarnings("rawtypes")
  private void setPosition() {
    Coordinates coor;
    try {
      coor = GeoCoder.getGeoCoordinates(company.getAddress());

      double latitude = Double.parseDouble(coor.getLatitude());
      double longitude = Double.parseDouble(coor.getLongitude());
      position = new GeoPosition(latitude, longitude);
      jXMapKit.setAddressLocation(position);

      Set<Waypoint> waypoints = new HashSet<Waypoint>();
      waypoints.add(new Waypoint(latitude, longitude));

      WaypointPainter<?> painter = new WaypointPainter();
      painter.setWaypoints(waypoints);
      //	        painter.setRenderer(new WaypointRenderer() {
      //	            public boolean paintWaypoint(Graphics2D g, JXMapViewer map, Waypoint wp) {
      //	                g.setColor(Color.RED);
      //	                g.drawLine(-5,-5,+5,+5);
      //	                g.drawLine(-5,+5,+5,-5);
      //	                return true;
      //	            }
      //	        });

      jXMapKit.getMainMap().setOverlayPainter(painter);
      jXMapKit.getMainMap().setZoom(2);
      jXMapKit.setAddressLocationShown(true);
      jXMapKit.setCenterPosition(position);
      jXMapKit.setDataProviderCreditShown(true);
    } catch (NonExistentAddressException e) {
      JOptionPane.showMessageDialog(
          this,
          e.getMessage(),
          ApplicationInternationalization.getString("Error"),
          JOptionPane.ERROR_MESSAGE);
    } catch (WSResponseException e) {
      JOptionPane.showMessageDialog(
          this,
          e.getMessage(),
          ApplicationInternationalization.getString("Error"),
          JOptionPane.ERROR_MESSAGE);
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          this,
          e.getMessage(),
          ApplicationInternationalization.getString("Error"),
          JOptionPane.ERROR_MESSAGE);
    } catch (JDOMException e) {
      JOptionPane.showMessageDialog(
          this,
          e.getMessage(),
          ApplicationInternationalization.getString("Error"),
          JOptionPane.ERROR_MESSAGE);
    }
  }
Ejemplo n.º 2
0
 public boolean findItem(JXMapKit map, Point2D pt) {
   GeoPosition gp = pos.getPoint();
   Point2D pt1 = map.getMainMap().getTileFactory().geoToPixel(gp, map.getMainMap().getZoom());
   return pt1.distance(pt) < 20;
 }
Ejemplo n.º 3
0
  public JPDetailsCompany(JFMain frame) {
    setOpaque(false);
    this.parent = frame;
    Font font = new Font("Times New Roman", Font.PLAIN, 14);

    try {
      this.setPreferredSize(new java.awt.Dimension(850, 388));
      this.setLayout(null);
      {
        lblTitle = new JLabel();
        this.add(
            lblTitle,
            new GridBagConstraints(
                0,
                0,
                1,
                1,
                0.0,
                0.0,
                GridBagConstraints.CENTER,
                GridBagConstraints.NONE,
                new Insets(0, 0, 0, 0),
                0,
                0));
        lblTitle.setName("lblTitle");
        lblTitle.setText(ApplicationInternationalization.getString("companyTitle"));
        lblTitle.setBounds(85, 47, 282, 40);
        Font newFont = new Font("Times New Roman", Font.BOLD, 20);
        lblTitle.setFont(newFont);
      }
      {
        panelInfo = new JPanel();
        this.add(panelInfo);
        panelInfo.setLayout(null);
        panelInfo.setBounds(40, 73, 468, 195);
        panelInfo.setName("panelInfo");
        {
          panelDetailsCompany = new JPanel();
          panelDetailsCompany.setLayout(null);
          panelInfo.add(
              panelDetailsCompany,
              new GridBagConstraints(
                  0,
                  0,
                  1,
                  1,
                  0.0,
                  0.0,
                  GridBagConstraints.WEST,
                  GridBagConstraints.BOTH,
                  new Insets(0, 0, 0, 0),
                  0,
                  0));
          panelDetailsCompany.setName("panelDetailsCompany");
          {
            lblCountry = new JLabel();
            panelDetailsCompany.add(
                lblCountry,
                new AnchorConstraint(
                    718,
                    708,
                    815,
                    46,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            lblCountry.setName("lblCountry");
            lblCountry.setText(ApplicationInternationalization.getString("companyCountryPanel"));
            lblCountry.setBounds(21, 132, 269, 17);
            lblCountry.setFont(font);
          }
          {
            lblZip = new JLabel();
            panelDetailsCompany.add(
                lblZip,
                new AnchorConstraint(
                    593,
                    694,
                    684,
                    46,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            lblZip.setName("lblZip");
            lblZip.setText(ApplicationInternationalization.getString("companyZip"));
            lblZip.setBounds(21, 108, 268, 18);
            lblZip.setFont(font);
          }
          {
            lblAddress = new JXLabel();
            panelDetailsCompany.add(
                lblAddress,
                new AnchorConstraint(
                    474,
                    672,
                    559,
                    46,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            lblAddress.setName("lblAddress");
            lblAddress.setLineWrap(true);
            lblAddress.setText(ApplicationInternationalization.getString("companyAddress"));
            lblAddress.setBounds(21, 84, 268, 26);
            lblAddress.setFont(font);
          }
          {
            lblCif = new JLabel();
            panelDetailsCompany.add(
                lblCif,
                new AnchorConstraint(
                    281,
                    667,
                    372,
                    46,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            lblCif.setName("lblCif");
            lblCif.setText(ApplicationInternationalization.getString("companyCif"));
            lblCif.setBounds(21, 48, 274, 20);
            lblCif.setFont(font);
          }
          {
            lblNameCompany = new WrapLabel();
            panelDetailsCompany.add(
                lblNameCompany,
                new AnchorConstraint(
                    150,
                    663,
                    247,
                    46,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            lblNameCompany.setName("lblNameCompany");
            lblNameCompany.setText(ApplicationInternationalization.getString("companyName"));
            lblNameCompany.setBounds(21, 29, 274, 19);
            lblNameCompany.setFont(font);
          }
        }
        {
          panelImageCompany = new JPanel();
          panelImageCompany.setLayout(null);
          panelInfo.add(
              panelImageCompany,
              new GridBagConstraints(
                  1,
                  0,
                  1,
                  1,
                  0.0,
                  0.0,
                  GridBagConstraints.CENTER,
                  GridBagConstraints.BOTH,
                  new Insets(0, 0, 0, 0),
                  0,
                  0));
          panelImageCompany.setName("panelImageCompany");

          // Show the map
          jXMapKit = new JXMapKit();
          jXMapKit.setDefaultProvider(org.jdesktop.swingx.JXMapKit.DefaultProviders.OpenStreetMaps);
          jXMapKit.setDataProviderCreditShown(true);
          jXMapKit.setAutoscrolls(true);
          jXMapKit.setZoomButtonsVisible(false);

          panelImageCompany.add(
              jXMapKit,
              new GridBagConstraints(
                  0,
                  0,
                  1,
                  1,
                  0.0,
                  0.0,
                  GridBagConstraints.EAST,
                  GridBagConstraints.BOTH,
                  new Insets(0, 0, 0, 0),
                  0,
                  0));
          jXMapKit.setBounds(0, 0, 385, 231);
        }
      }
      {
        btnOK = new JButton();
        this.add(
            btnOK,
            new GridBagConstraints(
                -1,
                2,
                1,
                1,
                0.0,
                0.0,
                GridBagConstraints.EAST,
                GridBagConstraints.HORIZONTAL,
                new Insets(0, 330, 0, 10),
                0,
                0));
        btnOK.setName("btnOK");
        btnOK.setBounds(442, 292, 66, 23);
        btnOK.setText(ApplicationInternationalization.getString("btnOK"));
        btnOK.setDoubleBuffered(true);
        btnOK.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                parent.fadeOut();
                btnOK.setEnabled(false);
              }
            });
      }

      panelInfo.setOpaque(false);
      panelInfo.setBounds(12, 44, 815, 268);
      panelDetailsCompany.setOpaque(false);
      panelDetailsCompany.setBounds(55, 34, 307, 233);
      panelImageCompany.setOpaque(false);
      panelImageCompany.setBounds(368, 18, 385, 235);
      btnOK.setBounds(702, 324, 66, 23);

      Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
    } catch (Exception e) {
    }
  }