Example usage for java.awt Point getX

List of usage examples for java.awt Point getX

Introduction

In this page you can find the example usage for java.awt Point getX.

Prototype

public double getX() 

Source Link

Usage

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

/**
 * Given the element, and the (offsetX, offsetY) relative to element.
 * This function will calculate the offset point screen coordination.
 * /* w w  w  . j  ava  2s  .c  o  m*/
 * @param element WebElement, the element relative to which the coordination will be calculated.
 * @param offsetX String, the offset on x axis, in pixel or in percentage, for example 15 or 30%.
 * @param offsetX String, the offset on y axis, in pixel or in percentage, for example 45 or 50%.
 * 
 * @return Point, the offset point screen coordination; or null if any exception occured.
 *
 **/
public static Point getElementOffsetScreenLocation(WebElement element, String offsetX, String offsetY) {
    String debugmsg = StringUtils.debugmsg(false);

    try {
        Point screenLoc = WDLibrary.getScreenLocation(element);
        Dimension dimemsion = element.getSize();

        //calc coords according to the offset and element's location and dimension
        double dx, dy;
        dx = ImageUtils.calculateAbsoluteCoordinate(screenLoc.getX(), dimemsion.getWidth(), offsetX);
        dy = ImageUtils.calculateAbsoluteCoordinate(screenLoc.getY(), dimemsion.getHeight(), offsetY);

        return new Point((int) dx, (int) dy);
    } catch (Exception e) {
        IndependantLog.error(debugmsg + ": Exception", e);
        return null;
    }
}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Translates a panel (component) location to a Java2D point.
 * //from   w  ww .ja  va  2s.  co  m
 * @param screenPoint
 *            the screen location (<code>null</code> not permitted).
 * 
 * @return The Java2D coordinates.
 */

@Override
public Point2D translateScreenToJava2D(Point screenPoint) {
    Insets insets = getInsets();
    double x = (screenPoint.getX() - insets.left) / this.scaleX;
    double y = (screenPoint.getY() - insets.top) / this.scaleY;
    return new Point2D.Double(x, y);
}

From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java

/**
 * Shows information in a tooltip about the sequence over which the mouse
 * moved./*from  w  ww.j  ava 2  s .co m*/
 * 
 * @param e
 *            MouseEvent
 */
public void mouseMoved(MouseEvent e) {

    Point p = e.getPoint();

    String str = "<html>";
    int height = (int) ((double) (getHeight() - (2 * border)));
    int unitHeight = height / getHashMapSize();
    int currentTop = 0;

    String key = null;
    AbstractLogUnit item = null;
    boolean flag = false;
    // for dot
    int index = -1;
    for (Iterator itSets = dcModel.getSortedKeySetList().iterator(); itSets.hasNext();) {
        key = (String) itSets.next();

        if (dcModel.getTypeHashMap().equals(ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key))
            continue;
        index++;
        LogUnitList tempLogUnit = (LogUnitList) dcModel.getItemMap().get(key);
        currentTop = unit2Cord(index) + unitHeight / 2;
        if (currentTop - 5 >= p.getY() || p.getY() >= currentTop + 5)
            continue;
        // get the descriptiveStatistics object
        for (Iterator itItm = tempLogUnit.iterator(); itItm.hasNext();) {
            item = (AbstractLogUnit) itItm.next();
            if (dcModel.getEventTypeToKeep() != null && (!dcModel.getEventTypeToKeep().contains(item.getType())
                    || !dcModel.getInstanceTypeToKeep().contains(item.getProcessInstance().getName())))
                continue;
            int x = 0;

            x = time2coord(item.getCurrentTimeStamp()) + border;
            if (x - 5 <= p.getX() && p.getX() <= x + 5) {
                flag = true;
                str += item.getProcessInstance().getName() + " | " + item.getElement() + " | "
                        + item.getOriginator() + " | " + item.getTimestamp() + " | " + item.getType();
                if (!timeOption.equals(TIME_ACTUAL))
                    str += " | Position:" + timeFormat(item.getCurrentTimeStamp());
                str += "<br>";
            }
        }
    }
    // for item line
    index = -1;
    for (Iterator itSets = dcModel.getSortedKeySetList().iterator(); itSets.hasNext();) {
        key = (String) itSets.next();

        if (dcModel.getTypeHashMap().equals(ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key))
            continue;
        index++;
        LogUnitList tempLogUnit = (LogUnitList) dcModel.getItemMap().get(key);
        currentTop = unit2Cord(index) + unitHeight / 2;
        if (currentTop - 5 >= p.getY() || p.getY() >= currentTop + 5)
            continue;
        LogUnitList tempUnitList = new LogUnitList();
        // get the descriptiveStatistics object
        for (Iterator itItm = tempLogUnit.iterator(); itItm.hasNext();) {
            item = (AbstractLogUnit) itItm.next();
            if (dcModel.getEventTypeToKeep() != null && (!dcModel.getEventTypeToKeep().contains(item.getType())
                    || !dcModel.getInstanceTypeToKeep().contains(item.getProcessInstance().getName())))
                continue;
            if (bDrawLine && item.getType().equals(dca.getSettingPanel().getStartEvent())) {
                tempUnitList.addEvent(item);
                continue;
            }
            if (bDrawLine && item.getType().equals(dca.getSettingPanel().getEndEvent())) {
                for (Iterator itr = tempUnitList.iterator(); itr.hasNext();) {
                    AbstractLogUnit item2 = (AbstractLogUnit) itr.next();
                    if (item2.getElement().equals(item.getElement())
                            && item2.getProcessInstance().equals(item.getProcessInstance())) {
                        int x1 = time2coord(item2.getCurrentTimeStamp()) + border;
                        int x2 = time2coord(item.getCurrentTimeStamp()) + border;
                        if (x1 + 5 <= p.getX() && p.getX() <= x2 - 5) {
                            flag = true;
                            str += item.getProcessInstance().getName() + " | " + item.getElement() + " | "
                                    + item.getOriginator() + " |(start)" + item.getTimestamp() + "-(complete)"
                                    + item2.getTimestamp() + "<br>";
                            tempUnitList.removeEvent(item2);
                        }
                        break;
                    }
                }
            }
        }
    }

    str += "</html>";
    if (flag) {
        this.setToolTipText(str);
        repaint();
        bTooltip = true;
    } else {
        this.setToolTipText(null);
        if (bTooltip) {
            repaint();
            bTooltip = false;
        }
    }
}

