Package org.woped.core.model

Examples of org.woped.core.model.CreationMap


                    } else {
                        smallestY = p.y;
                    }
                }
            }
            CreationMap map = new CreationMap();
            map.setId(T_STAR);
            map.setName(T_STAR);
            map.setType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE);
            tStar = new TransitionModel(map);
            GraphConstants.setBorderColor(tStar.getAttributes(), T_STAR_COLOR);
            GraphConstants.setForeground(tStar.getNameModel().getAttributes(), T_STAR_COLOR);
            tStar.addPort();
            tStar.addPort();

            Point point;
            int x = 100;
            Point sourceArcPoint = null;
            Point sinkArcPoint = null;
            if (editor.isRotateSelected()) {
                point = new Point(biggestX + x, ((biggestY - smallestY) / 2) + tStar.getHeight());
                tStar.getNameModel().setPosition((biggestX + x + tStar.getWidth()),
                        ((biggestY - smallestY) / 2) + tStar.getHeight());
                sourceArcPoint = new Point(point.x + tStar.getWidth() / 2, source.getPosition().y + source.getHeight()
                        / 2);
                sinkArcPoint = new Point(point.x + tStar.getWidth() / 2, sink.getPosition().y + sink.getHeight() / 2);
            } else {
                point = new Point(((biggestX - smallestX) / 2) + tStar.getWidth(), biggestY + x);
                tStar.getNameModel().setPosition(((biggestX - smallestX) / 2) + tStar.getWidth(),
                        (biggestY + x + tStar.getHeight()));
                sourceArcPoint = new Point(source.getPosition().x + source.getWidth() / 2, point.y + tStar.getHeight()
                        / 2);
                sinkArcPoint = new Point(sink.getPosition().x + sink.getWidth() / 2, point.y + tStar.getHeight() / 2);
            }
            tStar.setPosition(point);
            GroupModel group = editor.getGraph().groupName(tStar, (tStar).getNameModel());
            group.setUngroupable(false);
            group.add(tStar);
            group.add(tStar.getNameModel());
            tStarComponents[0] = group;
            editor.getGraph().getGraphLayoutCache().insert(group);

            CreationMap sinkTStarMap = CreationMap.createMap();
            sinkTStarMap.setArcSourceId(sink.getId());
            sinkTStarMap.setArcTargetId(tStar.getId());
            sinkTStarMap.setEditOnCreation(false);
            List<Point> sinkTStarPointList = new ArrayList<Point>();
            sinkTStarPointList.add(sinkArcPoint);
            sinkTStarMap.setArcPoints(sinkTStarPointList);
            ArcModel sinkTStarArc = createArc(sinkTStarMap, true);
            tStarComponents[1] = sinkTStarArc;

            CreationMap tStarSourceMap = CreationMap.createMap();
            tStarSourceMap.setArcSourceId(tStar.getId());
            tStarSourceMap.setArcTargetId(source.getId());
            tStarSourceMap.setEditOnCreation(false);
            List<Point> tStarSourcePointList = new ArrayList<Point>();
            tStarSourcePointList.add(sourceArcPoint);
            tStarSourceMap.setArcPoints(tStarSourcePointList);
            ArcModel tStarSourceArc = createArc(tStarSourceMap, true);
            tStarComponents[2] = tStarSourceArc;
            editor.getGraph().setEnabled(false);
        }
    }
