1 9 10 package org.netbeans.modules.web.jsf.navigation.vwmodel; 11 12 import org.netbeans.modules.web.jsf.navigation.vwmodel.Page; 13 import java.awt.Dimension ; 14 import java.awt.FontMetrics ; 15 import java.awt.Image ; 16 import java.awt.Rectangle ; 17 18 22 public class GraphUtilities { 23 private static final String LAYOUT_TYPE = "layoutType"; private static final String LINK_TYPE = "linkType"; 26 private static final String LAYOUT_TYPE_DRAGGABLE = "draggable"; private static final String LAYOUT_TYPE_FLAT = "flat"; 29 private static final String LINK_TYPE_LINE = "line"; private static final String LINK_TYPE_ARC = "arc"; 32 public static final int STRAIGHT_LINE = 0; 33 public static final int ARC_LINE = 1; 34 public static int linkType = STRAIGHT_LINE; 35 36 public static final int LEFT = 0; 37 public static final int RIGHT = 1; 38 public static final int UP = 2; 39 public static final int DOWN = 3; 40 41 private static final int MOVE_STEP = 5; 42 43 static final int LINK_THRESHOLD = 10; static final int PAGEWIDTH = 80; static final int ZOOMEDPAGEWIDTH = 2*PAGEWIDTH; 46 static final int PAGEHEIGHT = PAGEWIDTH*11/8; static final int ZOOMEDPAGEHEIGHT = 2*PAGEHEIGHT; 48 static final int EARSIZE = PAGEWIDTH/5; static final int ARROWSIZE = 8; static final int ICONSIZE = 16; static final int ICONSPACING = 3; static final int ARROWSIZEROT = (int)(((float)ARROWSIZE)*0.707); static final int PORTWIDTH = 50; static final int PORTHEIGHT = 12; static final int PORTNIBWIDTH = 8; static final int PORTNIBHEIGHT = 6; static final int YSPACING = 40; 58 static final int XSPACING= 100; 59 static final int LEFT_OFFSET= 3*ARROWSIZE; static final int TOP_OFFSET= LEFT_OFFSET; 61 62 66 static final int SCROLLZONE = PAGEWIDTH; 68 69 73 74 private static Image getErrorIcon() { 75 if (errorIcon == null) { 76 errorIcon = org.openide.util.Utilities.loadImage("org/netbeans/modules/web/jsf/navigation/vwmodel/error.gif"); } 78 return errorIcon; 79 } 80 81 private static Image errorIcon; 82 83 84 private static Image getDynamicIcon() { 85 if (dynamicIcon == null) { 86 dynamicIcon = org.openide.util.Utilities.loadImage("org/netbeans/modules/web/jsf/navigation/vwmodel/dynamic.gif"); } 88 return dynamicIcon; 89 } 90 91 private static Image dynamicIcon; 92 93 96 static Image getCommandIcon() { 97 if (commandIcon == null) { 98 commandIcon = org.openide.util.Utilities.loadImage("org/netbeans/modules/web/jsf/navigation/vwmodel/command.gif"); } 100 return commandIcon; 101 } 102 103 private static Image commandIcon; 104 105 108 static Image getIdeaIcon() { 109 if (ideaIcon == null) { 110 ideaIcon = org.openide.util.Utilities.loadImage("org/netbeans/modules/web/jsf/navigation/vwmodel/lightbulb.gif"); } 112 return ideaIcon; 113 } 114 115 private static Image ideaIcon; 116 117 118 static int getStringWidth(FontMetrics metrics, String s) { 119 int w = 0; 120 if (s == null) { 121 return 0; 122 } 123 int n = s.length(); 124 for (int j = 0; j < n; j++) { 125 w += metrics.charWidth(s.charAt(j)); 126 } 127 return w; 128 } 129 130 131 public interface Layout { 132 145 public Dimension computeLayout(NavigationModel document, Rectangle alloc, 146 FontMetrics metrics, Page selected, 147 boolean keepPages, boolean keepLinks); 148 149 161 public boolean computePageLayout(NavigationModel document, Page page, FontMetrics metrics); 162 } 163 } 164 | Popular Tags |