001: package org.jsqltool.jgraph.gui;
002:
003: import javax.swing.*;
004: import javax.swing.table.*;
005: import javax.swing.event.*;
006: import java.awt.*;
007: import org.jsqltool.conn.DbConnectionUtil;
008: import java.awt.event.*;
009: import org.jsqltool.gui.panel.*;
010: import org.jsqltool.gui.tablepanel.*;
011: import org.jsqltool.utils.Options;
012: import org.jsqltool.utils.ImageLoader;
013: import org.jgraph.JGraph;
014: import java.util.ArrayList;
015: import java.awt.geom.Point2D;
016: import org.jgraph.graph.*;
017:
018: /**
019: * <p>Title: JSqlTool Project</p>
020: * <p>Description: Vertex View, used by JGraph to represent an entity (table/view/synonymn).
021: * </p>
022: * <p>Copyright: Copyright (C) 2006 Mauro Carniel</p>
023: *
024: * <p> This file is part of JSqlTool project.
025: * This library is free software; you can redistribute it and/or
026: * modify it under the terms of the (LGPL) Lesser General Public
027: * License as published by the Free Software Foundation;
028: *
029: * GNU LESSER GENERAL PUBLIC LICENSE
030: * Version 2.1, February 1999
031: *
032: * This library is distributed in the hope that it will be useful,
033: * but WITHOUT ANY WARRANTY; without even the implied warranty of
034: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
035: * Library General Public License for more details.
036: *
037: * You should have received a copy of the GNU Library General Public
038: * License along with this library; if not, write to the Free
039: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
040: *
041: * The author may be contacted at:
042: * maurocarniel@tin.it</p>
043: *
044: * @author Mauro Carniel
045: * @version 1.0
046: */
047: public class EntityVertexView extends VertexView {
048:
049: private DefaultGraphCell data = null;
050:
051: private EntityPanel node = null;
052:
053: private VertexRenderer renderer = new VertexRenderer() {
054: public Component getRendererComponent(JGraph graph,
055: CellView view, boolean sel, boolean focus,
056: boolean preview) {
057: gridColor = graph.getGridColor();
058: highlightColor = graph.getHighlightColor();
059: lockedHandleColor = graph.getLockedHandleColor();
060: isDoubleBuffered = graph.isDoubleBuffered();
061: hasFocus = focus;
062: childrenSelected = graph.getSelectionModel()
063: .isChildrenSelected(view.getCell());
064: selected = sel;
065: this .preview = preview;
066: if (EntityVertexView.this .isLeaf()
067: || GraphConstants.isGroupOpaque(view
068: .getAllAttributes()))
069: installAttributes(view);
070: else
071: resetAttributes();
072:
073: node.setSize(200, 200);
074: return node;
075: }
076:
077: };
078:
079: public CellViewRenderer getRenderer() {
080: return renderer;
081: }
082:
083: public Point2D getPerimeterPoint(EdgeView edge, Point2D source,
084: Point2D p) {
085: return ((VertexRenderer) renderer).getPerimeterPoint(this ,
086: source, p);
087: }
088:
089: /**
090: * Costructor called by SchemaFrame class to create an "entity node".
091: */
092: public EntityVertexView(DefaultGraphCell data) {
093: this .data = data;
094: this .node = (EntityPanel) data.getUserObject();
095: cell = null;
096: parent = null;
097: childViews = new ArrayList(0);
098: allAttributes = createAttributeMap();
099: attributes = allAttributes;
100: groupBounds = VertexView.defaultBounds;
101: setCell(data);
102: }
103:
104: }
|