From source file:org.pmedv.blackboard.components.BoardEditor.java

/**
 * Setup the listeners//from  w w  w  . j  a v a 2  s  .c o m
 */
private void initListeners() {
    addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {
            handleMouseDragged(e);
        }

        @Override
        public void mouseMoved(MouseEvent e) {

            Point p = e.getPoint();
            p = BoardUtil.mirrorTransform(p, zoomLayer, e);

            if (editorMode.equals(EditorMode.CHECK_CONNECTIONS)) {
                mouseOverLine = EditorUtils.findMouseOverLine(e, BoardEditor.this);
            } else {
                mouseOverPin = EditorUtils.findPin(e.getX(), e.getY(), BoardEditor.this);
            }

            win.getCustomLabel().setText("x : " + e.getX() + " y : " + e.getY());

            if (mouseOverPin != null) {
                tooltipBuffer.delete(0, tooltipBuffer.length());
                tooltipBuffer.append(mouseOverPin.getNum());
                if (mouseOverPin.getName() != null) {
                    tooltipBuffer.append(" " + mouseOverPin.getName());
                }
                BoardEditor.this.setToolTipText(tooltipBuffer.toString());
                ToolTipManager.sharedInstance()
                        .mouseMoved(new MouseEvent(BoardEditor.this, 0, 0, 0, (int) p.getX(), (int) p.getY(), // X-Y of the mouse for the tool tip
                                0, false));
            } else if (mouseOverLine != null) {
                tooltipBuffer.delete(0, tooltipBuffer.length());
                tooltipBuffer.append("net : " + mouseOverLine.getNetIndex());
                BoardEditor.this.setToolTipText(tooltipBuffer.toString());

                ToolTipManager.sharedInstance()
                        .mouseMoved(new MouseEvent(BoardEditor.this, 0, 0, 0, (int) p.getX(), (int) p.getY(), // X-Y of the mouse for the tool tip
                                0, false));

            } else {
                BoardEditor.this.setToolTipText(null);
            }

        }
    });
    addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            handleMousePressed(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            handleMouseReleased(e);
        }
    });
    addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {

            Boolean invertMouse = (Boolean) Preferences.values
                    .get("org.pmedv.blackboard.BoardDesignerPerspective.invertMouse");

            if (invertMouse) {
                if (currentZoomIndex - e.getWheelRotation() < zoomLevels.length
                        && currentZoomIndex - e.getWheelRotation() > 0) {
                    currentZoomIndex -= e.getWheelRotation();
                }
            } else {
                if (currentZoomIndex + e.getWheelRotation() < zoomLevels.length
                        && currentZoomIndex + e.getWheelRotation() > 0) {
                    currentZoomIndex += e.getWheelRotation();
                }
            }

            JXLayer<?> layer = getZoomLayer();
            TransformUI ui = (TransformUI) (Object) layer.getUI();
            DefaultTransformModel model = (DefaultTransformModel) ui.getModel();
            model.setScale(zoomLevels[currentZoomIndex]);
            ctx.getBean(ApplicationWindow.class).getZoomCombo().setSelectedItem(zoomLevels[currentZoomIndex]);
        }
    });
    addMouseMotionListener(AppContext.getContext().getBean(AddTextCommand.class));
}

From source file:com.redsqirl.workflow.server.Workflow.java

