Example usage for java.awt Point Point

List of usage examples for java.awt Point Point

Introduction

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

Prototype

public Point(int x, int y) 

Source Link

Document

Constructs and initializes a point at the specified (x,y) location in the coordinate space.

Usage

From source file:com.t_oster.visicut.misc.Helper.java

public static Point toPoint(Point2D p) {
    return new Point((int) p.getX(), (int) p.getY());
}

From source file:com.floreantpos.jasperreport.swing.JRViewerPanel.java

/**
 *
 *//*from   www.  ja  v a 2  s.  c om*/
public void gotoHyperlink(JRPrintHyperlink hyperlink) {
    switch (hyperlink.getHyperlinkTypeValue()) {
    case REFERENCE: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case LOCAL_ANCHOR: {
        if (hyperlink.getHyperlinkAnchor() != null) {
            Map anchorIndexes = viewerContext.getJasperPrint().getAnchorIndexes();
            JRPrintAnchorIndex anchorIndex = (JRPrintAnchorIndex) anchorIndexes
                    .get(hyperlink.getHyperlinkAnchor());
            if (anchorIndex.getPageIndex() != viewerContext.getPageIndex()) {
                viewerContext.setPageIndex(anchorIndex.getPageIndex());
                viewerContext.refreshPage();
            }
            Container container = pnlInScroll.getParent();
            if (container instanceof JViewport) {
                JViewport viewport = (JViewport) container;

                int newX = (int) (anchorIndex.getElementAbsoluteX() * realZoom);
                int newY = (int) (anchorIndex.getElementAbsoluteY() * realZoom);

                int maxX = pnlInScroll.getWidth() - viewport.getWidth();
                int maxY = pnlInScroll.getHeight() - viewport.getHeight();

                if (newX < 0) {
                    newX = 0;
                }
                if (newX > maxX) {
                    newX = maxX;
                }
                if (newY < 0) {
                    newY = 0;
                }
                if (newY > maxY) {
                    newY = maxY;
                }

                viewport.setViewPosition(new Point(newX, newY));
            }
        }

        break;
    }
    case LOCAL_PAGE: {
        int page = viewerContext.getPageIndex() + 1;
        if (hyperlink.getHyperlinkPage() != null) {
            page = hyperlink.getHyperlinkPage().intValue();
        }

        if (page >= 1 && page <= viewerContext.getJasperPrint().getPages().size()
                && page != viewerContext.getPageIndex() + 1) {
            viewerContext.setPageIndex(page - 1);
            viewerContext.refreshPage();
            Container container = pnlInScroll.getParent();
            if (container instanceof JViewport) {
                JViewport viewport = (JViewport) container;
                viewport.setViewPosition(new Point(0, 0));
            }
        }

        break;
    }
    case REMOTE_ANCHOR: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
            System.out.println("Hyperlink anchor    : " + hyperlink.getHyperlinkAnchor());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case REMOTE_PAGE: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
            System.out.println("Hyperlink page      : " + hyperlink.getHyperlinkPage());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case CUSTOM: {
        if (isOnlyHyperlinkListener()) {
            System.out.println("Hyperlink of type " + hyperlink.getLinkType());
            System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
        }
        break;
    }
    case NONE:
    default: {
        break;
    }
    }
}

From source file:au.org.ala.delta.editor.ui.image.ImageOverlayEditorController.java

