protected GraphArc createArc(OWLEntity srcCls, OWLEntity targetCls, String relType, Icon icon) { GraphNode srcNode = new DefaultGraphNode(srcCls); GraphNode destNode = new DefaultGraphNode(targetCls); return createArc(srcNode, destNode, relType, icon); }
PCamera camera = ((PLayer) this.getParent()).getCamera(0); double viewScale = camera.getViewScale(); double scaleFactor = 1.0 / viewScale; double unscaledWidth = this.getGlobalBounds().width; double unscaledHeight = this.getGlobalBounds().height; double scaledWidth = this.getGlobalBounds().width * viewScale; double scaledHeight = this.getGlobalBounds().height * viewScale; this.scaleAboutPoint(scaleFactor, getX(), getY()); this.translate(-1 * xFactor, -1 * yFactor); this.translate(xFactor, yFactor); this.scaleAboutPoint(1.0 / getScale(), getX(), getY());
public void removeAttribute(Object key) { addAttribute(key, null); }
@Override public boolean setBounds(double x, double y, double width, double height) { // TODO handle maximum width? boolean changed = super.setBounds(x, y, width, height); if (changed) { if (pImage != null) { pImage.setBounds(getX() + PADDING_X, getY() + PADDING_Y, iconWidth, iconHeight); } textNode.setBounds(getX() + PADDING_X + iconWidth + ICON_GAP, getY() + PADDING_Y, textNode.getWidth(), textNode.getHeight()); updateArcLocations(); invalidatePaint(); fireChangeListeners(); } return changed; }
public DefaultGraphNode(Object userObject, String text, Icon icon, Object type) { super(); this.userObject = userObject; this.changeListeners = new ArrayList<ChangeListener>(); this.style = new DefaultGraphNodeStyle(); this.selected = false; this.highlighted = false; this.matching = false; this.arcs = new ArrayList<GraphArc>(); this.setPickable(true); this.setChildrenPickable(false); textNode = new GraphTextNode(); // make this node match the text size textNode.setConstrainWidthToTextWidth(true); textNode.setConstrainHeightToTextHeight(true); textNode.setPickable(false); addChild(textNode); setText(text); setIcon(icon); setType(type); }
/** * Populate the specified layout constraint */ public void populateLayoutConstraint(LayoutConstraint constraint) { if (constraint instanceof LabelLayoutConstraint) { LabelLayoutConstraint labelConstraint = (LabelLayoutConstraint) constraint; labelConstraint.label = fullText; labelConstraint.pointSize = 18; } else if (constraint instanceof BasicEntityConstraint) { BasicEntityConstraint basicEntityConstraint = (BasicEntityConstraint) constraint; if (this.hasPreferredLocation()) { basicEntityConstraint.hasPreferredLocation = true; basicEntityConstraint.preferredX = this.getX(); basicEntityConstraint.preferredY = this.getY(); } } }
if(node instanceof DefaultGraphNode) { DefaultGraphNode graphNode = (DefaultGraphNode)node; OWLEntity entity = (OWLEntity)graphNode.getUserObject(); out.println(entity.getIRI().toString() + "," + graphNode.getX() + "," + graphNode.getY());
Graphics2D g2 = paintContext.getGraphics(); PBounds bounds = getBounds(); bg = updateGradientPaintPoints((GradientPaint) bg); borderPaint = updateGradientPaintPoints((GradientPaint) borderPaint); addOverlayIcons(style.getOverlayIcons(this));
public void setHighlighted(boolean highlighted) { if (this.highlighted != highlighted) { this.highlighted = highlighted; bubbleNode(); textNode.invalidatePaint(); invalidatePaint(); } }
buffer.append(elideText(text, maxCharsPerLine)); break; int end = findWhiteSpace(text, maxCharsPerLine); if (end == -1) { end = Math.min(text.length(), maxCharsPerLine);
public void setIcon(Icon icon) { if (pImage != null) { pImage.removeAllChildren(); pImage.removeFromParent(); pImage.getImage().flush(); } if ((icon != null) && (icon instanceof ImageIcon)) { iconWidth = icon.getIconWidth(); iconHeight = icon.getIconHeight(); pImage = new PImage(((ImageIcon) icon).getImage()); pImage.setPickable(false); addChild(pImage); updateBounds(); } }
if (icons == null || !icons.equals(overlayIcons)) { for (PImage overlayIcon : overlayIconMap.values()) { removeChild(overlayIcon); overlayIcon = new PImage(((ImageIcon) icon).getImage()); overlayIcon.setPickable(false); addChild(overlayIcon); overlayIconMap.put(icon, overlayIcon);
private void showAllTooltips() { for(GraphNode node : graphController.getModel().getAllNodes()) { // make sure there isn't already a tooltip showing if(existingTooltipsMap.get((PNode)node) == null) { FrameTooltipNode toolTip = new FrameTooltipNode(graphController.getModel().getOwlModelManager(), (AbstractGraph)graphController.getGraph(), (PNode)node, (OWLEntity)node.getUserObject()); ((PNode)node).addChild(toolTip); existingTooltipsMap.put((PNode)node, toolTip); ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { PNode targetNode = existingTooltipsMap.get((PNode)e.getSource()); if(targetNode != null) { FrameTooltipNode toolTip = (FrameTooltipNode)targetNode; toolTip.updateLocation((AbstractGraph)graphController.getGraph(), toolTip.getParent()); } } }; ((DefaultGraphNode)node).addChangeListener(changeListener); changeListenerMap.put(toolTip, changeListener); } } } }
/** * Sets the bounds of this node based on the icon and text size. Takes into consideration the * maximum node width too. */ private void updateBounds() { PBounds textBounds = textNode.getBounds(); double w = (3 * PADDING_X) + iconWidth + ICON_GAP + textBounds.getWidth(); double h = (2 * PADDING_Y) + Math.max(iconHeight, textBounds.getHeight()); setBounds(getX(), getY(), w, h); }
public GraphNode addNode(Object userObject, String text, Icon icon, Object type) { if (userObject == null) { throw new NullPointerException("All graph nodes must have a user object."); } if (!nodes.containsKey(userObject)) { if (type == null) { type = GraphItem.UNKNOWN_TYPE; } DefaultGraphNode node = new DefaultGraphNode(userObject, text, icon, type); addNodeInternal(node); } return nodes.get(userObject); }
private void createDomainRangeRels(Set<OWLEntity> domains, Set<OWLEntity> ranges, OWLObjectProperty property) { // make relationships between all named classes in the domain and all named classes in the range for(OWLEntity domainClass : domains) { GraphNode srcNode = new DefaultGraphNode(domainClass); for (OWLEntity rangeClass : ranges) { GraphNode destNode = new DefaultGraphNode(rangeClass); String relType = owlModelManager.getRendering(property) + SUFFIX_DOMAIN_RANGE; GraphArc arc = createArc(srcNode, destNode, relType, null); if(!domainRangeRelsBuffer.contains(arc)) { domainRangeRelsBuffer.add(arc); } } } }