001: /*
002: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/treeview/TVLocale.java,v 1.1 2005/04/20 22:21:28 paulby Exp $
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is the Java 3D(tm) Scene Graph Editor.
011: * The Initial Developer of the Original Code is Paul Byrne.
012: * Portions created by Paul Byrne are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Paul Byrne.
016: *
017: **/
018: package org.jdesktop.j3dedit.scenegrapheditor.treeview;
019:
020: import java.awt.Graphics;
021: import java.awt.Graphics2D;
022: import java.awt.Point;
023: import java.awt.Shape;
024: import java.awt.Color;
025: import java.awt.geom.GeneralPath;
026: import java.awt.Polygon;
027: import java.awt.Dimension;
028: import java.awt.Font;
029: import java.awt.font.GlyphVector;
030: import java.awt.font.FontRenderContext;
031: import java.awt.geom.AffineTransform;
032: import java.util.Properties;
033:
034: import org.jdesktop.j3dedit.treelayout.TreePanel;
035: import org.jdesktop.j3dedit.scenegraph.SGObject;
036: import org.jdesktop.j3dedit.scenegraph.SGGroup;
037:
038: /**
039: * @author Paul Byrne
040: * @version 1.4, 01/18/02
041: */
042: public class TVLocale extends TVObject {
043:
044: private GlyphVector text = null;
045: private int textYOffset;
046: private int textXOffset;
047: protected GeneralPath hiddenLink;
048:
049: /** Creates new groupTreeNode */
050: public TVLocale(SGObject sgObject) {
051: super (39, 29, 29, sgObject);
052: hiddenLink = new GeneralPath();
053:
054: int w = getMinimumSize().width;
055: int h = getMinimumSize().height;
056:
057: hiddenLink.moveTo(w / 2, 0);
058: hiddenLink.lineTo(w / 2, 10);
059:
060: hiddenLink.moveTo(0, 10);
061: hiddenLink.lineTo(0, 5);
062: hiddenLink.lineTo(w, 5);
063: hiddenLink.lineTo(w, 10);
064: }
065:
066: public int numChildrenIgnoreHiddenFlag() {
067: return ((SGGroup) sgObject).numChildren();
068: }
069:
070: public int numChildren() {
071: return ((SGGroup) sgObject).numChildren();
072: }
073:
074: public org.jdesktop.j3dedit.treelayout.TreeNode getChild(int index) {
075: return (TVObject) ((SGGroup) sgObject).getChild(index)
076: .getTreeViewObject();
077: }
078:
079: public void setContainer(TreePanel panel) {
080: container = panel;
081:
082: for (int i = 0; i < numChildrenIgnoreHiddenFlag(); i++)
083: getChild(i).setContainer(panel);
084: }
085:
086: protected Point getBehaviorLinkEntry(Point behaviorLocation) {
087: return new Point(computedPosition.x + nodeSize.width / 2,
088: computedPosition.y + nodeSize.height / 2);
089: }
090:
091: private void createGlyphVector() {
092: Font font = new Font("dialog", Font.PLAIN, 10);
093: FontRenderContext context = new FontRenderContext(
094: new AffineTransform(), false, false);
095: text = font.createGlyphVector(context, new char[] { 'L', 'o',
096: 'c', 'a', 'l', 'e' });
097:
098: textYOffset = (int) (text.getLogicalBounds().getHeight());
099: textXOffset = (getNodeSize().height - (int) (text
100: .getLogicalBounds().getWidth())) / 2;
101: //+ getNodeSize().height/4;
102: }
103:
104: public void drawNode(Graphics2D g) {
105: super .drawNode(g);
106: Point computedPosition = getComputedPosition();
107: Dimension nodeSize = getNodeSize();
108:
109: Color origColor = g.getColor();
110:
111: if (icon != null && drawAsIcon) {
112: g.drawImage(icon, computedPosition.x, computedPosition.y,
113: null);
114: } else {
115: if (text == null)
116: createGlyphVector();
117:
118: g.setColor(Color.white);
119: g.fillOval(computedPosition.x, computedPosition.y,
120: nodeSize.width, nodeSize.height);
121: g.setColor(Color.black);
122: g.drawOval(computedPosition.x, computedPosition.y,
123: nodeSize.width, nodeSize.height);
124:
125: g.drawGlyphVector(text,
126: (float) (computedPosition.x + textXOffset),
127: (float) (computedPosition.y + textYOffset));
128: }
129:
130: g.setColor(origColor);
131: }
132:
133: }
|