View Full Code Here


    return buttonCancel;
  }

  private void apply() {
    CreationMap map = transition.getCreationMap();
    map.setTriggerPosition(transition.getTriggerPosition());
    map.setResourcePosition(transition.getResourcePosition());

    // Remove old trigger plus resource classes if existing
    // Remember them here as deleteCell will cross-update the tool-specific
    // info
    DefaultGraphCell trigger = transition.hasTrigger() ? transition
        .getToolSpecific().getTrigger() : null;
    DefaultGraphCell resource = transition.hasResource() ? transition
        .getToolSpecific().getTransResource() : null;
    if (trigger != null) {
      getEditor().deleteCell(trigger, true);
    }
    if (resource != null) {
      getEditor().deleteCell(resource, true);
    }

    // Set new trigger and resource information
    if (getTriggerResourceRadioButton().isSelected()) {
      map.setTriggerType(TriggerModel.TRIGGER_RESOURCE);
      getEditor().createTrigger(map);

      String selectedRole = getRoleComboxBoxModel().getSelectedItem()
          .toString();
      String selectedGroup = getGroupComboxBoxModel().getSelectedItem()
          .toString();

      if (!selectedRole.equals(ROLE_NONE)
          && !selectedGroup.equals(GROUP_NONE)) {
        map.setResourceOrgUnit(selectedGroup);
        map.setResourceRole(selectedRole);
        getEditor().createTransitionResource(map);
      }
    } else if (getTriggerTimeRadioButton().isSelected()) {
      map.setTriggerType(TriggerModel.TRIGGER_TIME);
      getEditor().createTrigger(map);
    } else if (getTriggerMessageRadioButton().isSelected()) {
      map.setTriggerType(TriggerModel.TRIGGER_MESSAGE);
      getEditor().createTrigger(map);
    }

    // Name change handling
    transition.setNameValue(getNameTextField().getText());
View Full Code Here

 
  private void transformTransition(int nodeType, int operatorType)
  {
    LoggerManager.debug(Constants.EDITOR_LOGGER, "transformTransition()");

    CreationMap oldMap = transition.getCreationMap();
    CreationMap newMap = CreationMap.createMap();

    newMap = (CreationMap)oldMap.clone();
    // Most of the settings are just taken from the old model, but some
    // settings need to be different, of course (operator type,...)
    newMap.setType(nodeType);
    newMap.setOperatorType(operatorType);   
   
    ArrayList<CreationMap> incAcrs = new ArrayList<CreationMap>();
    ArrayList<CreationMap> outAcrs = new ArrayList<CreationMap>();

    Map<String, ArcModel> arcMap = editor.getModelProcessor().getElementContainer().getArcMap();
View Full Code Here

    }

    private void importPlaces(Place[] places, int editorIndex) throws Exception
    {
        int tokens;
        CreationMap map;
        // ??? int x;
        // ??? int y;
        for (int i = 0; i < places.length; i++)
        {
            map = CreationMap.createMap();
            map.setEditOnCreation(false);
            map.setId(places[i].getId());
            map.setType(AbstractPetriNetElementModel.PLACE_TYPE);
            map.setPosition(places[i].getGraphics().getPositionArray(0).getX(), places[i].getGraphics().getPositionArray(0).getY());
            map.setName(places[i].getName().getValue());
            /*
             * ODO Offset if
             * (places[i].getName().getGraphics().getOffsetArray().length > 0)
             * map.setNamePosition(places[i].getName().getGraphics().getOffsetArray(0).getX(),
             * places[i].getName() .getGraphics().getOffsetArray(0).getY()); if
             * (places[i].getName().getGraphics().getOffsetArray().length > 1) {
             * tempWidth =
             * places[i].getName().getGraphics().getOffsetArray(1).getX() -
             * places[i].getName().getGraphics().getOffsetArray(0).getX();
             * tempHeight =
             * places[i].getName().getGraphics().getOffsetArray(1).getX() -
             * places[i].getName().getGraphics().getOffsetArray(0).getX();
             * map.setNameSize(new Dimension(tempWidth, tempHeight)); }
             */
            if (places[i].isSetInitialMarking() && (tokens = Integer.parseInt(places[i].getInitialMarking().getValue())) != -1)
            {
                map.setTokens(tokens);
            }
            getEditor()[editorIndex].create(map);
            LoggerManager.debug(Constants.FILE_LOGGER, "   ... Place (ID:" + places[i].getId() + ") imported");
        }
    }
View Full Code Here

        }
    }

    private void importTransitions(Transition[] transitions, int editorIndex) throws Exception
    {
        CreationMap map;

        for (int i = 0; i < transitions.length; i++)
        {
            map = CreationMap.createMap();
            map.setEditOnCreation(false);
            map.setType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE);
            map.setId(transitions[i].getId());
            map.setPosition(transitions[i].getGraphics().getPositionArray(0).getX(), transitions[i].getGraphics().getPositionArray(0).getY());
            map.setName(transitions[i].getName().getValue());
            /*
             * TOO Offset if
             * (transitions[i].getName().getGraphics().getOffsetArray().length >
             * 0)
             * map.setNamePosition(transitions[i].getName().getGraphics().getOffsetArray(0).getX(),
             * transitions[i]
             * .getName().getGraphics().getOffsetArray(0).getY()); if
             * (transitions[i].getName().getGraphics().getOffsetArray().length >
             * 1) { tempWidth =
             * transitions[i].getName().getGraphics().getOffsetArray(1).getX() -
             * transitions[i].getName().getGraphics().getOffsetArray(0).getY();
             * tempHeight =
             * transitions[i].getName().getGraphics().getOffsetArray(1).getX() -
             * transitions[i].getName().getGraphics().getOffsetArray(0).getY();
             * map.setNameSize(new Dimension(tempWidth, tempHeight)); }
             */
            if (ConfigurationManager.getConfiguration().isImportToolspecific() && transitions[i].isSetToolspecific())
            {
                if (transitions[i].getToolspecific().getTool().equals("WoPeD") || transitions[i].getToolspecific().getTool().equals("PWT"))
                {
                    if (transitions[i].getToolspecific().isSetOperator())
                    {
                        map.setOperatorType(transitions[i].getToolspecific().getOperator().getOperatorType());
                        map.setType(TransitionModel.TRANS_OPERATOR_TYPE);
                        map.setId(transitions[i].getToolspecific().getOperator().getId());
                    }
                    /*
                     * else if
                     * (transitions[i].getToolspecific().isSetSubprocess()) {
                     * map.setType(PetriNetModelElement.SUBP_TYPE); }
                     */
                    if (transitions[i].getToolspecific().isSetTrigger())
                    {
                        map.setTriggerType(transitions[i].getToolspecific().getTrigger().getTriggerType());
                        map.setTriggerPosition(transitions[i].getToolspecific().getTrigger().getGraphics().getPositionArray(0).getX(), transitions[i].getToolspecific().getTrigger().getGraphics()
                                .getPositionArray(0).getY());
                    }
                } else
                {
                    map.addUnknownToolSpec(transitions[i].getToolspecific());
                }
            }
            if (!getEditor()[editorIndex].getModelProcessor().getElementContainer().containsElement(map.getId()))
            {
                getEditor()[editorIndex].create(map);
                LoggerManager.debug(Constants.FILE_LOGGER, " ... Transition (ID:" + map.getId() + ")imported");
            }
        }
    }
