001: /*
002: * @(#)GraphUI.java 1.0 03-JUL-04
003: *
004: * Copyright (c) 2001-2004 Gaudenz Alder
005: *
006: */
007: package org.jgraph.plaf;
008:
009: import java.awt.Graphics;
010: import java.awt.Point;
011: import java.awt.event.MouseEvent;
012: import java.awt.geom.Dimension2D;
013: import java.awt.geom.Rectangle2D;
014:
015: import javax.swing.plaf.ComponentUI;
016:
017: import org.jgraph.JGraph;
018: import org.jgraph.graph.CellHandle;
019: import org.jgraph.graph.CellView;
020:
021: /**
022: * Pluggable look and feel interface for JGraph.
023: *
024: * @version 1.0 1/1/02
025: * @author Gaudenz Alder
026: */
027: public abstract class GraphUI extends ComponentUI {
028:
029: /**
030: * Paints the renderer of <code>view</code> to <code>g</code>
031: * at <code>bounds</code>.
032: */
033: public abstract void paintCell(Graphics g, CellView view,
034: Rectangle2D bounds, boolean preview);
035:
036: /**
037: * Paints the renderers of <code>portViews</code> to <code>g</code>.
038: */
039: public abstract void paintPorts(Graphics g, CellView[] portViews);
040:
041: /**
042: * Messaged to update the selection based on a MouseEvent for a group of
043: * cells. If the event is a toggle selection event, the cells are either
044: * selected, or deselected. Otherwise the cells are selected.
045: */
046: public abstract void selectCellsForEvent(JGraph graph,
047: Object[] cells, MouseEvent event);
048:
049: /**
050: * Returns the preferred size for <code>view</code>.
051: */
052: public abstract Dimension2D getPreferredSize(JGraph graph,
053: CellView view);
054:
055: /**
056: * Returns the <code>CellHandle</code> that is currently active,
057: * or <code>null</code> if no handle is active.
058: */
059: public abstract CellHandle getHandle();
060:
061: /**
062: * Returns true if the graph is being edited. The item that is being
063: * edited can be returned by getEditingCell().
064: */
065: public abstract boolean isEditing(JGraph graph);
066:
067: /**
068: * Stops the current editing session. This has no effect if the
069: * graph isn't being edited. Returns true if the editor allows the
070: * editing session to stop.
071: */
072: public abstract boolean stopEditing(JGraph graph);
073:
074: /**
075: * Cancels the current editing session. This has no effect if the
076: * graph isn't being edited. Returns true if the editor allows the
077: * editing session to stop.
078: */
079: public abstract void cancelEditing(JGraph graph);
080:
081: /**
082: * Selects the cell and tries to edit it. Editing will
083: * fail if the CellEditor won't allow it for the selected item.
084: */
085: public abstract void startEditingAtCell(JGraph graph, Object cell);
086:
087: /**
088: * Returns the cell that is being edited.
089: */
090: public abstract Object getEditingCell(JGraph graph);
091:
092: /**
093: * Sets the current location for Drag-and-Drop activity. Should be set to
094: * null after a drop.
095: */
096: public abstract void setInsertionLocation(Point p);
097:
098: /**
099: * Returns the insertion location for DnD operations.
100: */
101: public abstract Point getInsertionLocation();
102:
103: /**
104: * Updates the handle.
105: */
106: public abstract void updateHandle();
107:
108: /**
109: * Returns the current drop action.
110: */
111: public abstract int getDropAction();
112:
113: }
|