@Action
public void addAllUsualOverlays() {
    // We dont' want to base the overlay position on the menu click location in this case.
    if (_selection.getSelectedPoint() != null) {
        _selection.getSelectedPoint().setLocation(Integer.MIN_VALUE, Integer.MIN_VALUE);
    }// w  w w .ja v  a  2  s . co  m
    Image image = _selection.getSelectedImage();
    if (image.getSubject() instanceof Character) {
        Character character = (Character) image.getSubject();
        Point origin = new Point(150, 300);
        if (image.getOverlay(OverlayType.OLFEATURE) == null) {
            ImageOverlay newOverlay = newOverlay(OverlayType.OLFEATURE);

            newOverlay.setX(origin.x);
            newOverlay.setY(origin.y);
            origin.x += 25;
            origin.y += 50;
            image.updateOverlay(newOverlay);

        }
        if (character.getCharacterType().isMultistate()) {
            addStateOverlays((MultiStateCharacter) character, origin);
        } else if (character.getCharacterType().isNumeric()) {
            if (image.getOverlay(OverlayType.OLENTER) == null) {
                ImageOverlay newOverlay = newOverlay(OverlayType.OLENTER);
                newOverlay.setX(400);
                newOverlay.setY(600);
                image.updateOverlay(newOverlay);
            }
            if (image.getOverlay(OverlayType.OLUNITS) == null
                    && StringUtils.isNotEmpty(((NumericCharacter<?>) character).getUnits())) {
                ImageOverlay newOverlay = newOverlay(OverlayType.OLUNITS);

                newOverlay.setX(Short.MIN_VALUE);
                newOverlay.setY(Short.MIN_VALUE);
                image.updateOverlay(newOverlay);

            }
        }
        if (image.getOverlay(OverlayType.OLOK) == null) {
            newOverlay(OverlayType.OLOK);
        }
        if (image.getOverlay(OverlayType.OLCANCEL) == null) {
            newOverlay(OverlayType.OLCANCEL);
        }
        if (StringUtils.isNotEmpty(character.getNotes()) && image.getOverlay(OverlayType.OLNOTES) == null) {
            newOverlay(OverlayType.OLNOTES);
        }
    }
}

From source file:com.croer.javaorange.diviner.SimpleOrangeDiviner.java

@Override
public void show(JComponent jComponent) {
    this.jComponent = jComponent;
    System.out.println(configuration.getString(jComponent.getName()));
    Point location = jComponent.getLocationOnScreen();
    Dimension size = jComponent.getSize();
    Point xy = new Point(location.x, location.y + size.height);

    setLocation(xy);/*w  w w  .j  av  a 2 s.co  m*/
    //        EventQueue.invokeLater(new Runnable() {
    //
    //            public void run() {
    //                jTextField3.requestFocusInWindow();
    //            }
    //        });
    pack();
    setVisible(true);
}

From source file:business.ImageManager.java

public void doDrawPathArmyAllyOrder(Graphics2D big, Point ori, Point dest) {
    final int x = 45;
    final int y = 45;
    doDrawPathOrdemArmy(big, new Point((int) ori.getX() + x, (int) ori.getY() + y),
            new Point((int) dest.getX() + x, (int) dest.getY() + y), colorAllyArmyOrdem);
}

From source file:com.mirth.connect.client.ui.DashboardPanel.java

/**
 * Makes the status table with all current server information.
 *//* w ww  .j av  a2 s. c o m*/