public String aggregateElements(List<String> componentIds, String subworkflowName,
        Map<String, Entry<String, String>> inputs, Map<String, Entry<String, String>> outputs)
        throws RemoteException {
    String error = null;/* ww w  .  ja v a2 s .co m*/
    Workflow copy = null;
    // Replace elements by the subworkflow
    Point positionSuperAction = new Point(0, 0);
    try {
        copy = (Workflow) clone();
    } catch (Exception e) {
        error = "Fail to clone the workflow";
        logger.error(error, e);
        return error;
    }

    // Remove elements that are in the SuperAction
    logger.debug("Elements before aggregating: " + getComponentIds());
    try {
        Iterator<String> itToDel = componentIds.iterator();
        while (itToDel.hasNext()) {
            String id = itToDel.next();
            positionSuperAction.move((int) positionSuperAction.getX() + getElement(id).getX(),
                    (int) positionSuperAction.getY() + getElement(id).getY());
            removeElement(id);
        }
    } catch (Exception e) {
        error = "Fail to remove an element";
        logger.error(error, e);
        return error;
    }

    // Calculate the position of the new SuperAction
    positionSuperAction.move((int) positionSuperAction.getX() / componentIds.size(),
            (int) positionSuperAction.getY() / componentIds.size());

    // Add the new element
    String idSA = null;
    try {
        idSA = addElement(subworkflowName);
    } catch (Exception e) {
        error = "Fail to create the super action " + subworkflowName;
        logger.error(error, e);
        return error;
    }

    // Add the new input links
    DataFlowElement newSA = getElement(idSA);
    newSA.setPosition((int) positionSuperAction.getX(), (int) positionSuperAction.getY());

    logger.debug("Elements after aggregating: " + getComponentIds());
    Iterator<String> entries = inputs.keySet().iterator();
    while (entries.hasNext() && error == null) {
        String inputName = entries.next();
        if (logger.isDebugEnabled()) {
            logger.debug("link " + inputs.get(inputName).getKey() + "," + inputs.get(inputName).getValue()
                    + "->" + inputName + "," + idSA);
        }
        error = addLink(inputs.get(inputName).getValue(), inputs.get(inputName).getKey(), inputName, idSA);
    }

    // Add the new output links
    logger.debug("Old elements: " + copy.getComponentIds());
    entries = outputs.keySet().iterator();
    while (entries.hasNext() && error == null) {
        String outputName = entries.next();
        logger.debug(
                "Get element " + outputs.get(outputName).getKey() + "," + outputs.get(outputName).getValue());
        Map<String, List<DataFlowElement>> outEls = copy.getElement(outputs.get(outputName).getKey())
                .getOutputComponent();
        if (outEls != null && outEls.containsKey(outputs.get(outputName).getValue())
                && outEls.get(outputs.get(outputName).getValue()) != null) {
            Iterator<DataFlowElement> it = outEls.get(outputs.get(outputName).getValue()).iterator();
            while (it.hasNext()) {
                DataFlowElement curEl = it.next();
                if (getElement(curEl.getComponentId()) != null) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("link " + outputName + "," + idSA + "->"
                                + copy.getElement(outputs.get(outputName).getKey()).getInputNamePerOutput()
                                        .get(outputs.get(outputName).getValue()).get(curEl.getComponentId())
                                + "," + curEl.getComponentId());
                    }
                    error = addLink(outputName, idSA,
                            copy.getElement(outputs.get(outputName).getKey()).getInputNamePerOutput()
                                    .get(outputs.get(outputName).getValue()).get(curEl.getComponentId()),
                            curEl.getComponentId());

                    if (error == null) {

                        String newAlias = getElement(curEl.getComponentId()).getAliasesPerComponentInput()
                                .get(idSA).getKey();
                        String oldAlias = curEl.getAliasesPerComponentInput()
                                .get(outputs.get(outputName).getKey()).getKey();

                        getElement(curEl.getComponentId()).replaceInAllInteraction(
                                "([_ \\W]|^)(" + Pattern.quote(oldAlias) + ")([_ \\W]|$)",
                                "$1" + newAlias + "$3", true);
                    }
                }

            }
        }
    }

    {
        //Generate name for all the outputs
        Map<String, DFEOutput> mapOutput = newSA.getDFEOutput();
        Iterator<String> outputNameIt = mapOutput.keySet().iterator();
        while (outputNameIt.hasNext()) {
            String dataName = outputNameIt.next();
            if (mapOutput.get(dataName).getSavingState() != SavingState.RECORDED
                    && (mapOutput.get(dataName).getPath() == null
                            || !mapOutput.get(dataName).isPathAutoGeneratedForUser(idSA, dataName))) {
                mapOutput.get(dataName).generatePath(idSA, dataName);
            }
        }
    }

    if (error != null) {
        this.element = copy.element;
    }

    return error;

}

From source file:unikn.dbis.univis.navigation.tree.VTree.java

/**
 * TODO: document me!!!/*from   w w  w . ja v a  2 s.c o m*/
 *
 * @param p
 */
public void showPopupMenu(Point p) {

    // Remove all items from popup menu.
    popupMenu.removeAll();

    Object o = getLastSelectedPathComponent();

    if (o instanceof DefaultMutableTreeNode) {

        DefaultMutableTreeNode node = (DefaultMutableTreeNode) o;

        Object userObject = node.getUserObject();

        if (userObject instanceof VDimension) {

            VDimension dimension = (VDimension) userObject;

            try {
                Point p2 = new Point(p);
                SwingUtilities.convertPointToScreen(p2, this);

                final FilterItemContainer container = createFilterContainer(dimension, p2);

                if (!container.isEmpty()) {
                    /*
                    JLabel header = new JLabel(MessageResolver.getMessage("data_reference." + dimension.getI18nKey()));
                    Font font = header.getFont();
                    header.setFont(new Font(font.getFontName(), Font.BOLD, font.getSize() + 2));
                    popupMenu.add(header);
                    popupMenu.add(new JPopupMenu.Separator());
                    */

                    popupMenu = new FilterPopupMenu(
                            MessageResolver.getMessage("data_reference." + dimension.getI18nKey()));

                    final JCheckBox button = new JCheckBox("Check/Uncheck all");

                    button.setSelected(container.isAllChecked());

                    button.addActionListener(new ActionListener() {
                        /**
                         * Invoked when an action occurs.
                         */
                        public void actionPerformed(ActionEvent e) {

                            for (Component c : container.getComponents()) {
                                if (c instanceof VBidirectionalBrowsingItem) {
                                    ((VBidirectionalBrowsingItem) c).getCheckBox()
                                            .setChecked(button.isSelected());
                                }
                            }
                        }
                    });

                    popupMenu.add(button);

                    popupMenu.add(new JPopupMenu.Separator());

                    popupMenu.add(container);

                    JButton view = new JButton(MessageResolver.getMessage("filtering"), VIcons.FILTER);
                    view.addActionListener(new ActionListener() {

                        /**
                         * Invoked when an action occurs.
                         */
                        public void actionPerformed(ActionEvent e) {
                            popupMenu.setVisible(false);
                        }
                    });

                    popupMenu.add(new JPopupMenu.Separator());

                    popupMenu.add(view);

                    popupMenu.show(VTree.this, (int) p.getX(), (int) p.getY());
                } else {
                    JOptionPane.showMessageDialog(VTree.this.getParent().getParent().getParent(),
                            MessageResolver.getMessage("no_items_found"),
                            MessageResolver.getMessage("error_message"), JOptionPane.ERROR_MESSAGE);
                }
            } catch (SQLException sqle) {
                VExplorer.publishException(sqle);

                if (LOG.isErrorEnabled()) {
                    LOG.error(sqle.getMessage(), sqle);
                }
            }
        }
    }
}