View Full Code Here

    private void importArcs(Arc[] arcs, int editorIndex) throws Exception
    {
        AbstractPetriNetElementModel currentSourceModel = null;
        AbstractPetriNetElementModel currentTargetModel = null;
        ArcModel arc = null;
        CreationMap map;
        for (int i = 0; i < arcs.length; i++)
        {
            currentSourceModel = (AbstractPetriNetElementModel) getEditor()[editorIndex].getModelProcessor().getElementContainer().getElementById(arcs[i].getSource());
            currentTargetModel = (AbstractPetriNetElementModel) getEditor()[editorIndex].getModelProcessor().getElementContainer().getElementById(arcs[i].getTarget());
            String tempID;

            if (ConfigurationManager.getConfiguration().isImportToolspecific())
            {
                if (currentTargetModel == null && currentSourceModel != null)
                {
                    if (arcs[i].getTarget().indexOf(OperatorTransitionModel.INNERID_SEPERATOR) != 0)
                    {
                        tempID = arcs[i].getTarget().substring(0, arcs[i].getTarget().indexOf(OperatorTransitionModel.INNERID_SEPERATOR));
                    } else
                    {
                        tempID = arcs[i].getTarget().substring(0, arcs[i].getTarget().indexOf(OperatorTransitionModel.INNERID_SEPERATOR_OLD));
                    }
                    if (isOperator(getEditor()[editorIndex].getModelProcessor(), tempID))
                    {
                        map = CreationMap.createMap();
                        map.setArcSourceId(arcs[i].getSource());
                        map.setArcTargetId(tempID);
                        arc = (ArcModel)getEditor()[editorIndex].create(map);
                    }
                }
                if (currentSourceModel == null && currentTargetModel != null)
                {
                    if (arcs[i].getSource().indexOf(OperatorTransitionModel.INNERID_SEPERATOR) != 0)
                    {
                        tempID = arcs[i].getSource().substring(0, arcs[i].getSource().indexOf(OperatorTransitionModel.INNERID_SEPERATOR));
                    } else
                    {
                        tempID = arcs[i].getSource().substring(0, arcs[i].getSource().indexOf(OperatorTransitionModel.INNERID_SEPERATOR_OLD));
                    }

                    if (isOperator(getEditor()[editorIndex].getModelProcessor(), tempID))
                    {
                        map = CreationMap.createMap();
                        map.setArcSourceId(tempID);
                        map.setArcTargetId(arcs[i].getTarget());
                        arc = (ArcModel)getEditor()[editorIndex].create(map);
                    }
                }
                if (currentTargetModel != null && currentSourceModel != null)
                {
                    map = CreationMap.createMap();
                    map.setArcSourceId(arcs[i].getSource());
                    map.setArcTargetId(arcs[i].getTarget());
                    arc = (ArcModel)getEditor()[editorIndex].create(map);
                }
            } else
            {
                map = CreationMap.createMap();
                map.setArcSourceId(arcs[i].getSource());
                map.setArcTargetId(arcs[i].getTarget());
                arc = (ArcModel)getEditor()[editorIndex].create(map);
            }
            if (arcs[i].isSetGraphics() && arc != null)
            {
                for (int j = 0; j < arcs[i].getGraphics().getPositionArray().length; j++)
View Full Code Here

    Object cell;
    ArcModel anArc;
    Iterator<String> anIter;
    if (editor != null)
    {
      CreationMap map = CreationMap.createMap();
      if (editor.getLastMousePosition() != null)
      {
        map.setPosition((int)(editor.getLastMousePosition().getX() / editor.getGraph().getScale()),
                (int)(editor.getLastMousePosition().getY() / editor.getGraph().getScale()));               
      }

      switch (event.getOrder())
      {
      // Petrinet
      case AbstractViewEvent.ADD_PLACE:
        map.setType(AbstractPetriNetElementModel.PLACE_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_TRANSITION:
        map.setType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.AND_JOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.AND_SPLIT_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDSPLITJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.AND_SPLITJOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XOR_JOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XOR_SPLIT_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORSPLITJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XOR_SPLITJOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDJOINXORSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.ANDJOIN_XORSPLIT_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORJOINANDSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XORJOIN_ANDSPLIT_TYPE);
        editor.create(map);
        break;
      // General
      case AbstractViewEvent.RENAME:
        cell = editor.getGraph().getSelectionCell();
View Full Code Here

  private CreationMap getCreateTriggerMap(Object cell, int triggertype)
  {
    if (cell != null)
    {
      CreationMap map = null;
      if (cell instanceof TriggerModel)
      {
        cell = ((TriggerModel) cell).getParent();
      }
      if (cell instanceof GroupModel)
      {
        cell = ((GroupModel) cell).getMainElement();
      }
      if (cell instanceof TransitionModel)
      {
        map = ((TransitionModel) cell).getCreationMap();
      }
      if (map != null)
      {
        map.setTriggerType(triggertype);
      }
      return map;
    }
    return null;
  }
View Full Code Here

    getGraph().setMinPreferredHeight(0);
    getEditor().setLastMousePosition(e.getPoint());

    // If in drawing mode, create new node at current position
    if (getEditor().isDrawingMode() && firstPort == null) {
      CreationMap map = CreationMap.createMap();
      if (getEditor().getCreateElementType() > 100 && getEditor().getCreateElementType() < 110) {
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(getEditor().getCreateElementType());
        getEditor().create(map);
      }
      else {
        map.setType(getEditor().getCreateElementType());
        getEditor().create(map);
      }
     
      return;
    }

    // Set normal cursor and determine current position of mouse click
    getGraph().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    Object currentCell = getGraph().getFirstCellForLocation(e.getX(), e.getY());
   
    // Set selection to object under cursor unless group selection is active
    if (currentCell != null && getGraph().getSelectionCount() <= 1)
      getGraph().setSelectionCell(currentCell);

    // Handle right mouse button behaviour
    if (SwingUtilities.isRightMouseButton(e)) {

      if (!getEditor().isDrawingMode()) {
        VisualController.getInstance().setArcpointSelection(isArcPoint(e));
        e.consume();
        PopupMenuPetrinet.setMediator(mediator);
        PopupMenuPetrinet.getInstance().show(currentCell, getGraph(),
            (int) (getEditor().getLastMousePosition().getX()),
            (int) (getEditor().getLastMousePosition().getY()));
      }
      return;
    }
    else {
      if (e.getClickCount() == 2) {
        // Handle single left mouse double click behaviour
        while (currentCell instanceof GroupModel) {
          currentCell = ((GroupModel) currentCell).getMainElement();
        }
     
        // Double click on subprocess element opens subprocess editor
        if (currentCell instanceof SubProcessModel) {
          getEditor().fireViewEvent(
            new ViewEvent(this, AbstractViewEvent.VIEWEVENTTYPE_GUI,
                      AbstractViewEvent.OPEN_SUBPROCESS));
        }
        // Double click on normal element opens property dialog
        else {
          getEditor().setLastMousePosition(e.getPoint());
          getEditor().fireViewEvent(
            new EditorViewEvent(this, AbstractViewEvent.VIEWEVENTTYPE_EDIT,
                          AbstractViewEvent.OPEN_PROPERTIES));

        }
      }
      else {
        // Handle single left mouse button click behaviour
        if (ConfigurationManager.getConfiguration().isSmartEditing()
            && port == null && firstPort != null && firstPort != port) {
          // Smart editing is enabled, i. e. create elements on the fly
          CreationMap[] maps = new CreationMap[2];
          boolean allowConnection = true;
          Object element = ((firstPort != null) ? ((DefaultPort) firstPort.getCell()).getParent() : null);
         
          if (element instanceof AbstractPetriNetElementModel) {
            allowConnection = ((AbstractPetriNetElementModel) element).getAllowOutgoingConnections();
          }
         
          // Check if connection is between valid nodes
          if (allowConnection) {
            DefaultPort source = (DefaultPort) firstPort.getCell();
            CreationMap map = CreationMap.createMap();
            if (source.getParent() instanceof TransitionModel) {
              map.setType(AbstractPetriNetElementModel.PLACE_TYPE);
              map.setId(getEditor().getModelProcessor().getNewElementId(map.getType()));
              maps[0] = map;
            }
            else {
              if (source.getParent() instanceof PlaceModel) {
                map.setType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE);
                map.setId(getEditor().getModelProcessor().getNewElementId(map.getType()));
                maps[0] = map;
              }
            }

            String targetId = map.getId();
            map = CreationMap.createMap();
            map.setArcSourceId(((AbstractPetriNetElementModel) (source).getParent()).getId());
            map.setArcTargetId(targetId);
            maps[1] = map;
          }

          GraphCell[] result = getEditor().createAll(maps);
          getGraph().startEditingAtCell(result[0]);
        }
        else {
          // No smart editing, just draw connections
          if (e != null && !e.isConsumed() && port != null && firstPort != null && firstPort != port) {
            // Fetch the underlying source and target port
            Port source = (Port) firstPort.getCell();
            Port target = (Port) port.getCell();

            // Check if connection is valid
            CreationMap map = CreationMap.createMap();
            map.setArcSourceId(((AbstractPetriNetElementModel) ((DefaultPort) source).getParent()).getId());
            map.setArcTargetId(((AbstractPetriNetElementModel) ((DefaultPort) target).getParent()).getId());
            getEditor().create(map);
            e.consume();
          }
        }
     
View Full Code Here

    private TransitionModel createSimpleTransition()
    {

        TransitionModel aTranstitonModel;
        CreationMap map = CreationMap.createMap();
        map.setId(getNewElementId());
        if(getNameValue()!=null)
          map.setName(getNameValue());
        else
          map.setName(getId().toString());
        map.setType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE);
        if (getPosition() != null)
          map.setPosition(getPosition());
        else
          map.setPosition(new Point(0,0));
        aTranstitonModel = (TransitionModel) ModelElementFactory.createModelElement(map);

        return aTranstitonModel;
    }
View Full Code Here

TOP

Related Classes of org.woped.core.model.CreationMap

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.