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.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java

/**
 * adjusts the viewable are of the log (zoom)
 * /*from   w w  w .  j  a  v a  2 s.  co m*/
 * @param aZoom
 *            fraction of the log to be viewable (within (0,1] !)
 */
public void setViewportZoomX(double aZoom) {
    if (aZoom > 1.0) { // ensure sane values
        viewportZoomX = 1.0;
    } else if (aZoom <= 0.0) {
        viewportZoomX = 0.00000000001;
    } else {
        viewportZoomX = aZoom;
    }
    double ratio = updWidth;
    updWidth = (int) ((double) getParent().getWidth() * (1.0 / aZoom));
    ratio = updWidth / ratio;
    Dimension dim = new Dimension(updWidth, updHight);
    Point d = dca.getScrollPane().getViewport().getViewPosition();
    Point p = new Point((int) ((double) d.getX() * ratio), (int) ((double) d.getY()));

    this.setPreferredSize(dim);
    updateMilli2pixelsRatio();

    this.revalidate();
    dca.setScrollBarPosition(p);
}

From source file:de.tor.tribes.ui.panels.MinimapPanel.java

/**
 * Creates new form MinimapPanel/*  ww w. j  a va2  s.  c o m*/
 */
MinimapPanel() {
    initComponents();
    setSize(300, 300);
    mMinimapListeners = new LinkedList<>();
    mToolChangeListeners = new LinkedList<>();
    setCursor(ImageManager.getCursor(iCurrentCursor));
    mScreenshotPanel = new ScreenshotPanel();
    minimapButtons.put(ID_MINIMAP, new Rectangle(2, 2, 26, 26));
    minimapButtons.put(ID_ALLY_CHART, new Rectangle(30, 2, 26, 26));
    minimapButtons.put(ID_TRIBE_CHART, new Rectangle(60, 2, 26, 26));
    try {
        minimapIcons.put(ID_MINIMAP, ImageIO.read(new File("./graphics/icons/minimap.png")));
        minimapIcons.put(ID_ALLY_CHART, ImageIO.read(new File("./graphics/icons/ally_chart.png")));
        minimapIcons.put(ID_TRIBE_CHART, ImageIO.read(new File("./graphics/icons/tribe_chart.png")));
    } catch (Exception ignored) {
    }
    jPanel1.add(mScreenshotPanel);
    rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension());
    zoomed = false;
    MarkerManager.getSingleton().addManagerListener(this);
    TagManager.getSingleton().addManagerListener(this);
    MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart);
    if (!GlobalOptions.isMinimal()) {
        MinimapRepaintThread.getSingleton().start();
    }
    addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (!showControls && e.getButton() != MouseEvent.BUTTON1) {
                //show controls
                Point p = e.getPoint();
                p.translate(-5, -5);
                showControls(p);
                return;
            }
            if (!showControls && iCurrentView == ID_MINIMAP) {
                Point p = mousePosToMapPosition(e.getX(), e.getY());
                DSWorkbenchMainFrame.getSingleton().centerPosition(p.getX(), p.getY());
                MapPanel.getSingleton().getMapRenderer().initiateRedraw(MapRenderer.ALL_LAYERS);
                if (MinimapZoomFrame.getSingleton().isVisible()) {
                    MinimapZoomFrame.getSingleton().toFront();
                }
            } else {
                if (minimapButtons.get(ID_MINIMAP).contains(e.getPoint())) {
                    iCurrentView = ID_MINIMAP;
                    mBuffer = null;
                    showControls = false;
                    MinimapRepaintThread.getSingleton().update();
                } else if (minimapButtons.get(ID_ALLY_CHART).contains(e.getPoint())) {
                    iCurrentView = ID_ALLY_CHART;
                    lastHash = 0;
                    showControls = false;
                    updateComplete();
                } else if (minimapButtons.get(ID_TRIBE_CHART).contains(e.getPoint())) {
                    iCurrentView = ID_TRIBE_CHART;
                    lastHash = 0;
                    showControls = false;
                    updateComplete();
                }
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            if (iCurrentView != ID_MINIMAP) {
                return;
            }
            if (iCurrentCursor == ImageManager.CURSOR_SHOT || iCurrentCursor == ImageManager.CURSOR_ZOOM) {
                iXDown = e.getX();
                iYDown = e.getY();
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (iCurrentView != ID_MINIMAP) {
                return;
            }
            if (rDrag == null) {
                return;
            }
            if (iCurrentCursor == ImageManager.CURSOR_SHOT) {
                try {
                    BufferedImage i = MinimapRepaintThread.getSingleton().getImage();
                    double widthFactor = ((double) ServerSettings.getSingleton().getMapDimension().width)
                            / getWidth();
                    double heightFactor = ((double) ServerSettings.getSingleton().getMapDimension().height)
                            / getHeight();

                    int x = (int) Math.rint(widthFactor * rDrag.getX());
                    int y = (int) Math.rint(heightFactor * rDrag.getY());
                    int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX()));
                    int h = (int) Math.rint(heightFactor * (rDrag.getHeight() - rDrag.getY()));
                    BufferedImage sub = i.getSubimage(x, y, w, h);
                    mScreenshotPanel.setBuffer(sub);
                    jPanel1.setSize(mScreenshotPanel.getSize());
                    jPanel1.setPreferredSize(mScreenshotPanel.getSize());
                    jPanel1.setMinimumSize(mScreenshotPanel.getSize());
                    jPanel1.setMaximumSize(mScreenshotPanel.getSize());
                    jScreenshotPreview.pack();
                    jScreenshotControl.pack();
                    jScreenshotPreview.setVisible(true);
                    jScreenshotControl.setVisible(true);
                } catch (Exception ie) {
                    logger.error("Failed to initialize mapshot", ie);
                }
            } else if (iCurrentCursor == ImageManager.CURSOR_ZOOM) {
                if (!zoomed) {
                    Rectangle mapDim = ServerSettings.getSingleton().getMapDimension();
                    double widthFactor = ((double) mapDim.width) / getWidth();
                    double heightFactor = ((double) mapDim.height) / getHeight();

                    int x = (int) Math.rint(widthFactor * rDrag.getX() + mapDim.getMinX());
                    int y = (int) Math.rint(heightFactor * rDrag.getY() + mapDim.getMinY());
                    int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX()));

                    if (w >= 10) {
                        rVisiblePart = new Rectangle(x, y, w, w);
                        MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart);
                        redraw();
                        zoomed = true;
                    }
                } else {
                    rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension());
                    MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart);
                    redraw();
                    zoomed = false;
                }
                MinimapZoomFrame.getSingleton().setVisible(false);
            }
            iXDown = 0;
            iYDown = 0;
            rDrag = null;
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            if (iCurrentView != ID_MINIMAP) {
                return;
            }
            switch (iCurrentCursor) {
            case ImageManager.CURSOR_ZOOM: {
                MinimapZoomFrame.getSingleton().setVisible(true);
            }
            }
        }

        @Override
        public void mouseExited(MouseEvent e) {
            if (MinimapZoomFrame.getSingleton().isVisible()) {
                MinimapZoomFrame.getSingleton().setVisible(false);
            }
            iXDown = 0;
            iYDown = 0;
            rDrag = null;
        }
    });

    addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseDragged(MouseEvent e) {
            if (iCurrentView != ID_MINIMAP) {
                return;
            }
            switch (iCurrentCursor) {
            case ImageManager.CURSOR_MOVE: {
                Point p = mousePosToMapPosition(e.getX(), e.getY());
                DSWorkbenchMainFrame.getSingleton().centerPosition(p.x, p.y);
                rDrag = null;
                break;
            }
            case ImageManager.CURSOR_SHOT: {
                rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY());
                break;
            }
            case ImageManager.CURSOR_ZOOM: {
                rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY());
                break;
            }
            }
        }

        @Override
        public void mouseMoved(MouseEvent e) {
            if (iCurrentView == ID_MINIMAP) {
                switch (iCurrentCursor) {
                case ImageManager.CURSOR_ZOOM: {
                    if (!MinimapZoomFrame.getSingleton().isVisible()) {
                        MinimapZoomFrame.getSingleton().setVisible(true);
                    }
                    int mapWidth = (int) ServerSettings.getSingleton().getMapDimension().getWidth();
                    int mapHeight = (int) ServerSettings.getSingleton().getMapDimension().getHeight();

                    int x = (int) Math.rint((double) mapWidth / (double) getWidth() * (double) e.getX());
                    int y = (int) Math.rint((double) mapHeight / (double) getHeight() * (double) e.getY());
                    MinimapZoomFrame.getSingleton().updatePosition(x, y);
                    break;
                }
                default: {
                    if (MinimapZoomFrame.getSingleton().isVisible()) {
                        MinimapZoomFrame.getSingleton().setVisible(false);
                    }
                }
                }
            }
            Point location = minimapButtons.get(ID_MINIMAP).getLocation();
            location.translate(-2, -2);
            if (!new Rectangle(location.x, location.y, 88, 30).contains(e.getPoint())) {
                //hide controls
                showControls = false;
                repaint();
            }
        }
    });

    addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {

            if (iCurrentView != ID_MINIMAP) {
                return;
            }
            iCurrentCursor += e.getWheelRotation();
            if (iCurrentCursor == ImageManager.CURSOR_DEFAULT + e.getWheelRotation()) {
                if (e.getWheelRotation() < 0) {
                    iCurrentCursor = ImageManager.CURSOR_SHOT;
                } else {
                    iCurrentCursor = ImageManager.CURSOR_MOVE;
                }
            } else if (iCurrentCursor < ImageManager.CURSOR_MOVE) {
                iCurrentCursor = ImageManager.CURSOR_DEFAULT;
            } else if (iCurrentCursor > ImageManager.CURSOR_SHOT) {
                iCurrentCursor = ImageManager.CURSOR_DEFAULT;
            }
            if (iCurrentCursor != ImageManager.CURSOR_ZOOM) {
                if (MinimapZoomFrame.getSingleton().isVisible()) {
                    MinimapZoomFrame.getSingleton().setVisible(false);
                }
            } else {
                MinimapZoomFrame.getSingleton().setVisible(true);
            }
            setCurrentCursor(iCurrentCursor);
        }
    });

}