public void makeStatusTable() {
    List<String> columns = new ArrayList<String>();

    for (DashboardColumnPlugin plugin : LoadedExtensions.getInstance().getDashboardColumnPlugins().values()) {
        if (plugin.isDisplayFirst()) {
            columns.add(plugin.getColumnHeader());
        }
    }

    columns.addAll(Arrays.asList(defaultColumns));

    for (DashboardColumnPlugin plugin : LoadedExtensions.getInstance().getDashboardColumnPlugins().values()) {
        if (!plugin.isDisplayFirst()) {
            columns.add(plugin.getColumnHeader());
        }
    }

    DashboardTreeTableModel model = new DashboardTreeTableModel();
    model.setColumnIdentifiers(columns);
    model.setNodeFactory(new DefaultDashboardTableNodeFactory());

    for (DashboardTablePlugin plugin : LoadedExtensions.getInstance().getDashboardTablePlugins().values()) {
        dashboardTable = plugin.getTable();

        if (dashboardTable != null) {
            break;
        }
    }

    defaultVisibleColumns.addAll(columns);

    if (dashboardTable == null) {
        dashboardTable = new MirthTreeTable("dashboardPanel", defaultVisibleColumns);
    }

    dashboardTable.setColumnFactory(new DashboardTableColumnFactory());
    dashboardTable.setTreeTableModel(model);
    dashboardTable.setDoubleBuffered(true);
    dashboardTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    dashboardTable.setHorizontalScrollEnabled(true);
    dashboardTable.packTable(UIConstants.COL_MARGIN);
    dashboardTable.setRowHeight(UIConstants.ROW_HEIGHT);
    dashboardTable.setOpaque(true);
    dashboardTable.setRowSelectionAllowed(true);
    dashboardTable.setSortable(true);
    dashboardTable.putClientProperty("JTree.lineStyle", "Horizontal");
    dashboardTable.setAutoCreateColumnsFromModel(false);
    dashboardTable.setShowGrid(true, true);
    dashboardTable.restoreColumnPreferences();
    dashboardTable.setMirthColumnControlEnabled(true);

    dashboardTable.setTreeCellRenderer(new DefaultTreeCellRenderer() {
        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
                boolean leaf, int row, boolean hasFocus) {
            JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row,
                    hasFocus);

            TreePath path = dashboardTable.getPathForRow(row);
            if (path != null) {
                AbstractDashboardTableNode node = ((AbstractDashboardTableNode) path.getLastPathComponent());
                if (node.isGroupNode()) {
                    setIcon(UIConstants.ICON_GROUP);
                } else {
                    DashboardStatus status = node.getDashboardStatus();
                    if (status.getStatusType() == StatusType.CHANNEL) {
                        setIcon(UIConstants.ICON_CHANNEL);
                    } else {
                        setIcon(UIConstants.ICON_CONNECTOR);
                    }
                }
            }

            return label;
        }
    });
    dashboardTable.setLeafIcon(UIConstants.ICON_CONNECTOR);
    dashboardTable.setOpenIcon(UIConstants.ICON_CHANNEL);
    dashboardTable.setClosedIcon(UIConstants.ICON_CHANNEL);

    dashboardTableScrollPane.setViewportView(dashboardTable);

    dashboardTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent event) {
            checkSelectionAndPopupMenu(event);
        }

        @Override
        public void mouseReleased(MouseEvent event) {
            checkSelectionAndPopupMenu(event);
        }

        @Override
        public void mouseClicked(MouseEvent event) {
            int clickedRow = dashboardTable.rowAtPoint(new Point(event.getX(), event.getY()));
            if (clickedRow == -1) {
                return;
            }

            TreePath path = dashboardTable.getPathForRow(clickedRow);
            if (path != null && ((AbstractDashboardTableNode) path.getLastPathComponent()).isGroupNode()) {
                return;
            }

            if (event.getClickCount() >= 2 && dashboardTable.getSelectedRowCount() == 1
                    && dashboardTable.getSelectedRow() == clickedRow) {
                parent.doShowMessages();
            }
        }
    });

    dashboardTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            /*
             * MIRTH-3199: Only update the panel plugin if the selection is finished. This does
             * mean that the logs aren't updated live when adding to or removing from a
             * currently adjusting selection, but it's much more efficient when it comes to the
             * number of requests being done from the client. Plus, it actually will still
             * update while a selection is adjusting if the refresh interval on the dashboard
             * elapses. We can change this so that plugins are updated during a selection
             * adjustment, but it would first require a major rewrite of the connection log /
             * status column plugin.
             */
            updatePopupMenu(!event.getValueIsAdjusting());
        }
    });
}

From source file:de.fhg.igd.mapviewer.waypoints.CustomWaypointPainter.java

/**
 * Find the way-points in a given rectangular area
 * //from   ww  w  .ja  v  a 2s .  c o m
 * @param rect the area
 * @return the way-points in the area
 */