From source file:com.redsqirl.workflow.server.Workflow.java

public SubDataFlow createSA(List<String> componentIds, String subworkflowName, String subworkflowComment,
        Map<String, Entry<String, String>> inputs, Map<String, Entry<String, String>> outputs)
        throws Exception {
    logger.debug("To aggregate: " + componentIds);
    int posIncr = 150;
    String error = null;//from ww w.ja  va  2s .  c o  m
    // Create subworkflow object
    SubWorkflow sw = new SubWorkflow(subworkflowName);

    DataFlowCoordinatorVariables subWfVars = new WfCoordVariables();

    // Copy Elements
    Workflow copy = null;
    try {
        copy = (Workflow) clone();
    } catch (Exception e) {
        error = "Fail to clone the workflow";
        logger.error(error, e);
    }
    if (error == null) {
        Iterator<String> idIt = copy.getComponentIds().iterator();
        try {
            while (idIt.hasNext()) {
                String cur = idIt.next();
                if (!componentIds.contains(cur)) {
                    logger.debug("To remove: " + cur);
                    copy.removeElement(cur);
                } else {
                    DataFlowElement curEl = getElement(cur);
                    curEl.cleanDataOut();
                    //curEl.setPosition(curEl.getX() + posIncr, curEl.getY());
                    Set<String> varRequired = curEl.getRequiredVariables();
                    if (varRequired != null && !varRequired.isEmpty()) {
                        DataFlowCoordinatorVariables coordVars = copy.getCoordinator(curEl.getCoordinatorName())
                                .getVariables();
                        Iterator<String> varIt = varRequired.iterator();
                        while (varIt.hasNext()) {
                            String varCur = varIt.next();
                            subWfVars.addVariable(coordVars.getVariable(varCur));
                        }
                    }
                }
            }
        } catch (Exception e) {
            error = "Fail to remove an element";
            logger.error(error, e);
        }
    }

    if (error == null) {
        String coordinatorName = null;
        Iterator<String> idIt = componentIds.iterator();
        while (idIt.hasNext()) {
            String cur = idIt.next();
            DataFlowElement newEl = copy.getElement(cur);
            logger.debug("To copy: " + cur);
            if (coordinatorName == null) {
                coordinatorName = newEl.getCoordinatorName();
            }
            sw.addElement(newEl, coordinatorName);
        }
        DataFlowCoordinator coordinatorSW = sw.getCoordinator(coordinatorName);
        try {
            // Create Action inputs
            Iterator<String> entries = inputs.keySet().iterator();
            Map<String, DFEOutput> inputsForHelp = new HashMap<String, DFEOutput>();
            while (entries.hasNext() && error == null) {
                String inputName = entries.next();

                // Get the DFEOutput from which we copy the constraint
                DFEOutput constraint = this.getElement(inputs.get(inputName).getKey()).getDFEOutput()
                        .get(inputs.get(inputName).getValue());
                inputsForHelp.put(inputName, constraint);
                sw.addElement((new SubWorkflowInput()).getName(), inputName, coordinatorSW);

                if (error == null) {
                    // Update Data Type
                    SubWorkflowInput input = (SubWorkflowInput) sw.getElement(inputName);
                    input.update(input.getInteraction(Source.key_datatype));
                    Tree<String> dataTypeTree = input.getInteraction(Source.key_datatype).getTree();
                    dataTypeTree.getFirstChild("list").getFirstChild("output").add(constraint.getBrowserName());

                    logger.debug("Update Data Type");

                    // Update Data SubType
                    input.update(input.getInteraction(Source.key_datasubtype));
                    ((ListInteraction) input.getInteraction(Source.key_datasubtype))
                            .setValue(constraint.getTypeName());

                    logger.debug("Update Data SubType");

                    if (PathType.MATERIALIZED.equals(constraint.getPathType())) {
                        List<String> vals = new LinkedList<String>();
                        vals.add(LanguageManagerWF.getText("superactioninput.allow_materialized"));
                        ((AppendListInteraction) input.getInteraction(SubWorkflowInput.key_materialized))
                                .setValues(vals);
                    }

                    // Update header
                    input.update(input.getInteraction(SubWorkflowInput.key_headerInt));
                    InputInteraction header = (InputInteraction) input
                            .getInteraction(SubWorkflowInput.key_headerInt);
                    header.setValue(constraint.getFields().mountStringHeader());

                    input.update(input.getInteraction(SubWorkflowInput.key_fieldDefInt));

                    input.updateOut();

                    logger.debug("Update Out");

                    Iterator<DataFlowElement> toLinkIt = this.getElement(inputs.get(inputName).getKey())
                            .getOutputComponent().get(inputs.get(inputName).getValue()).iterator();
                    Point positionSuperActionInput = new Point(0, 0);
                    int numberOfInput = 0;
                    while (toLinkIt.hasNext()) {
                        DataFlowElement curEl = toLinkIt.next();
                        if (componentIds.contains(curEl.getComponentId())) {
                            // Create link
                            sw.addLink(SubWorkflowInput.out_name, inputName,
                                    getElement(inputs.get(inputName).getKey()).getInputNamePerOutput()
                                            .get(inputs.get(inputName).getValue()).get(curEl.getComponentId()),
                                    curEl.getComponentId());

                            String newAlias = sw.getElement(curEl.getComponentId())
                                    .getAliasesPerComponentInput().get(inputName).getKey();
                            String oldAlias = curEl.getAliasesPerComponentInput()
                                    .get(inputs.get(inputName).getKey()).getKey();

                            sw.getElement(curEl.getComponentId()).replaceInAllInteraction(
                                    "([_ \\W]|^)(" + Pattern.quote(oldAlias) + ")([_ \\W]|$)",
                                    "$1" + newAlias + "$3", true);

                            positionSuperActionInput.move((int) positionSuperActionInput.getX() + curEl.getX(),
                                    (int) positionSuperActionInput.getY() + curEl.getY());
                            ++numberOfInput;
                        }
                    }
                    input.setPosition((int) (positionSuperActionInput.getX() / numberOfInput) - posIncr,
                            (int) (positionSuperActionInput.getY() / numberOfInput));
                }
            }

            logger.debug("Create Action");

            // Create Action outputs
            entries = outputs.keySet().iterator();
            Map<String, DFEOutput> outputsForHelp = new HashMap<String, DFEOutput>();
            while (entries.hasNext() && error == null) {
                String outputName = entries.next();

                sw.addElement((new SubWorkflowOutput()).getName(), outputName, coordinatorSW);

                if (error == null) {
                    sw.addLink(outputs.get(outputName).getValue(), outputs.get(outputName).getKey(),
                            SubWorkflowOutput.input_name, outputName);
                    DataFlowElement in = sw.getElement(outputs.get(outputName).getKey());
                    sw.getElement(outputName).setPosition(in.getX() + posIncr, in.getY());
                    outputsForHelp.put(outputName, in.getDFEOutput().get(outputs.get(outputName).getValue()));
                }
            }

            logger.debug("createSA " + error);
            sw.getCoordinator(coordinatorName).getVariables().addAll(subWfVars);
            sw.setComment(generateHelp(RedSqirlModel.getModelAndSW(subworkflowName)[1], subworkflowComment,
                    inputsForHelp, outputsForHelp, subWfVars));
        } catch (Exception e) {
            error = "Fail to create an input or output super action";
            logger.error(error, e);
        }
    }

    if (error != null) {
        throw new Exception(error);
    }

    sw.moveToTopRightCorner(50, 50);

    return sw;
}