From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java

private int calcDropPosition(final AbstractElement destination, final Point dropPoint) {
    int result = DRAG_POSITION_UNKNOWN;
    if (destination.getClass() == ElementRoot.class) {
        result = dropPoint.getX() < destination.getBounds().getCenterX() ? DRAG_POSITION_LEFT
                : DRAG_POSITION_RIGHT;/*from   ww  w  .j  av  a  2 s  .c  o m*/
    } else {
        final boolean destinationIsLeft = destination.isLeftDirection();
        final Rectangle2D bounds = destination.getBounds();

        if (bounds != null && dropPoint != null) {
            final double edgeOffset = bounds.getWidth() * 0.2d;
            if (dropPoint.getX() >= (bounds.getX() + edgeOffset)
                    && dropPoint.getX() <= (bounds.getMaxX() - edgeOffset)) {
                result = dropPoint.getY() < bounds.getCenterY() ? DRAG_POSITION_TOP : DRAG_POSITION_BOTTOM;
            } else if (destinationIsLeft) {
                result = dropPoint.getX() < bounds.getCenterX() ? DRAG_POSITION_LEFT : DRAG_POSITION_UNKNOWN;
            } else {
                result = dropPoint.getX() > bounds.getCenterX() ? DRAG_POSITION_RIGHT : DRAG_POSITION_UNKNOWN;
            }
        }
    }
    return result;
}