public Set<W> findWaypoints(Rectangle rect) {
    Rectangle viewPort = getMapKit().getMainMap().getViewportBounds();

    final Rectangle worldRect = new Rectangle(viewPort.x + rect.x, viewPort.y + rect.y, rect.width,
            rect.height);

    final int zoom = getMapKit().getMainMap().getZoom();
    final PixelConverter converter = getMapKit().getMainMap().getTileFactory().getTileProvider().getConverter();

    final GeoPosition topLeft = converter.pixelToGeo(new Point(worldRect.x, worldRect.y), zoom);
    final GeoPosition bottomRight = converter
            .pixelToGeo((new Point(worldRect.x + worldRect.width, worldRect.y + worldRect.height)), zoom);

    return findWaypoints(topLeft, bottomRight, worldRect, converter, zoom);
}

From source file:it.unibas.spicygui.controllo.datasource.operators.CreaWidgetAlberi.java

private ConnectionConstraint createConnectionConstraint(boolean source, Widget widgetKeyOriginale,
        Widget widgetForeignKeyOriginale, VMDPinWidgetKey widgetForeignKey, int ascissa,
        VMDPinWidgetKey widgetKey, Stroke stroke) {
    Point originalPointForeignKey = widgetForeignKeyOriginale.getPreferredLocation();
    Point originalPointKey = widgetKeyOriginale.getPreferredLocation();
    Point newPointForeignKey = new Point(originalPointForeignKey.x, originalPointForeignKey.y);
    Point newPointKey = new Point(originalPointKey.x, originalPointKey.y);

    mainLayer.addChild(widgetForeignKey, new CaratteristicheWidgetConstraint(Costanti.FOREIGN_KEY,
            widgetForeignKeyOriginale, newPointForeignKey));
    mainLayer.addChild(widgetKey,//from  w ww .  j av a  2s. c o m
            new CaratteristicheWidgetConstraint(Costanti.KEY, widgetKeyOriginale, newPointKey));
    ConnectionConstraint connectionConstraint = new ConnectionConstraint();
    VMDPinWidgetKey widgetIntermediateForeignKey = new VMDPinWidgetKey(scene);
    VMDPinWidgetKey widgetIntermediateKey = new VMDPinWidgetKey(scene);
    settaWidgetKey(widgetIntermediateForeignKey);
    settaWidgetKey(widgetIntermediateKey);
    Point keyPoint = null;
    if (source) {
        widgetIntermediateForeignKey.setPreferredLocation(new Point(
                widgetForeignKeyOriginale.getPreferredLocation().x + OFFSET_ASCISSA_SOURCE_SECONDO_WIDGET,
                widgetForeignKeyOriginale.getPreferredLocation().y + OFFSET_ORDINATA_TARGET));
        keyPoint = new Point(widgetKeyOriginale.getPreferredLocation().x + OFFSET_ASCISSA_SOURCE_SECONDO_WIDGET,
                widgetKeyOriginale.getPreferredLocation().y);
    } else {
        widgetIntermediateForeignKey.setPreferredLocation(new Point(
                widgetForeignKeyOriginale.getPreferredLocation().x + OFFSET_ASCISSA_TARGET_SECONDO_WIDGET,
                widgetForeignKeyOriginale.getPreferredLocation().y + OFFSET_ORDINATA_TARGET));
        keyPoint = new Point(widgetKeyOriginale.getPreferredLocation().x + OFFSET_ASCISSA_TARGET_SECONDO_WIDGET,
                widgetKeyOriginale.getPreferredLocation().y);
    }

    repositionatingWidgetConstraints(keyPoint, widgetKey, widgetIntermediateKey);
    mainLayer.addChild(widgetIntermediateForeignKey, new CaratteristicheWidgetConstraint(Costanti.FOREIGN_KEY,
            widgetForeignKeyOriginale, newPointForeignKey));
    mainLayer.addChild(widgetIntermediateKey,
            new CaratteristicheWidgetConstraint(Costanti.KEY, widgetKeyOriginale, newPointKey));
    connectionConstraint.addConnection(creaConnection(widgetKey, widgetIntermediateKey, true, stroke));
    connectionConstraint.addConnection(creaConnection(widgetKey, widgetForeignKey, false, stroke));
    connectionConstraint
            .addConnection(creaConnection(widgetIntermediateForeignKey, widgetForeignKey, false, stroke));
    scene.validate();

    return connectionConstraint;
}

