/** * 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()); }
/** * Clears the arc types, then iterates through all the arcs and adds the * arc types back in. */ public void recalculateArcTypes() { arcTypes.clear(); for (GraphArc arc: arcs.values()) { Object arcType = arc.getType(); if (!arcTypes.contains(arcType)) { arcTypes.add(arcType); fireArcTypeAddedEvent(arcType); } } }
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); } };
/** * Uses the arc cache to get all the unique arc types for the given node. */ private void prepareNodeSpecificActions(GraphNode node, JMenu expandBasedOnMenu) { expandBasedOnActions.clear(); expandBasedOnMenu.removeAll(); for(GraphArc arc : model.getCachedArcsForEntity((OWLEntity)node.getUserObject())) { Action action = getNodeExpansionAction(arc.getType().toString()); if(!expandBasedOnActions.contains(action)) { expandBasedOnActions.add(action); expandBasedOnMenu.add(action); } } }
private Set<GraphArc> loadUnreifiedRelations(OWLEntity entityOfInterest, boolean mustBeVisible) { unreifyRelationInstances(); Set<GraphArc> unreifiedRels = artifactToUnreifiedRels.get(entityOfInterest); if(unreifiedRels != null) { for(GraphArc arc : unreifiedRels) { if(!filterManager.isArcTypeVisible(arc.getType())) { unreifiedRels.remove(arc); } else { if(!isDisplayableNode((OWLEntity)arc.getDestination().getUserObject(), mustBeVisible)) { unreifiedRels.remove(arc); } } } } return unreifiedRels == null ? new HashSet<GraphArc>() : unreifiedRels; }
/** * Finds relationships between an artifact as a item in the domain, and the ranges of its * properties */ private Set<GraphArc> loadDomainRangeRels(OWLEntity entityOfInterest, boolean outgoing, boolean mustBeVisible) { Set<GraphArc> domainRangeArcs = new HashSet<GraphArc>(); getDomainRangeRelationships(); // ensures that domain range rels are created for (GraphArc relationship : domainRangeRelsBuffer) { if(!filterManager.isArcTypeVisible(relationship.getType())) continue; OWLEntity sourceObject = (OWLEntity) relationship.getSource().getUserObject(); OWLEntity destObject = (OWLEntity) relationship.getDestination().getUserObject(); if (!isDisplayableNode(sourceObject, mustBeVisible) || !isDisplayableNode(destObject, mustBeVisible)) { continue; } if ((outgoing && sourceObject.equals(entityOfInterest)) || destObject.equals(entityOfInterest)) { if(outgoing) relationship.setInverted(false); domainRangeArcs.add(relationship); } } return domainRangeArcs; }
if (layoutRelTypes.contains(arc.getType())) { filteredArcs.add(arc);
/** * Adds the list of arcs to the graph model. All nodes included in the arc relationships are * also added to the model if necessary. * * @param arcs */ private void addArcsToModel(Collection<GraphArc> arcs, boolean removeOldNodes) { Set<GraphNode> newGraphNodes = new HashSet<GraphNode>(); for (GraphArc arc : arcs) { GraphArc createdArc = addArc((OWLEntity) arc.getSource().getUserObject(), (OWLEntity) arc.getDestination().getUserObject(), arc.getType().toString(), arc.getIcon()); if (createdArc != null) { newGraphNodes.add(createdArc.getSource()); newGraphNodes.add(createdArc.getDestination()); createdArc.setInverted(arc.isInverted()); //PNode n = (PNode)createdArc.getDestination(); //System.out.println(n.getRoot().getClass()); } } if (removeOldNodes) { // remove all old nodes GraphNode[] allNodes = getAllNodes().toArray(new GraphNode[getAllNodes().size()]); for (GraphNode node : allNodes) { if (!newGraphNodes.contains(node)) { removeNode(node.getUserObject()); } } } }
/** * @see javax.swing.JComponent#getToolTipText(java.awt.event.MouseEvent) */ public String getToolTipText(MouseEvent e) { String tooltipText = ""; if (e != null) { PNode pnode = getCamera().pick(e.getX(), e.getY(), 1).getPickedNode(); if (pnode.getVisible()) { if (pnode instanceof GraphNode && isShowNodeTooltips()) { GraphNode node = (GraphNode) pnode; tooltipText = node.getTooltip(); ttBackground = node.getNodeStyle().getTooltipBackgroundColor(); ttTextColor = node.getNodeStyle().getTooltipTextColor(); ttFont = node.getNodeStyle().getTooltipFont(); } else if (pnode instanceof GraphArc) { GraphArc arc = (GraphArc) pnode; tooltipText = arc.getTooltip(); if (tooltipText == null || tooltipText.equals("")) { tooltipText = arc.getSource().getText() + " ---" + arc.getType() + "---> " + arc.getDestination().getText(); } ttBackground = arc.getArcStyle().getTooltipBackgroundColor(); ttTextColor = arc.getArcStyle().getTooltipTextColor(); ttFont = arc.getArcStyle().getTooltipFont(); } } } return (tooltipText.length() > 0 ? " " + tooltipText + " " : ""); }