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:nl.b3p.imagetool.ImageTool.java

public static BufferedImage drawGeometries(BufferedImage bi, CombineImageSettings settings, int srid, Bbox bbox,
        int width, int height) throws Exception {
    List wktGeoms = settings.getWktGeoms();
    if (wktGeoms == null || wktGeoms.size() <= 0) {
        return bi;
    }/*from  w  ww . jav  a  2s. c  o m*/
    BufferedImage newBufIm = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE);
    //        BufferedImage newBufIm = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D gbi = newBufIm.createGraphics();
    gbi.drawImage(bi, 0, 0, null);
    for (int i = 0; i < wktGeoms.size(); i++) {
        gbi.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
        CombineImageWkt ciw = (CombineImageWkt) wktGeoms.get(i);
        Color color = settings.getDefaultWktGeomColor();
        if (ciw.getColor() != null) {
            color = ciw.getColor();
        }
        gbi.setColor(color);
        String wktGeom = ciw.getWktGeom();
        Geometry geom = geometrieFromText(wktGeom, srid);
        Shape shape = createImage(geom, srid, bbox, width, height);
        Point centerPoint = null;
        if (geom instanceof Polygon) {
            gbi.fill(shape);
        } else if (geom instanceof com.vividsolutions.jts.geom.Point) {
            centerPoint = calculateCenter(shape, srid, bbox, width, height);
            gbi.draw(new Ellipse2D.Double(centerPoint.getX(), centerPoint.getY(), 4, 4));
        } else {
            gbi.setStroke(new BasicStroke(3));
            gbi.draw(shape);
        }
        if (ciw.getLabel() != null) {
            if (centerPoint == null) {
                centerPoint = calculateCenter(shape, srid, bbox, width, height);
            }
            gbi.setColor(Color.black);
            gbi.drawString(ciw.getLabel(), (float) centerPoint.getX(), (float) centerPoint.getY());
        }
    }
    gbi.dispose();
    return newBufIm;
}

From source file:it.unibo.alchemist.boundary.monitors.Generic2DDisplay.java

private static boolean isInsideRectangle(final Point viewPoint, final int rx, final int ry, final int width,
        final int height) {
    final double x = viewPoint.getX();
    final double y = viewPoint.getY();
    return x >= rx && x <= rx + width && y >= ry && y <= ry + height;
}

From source file:Main.java

public void mouseDragged(MouseEvent e) {
    Point current = this.getScreenLocation(e);
    Point offset = new Point((int) current.getX() - (int) start_drag.getX(),
            (int) current.getY() - (int) start_drag.getY());
    JFrame frame = this.getFrame(target);
    Point new_location = new Point((int) (this.start_loc.getX() + offset.getX()),
            (int) (this.start_loc.getY() + offset.getY()));
    frame.setLocation(new_location);
}

From source file:Main.java

Point getScreenLocation(MouseEvent e) {
    Point cursor = e.getPoint();// w  w w.  j av a 2s .  c o  m
    Point target_location = this.target.getLocationOnScreen();
    return new Point((int) (target_location.getX() + cursor.getX()),
            (int) (target_location.getY() + cursor.getY()));
}

From source file:com.db2eshop.gui.component.tab.menu.TabRightClickPopupMenu.java

/**
 * <p>relocate.</p>/*from  w w w .  j  a  v  a 2 s.  c  om*/
 *
 * @param point a {@link java.awt.Point} object.
 */
public void relocate(Point point) {
    Point mainFrameLocation = mainFrame.getLocation();
    this.setLocation((int) (mainFrameLocation.getX() + point.getX()) + 40,
            (int) (mainFrameLocation.getY() + point.getY()) + 70);
}

From source file:com.db2eshop.gui.dialog.BaseDialog.java

/**
 * <p>relocate.</p>//from  ww  w.  j av  a  2s. c o m
 */
public void relocate() {
    log.debug("Relocation.");

    Point location = mainFrame.getLocation();
    Point newLocation = new Point((int) location.getX() + 40, (int) location.getY() + 40);
    this.setLocation(newLocation);
}

From source file:modelibra.designer.metaconceptgraphic.MetaConceptGraphic.java

public void setLocation(Point point) {
    Double xDouble = point.getX();
    Integer x = new Integer(xDouble.intValue());
    setX(x);/*from w w w .ja va2s.  c  om*/

    Double yDouble = point.getY();
    Integer y = new Integer(yDouble.intValue());
    setY(y);
}

From source file:slash.navigation.converter.gui.profileview.LazyToolTipChartPanel.java

protected String getTooltipAtPoint(Point point) {
    XYPlot plot = (XYPlot) getChart().getPlot();
    PlotRenderingInfo info = getChartRenderingInfo().getPlotInfo();
    double x0 = point.getX();
    double x1 = x0 - 2 * getScaleX();
    double x2 = x0 + 4 * getScaleX();

    ValueAxis domainAxis = plot.getDomainAxis();
    Rectangle2D screenArea = scale(info.getDataArea());
    double tx1 = domainAxis.java2DToValue(x1, screenArea, BOTTOM);
    double tx2 = domainAxis.java2DToValue(x2, screenArea, BOTTOM);

    for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); datasetIndex++) {
        XYDataset dataset = plot.getDataset(datasetIndex);
        for (int seriesIndex = 0; seriesIndex < dataset.getSeriesCount(); seriesIndex++) {
            int itemCount = dataset.getItemCount(seriesIndex);
            for (int itemIndex = 0; itemIndex < itemCount; itemIndex++) {
                double xValue = dataset.getXValue(seriesIndex, itemIndex);
                if (tx1 < xValue && xValue < tx2)
                    return toolTipGenerator.generateToolTip(dataset, seriesIndex, itemIndex);
            }//from   w w w.j a  v  a  2 s.c  o  m
        }
    }
    return null;
}

From source file:net.chaosserver.timelord.swingui.PreviousDayPanel.java

/**
 * Listens for action from this panel. If the pick date button is choosen
 * displays a Calendar allowing a user to select a date for display.
 *
 * @param evt the event triggering things
 *//*from w w w.  j av a2 s  .  com*/
public void actionPerformed(ActionEvent evt) {
    if (ACTION_PICK_DAY.equals(evt.getActionCommand())) {
        Frame ownerFrame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, this);
        JCalendarDialog calendarDialog = new JCalendarDialog(ownerFrame, getDisplayDate());

        calendarDialog.pack();

        Point ownerFrameLocation = ownerFrame.getLocation();
        ownerFrameLocation.setLocation(ownerFrameLocation.getX() + LayoutConstants.CHILD_FRAME_X_OFFSET,
                ownerFrameLocation.getY() + LayoutConstants.CHILD_FRAME_Y_OFFSET);

        calendarDialog.setLocation(ownerFrameLocation);
        calendarDialog.setVisible(true);

        Date choosenDate = calendarDialog.getChoosenDate();

        if (choosenDate != null) {
            setDisplayDate(choosenDate);
        }
    }
}

From source file:org.kalypso.ogc.gml.widgets.base.PanToWidget.java

@Override
public void mouseReleased(final MouseEvent e) {
    if (!ArrayUtils.contains(m_mouseButtons, e.getButton()))
        return;/*from  ww w  . j  a v  a2s  . c  o  m*/

    if (m_world2screen == null)
        return;

    final Point point = e.getPoint();

    final GM_Position pixelPos = GeometryFactory.createGM_Position(point.getX(), point.getY());
    m_endPoint = m_world2screen.getSourcePoint(pixelPos);

    perform();
}