From source file:op.care.prescription.DlgRegular.java

private void tblDosisMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblDosisMousePressed
    if (!SwingUtilities.isRightMouseButton(evt)) {
        return;//from w ww .  j a  v  a2s  .  c o  m
    }

    final TMDose tm = (TMDose) tblDosis.getModel();
    if (tm.getRowCount() == 0) {
        return;
    }
    Point p = evt.getPoint();
    Point p2 = evt.getPoint();
    // Convert a coordinate relative to a component's bounds to screen coordinates
    SwingUtilities.convertPointToScreen(p2, tblDosis);

    //        final Point screenposition = p2;
    final int row = tblDosis.rowAtPoint(p);

    ListSelectionModel lsm = tblDosis.getSelectionModel();
    lsm.setSelectionInterval(row, row);

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

    //-----------------------------------------
    JMenuItem itemPopupDelete = new JMenuItem(SYSTools.xx("misc.msg.delete"), SYSConst.icon22delete);
    itemPopupDelete.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            PrescriptionSchedule schedule = prescription.getPrescriptionSchedule().get(row);
            prescription.getPrescriptionSchedule().remove(schedule);
            schedules2delete.add(schedule);
            reloadTable();
        }
    });
    menu.add(itemPopupDelete);
    menu.show(evt.getComponent(), (int) p.getX(), (int) p.getY());

}

