/**
   * Returns a newly created Figure to represent the port.
   *
   * @return The created Figure.
   */
  protected IFigure createFigure() {
    final PortFigure portFig = new PortFigure((Port) getModel());
    IFigure rectFig = portFig.getPortFigure();
    SmartViewModelFactory.setPortFigureRegistry(getPort(), portFig);

    rectFig.addMouseListener(
        new MouseListener() {
          public void mouseDoubleClicked(MouseEvent me) {}

          public void mouseReleased(MouseEvent me) {}

          public void mousePressed(MouseEvent me) {
            if (me.button == 1) {
              //			    		if (SmartViewModelUtility.isDoConnectEnabled()) {
              //			    			SmartViewModelUtility.assignSrcDstPort(getPort(), me.getLocation());
              //			    		}

              if (!portFig
                  .getPort()
                  .getPortName()
                  .equals(SmartViewModelFactory.getSelectedPort())) {
                if ((SmartViewModelFactory.getMode() == 0)
                    && (portFig.getPort().getPortType() == 1)) {
                  Logger.info(
                      "In PowerView mode, signal ports can not be selected. SmartView operation skipped.");
                } else if ((SmartViewModelFactory.getMode() == 1)
                    && (portFig.getPort().getPortType() == 0)) {
                  Logger.info(
                      "In SignalView mode, power ports can not be selected. SmartView operation skipped.");
                } else if (SmartViewModelFactory.getMode() == 2) {
                  Logger.info(
                      "In IconView mode, power/signal ports can not be selected. SmartView operation skipped.");
                } else {
                  String portName = portFig.getPort().getPortName();
                  String tmpStr[] = SmartViewModelFactory.getSelectedPort().split("/");
                  String srcPin = "";
                  if (tmpStr[0].equals(SmartViewModelFactory.getTopModuleName()))
                    srcPin = tmpStr[1];
                  else srcPin = portName;

                  if (SmartViewModelFactory.verifyPortAttachedWire(srcPin) == true)
                    Logger.info(
                        "Wire attached with port, already highlighted. SmartView operation skipped.");
                  else {
                    SmartViewModelFactory.setSelectedPort(portFig.getPort().getPortName());
                    if (SmartViewModelFactory.getSelectedPortFig() != null)
                      SmartViewModelFactory.getSelectedPortFig()
                          .setBackgroundColor(LogicColorConstants.connectorGreen);

                    portFig.getPortFigure().setBackgroundColor(LogicColorConstants.connectorRed);
                    SmartViewModelFactory.setSelectedPortFig(portFig.getPortFigure());
                  }
                }
              } else {
                if (SmartViewModelFactory.getSelectedPortFig() != null)
                  SmartViewModelFactory.getSelectedPortFig()
                      .setBackgroundColor(LogicColorConstants.connectorGreen);
                SmartViewModelFactory.setSelectedPort("");
              }
            }
          }
        });

    return rectFig;
  }
 public ElementDBNode[] getSelectedDBNode() {
   ElementDBNode[] selectedElement = new ElementDBNode[1];
   selectedElement[0] = DBNodeFactory.dbNode(SmartViewModelFactory.getPortModel(getPort()));
   return selectedElement;
 }