From source file:op.care.nursingprocess.DlgNursingProcess.java

private void tblPlanungMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblPlanungMousePressed
    if (!SwingUtilities.isRightMouseButton(evt)) {
        return;//from   w w  w  .  j av  a 2s.c o  m
    }

    Point p = evt.getPoint();
    ListSelectionModel lsm = tblPlanung.getSelectionModel();
    int row = tblPlanung.rowAtPoint(p);
    if (lsm.isSelectionEmpty() || (lsm.getMinSelectionIndex() == lsm.getMaxSelectionIndex())) {
        lsm.setSelectionInterval(row, row);
    }

    menu = new JPopupMenu();

    /***
     *      _ _                 ____                         ____       _      _
     *     (_) |_ ___ _ __ ___ |  _ \ ___  _ __  _   _ _ __ |  _ \  ___| | ___| |_ ___
     *     | | __/ _ \ '_ ` _ \| |_) / _ \| '_ \| | | | '_ \| | | |/ _ \ |/ _ \ __/ _ \
     *     | | ||  __/ | | | | |  __/ (_) | |_) | |_| | |_) | |_| |  __/ |  __/ ||  __/
     *     |_|\__\___|_| |_| |_|_|   \___/| .__/ \__,_| .__/|____/ \___|_|\___|\__\___|
     *                                    |_|         |_|
     */
    JMenuItem itemPopupDelete = new JMenuItem(SYSTools.xx("misc.commands.delete"), SYSConst.icon22delete);
    itemPopupDelete.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            for (int row : tblPlanung.getSelectedRows()) {
                listInterventionSchedule2Remove
                        .add(((TMPlan) tblPlanung.getModel()).getInterventionSchedule(row));
                nursingProcess.getInterventionSchedule()
                        .remove(((TMPlan) tblPlanung.getModel()).getInterventionSchedule(row));
            }
            ((TMPlan) tblPlanung.getModel()).fireTableDataChanged();
        }
    });
    menu.add(itemPopupDelete);

    /***
     *      _ _                 ____                        ____       _              _       _
     *     (_) |_ ___ _ __ ___ |  _ \ ___  _ __  _   _ _ __/ ___|  ___| |__   ___  __| |_   _| | ___
     *     | | __/ _ \ '_ ` _ \| |_) / _ \| '_ \| | | | '_ \___ \ / __| '_ \ / _ \/ _` | | | | |/ _ \
     *     | | ||  __/ | | | | |  __/ (_) | |_) | |_| | |_) |__) | (__| | | |  __/ (_| | |_| | |  __/
     *     |_|\__\___|_| |_| |_|_|   \___/| .__/ \__,_| .__/____/ \___|_| |_|\___|\__,_|\__,_|_|\___|
     *                                    |_|         |_|
     */
    final JMenuItem itemPopupSchedule = new JMenuItem(SYSTools.xx("misc.commands.editsheduling"),
            SYSConst.icon22clock);
    itemPopupSchedule.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            final JidePopup popup = new JidePopup();

            /**
             * This routine uses the <b>first</b> element of the selection as the template for editing
             * the schedule. After the edit it clones this "template", removes the original
             * InterventionSchedules (copying the apropriate Intervention of every single
             * Schedule first) and finally creates new schedules and adds them to
             * the CareProcess in question.
             */
            int row = tblPlanung.getSelectedRows()[0];
            InterventionSchedule firstInterventionScheduleWillBeTemplate = ((TMPlan) tblPlanung.getModel())
                    .getInterventionSchedule(row);
            JPanel dlg = new PnlSchedule(firstInterventionScheduleWillBeTemplate, new Closure() {
                @Override
                public void execute(Object o) {
                    if (o != null) {
                        InterventionSchedule template = (InterventionSchedule) o;
                        ArrayList<InterventionSchedule> listInterventionSchedule2Add = new ArrayList();
                        for (int row : tblPlanung.getSelectedRows()) {
                            InterventionSchedule oldTermin = ((TMPlan) tblPlanung.getModel())
                                    .getInterventionSchedule(row);
                            InterventionSchedule newTermin = template.clone();
                            newTermin.setIntervention(oldTermin.getIntervention());
                            listInterventionSchedule2Remove.add(oldTermin);
                            listInterventionSchedule2Add.add(newTermin);
                        }
                        nursingProcess.getInterventionSchedule().removeAll(listInterventionSchedule2Remove);
                        nursingProcess.getInterventionSchedule().addAll(listInterventionSchedule2Add);
                        popup.hidePopup();
                        Collections.sort(nursingProcess.getInterventionSchedule());
                        ((TMPlan) tblPlanung.getModel()).fireTableDataChanged();
                    }
                }
            });

            popup.setMovable(false);
            popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
            popup.getContentPane().add(dlg);
            popup.setOwner(jspPlanung);
            popup.removeExcludedComponent(jspPlanung);
            popup.setDefaultFocusComponent(dlg);

            GUITools.showPopup(popup, SwingConstants.SOUTH_WEST);
        }
    });
    menu.add(itemPopupSchedule);

    menu.show(evt.getComponent(), (int) p.getX(), (int) p.getY());
}

