You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects General forum

how to control transparency in graphic elem...   Yongzhi YU Apr 28, 2005
Re: how to control transparency in graphic...   Kirk Kuykendall Apr 28, 2005
Re: how to control transparency in graphic...   Yongzhi YU May 02, 2005
Re: how to control transparency in graphic...   Kirk Kuykendall May 02, 2005
Re: how to control transparency in graphic...   Yongzhi YU May 04, 2005
Re: how to control transparency in graphic...   Michael Zand Jul 26, 2005
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject how to control transparency in graphic element 
Author Yongzhi YU 
Date Apr 28, 2005 
Message Hi All:
I am developing an application using java ArcObjects. I need to control the transparency of the graphic elements that I display with the map image. I use:

myMapDescription.setCustomGraphics(myGraphics);

to set these customized graphic elements on the map.
MyGraphics is an IGraphicElementsProxy that contains all the graphic elements. I have problem to set the transparency of these elements. I used the "setTransparency" function in IRgbColor when I set the color of my graphic element, but then I realize this function has the following description in its javadoc:

******
Transparency is the degree to which a color is opaque. True transparency is only supported at the layer level. For graphic elements, 0 for transparent and 255 for opaque are the only supported values. For layer transparency to work properly the display device must be set to "True Color (32 bit)".
******

It looks like I can only have 100% transparent or 100% opaque for my graphic element.

Is there any other way to control the transparency of a customized graphic?

Many thanks.

Yongzhi
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: how to control transparency in graphic element 
Author Kirk Kuykendall 
Date Apr 28, 2005 
Message Write a class that implements ILayer and have it contain an IElementCollection that gets drawn when ILayer.Draw is called.

Also implement IGeoDataset, IPersistStream and ILayerEffects. Return true for ILayerEffects.SupportsTransparency.
 
  Kirk Kuykendall
AmberGIS Programming Services & Sales
http://www.ambergis.com
Now Answering questions at:
http://gis.stackexchange.com/


 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: how to control transparency in graphic element 
Author Yongzhi YU 
Date May 02, 2005 
Message Hi Kirk:
Thank you very much for your timely reply.
I tried the method you mentioned but I have a problem with the ILayer I added to the map. It looks like the map server kept a record of the layer I added to the map, and the existing of this layer will affect the static properties the map service -- for example, if I added the layer by:

******
m_map.addLayer(graphicsLayer);
******

the layer IDs of other existing layers will be affected and I have to use the following code to move the layer to the end.

******
m_map.moveLayer(graphicsLayer, m_map.getLayerCount()-1).
******

And this layer will stay in the map server until I physically remove it with the following code:

******
m_map.deleteLayer(graphicsLayer);
******

In addition, does this mean is if there are two applications using the same map on the map server, and one application adds a layer to the map, this added layer will affect the other application?
The graphics I want to display on the map are just temporary graphics and I do not want these graphics affect the static properties of current map service.
I just post another question on this forum related to this problem, in which I asked how to add a layer dynamically to the map collected from the map server.
Thanks very much again for your kind help. ^_^
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: how to control transparency in graphic element 
Author Kirk Kuykendall 
Date May 02, 2005 
Message Sorry Yongzhi, but I've never tried this approach in ArcGIS server. You might be better off trying Brian Flood's approach:
http://www.spatialdatalogic.com/CS/blogs/brian_flood/archive/2004/12/13/3.aspx

I'm not sure if he tested it with server though.


 
  Kirk Kuykendall
AmberGIS Programming Services & Sales
http://www.ambergis.com
Now Answering questions at:
http://gis.stackexchange.com/


 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: how to control transparency in graphic element 
Author Yongzhi YU 
Date May 04, 2005 
Message Hi Kirk:
Thanks very much for you reply again.
I tried another way to add my graphic elements to the map, in which I add my graphic elements into a CompositeGraphicsLayer and then add the layer to the map. Then I remove the layer as soon as I export the map image. The problem I have is the added layer does not show on the map. All the original layers are fine and were shown on the map image though. I just wander if I missed anything in the code that makes the image can not be generated properly.
P.S., if I do not use a CompositeGraphicsLayer, but to use something like "m_mapDesc.setCustomGraphics(graphics);", the graphic elements will be displayed on the map image with no problem.
I will post a similar message on the forum to ask if there is anything wrong with the way I add the layer and generate the image.

The code is as following:
******************************
IImageType m_imageType = null;
IImageDisplay m_imageDisplay = null;
IMapImage mapImage = null;
ILayer customizedLayer = null;
IMap m_map = new IMapProxy(m_mapServerObj.getMap(m_mapServer.getDefaultMapName()));
try{
if (m_mapServer.getDefaultMapName() != null) {
m_imageType = new IImageTypeProxy(m_context.createObject(ImageType.
getClsid()));
m_imageType.setFormat(esriImageFormat.esriImagePNG);
m_imageType.setReturnType(esriImageReturnType.esriImageReturnURL);

m_imageDesc = new IImageDescriptionProxy(m_context.createObject(ImageDescription.getClsid()));
m_imageDesc.setDisplay(m_imageDisplay);
m_imageDesc.setType(m_imageType);

customizedLayer = new CompositeGraphicsLayer(m_context.createObject(CompositeGraphicsLayer.getClsid()));

customizedLayer.setName("Added Graphics Layer");
customizedLayer.setVisible(true);
customizedLayer.setCached(false);
m_map.addLayer(customizedLayer);
m_mapDesc = (m_mapServer.getServerInfo(m_mapServer.getDefaultMapName())).getDefaultMapDescription();

ArrayList mapGraphics = getMyMapGraphics();
if(mapGraphics!=null && mapGraphics.size()>0){

for(int i=0;i IElement curGI = (IElement)mapGraphics.get(i);
((CompositeGraphicsLayer)customizedLayer).addElement(curGI,0);
}
}

mapImage = m_mapServer.exportMapImage(m_mapDesc, m_imageDesc);
String mapImageUrl = mapImage.getURL();
return mapImageUrl;

} else {
throw new RuntimeException("No Default Map available !!! ");
}
}catch (Exception e){
e.printStackTrace();
throw e;
}finally{
if(customizedLayer!=null){
try{
m_map.deleteLayer(customizedLayer);
m_mapDesc = (m_mapServer.getServerInfo(m_mapServer.getDefaultMapName())).getDefaultMapDescription();
}catch (Exception me){
me.printStackTrace()
}
}
}
****************************** 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: how to control transparency in graphic element 
Author Michael Zand 
Date Jul 26, 2005 
Message Hi,
It's good to seen another developer who is using java with ArcGIS.
I think your problem is that you need a call to refreshServerObjects() before you make the call getDefaultMapDescription(). Otherwise the map description won't know about the layer you just added.
By the way, I was wondering if your graphics include north arrow and or scale bars? I have been creating them using MapSurroundFrames but I would be interested if there is a way to do it by putting them in a new layer.
Thanks,
Michael 
  Michael Zand
Information Builders, Inc.
www.informationbuilders.com