001: /*
002: * @(#)CellView.java 1.0 03-JUL-04
003: *
004: * Copyright (c) 2001-2004 Gaudenz Alder
005: *
006: */
007: package org.jgraph.graph;
008:
009: import java.awt.Component;
010: import java.awt.geom.Point2D;
011: import java.awt.geom.Rectangle2D;
012: import java.util.Map;
013:
014: import org.jgraph.JGraph;
015:
016: /**
017: * Defines the requirements for an object that
018: * represents a view for a model cell.
019: *
020: * @version 1.0 1/1/02
021: * @author Gaudenz Alder
022: */
023:
024: public interface CellView {
025:
026: //
027: // Data Source
028: //
029:
030: /**
031: * Returns the model object that this view represents.
032: */
033: Object getCell();
034:
035: /**
036: * Refresh this view based on the model cell. This is
037: * messaged when the model cell has changed.
038: */
039: void refresh(GraphLayoutCache cache, CellMapper mapper,
040: boolean createDependentViews);
041:
042: /**
043: * Update this view's attributes. This is messaged whenever refresh is
044: * messaged, and additionally when the context of the cell has changed,
045: * and during live-preview changes to the view.
046: * @param cache TODO
047: */
048: void update(GraphLayoutCache cache);
049:
050: void childUpdated();
051:
052: //
053: // Group Structure
054: //
055:
056: /**
057: * Returns the parent of view of this view.
058: */
059: CellView getParentView();
060:
061: /**
062: * Returns the child views of this view.
063: */
064: CellView[] getChildViews();
065:
066: /**
067: * Removes this view from the list of childs of the parent.
068: */
069: void removeFromParent();
070:
071: /**
072: * Returns true if the view is a leaf.
073: */
074: boolean isLeaf();
075:
076: //
077: // View Methods
078: //
079:
080: /**
081: * Returns the bounds for the view.
082: */
083: Rectangle2D getBounds();
084:
085: /**
086: * Returns true if the view intersects the given rectangle.
087: */
088: boolean intersects(JGraph g, Rectangle2D rect);
089:
090: /**
091: * Returns the intersection of the bounding rectangle and the straight line
092: * between the source and the specified point p. The specified point is
093: * expected not to intersect the bounds. Note: You must override this method
094: * if you use a different renderer. This is because this method relies on
095: * the VertexRenderer interface, which can not be safely assumed for
096: * subclassers.
097: */
098: Point2D getPerimeterPoint(EdgeView edge, Point2D source, Point2D p);
099:
100: /**
101: * Apply the specified map of attributes on the view.
102: */
103: Map changeAttributes(GraphLayoutCache cache, Map map);
104:
105: /**
106: * Returns all attributes of the view as a map.
107: */
108: AttributeMap getAttributes();
109:
110: AttributeMap getAllAttributes();
111:
112: //
113: // Renderer, Editor and Handle
114: //
115:
116: /**
117: * Returns a renderer component, configured for the view.
118: */
119: Component getRendererComponent(JGraph graph, boolean selected,
120: boolean focus, boolean preview);
121:
122: /**
123: * Returns a cell handle for the view.
124: */
125: CellHandle getHandle(GraphContext context);
126:
127: /**
128: * Returns a cell editor for the view.
129: */
130: GraphCellEditor getEditor();
131:
132: }
|