001: package net.refractions.udig.project.internal.render.impl;
002:
003: import java.io.IOException;
004:
005: import net.refractions.udig.project.ILayer;
006: import net.refractions.udig.project.internal.render.Renderer;
007: import net.refractions.udig.project.render.IRenderContext;
008: import net.refractions.udig.project.render.IRenderMetrics;
009: import net.refractions.udig.project.render.IRenderMetricsFactory;
010: import net.refractions.udig.project.render.IRenderer;
011:
012: import org.eclipse.core.runtime.IConfigurationElement;
013:
014: /**
015: * Used by Renderer creator for storing extra information about the RenderMetrics, such as the name and id provided by the Extension point.
016: *
017: * @author Jesse
018: * @since 1.1.0
019: */
020: class InternalRenderMetricsFactory implements IRenderMetricsFactory {
021: final IRenderMetricsFactory delegate;
022: private IConfigurationElement element;
023:
024: public InternalRenderMetricsFactory(IRenderMetricsFactory delegate,
025: IConfigurationElement element) {
026: this .delegate = delegate;
027: this .element = element;
028: }
029:
030: public boolean canRender(IRenderContext context) throws IOException {
031: return delegate.canRender(context);
032: }
033:
034: public InternalRenderMetricsFactory.InternalRenderMetrics createMetrics(
035: IRenderContext context) {
036: return new InternalRenderMetrics(delegate
037: .createMetrics(context), element);
038: }
039:
040: public Class<? extends IRenderer> getRendererType() {
041: return delegate.getRendererType();
042: }
043:
044: static class InternalRenderMetrics implements IRenderMetrics {
045: final IRenderMetrics delegate;
046: private String name;
047: private String description;
048: private String id;
049:
050: public InternalRenderMetrics(final IRenderMetrics delegate,
051: IConfigurationElement element) {
052: super ();
053: this .delegate = delegate;
054: name = element.getAttribute("name"); //$NON-NLS-1$
055: id = element.getNamespaceIdentifier()
056: + "." + element.getAttribute("id"); //$NON-NLS-1$ //$NON-NLS-2$
057: IConfigurationElement[] descChild = element
058: .getChildren("description"); //$NON-NLS-1$
059: if (descChild.length > 0) {
060: description = descChild[0].getValue();
061: }
062: }
063:
064: public boolean canAddLayer(ILayer layer) {
065: return delegate.canAddLayer(layer);
066: }
067:
068: public boolean canStyle(String styleID, Object value) {
069: return delegate.canStyle(styleID, value);
070: }
071:
072: public Renderer createRenderer() {
073: return delegate.createRenderer();
074: }
075:
076: public IRenderContext getRenderContext() {
077: return delegate.getRenderContext().copy();
078: }
079:
080: public IRenderMetricsFactory getRenderMetricsFactory() {
081: return delegate.getRenderMetricsFactory();
082: }
083:
084: public boolean isOptimized() {
085: return delegate.isOptimized();
086: }
087:
088: public String getDescription() {
089: return description;
090: }
091:
092: public String getName() {
093: return name;
094: }
095:
096: public String getId() {
097: return id;
098: }
099:
100: @Override
101: public String toString() {
102: return delegate.toString();
103: }
104: }
105: }
|