From source file:op.care.sysfiles.PnlFiles.java

private void tblFilesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblFilesMousePressed

    Point p = evt.getPoint();
    ListSelectionModel lsm = tblFiles.getSelectionModel();
    Point p2 = evt.getPoint();/*from  w ww .  j  a  v a2  s .  c  om*/
    SwingUtilities.convertPointToScreen(p2, tblFiles);
    final Point screenposition = p2;

    boolean singleRowSelected = lsm.getMaxSelectionIndex() == lsm.getMinSelectionIndex();

    final int row = tblFiles.rowAtPoint(p);
    final int col = tblFiles.columnAtPoint(p);

    if (singleRowSelected) {
        lsm.setSelectionInterval(row, row);
    }

    final TMSYSFiles tm = (TMSYSFiles) tblFiles.getModel();
    final SYSFiles sysfile = tm.getRow(tblFiles.convertRowIndexToModel(row));

    if (SwingUtilities.isRightMouseButton(evt)) {

        SYSTools.unregisterListeners(menu);
        menu = new JPopupMenu();

        // SELECT
        JMenuItem itemPopupShow = new JMenuItem(SYSTools.xx("misc.commands.show"), SYSConst.icon22magnify1);
        itemPopupShow.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SYSFilesTools.handleFile(sysfile, Desktop.Action.OPEN);
            }
        });
        menu.add(itemPopupShow);

        if (col == TMSYSFiles.COL_DESCRIPTION
                && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) {

            final JMenuItem itemPopupEdit = new JMenuItem(SYSTools.xx("misc.commands.edit"),
                    SYSConst.icon22edit3);
            itemPopupEdit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {

                    final JidePopup popup = new JidePopup();
                    popup.setMovable(false);
                    popup.getContentPane()
                            .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));

                    final JComponent editor = new JTextArea(sysfile.getBeschreibung(), 10, 40);
                    ((JTextArea) editor).setLineWrap(true);
                    ((JTextArea) editor).setWrapStyleWord(true);
                    ((JTextArea) editor).setEditable(true);

                    popup.getContentPane().add(new JScrollPane(editor));
                    final JButton saveButton = new JButton(SYSConst.icon22apply);
                    saveButton.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent actionEvent) {
                            EntityManager em = OPDE.createEM();
                            try {
                                em.getTransaction().begin();
                                popup.hidePopup();
                                SYSFiles mySysfile = em.merge(sysfile);
                                mySysfile.setBeschreibung(((JTextArea) editor).getText().trim());
                                em.getTransaction().commit();
                                tm.setSYSFile(tblFiles.convertRowIndexToModel(row), mySysfile);
                            } catch (Exception e) {
                                em.getTransaction().rollback();
                                OPDE.fatal(e);
                            } finally {
                                em.close();
                            }

                        }
                    });

                    saveButton.setHorizontalAlignment(SwingConstants.RIGHT);
                    JPanel pnl = new JPanel(new BorderLayout(10, 10));
                    JScrollPane pnlEditor = new JScrollPane(editor);

                    pnl.add(pnlEditor, BorderLayout.CENTER);
                    JPanel buttonPanel = new JPanel();
                    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
                    buttonPanel.add(saveButton);
                    pnl.setBorder(new EmptyBorder(10, 10, 10, 10));
                    pnl.add(buttonPanel, BorderLayout.SOUTH);

                    popup.setOwner(tblFiles);
                    popup.removeExcludedComponent(tblFiles);
                    popup.getContentPane().add(pnl);
                    popup.setDefaultFocusComponent(editor);

                    popup.showPopup(screenposition.x, screenposition.y);

                }
            });
            menu.add(itemPopupEdit);
        }

        if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, internalClassID)) {
            JMenuItem itemPopupDelete = new JMenuItem(SYSTools.xx("misc.commands.delete"),
                    SYSConst.icon22delete);
            itemPopupDelete.addActionListener(new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent evt) {

                    new DlgYesNo(
                            SYSTools.xx("misc.questions.delete1") + "<br/><b>" + sysfile.getFilename()
                                    + "</b><br/>" + SYSTools.xx("misc.questions.delete2"),
                            new ImageIcon(getClass().getResource("/artwork/48x48/bw/trashcan_empty.png")),
                            new Closure() {
                                @Override
                                public void execute(Object o) {
                                    if (o.equals(JOptionPane.YES_OPTION)) {
                                        SYSFilesTools.deleteFile(sysfile);
                                        reloadTable();
                                    }
                                }
                            });

                }
            });
            menu.add(itemPopupDelete);
            itemPopupDelete.setEnabled(singleRowSelected);
        }

        menu.show(evt.getComponent(), (int) p.getX(), (int) p.getY());
    } else if (evt.getClickCount() == 2) {
        SYSFilesTools.handleFile(sysfile, Desktop.Action.OPEN);
    }

}

