/** * Sets the arc types - maps a color to each arc type. */ public void setTypes(Collection<? extends Object> types) { setArcTypes(types); }
/** * Sets the arc types - this is done to map a background color/gradient to each arc type. * @param arcTypes the node types to add */ public void setArcTypes(Collection<? extends Object> arcTypes) { for (Object type : arcTypes) { addArcType(type); } }
public DefaultGraphArcStyle() { loadDefaultColors(); this.nextColorIndex = 0; this.arcTypeToColor = new HashMap<Object, Paint>(); this.defaultArcColor = getNextDefaultColor(); // new Color(64, 64, 128) this.dashWidth = 10f; this.capSquare = BasicStroke.CAP_SQUARE; tooltipBackground = defaultArcColor; tooltipTextColor = GraphicsUtils.getTextColor(tooltipBackground); tooltipFont = PText.DEFAULT_FONT; }
public MainFrame() { super("Baby Shrimp Test"); SampleGraphModel model = new SampleGraphModel(); this.graph = new FlatGraph(model); // color the nodes based on node type DefaultGraphNodeStyle nodeStyle = new DefaultGraphNodeStyle(); nodeStyle.setNodeTypes(model.getNodeTypes()); this.graph.setGraphNodeStyle(nodeStyle); // color the arcs based on arc type DefaultGraphArcStyle arcStyle = new DefaultGraphArcStyle(); arcStyle.setArcTypes(model.getArcTypes()); this.graph.setGraphArcStyle(arcStyle); initialize(); // run the initial layout on the nodes //SwingUtilities.invokeLater(new Runnable() { // public void run() { // try { // Thread.sleep(100); // } catch (InterruptedException e) { // } // graph.performLayout(); //} //}); }
public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Paint paint = getTypePaint(type); g2.setPaint(paint); g2.setStroke(new BasicStroke(3)); int midY = y + (height / 2); g2.drawLine(x + 2, midY, x + width - 4, midY); } };
public DefaultGraphArc(Object userObject, GraphNode src, GraphNode dest, Icon icon, Object type) { super(); this.userObject = userObject; this.src = src; this.dest = dest; setType(type); //this.path = new GeneralPath(); this.curveFactor = 0; this.selected = false; this.highlighted = false; this.showArrowHead = true; this.arrowHead = new ArrowHead(); this.inverted = false; if(icon != null) { this.icon = icon; image = new PImage(((ImageIcon) icon).getImage()); addChild(image); } this.style = new DefaultGraphArcStyle(); }
/** * Adds the arc type and maps a color/gradient to it which is used as the line color for the * arc. If the arc type already exists then nothing is done. * * @param type the node type to add */ public void addArcType(Object type) { if (!arcTypeToColor.containsKey(type)) { Color color = getNextDefaultColor(); arcTypeToColor.put(type, color); } }
public Stroke getStroke(GraphArc arc) { float width = (arc.isSelected() && arc.isHighlighted() ? THICK_STROKE_WIDTH : (arc.isHighlighted() || arc.isSelected() ? MEDIUM_STROKE_WIDTH : THIN_STROKE_WIDTH)); return createStroke(width, isDashed); }
public Stroke getStroke(GraphArc arc) { if (arc.getType().toString().contains(ProtegeGraphModel.DIRECT_SUBCLASS_SLOT_TYPE) || arc.getType().toString().contains(ProtegeGraphModel.DIRECT_INDIVIDUAL_SLOT_TYPE)) { setDashed(false); } else { setDashed(true); if (arc.getType().toString().contains("Equivalent")) { setDashedCapSquare(BasicStroke.CAP_ROUND); setDashWidth(2f); } else { setDashedCapSquare(BasicStroke.CAP_SQUARE); setDashWidth(10f); } } return super.getStroke(arc); } };
/** * Returns the paint to use for the arc. Checks if the arc type has a color mapped to it, if so * that color/paint is returned. Otherwise the default arc color is returned. * @param arc the arc whose paint/color will be returned * @return the paint or color for the arc */ public Paint getPaint(GraphArc arc) { return getTypePaint(arc.getType()); }
public AbstractGraph() { super(); this.model = new DefaultGraphModel(); this.graphModelListeners = new ArrayList<GraphModelListener>(); this.layouts = new ArrayList<LayoutAction>(); addDefaultLayouts(); this.graphPopupListener = new GraphPopupListener(); getCamera().addInputEventListener(graphPopupListener); this.filterManager = new FilterManager(this); this.filterManager.addFilterChangedListener(filterListener); this.selectedNodes = new NodeCollection(); selectedNodes.addCollectionListener(selectionListener); this.matchingNodes = new NodeCollection(); matchingNodes.addCollectionListener(matchingListener); this.nodeStyle = new DefaultGraphNodeStyle(); this.arcStyle = new DefaultGraphArcStyle(); addFocusListener(focusListener); // register to use our custom tooltips CustomToolTipManager.sharedInstance().registerComponent(this); initializeLayers(); // this is needed to handle keyboard events getRoot().getDefaultInputManager().setKeyboardFocus(new KeyHandlerDelegate(getCamera())); }
arcStyle.setArcTypes(model.getArcTypes()); this.graph.setGraphArcStyle(arcStyle);