/** * Returns the label size of the specified view in the given graph. */ public Dimension getLabelSize(EdgeView view, String label) { if (label != null && fontGraphics != null) { fontGraphics.setFont(GraphConstants .getFont(view.getAllAttributes())); metrics = fontGraphics.getFontMetrics(); int sw = (int)(metrics.stringWidth(label) * LABELWIDTHBUFFER); int sh = metrics.getHeight(); return new Dimension(sw, sh); } return null; }
/** * Overriding this in order to set the size of an editor to that of an * edited view. */ public Component getGraphCellEditorComponent(JGraph graph, Object cell, boolean isSelected) { Component component = super.getGraphCellEditorComponent(graph, cell, isSelected); // set the size of an editor to that of the view CellView view = graph.getGraphLayoutCache().getMapping(cell, false); Rectangle2D tmp = view.getBounds(); editingComponent.setBounds((int) tmp.getX(), (int) tmp.getY(), (int) tmp.getWidth(), (int) tmp.getHeight()); // I have to set a font here instead of in the // RealCellEditor.getGraphCellEditorComponent() because // I don't know what cell is being edited when in the // RealCellEditor.getGraphCellEditorComponent(). Font font = GraphConstants.getFont(view.getAllAttributes()); editingComponent.setFont((font != null) ? font : graph.getFont()); return component; }
for (int i = 0; i < values.length; i++) { String label = String.valueOf(values[i]); Font font = GraphConstants.getFont(attributes); Color fontColor = GraphConstants.getForeground(attributes); String hexFontColor = null;
/** * Configures the editor. Passed onto the realEditor. */ public Component getGraphCellEditorComponent( JGraph graph, Object cell, boolean isSelected) { setGraph(graph); editingComponent = realEditor.getGraphCellEditorComponent(graph, cell, isSelected); determineOffset(graph, cell, isSelected); canEdit = (lastCell != null && cell != null && lastCell.equals(cell)); CellView view = graph.getGraphLayoutCache().getMapping(cell, false); if (view != null) setFont(GraphConstants.getFont(view.getAllAttributes())); editingContainer.setFont(font); return editingContainer; }
Font font = GraphConstants.getFont(attributes); int fontsize = (font != null) ? font.getSize() : 11; int textHeight = (fontsize + SVGUtils.LINESPACING) * values.length;
/** * Install the attributes of specified cell in this renderer instance. This * means, retrieve every published key from the cells hashtable and set * global variables or superclass properties accordingly. * * @param view * the cell view to retrieve the attribute values from. */ protected void installAttributes(CellView view) { Map map = view.getAllAttributes(); setIcon(GraphConstants.getIcon(map)); setOpaque(GraphConstants.isOpaque(map)); setBorder(GraphConstants.getBorder(map)); setVerticalAlignment(GraphConstants.getVerticalAlignment(map)); setHorizontalAlignment(GraphConstants.getHorizontalAlignment(map)); setVerticalTextPosition(GraphConstants.getVerticalTextPosition(map)); setHorizontalTextPosition(GraphConstants.getHorizontalTextPosition(map)); bordercolor = GraphConstants.getBorderColor(map); borderWidth = Math.max(1, Math.round(GraphConstants.getLineWidth(map))); if (getBorder() == null && bordercolor != null) setBorder(BorderFactory.createLineBorder(bordercolor, borderWidth)); Color foreground = GraphConstants.getForeground(map); setForeground((foreground != null) ? foreground : defaultForeground); Color gradientColor = GraphConstants.getGradientColor(map); setGradientColor(gradientColor); Color background = GraphConstants.getBackground(map); setBackground((background != null) ? background : defaultBackground); setFont(GraphConstants.getFont(map)); labelEnabled = GraphConstants.isLabelEnabled(map); }
setGradientColor(gradientColor); setOpaque(GraphConstants.isOpaque(map)); setFont(GraphConstants.getFont(map)); Color tmp = GraphConstants.getForeground(map); fontColor = (tmp != null) ? tmp : getForeground();