Package com.mxgraph.view

Examples of com.mxgraph.view.mxCellState


          // check for new distance
          int neighborIndex = vertexListStatic.indexOf(currNeighbor);
          double oldDistance = distances[neighborIndex];
          double currEdgeWeight;

          currEdgeWeight = costFunction.getCost(new mxCellState(view, connectingEdge, null));

          double newDistance = minDistance + currEdgeWeight;

          //final part - updating the structure
          if (newDistance < oldDistance)
View Full Code Here


      {
        Object currEdge = edges[j];
        Object source = aGraph.getTerminal(currEdge, true);
        Object target = aGraph.getTerminal(currEdge, false);

        double dist = (Double) distanceMap.get(source) + costFunction.getCost(new mxCellState(view, currEdge, null));

        if (dist < (Double) distanceMap.get(target))
        {
          distanceMap.put(target, dist);
          parentMap.put(target, source);
        }

        //for undirected graphs, check the reverse direction too
        if (!mxGraphProperties.isDirected(aGraph.getProperties(), mxGraphProperties.DEFAULT_DIRECTED))
        {
          dist = (Double) distanceMap.get(target) + costFunction.getCost(new mxCellState(view, currEdge, null));

          if (dist < (Double) distanceMap.get(source))
          {
            distanceMap.put(source, dist);
            parentMap.put(source, target);
          }
        }

      }
    }

    for (int i = 0; i < edgeNum; i++)
    {
      Object currEdge = edges[i];
      Object source = aGraph.getTerminal(currEdge, true);
      Object target = aGraph.getTerminal(currEdge, false);

      double dist = (Double) distanceMap.get(source) + costFunction.getCost(new mxCellState(view, currEdge, null));

      if (dist < (Double) distanceMap.get(target))
      {
        throw new StructuralException("The graph contains a negative cycle, so Bellman-Ford can't be completed.");
      }
View Full Code Here

    Iterator<Object> it = edges.iterator();

    while (it.hasNext())
    {
      Object edge = it.next();
      mxCellState state = graph.getView().getState(edge);
      Object source = (state != null) ? state.getVisibleTerminal(true)
          : graph.getView().getVisibleTerminal(edge, true);
      Object target = (state != null) ? state.getVisibleTerminal(false)
          : graph.getView().getVisibleTerminal(edge, false);

      if (((source != target) && ((target == cell && (parent == null || graph
          .isValidAncestor(source, parent, traverseAncestors))) || (source == cell && (parent == null || graph
          .isValidAncestor(target, parent, traverseAncestors))))))
View Full Code Here

  }
 
  protected void generateActivityDiagramInterchangeElements() {
    for (String flowElementId : generatedVertices.keySet()) {
      Object vertex = generatedVertices.get(flowElementId);
      mxCellState cellState = graph.getView().getState(vertex);
      GraphicInfo subProcessGraphicInfo = createDiagramInterchangeInformation(handledFlowElements.get(flowElementId),
              (int) cellState.getX(), (int) cellState.getY(), (int) cellState.getWidth(), (int) cellState.getHeight());
     
      // The DI for the elements of a subprocess are generated without knowledge of the rest of the graph
      // So we must translate all it's elements with the x and y of the subprocess itself
      if (handledFlowElements.get(flowElementId) instanceof SubProcess) {
View Full Code Here

      // hence we force the starting point of the sequence flow to the closest rhombus corner point.
      FlowElement sourceElement = handledFlowElements.get(sequenceFlows.get(sequenceFlowId).getSourceRef());
      if (sourceElement instanceof Gateway && ((Gateway) sourceElement).getOutgoingFlows().size() > 1) {
        mxPoint startPoint = points.get(0);
        Object gatewayVertex = generatedVertices.get(sourceElement.getId());
        mxCellState gatewayState = graph.getView().getState(gatewayVertex);
       
        mxPoint northPoint = new mxPoint(gatewayState.getX() + (gatewayState.getWidth()) / 2, gatewayState.getY());
        mxPoint southPoint = new mxPoint(gatewayState.getX() + (gatewayState.getWidth()) / 2, gatewayState.getY() + gatewayState.getHeight());
        mxPoint eastPoint = new mxPoint(gatewayState.getX() + gatewayState.getWidth(), gatewayState.getY() + (gatewayState.getHeight()) / 2);
        mxPoint westPoint = new mxPoint(gatewayState.getX(), gatewayState.getY() + (gatewayState.getHeight()) / 2);
       
        double closestDistance = Double.MAX_VALUE;
        mxPoint closestPoint = null;
        for (mxPoint rhombusPoint : Arrays.asList(northPoint, southPoint, eastPoint, westPoint)) {
          double distance = euclidianDistance(startPoint, rhombusPoint);
View Full Code Here

   */
  protected mxCellState getState(MouseEvent e)
  {
    Object cell = getCell(e);
    mxGraphView view = graphComponent.getGraph().getView();
    mxCellState state = getStateToMark(view.getState(cell));

    return (state != null && intersects(state, e)) ? state : null;
  }
View Full Code Here

    if (editingCell != null)
    {
      stopEditing(true);
    }

    mxCellState state = graphComponent.getGraph().getView().getState(cell);

    if (state != null)
    {
      double scale = Math.max(minimumEditorScale, graphComponent
          .getGraph().getView().getScale());
      JTextComponent currentEditor = null;
      this.trigger = trigger;
      editingCell = cell;

      scrollPane.setBounds(getEditorBounds(state, scale));
      scrollPane.setVisible(true);

      String value = getInitialValue(state, trigger);

      // Configures the style of the in-place editor
      if (graphComponent.getGraph().isHtmlLabel(cell))
      {
        editorPane.setDocument(mxUtils.createHtmlDocumentObject(state
            .getStyle(), scale));
        editorPane.setText(mxUtils.getBodyMarkup(value, true));

        // Workaround for wordwrapping in editor pane
        // FIXME: Cursor not visible at end of line
        JPanel wrapper = new JPanel(new BorderLayout());
        wrapper.setOpaque(false);
        wrapper.add(editorPane, BorderLayout.CENTER);
        scrollPane.setViewportView(wrapper);

        currentEditor = editorPane;
      }
      else
      {
        textArea.setFont(mxUtils.getFont(state.getStyle(), scale));
        Color fontColor = mxUtils.getColor(state.getStyle(),
            mxConstants.STYLE_FONTCOLOR, Color.black);
        textArea.setForeground(fontColor);
        textArea.setText(value);

        scrollPane.setViewportView(textArea);
View Full Code Here

        trigger = null;
        graphComponent.labelChanged(cell, getCurrentValue(), trig);
      }
      else
      {
        mxCellState state = graphComponent.getGraph().getView()
            .getState(cell);
        graphComponent.redraw(state);
      }

      if (scrollPane.getParent() != null)
View Full Code Here

   * or outgoing. Default is false.
   */
  public Object getConstraint(Object key, Object cell, Object edge,
      boolean source)
  {
    mxCellState state = graph.getView().getState(cell);
    Map<String, Object> style = (state != null) ? state.getStyle() : graph
        .getCellStyle(cell);

    return (style != null) ? style.get(key) : null;
  }
View Full Code Here

    // Checks for oversize label bounding box and corrects
    // the return value accordingly
    if (useBoundingBox)
    {
      mxCellState state = graph.getView().getState(vertex);

      if (state != null)
      {
        double scale = graph.getView().getScale();
        mxRectangle tmp = state.getBoundingBox();

        double dx0 = (tmp.getX() - state.getX()) / scale;
        double dy0 = (tmp.getY() - state.getY()) / scale;
        double dx1 = (tmp.getX() + tmp.getWidth() - state.getX() - state
            .getWidth())
            / scale;
        double dy1 = (tmp.getY() + tmp.getHeight() - state.getY() - state
            .getHeight())
            / scale;

        geo = new mxRectangle(geo.getX() + dx0, geo.getY() + dy0, geo
            .getWidth()
View Full Code Here

TOP

Related Classes of com.mxgraph.view.mxCellState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.