Getting the graphic representation of my IltNetworkElement.Type

Article ID: 2376
Last updated: 29 May, 2018
Article ID: 2376
Last updated: 29 May, 2018
Revision: 3
Views: 518
Posted: 08 Oct, 2010
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

How can I retrieve the graphic representation of the IltNetworkElement.Type to use it in an independant Java object?

Answer

You can access the network element type renderer factory using global settings IltSettings.GetValue(Object key).

When the network element is rendered using an image, its default renderer factory is an IltNEImageBaseRendererFactory object, and using the getSourceImageName() method of this class will give you the image location. You can then use this location to retrieve the image from the IltDefaultImageRepository object accessible from your IlpContext.

For instance,
  IltSettings.GetValue("NetworkElement.Type.IP_ComputerFlat.Renderer");
returns an IltNEImageBaseRendererFactory, which will give you the location of the image source that is being used for the network element type.

Now, this methodology works fine for network element types that use an image for rendering.

For other types that are rendering themselves directly through graphic primitives (for example, NetworkElement.Type.NE) the IltNEImageBaseRendererFactory is not used.

To overcome this, you can use the BufferedImage class together with the paint method of your graphic object, and dump to a graphic file the representation of each Network Element types that you want to use.

Example

BufferedImage image = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
networkView.paint(g);
ImageIO.write(image, "jpg", new File("ne_type.jpg"));

This source code fragment demontrates the first methodology, using the IltSettings.GetValue() together with the IltNEImageBaseRendererFactory.getSourceImageName().

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2376
Last updated: 29 May, 2018
Revision: 3
Views: 518
Posted: 08 Oct, 2010 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Also listed in


Others in this category