From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java

protected void paintSelectionRectangle(final Graphics2D g2) {
    final Point origin = selectionHandler.getSelectionRectangleOrigin();
    final Point target = selectionHandler.getSelectionRectangleTarget();

    if (origin == null || target == null) {
        return;//from w  ww . j  a  va 2  s  .  c  o m
    }

    g2.setColor(Color.BLUE);
    g2.setStroke(SELECTION_STROKE);

    final double y1 = Math.min(origin.getY(), target.getY());
    final double x1 = Math.min(origin.getX(), target.getX());
    final double y2 = Math.max(origin.getY(), target.getY());
    final double x2 = Math.max(origin.getX(), target.getX());

    g2.draw(new Rectangle2D.Double(x1, y1, x2 - x1, y2 - y1));
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Translates a screen location to a Java2D point.
 * //from   www .  j av a 2s  .  c o  m
 * @param screenPoint
 *            the screen location.
 * @return The Java2D coordinates.
 */
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.forester.archaeopteryx.ControlPanel.java

private void buildJSlider(int width, int min, int max) {
    _color_branches_edpl_slider = new JSlider(min, max);
    Dimension d = _color_branches_edpl_slider.getSize();
    d.width = width;/*from   w ww  .ja va 2  s .  co m*/
    d.height = 100;
    _color_branches_edpl_slider.setPreferredSize(d);
    //       _color_branches_edpl_slider.setLayout(null);

    // slider popup with cutoff value
    _slider_popup = new JPopupMenu();
    JLabel text = new JLabel();
    text.setText(String.valueOf(_edpl_current_cutoff));
    _slider_popup.add(text);
    if (!_configuration.isUseNativeUI()) {
        _color_branches_edpl_slider.setBackground(ControlPanel.jcb_background_color);
        _color_branches_edpl_slider.setForeground(ControlPanel.jcb_text_color);
    }
    _color_branches_edpl_slider.setToolTipText("Set cutoff for EDPL (0.5-1.0)");
    _color_branches_edpl_slider.setMinorTickSpacing(10);
    _color_branches_edpl_slider.setMajorTickSpacing(50);
    _color_branches_edpl_slider.setPaintTicks(true);
    _color_branches_edpl_slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            // get Treepanel function
            final TreePanel tp = getMainPanel().getCurrentTreePanel();
            if (tp == null) {
                return;
            }
            Phylogeny phy = tp.getPhylogeny();
            _edpl_next_cutoff = ((double) ((JSlider) (e.getSource())).getValue() / 100.0);
            tp.edplSliderMovement(_edpl_next_cutoff, _edpl_current_cutoff);
            _edpl_current_cutoff = _edpl_next_cutoff;
            //              System.out.println("Neuer Wert: "+
            //              ((JSlider)(e.getSource())).getValue());
        }
    });
    _color_branches_edpl_slider.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent e) {
            if (_color_branches_edpl_slider.isEnabled()) {
                _slider_popup.setVisible(false);
            }
        }

        @Override
        public void mouseDragged(MouseEvent e) {
            if (_color_branches_edpl_slider.isEnabled()) {
                //               Point p = getMainPanel().getMainFrame().getLocation();
                Point p = _color_branches_edpl_slider.getLocationOnScreen();
                JLabel text = (JLabel) _slider_popup.getComponent(0);
                text.setText(String.valueOf(_edpl_current_cutoff));
                int x = (int) p.getX() + 18;
                int y = (int) p.getY() - 25;
                _slider_popup.setLocation(x, y);
                _slider_popup.setVisible(true);
            }

        }
    });
}