From source file:tufts.vue.RichTextBox.java

public Dimension getPreferredSize() {
    Dimension s = null;//from  w  w  w  .  j  ava  2  s .  co m
    //   Dimension s = super.getPreferredSize();

    Dimension minS = getMinimumSize();

    //System.out.println(javax.swing.SwingUtilities.getLocalBounds(this));
    //if (TestDebug||DEBUG.TEXT) out("getPrefer", s);

    // System.out.println("GetPrefSize : " +  mBounds.width + " "+ s.width);
    //    System.out.println("Required Lines : " + s.width/mBounds.width);
    Caret c = this.getCaret();
    Point position = c.getMagicCaretPosition();
    //    if (position != null)
    //       System.out.println("magic caret : " + position.getX());

    //HTMLDocument builds a hierarchical Element structure where each Element
    //represents a structural block of HTML, and not just a line of text. so I'm not sure
    //how to figure out what line you're on.

    Dimension min = new Dimension();
    final Dimension text = getMinimumSize();
    min.width = text.width;

    int EdgePadY = 0; // Was 3 in VUE 1.5
    int LabelPadLeft = 8; // Was 6 in VUE 1.5; fixed

    //System.out.println("Text.height : " + text.height);
    // *** set icon Y position in all cases to a centered vertical
    // position, but never such that baseline is below bottom of
    // first icon -- this is tricky tho, as first icon can move
    // down a bit to be centered with the label!

    min.width += LabelPadLeft;

    min.width = Math.max(min.width, minS.width);
    /*
    System.out.println("Min.Width =" + min.width);
    System.out.println("MinS.Width =" + minS.width);
    System.out.println("S.Width =" + s.width);
    System.out.println("MBounds.Width = " + mBounds.width);
    System.out.println("GetSize.Width = " + getSize().width);
    System.out.println("Bounds : " + this.getBounds().width);
    System.out.println("LWC width : " + lwc.width);
    System.out.println("LWC bounds : " + lwc.getBounds().width);
    System.out.println("LWC layoutbounds : " + lwc.getLayoutBounds().width);
    System.out.println("LWC min size : " + lwc.getMinimumSize().width);
    System.out.println("Get super width : " + super.getWidth());
    System.out.println("Selection Eend : " + this.getSelectionEnd());
    System.out.println("Selection Start : " +       this.getSelectionStart());
    System.out.println("Bounds Box Width : " +this.getBoxBounds().getBounds().width);      
    System.out.println("Visible Rect : " +this.getVisibleRect().width);*/
    //**      Rectangle p2 = null;
    //if (this.getGraphics() != null)
    //{
    //   System.out.println("GRAPHICS : " + this.getGraphics().toString());
    //   if (this.getGraphics().getClipBounds() != null)
    //   System.out.println("GRAPHICS : " + this.getGraphics().getClipBounds().width);
    //   this.getPreferredScrollableViewportSize().width
    //   
    //   

    View ui = getUI().getRootView(this);
    ui = ui.createFragment(this.getSelectionStart(), this.getSelectionEnd());
    //System.out.println("min span: " + ui.getMinimumSpan(View.X_AXIS));

    //**        int start = getSelectionStart();
    //**        int end = getSelectionEnd();
    //**       float f = ui.getPreferredSpan(View.X_AXIS);
    //System.out.println("Preferred span : " + f);

    //**       f = ui.getPreferredSpan(View.Y_AXIS);
    //System.out.println("Preferred span y : " + f);
    //**       f = ui.getPreferredSpan(View.X_AXIS);
    //System.out.println("{referred span X : " + f);
    //ui.breakView(View.X_AXIS, offset, pos, len)
    //((HTMLEditorKit)this.getEditorKit()).getViewFactory().create(this.getDocument().getDefaultRootElement()).
    //  System.out.println("BREAK WEIGHT : " + ui.getBreakWeight(View.X_AXIS, this.getCaretPosition(), this.getSelectionEnd()));
    //  System.out.println("RESIZE WEIGHT : " + ui.getResizeWeight(View.X_AXIS));
    //  System.out.println("RESIZE WEIGHTY : " + ui.getResizeWeight(View.Y_AXIS));
    //**       float align = ui.getAlignment(View.X_AXIS);
    //  System.out.println("align span : " + align);

    //**      try {
    //**         p2 = this.modelToView(this.getSelectionEnd());
    //**         
    //**      } catch (BadLocationException e) {         
    //**         //Nothing we can do really.
    //**      }
    //**      //if (p2 != null)
    //**         //System.out.println("Selection end rect : " + p2.x);
    //**      
    if (mBounds.width > 0) {
        //**           if (p2 != null && p2.x > mBounds.width)
        //**              mBounds.width = p2.x;

        //int height = 48;
        /*if (getFont() != null &&this.getFontMetrics(getFont())!=null)
        {
        System.out.println("A:"+this.getFontMetrics(getFont()).getMaxAscent());
        System.out.println("B:"+this.getFontMetrics(getFont()).getMaxDescent());
        }*/

        int height = super.getPreferredSize().height;//s.height;//Math.max(s.height, 48);

        Style style = ((HTMLDocument) getDocument()).getStyleSheet().getStyle("body");
        Object a = style.getAttribute(javax.swing.text.html.CSS.Attribute.FONT_SIZE);

        if (a != null) {
            if (DEBUG.TEXT)
                out("got style");
            int diff = 0;
            Integer i = new Integer(a.toString());
            diff = i.intValue();
            //minS.height = minS.height - diff;
            if (VUE.getActiveViewer() != null) {
                java.awt.Container parent = getParent();
                double zoom = 1.0;
                if (parent != null)
                    zoom = ((MapViewer) parent).getZoomFactor();
                else {
                    //parent is null during duplicate.
                    zoom = VUE.getActiveViewer().getZoomFactor();
                }
                zoom *= lwc.getMapScale();

                diff *= zoom;
            }
            height = height - diff;
        }

        if (position != null) {

            float minSpan = ui.getMinimumSpan(View.X_AXIS);
            float mins2 = Math.max(minSpan, (float) position.getX());
            s = new Dimension((int) (mBounds.width > mins2 ? mBounds.width : mins2), (int) height);
        } else {
            float minSpan = ui.getMinimumSpan(View.X_AXIS);
            s = new Dimension((int) (mBounds.width > minSpan ? mBounds.width : minSpan), (int) height);
        }
        //float widthRatio = ((float)s.width /(float)lwc.width);
        //   float heightRatio =((float)s.height/(float)lwc.height);
        /*    if ((widthRatio > 0) && (heightRatio > 0) && (widthRatio != heightRatio))
              {
                
        s.height = (int)(lwc.height * widthRatio);
              //   System.out.print("NEW SHEIGHT : " + s.height);
              //   prevDim = s;
        //            
              }
            System.out.println("width ratio : " + widthRatio);
              System.out.println("height ratio : " + heightRatio);
           */
        /*if (this.getGraphics() != null)
         System.out.println("FONT HEIGHT : " +this.getGraphics().getFontMetrics().getMaxAscent());
         System.out.println("===================================");
         System.out.println("super pref height : " + s.height);
         System.out.println("Min Vertical Span : " +ui.getMinimumSpan(View.Y_AXIS));
         System.out.println("MBounds height : " + mBounds.height);
         System.out.println("super pref height : " + s.height);
         System.out.println("Min Vertical Span : " +ui.getMinimumSpan(View.Y_AXIS));
         System.out.println("MBounds height : " + mBounds.height);
         System.out.println("Mins height : " + min.height);
         System.out.println("Bounds Y : " + this.getBounds().y);
         System.out.println("Bounds height :" +this.getBounds().height);
         System.out.println("Bounds2D Y : " +this.getBoxBounds().getY());
         System.out.println("Bounds2D height : " +this.getBoxBounds().getHeight());
         if (this.getCaret().getMagicCaretPosition() != null)
         System.out.println("Cursor : " + this.getCaret().getMagicCaretPosition().toString());
         //this.getCaret().getMagicCaretPosition().
         System.out.println("===================================");*/
        /*if (position != null)
        {
           System.out.println("Y Pos : " + position.getY());
        try {
            Rectangle r = modelToView(this.getCaretPosition());
            System.out.println("model pos : " + r.y);
            System.out.println("Model height : " + r.height);
         } catch (BadLocationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }
        }*/

    }
    // s.width = (int)(s.width * VUE.getActiveViewer().getZoomFactor());
    //   s.height = (int)(s.height * VUE.getActiveViewer().getZoomFactor());
    //   s.height=(int) this.getBoxBounds().getHeight();

    if (this.getBoxBounds() != null && s.height < this.getBoxBounds().getHeight()) {
        s.height = (int) this.getBoxBounds().getHeight();

    }

    return s;
}