Select to view content in your preferred language

How to take the end point to draw a line in ArcEngine (MOLE LINE SYMBOL)?

2109
1
08-08-2012 02:49 AM
ApoorvaGora
New Contributor
what i am trying to do is draw a line as a molelinesymbol the first point i am able to pick from the mouse click but how to pick the second point? I am using Joptionpane showinput dialog, but as soon as that dialog box appears, the application will just hung up and never respond again..
I am putting the complete code in the text file attached and the AddLine function below..looking forward to your help guys.. I am really stuck :confused:..

private void AddLine(IPoint location)
[INDENT]{
  try
  {
   [INDENT]// create the symbol using a default symbol ID code (fix task line)
   IMoleSymbol moleSymbol = new MoleLineSymbol();
   moleSymbol.setSymbolID ("GUTPF---------X");
   moleSymbol.setTextLabels (getLabels());
   moleSymbol.setTextSize (2.0);

   // override the default line color and width - these settings are optional
   //ILineSymbol lineSymbol = (ILineSymbol) moleSymbol;
   //lineSymbol.setColor (getRandomColor());
   //lineSymbol.setWidth (dRandom(1, 5));

   // create a new line geometry for the symbol - this symbol requires two points
   IPointCollection pointCollection = new Polyline();

   // place the first endpoint of the line somewhere inside the current map extent
   IActiveView activeView = m_mapWindow.getMapBean().getActiveView();
   Envelope ext = (Envelope) activeView.getExtent();
   double lat = dRandom (ext.getYMin(), ext.getYMax());
   double lon = dRandom (ext.getXMin(), ext.getXMax());
   pointCollection.addPoint (location, null, null);

   // here i am trying to take Lat-Long from inputdialog
   lat=Double.parseDouble(JOptionPane.showInputDialog("Latitude",""));
   lon=Double.parseDouble(JOptionPane.showInputDialog("Longitude",""));


   [INDENT][/INDENT]pointCollection.addPoint (createPoint(lon, lat),null,null);
   // set up the graphic element with the random geometry
   ILineElement lineElement = new LineElement();
   lineElement.setSymbol ((ILineSymbol)moleSymbol);
   IElement element = (IElement) lineElement;
   element.setGeometry ((IGeometry)pointCollection);

   // add the new element to the map and update the user interface
   activeView.getGraphicsContainer().addElement (element, 0);
   activeView.partialRefresh (esriViewGraphics, null, null);
   ++m_unitCount;
   updateTitle();[/INDENT]
  }
  catch ( Exception e ) { e.printStackTrace(); }[/INDENT]

}
0 Kudos
1 Reply
EricBader
Honored Contributor
Hello Apoorva:

This looks like a great question to post on the ArcObjects - All Development Languages forum here:
http://forums.arcgis.com/forums/20-ArcObjects-All-Development-Languages.

You may get a quicker response from there.

Hope this is helpful.
0 Kudos