From source file:view.WorkspacePanel.java

private void btnApplySignatureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplySignatureActionPerformed
    if (tempCCAlias != null) {
        signatureSettings.setPageNumber(imagePanel.getPageNumber());
        signatureSettings.setCcAlias(tempCCAlias);
        signatureSettings.setReason(tfReason.getText());
        signatureSettings.setLocation(tfLocation.getText());
        if (jRadioButton1.isSelected()) {
            signatureSettings.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED);
        } else if (jRadioButton2.isSelected()) {
            signatureSettings.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);
        } else if (jRadioButton3.isSelected()) {
            signatureSettings.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING);
        } else if (jRadioButton4.isSelected()) {
            signatureSettings// w w w  .  j ava2  s .c om
                    .setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS);
        }
        signatureSettings.setOcspClient(true);
        if (cbTimestamp.isSelected()) {
            signatureSettings.setTimestamp(true);
            if (tfTimestamp.getText().isEmpty()) {
                JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.timestampEmpty"),
                        "", JOptionPane.ERROR_MESSAGE);
                return;
            } else {
                signatureSettings.setTimestampServer(tfTimestamp.getText());
            }
        } else {
            signatureSettings.setTimestamp(false);
            cbTimestamp.setSelected(false);
            tfTimestamp.setVisible(false);
        }
        signatureSettings.setVisibleSignature(cbVisibleSignature.isSelected());

        if (cbVisibleSignature.isSelected()) {
            Point p = tempSignature.getScaledPositionOnDocument();
            Dimension d = tempSignature.getScaledSizeOnDocument();
            float p1 = (float) p.getX();
            float p3 = (float) d.getWidth() + p1;
            float p2 = (float) ((document.getPageDimension(imagePanel.getPageNumber(), 0).getHeight())
                    - (p.getY() + d.getHeight()));
            float p4 = (float) d.getHeight() + p2;

            signatureSettings.setVisibleSignature(true);
            if (tempSignature.getImageLocation() != null) {
                signatureSettings.getAppearance().setImageLocation(tempSignature.getImageLocation());
            }
            Rectangle rect = new Rectangle(p1, p2, p3, p4);
            signatureSettings.setSignaturePositionOnDocument(rect);
            signatureSettings.setText(tfText.getText());
        } else {
            signatureSettings.setVisibleSignature(false);
        }
        if (mainWindow.getOpenedFiles().size() > 1) {
            Object[] options = { Bundle.getBundle().getString("menuItem.allDocuments"),
                    Bundle.getBundle().getString("menuItem.onlyThis"),
                    Bundle.getBundle().getString("btn.cancel") };
            int i = JOptionPane.showOptionDialog(null,
                    Bundle.getBundle().getString("msg.multipleDocumentsOpened"),
                    Bundle.getBundle().getString("msg.multipleDocumentsOpenedTitle"),
                    JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
            if (i == 0) {
                signBatch(signatureSettings);
            } else if (i == 1) {
                signDocument(document, true, true);
            }
        } else {
            signDocument(document, true, true);
        }
    } else {
        JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("noSmartcardFound"),
                WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE);
        changeCard(CardEnum.SIGN_PANEL, false);
    }
}

