Пример #1
0
  @Override
  public void doRefreshVisual(Group visual) {
    if (getContent() == null) {
      throw new IllegalStateException();
    }

    // set CSS class
    visual.getStyleClass().clear();
    visual.getStyleClass().add(CSS_CLASS);
    org.eclipse.gef4.graph.Node node = getContent();
    Map<String, Object> attrs = node.getAttrs();
    if (attrs.containsKey(ZestProperties.ELEMENT_CSS_CLASS)) {
      refreshCssClass(visual, ZestProperties.getCssClass(node));
    }

    // set CSS id
    String id = null;
    if (attrs.containsKey(ZestProperties.ELEMENT_CSS_ID)) {
      id = ZestProperties.getCssId(node);
    }
    visual.setId(id);

    // set CSS style
    if (attrs.containsKey(ZestProperties.NODE_RECT_CSS_STYLE)) {
      rect.setStyle(ZestProperties.getNodeRectCssStyle(node));
    }
    if (attrs.containsKey(ZestProperties.NODE_LABEL_CSS_STYLE)) {
      labelText.setStyle(ZestProperties.getNodeLabelCssStyle(node));
    }

    // determine label
    Object label = attrs.get(ZestProperties.ELEMENT_LABEL);
    // use id if no label is set
    if (label == null) {
      label = id;
    }
    // use the the DEFAULT_LABEL if no label is set
    String str =
        label instanceof String
            ? (String) label
            : label == null ? NODE_LABEL_EMPTY : label.toString();
    // eventually let the fisheye mode trim the label
    str = refreshFisheye(visual, attrs, str);
    refreshLabel(visual, str);

    refreshIcon(visual, attrs.get(ZestProperties.NODE_ICON));
    refreshNestedGraphArea(visual, isNesting());
    refreshTooltip(visual, attrs.get(ZestProperties.NODE_TOOLTIP));
  }
Пример #2
0
  @Override
  public void doRefreshVisual(FXConnection visual) {
    GraphLayoutContext glc = getGraphLayoutContext();
    if (glc == null || edgeLabelPart == null) {
      return;
    }

    Edge edge = getContent();
    Map<String, Object> attrs = edge.getAttrs();
    FXGeometryNode<ICurve> curveNode = visual.getCurveNode();

    // css class
    visual.getStyleClass().clear();
    visual.getStyleClass().add(CSS_CLASS);
    if (attrs.containsKey(ZestProperties.ELEMENT_CSS_CLASS)) {
      String cssClass = ZestProperties.getCssClass(edge);
      visual.getStyleClass().add(cssClass);
    }

    // css id
    if (attrs.containsKey(ZestProperties.ELEMENT_CSS_ID)) {
      String cssId = ZestProperties.getCssId(edge);
      visual.setId(cssId);
    }

    // css style
    if (attrs.containsKey(ZestProperties.EDGE_CURVE_CSS_STYLE)) {
      String connCssStyle = ZestProperties.getEdgeCurveCssStyle(edge);
      curveNode.setStyle(connCssStyle);
    }
    if (attrs.containsKey(ZestProperties.EDGE_LABEL_CSS_STYLE)) {
      String textCssStyle = ZestProperties.getEdgeLabelCssStyle(edge);
      edgeLabelPart.getVisual().setStyle(textCssStyle);
    }

    // label
    Object label = attrs.get(ZestProperties.ELEMENT_LABEL);
    if (label instanceof String) {
      edgeLabelPart.getVisual().setText((String) label);
    }

    // default decoration for directed graphs
    if (ZestProperties.GRAPH_TYPE_DIRECTED.equals(ZestProperties.getType(glc.getGraph(), true))) {
      visual.setEndDecoration(new ArrowHead());
    } else {
      visual.setEndDecoration(null);
    }

    // custom decoration
    IFXDecoration sourceDecoration = ZestProperties.getSourceDecoration(edge);
    if (sourceDecoration != null) {
      visual.setStartDecoration(sourceDecoration);
    }
    IFXDecoration targetDecoration = ZestProperties.getTargetDecoration(edge);
    if (targetDecoration != null) {
      visual.setEndDecoration(targetDecoration);
    }

    // connection router
    IFXConnectionRouter router = ZestProperties.getRouter(edge);
    if (router != null) {
      visual.setRouter(router);
    }

    // dashes
    Object style = attrs.get(ZestProperties.EDGE_STYLE);
    if (style == ZestProperties.EDGE_STYLE_DASHED) {
      curveNode.getStrokeDashArray().setAll(DASH_LENGTH, GAP_LENGTH);
    } else if (style == ZestProperties.EDGE_STYLE_DASHDOT) {
      curveNode.getStrokeDashArray().setAll(DASH_LENGTH, GAP_LENGTH, DOT_LENGTH, GAP_LENGTH);
    } else if (style == ZestProperties.EDGE_STYLE_DASHDOTDOT) {
      curveNode
          .getStrokeDashArray()
          .setAll(DASH_LENGTH, GAP_LENGTH, DOT_LENGTH, GAP_LENGTH, DOT_LENGTH, GAP_LENGTH);
    } else if (style == ZestProperties.EDGE_STYLE_DOTTED) {
      curveNode.getStrokeDashArray().setAll(DOT_LENGTH, GAP_LENGTH);
    } else {
      curveNode.getStrokeDashArray().clear();
    }
  }