001: /* uDig - User Friendly Desktop Internet GIS client
002: * http://udig.refractions.net
003: * (C) 2004, Refractions Research Inc.
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation;
008: * version 2.1 of the License.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: */
015: package net.refractions.udig.printing.model;
016:
017: import java.awt.Graphics2D;
018:
019: import org.eclipse.core.runtime.IProgressMonitor;
020: import org.eclipse.ui.IMemento;
021:
022: /**
023: * Draws the preview for a box and prints the contents of a box. Must have a default constructor.
024: *
025: * @author Jesse
026: * @since 1.1.0
027: */
028: public interface BoxPrinter {
029:
030: /**
031: * Passes in a memento object so that the printer can be saved.
032: *
033: * @see AbstractBox
034: */
035: void save(IMemento memento);
036:
037: /**
038: * @param value the new value of the '<em>IMemento</em>' attribute.
039: * @see #save(IMemento)
040: */
041: void load(IMemento value);
042:
043: /**
044: * This method will be called by Page when the actual printing is being performed.
045: *
046: * The graphics object passed in will have its appropriate clipping set,
047: * so the drawing code can only draw inside this clip.
048: *
049: * @see Page
050: * @param graphics A <code>Graphics2D</code> object to perform the drawing on
051: * @param monitor
052: */
053: public void draw(Graphics2D graphics, IProgressMonitor monitor);
054:
055: /**
056: * This method is called by the frame work when it is time to display itself on
057: * the screen. It does not have to be a perfect representation of the actual printed value because
058: * It is not called during printing. It is recommended that caching be used for the preview as
059: * much as possible. This method may take as long as necessary, it is not run in the display thread.
060: *
061: * @param graphics A <code>Graphics2D</code> object to perform the drawing on.
062: * @param monitor
063: */
064: public void createPreview(Graphics2D graphics,
065: IProgressMonitor monitor);
066:
067: /**
068: * Returns true if a the preview has changed since last call of {@link #createPreview(Graphics2D, IProgressMonitor)}
069: * This method must <b>NOT</b> always return true because as long as it returns true createPreview is
070: * called and the screen is not updated. When it returns false the results of the last createPreview is
071: * drawn onto the screen.
072: *
073: * @return Returns true if a the preview has changed since last call of {@link #createPreview(Graphics2D, IProgressMonitor)}
074: */
075: public boolean isNewPreviewNeeded();
076:
077: /**
078: * Must return the id of the extension point where you registered this box printer.
079: * <p>
080: * <b>Each box printer has to be registered</b> in an extension to the extension point "net.refractions.udig.printing.ui.boxprinter".<br/>
081: * Say you have registered the extension with the id "myPrintBoxes" in the plugin "net.refractions.example.plugin":
082: * this method should then return the extension id "net.refractions.example.plugin.myPrintBoxes".
083: * </p>
084: * Failure to properly configure the extension point id will be noted on the console logs, no user
085: * interface notification will be performed.
086: *
087: * @return the id of the extension point that is used to load the BoxPrinter
088: */
089: public String getExtensionPointID();
090:
091: /**
092: * Returns the box the box set when the setBox method is called.
093: *
094: * @return the box the box set when the setBox method is called.
095: */
096: public Box getBox();
097:
098: /**
099: * Sets the owning box. getBox() should return the same box.
100: *
101: * @param box The box that owns this BoxPrinter.
102: */
103: public void setBox(Box box);
104: }
|