001: package net.refractions.udig.project;
002:
003: import java.awt.Color;
004: import java.io.IOException;
005: import java.net.URL;
006:
007: import net.refractions.udig.catalog.IGeoResource;
008:
009: import org.eclipse.core.runtime.IProgressMonitor;
010: import org.eclipse.ui.IMemento;
011:
012: /**
013: * TODO Purpose of net.refractions.udig.project
014: * <p>
015: * </p>
016: *
017: * @author Jesse
018: * @since 1.0.0
019: */
020: public abstract class StyleContent {
021:
022: /** <code>XPID</code> field */
023: public static final String XPID = "net.refractions.udig.project.style"; //$NON-NLS-1$
024:
025: private String id;
026:
027: /**
028: * Unique identifier of the style. This id must be the same as the id declared by the extension
029: * point.
030: * <p>
031: * This id is also used by Renderer and StyleConfigurator, often implementation will have a
032: * <code>static final String ID</code> defined for programmers.
033: * </p>
034: *
035: * @return The style id which identifies the style.
036: * @uml.property name="id"
037: */
038: public String getId() {
039: return id;
040: }
041:
042: /**
043: * Construct with ID suplied by subclass. This id must be the same as the id declared by the extension
044: * point.
045: *
046: * @param id
047: */
048: protected StyleContent(String id) {
049: this .id = id;
050: }
051:
052: /**
053: * Returns the class of the object which does the actual styling work.
054: *
055: * @return the class of the style object.
056: */
057: public abstract Class getStyleClass();
058:
059: /**
060: * Saves the state of a style object.
061: * <p>
062: * (Currently used with XMLMemento to persist StyleEntry, it is hoped that an EMFMemento can be
063: * writen).
064: * </p>
065: *
066: * @param style the style object to persisit.
067: * @param memento Momento used to store the style object state.
068: */
069: public abstract void save(IMemento memento, Object value);
070:
071: /**
072: * Loads a style object from a memento.
073: * <p>
074: * (Currently used with XMLMemento to persist StyleEntry, it is hoped that an EMFMemento can be
075: * writen).
076: * </p>
077: *
078: * @param memento object which contains previously saved object state.
079: * @return Loaded object and state.
080: */
081: public abstract Object load(IMemento memento);
082:
083: /**
084: * Loads a style object from a URL. This method is blocking.
085: *
086: * @param url the URL pointing to the style's location
087: * @param monitor Progress monitor to report back to caller, allowed to be null.
088: * @return a load style object, or null if it could not be loaded
089: * @throws IOException if there is an error loading the URL
090: */
091: public abstract Object load(URL url, IProgressMonitor monitor)
092: throws IOException;
093:
094: // /**
095: // * Creates a default style object from a geo resource. If the style does not support the
096: // * georesource, null should be returned. This method is allowed to block.
097: // *
098: // * @param resource The geo resource of the to be created layer.
099: // * @param scheme The color scheme of the map.
100: // * @param layerIndex The index to be used to determine which colors use in the style.
101: // *
102: // * @param monitor Progress monitor to report back to caller, allowed to be null.
103: // * @return A default style object, or null style does not apply to the georesource.
104: // * @throws IOException
105: // */
106: // public abstract Object createDefaultStyle(IGeoResource resource,
107: // ColourScheme scheme, int index, IProgressMonitor monitor)
108: // throws IOException;
109:
110: /**
111: * Creates a default Style give a resource and color.
112: *
113: * @param resource to attempt to create a style for.
114: * @param colour color to use while creating style.
115: * @param monitor monitor used to show progress of style creation.
116: * @return a "default" style or null if the style does not apply to the resource
117: * @throws IOException if a problem occurs accessing the GeoResource.
118: */
119: public abstract Object createDefaultStyle(IGeoResource resource,
120: Color colour, IProgressMonitor monitor) throws IOException;
121:
122: }
|