From source file:org.gumtree.vis.awt.JChartPanel.java

private void findSelectedMarker(Point point) {
    Line2D marker = null;/*from   w  ww .j a  va2 s.c  o m*/
    double distance = Double.MAX_VALUE;
    double cDis;
    for (Entry<Line2D, Color> entry : domainMarkerMap.entrySet()) {
        Line2D line = entry.getKey();
        Point2D p2 = line.getP2();
        double height = p2.getY();
        cDis = Double.MAX_VALUE;
        if (height < 1e-4) {
            double xScr = ChartMaskingUtilities.translateChartPoint(p2, getScreenDataArea(), getChart()).getX();
            cDis = Math.abs(point.getX() - xScr);
        } else {
            Point2D newP2 = ChartMaskingUtilities.translateChartPoint(p2, getScreenDataArea(), getChart());
            if (newP2.getY() < point.getY()) {
                cDis = Math.abs(point.getX() - newP2.getX());
            } else {
                cDis = newP2.distance(point);
            }
        }
        if (cDis <= distance) {
            distance = cDis;
            marker = line;
        }
    }
    for (Entry<Line2D, Color> entry : rangeMarkerMap.entrySet()) {
        Line2D line = entry.getKey();
        Point2D p1 = line.getP1();
        Point2D p2 = line.getP2();
        double width = p2.getX();
        cDis = Double.MAX_VALUE;
        if (width < 1e-4) {
            double yScr = ChartMaskingUtilities.translateChartPoint(p1, getScreenDataArea(), getChart()).getY();
            cDis = Math.abs(point.getY() - yScr);
        } else {
            Point2D newP2 = ChartMaskingUtilities.translateChartPoint(p2, getScreenDataArea(), getChart());
            if (newP2.getX() > point.getX()) {
                cDis = Math.abs(point.getY() - newP2.getY());
            } else {
                cDis = newP2.distance(point);
            }
        }
        if (cDis <= distance) {
            distance = cDis;
            marker = line;
        }
    }
    for (Entry<Line2D, Color> entry : markerMap.entrySet()) {
        Line2D line = entry.getKey();
        Point2D p1 = line.getP1();
        p1 = ChartMaskingUtilities.translateChartPoint(p1, getScreenDataArea(), getChart());
        cDis = p1.distance(point);
        if (cDis <= distance) {
            distance = cDis;
            marker = line;
        }
    }
    if (distance < 5) {
        selectedMarker = marker;
    } else {
        selectedMarker = null;
    }
}

From source file:Creator.WidgetPanel.java

public String createWidget(WidgetLink wl, Rectangle rect, int[] io_id) {

    if (widgetList.containsKey(wl.getWidgetCodeName())) {
        WidgetCode wc = widgetList.get(wl.getWidgetCodeName());
        Point per = wl.getPositionPercentage();

        int xPos = rect.x + (int) (per.getX() * rect.getWidth() / 100.0);
        int yPos = rect.y + (int) (per.getY() * rect.getHeight() / 100.0);

        String code = wc.getFullWidgetText();

        code = code.replace("`%IO_ID%`", String.valueOf(io_id[0])).replace("`%XPOS%`", String.valueOf(xPos))
                .replace("`%YPOS%`", String.valueOf(yPos));

        for (int i = 1; i < io_id.length; i++) {
            code = code.replace("`%IO_ID" + String.valueOf(i + 1) + "%`", String.valueOf(io_id[i]));
        }//w  w w. jav  a 2  s. c  o m

        for (Map.Entry<String, String> entry : wl.getVariables().entrySet()) {

            code = code.replace(entry.getKey(), entry.getValue());
        }

        return code;
    } else {
        System.out.println("Could not find a link for the widget named: " + wl.getWidgetCodeName());
        return "";
    }
}