From source file:Creator.WidgetPanel.java

/**
 * Calculates the percentage of the point inside the rectangle
 *
 * @param p point inside the rectangle//from  w w  w.j a va  2  s . co  m
 * @param r rectangle containing point
 * @return point - percentage values 0-100 for x,y
 */
public Point percentage(Point p, Rectangle r) {

    try {
        int xP = (int) (((double) (p.x - r.x) / (double) r.width) * 100.0);
        int yP = (int) (((double) (p.y - r.y) / (double) r.height) * 100.0);
        return new Point(xP, yP);
    } catch (Exception e) {
        System.out.println("Error finding percentage, probably divide by 0 problem");
        System.out.println("Rectangle: " + r + "\nPoint: " + p);
        return new Point(-1, -1);
    }

}

From source file:org.nekorp.workflow.desktop.servicio.reporte.orden.servicio.OrdenServicioDataFactory.java

private void generaSVGImagenDamage(ShapeView fondo, List<DamageDetailsVB> danios, File outputfile, int width,
        int height) {
    // Get a DOMImplementation.
    DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();

    // Create an instance of org.w3c.dom.Document.
    String svgNS = "http://www.w3.org/2000/svg";
    Document document = domImpl.createDocument(svgNS, "svg", null);

    // Create an instance of the SVG Generator.
    SVGGraphics2D g2 = new SVGGraphics2D(document);
    // pintar.//from   w  w w.  j a  va  2  s.  co  m
    g2.setSVGCanvasSize(new java.awt.Dimension(width, height));
    Point contexto = new Point((width - fondo.getShapeWidth()) / 2, (height - fondo.getShapeHeight()) / 2);
    g2.setColor(Color.WHITE);
    g2.fillRect(0, 0, width, height);
    AffineTransform saveXform = g2.getTransform();
    AffineTransform toCenterAt = new AffineTransform();
    toCenterAt.translate(contexto.getX(), contexto.getY());
    g2.transform(toCenterAt);
    fondo.paint(g2);
    g2.setTransform(saveXform);
    for (DamageDetailsVB x : danios) {
        DamageDetailGraphicsView obj = new DamageDetailGraphicsView();
        obj.setFontSize(esquemaFontSize);
        obj.setPosicion(new Point(x.getX(), x.getY()));
        obj.setContexto(contexto);
        if (x.getX() <= fondo.getShapeWidth() / 2) {
            if (x.getY() <= fondo.getShapeHeight() / 2) {
                obj.setOrientacion(DamageDetailGraphicsView.SuperiorIzquierda);
                //obj.setOrientacion(DamageDetailGraphicsView.SuperiorDerecha);
            } else {
                obj.setOrientacion(DamageDetailGraphicsView.InferiorIzquierda);
                //obj.setOrientacion(DamageDetailGraphicsView.InferiorDerecha);
            }
        } else {
            if (x.getY() <= fondo.getShapeHeight() / 2) {
                obj.setOrientacion(DamageDetailGraphicsView.SuperiorDerecha);
                //obj.setOrientacion(DamageDetailGraphicsView.SuperiorIzquierda);
            } else {
                obj.setOrientacion(DamageDetailGraphicsView.InferiorDerecha);
                //obj.setOrientacion(DamageDetailGraphicsView.InferiorIzquierda);
            }
        }
        obj.setCategoria(x.getCategoria());
        obj.setCaracteristica(x.getCaracteristica());
        obj.paint(g2);
    }
    try {
        g2.stream(outputfile.getCanonicalPath());
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}